Add a leafier tree with animals

This commit is contained in:
Sami Samhuri 2023-02-05 14:59:24 -08:00
parent 435c8a40c5
commit 4354a5dd56
No known key found for this signature in database
GPG key ID: 4B4195422742FC16
3 changed files with 37 additions and 4 deletions

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "TreeLeafierAnimals.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 KiB

View file

@ -35,10 +35,12 @@ struct ContentView: View {
var treeImageName: String {
if entries.isEmpty {
return "TreeBare"
} else if entries.count < 3 {
} else if entries.count < 3 { // 1-2
return "TreeLeafy"
} else {
} else if entries.count < 5 { // 3-4
return "TreeLeafier"
} else { // 5+
return "TreeLeafierAnimals"
}
}
@ -85,7 +87,7 @@ struct ContentView: View {
isEditing.toggle()
} label: {
Image(treeImageName)
.renderingMode(.template)
.renderingMode(entries.count > 0 ? .original : .template)
.resizable()
.scaledToFit()
.foregroundColor(.white)
@ -134,11 +136,21 @@ struct ContentView_Previews: PreviewProvider {
ContentView(entries: [
Entry(text: "Coffee"),
Entry(text: "Marion berries"),
Entry(text: "Burritos"),
Entry(text: "Mountains"),
])
.previewDisplayName("Leafier")
ContentView(entries: [
Entry(text: "Coffee"),
Entry(text: "Burritos"),
Entry(text: "Mountains"),
Entry(text: "Trees"),
Entry(text: "Clean Water"),
])
.previewDisplayName("Leafier with Animals")
}
.tint(.white)
.previewLayout(.sizeThatFits)
}
}