create random icons and save to documents dir
This commit is contained in:
@@ -33,12 +33,12 @@ struct SettingsView: View {
|
||||
showOnboardingButton
|
||||
whyBackgroundMode
|
||||
specialThanksCell
|
||||
|
||||
}
|
||||
|
||||
Group {
|
||||
addTestDataCell
|
||||
clearDB
|
||||
randomIcons
|
||||
|
||||
if useCloudKit {
|
||||
cloudKitStatus
|
||||
@@ -220,6 +220,45 @@ struct SettingsView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var randomIcons: some View {
|
||||
ZStack {
|
||||
theme.currentTheme.secondaryBGColor
|
||||
Button(action: {
|
||||
var iconViews = [UIImage]()
|
||||
for _ in 0...300 {
|
||||
iconViews.append(
|
||||
IconView(iconViewModel: IconViewModel(
|
||||
backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||
bgColor: Color.random(),
|
||||
bgOverlayColor: Color.random(),
|
||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||
innerColor: Color.random())
|
||||
).asImage(size: CGSize(width: 1024, height: 1024)))
|
||||
}
|
||||
|
||||
for (idx, image) in iconViews.enumerated() {
|
||||
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
||||
var path = paths[0].appendingPathComponent("icons").path
|
||||
path = path.appending("\(idx).jpg")
|
||||
let url = URL(fileURLWithPath: path)
|
||||
do {
|
||||
try image.jpegData(compressionQuality: 1.0)?.write(to: url, options: .atomic)
|
||||
print(url)
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
}, label: {
|
||||
Text("Create random icons")
|
||||
.foregroundColor(theme.currentTheme.labelColor)
|
||||
})
|
||||
.padding()
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
}
|
||||
|
||||
struct SettingsView_Previews: PreviewProvider {
|
||||
|
||||
Reference in New Issue
Block a user