Fuzz Buzz in bunt
This commit is contained in:
parent
57c56a4235
commit
cd16b94917
3 changed files with 20 additions and 12 deletions
|
|
@ -12,18 +12,29 @@ struct RangeView: TabContent {
|
|||
static var image = "list.bullet"
|
||||
|
||||
@State var texte: [String]
|
||||
|
||||
|
||||
func farbe(for i: Int ) -> Color {
|
||||
return i % 3 == 0 ? Color.green : Color.yellow
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
List(2...16, id: \.self) { i in
|
||||
HStack(spacing:0){
|
||||
Text("\(i)")
|
||||
if i.isMultiple(of: 3) { Text("Fizz")}
|
||||
|
||||
if i.isMultiple(of: 5) { Text("Buzz")}
|
||||
LazyHGrid(rows: [GridItem(.adaptive(minimum: 120))]){
|
||||
ForEach(2...16, id: \.self) { i in
|
||||
ZStack{
|
||||
if i % 4 == 0{
|
||||
Circle().fill(farbe(for: i))
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 25).fill(farbe(for: i))
|
||||
}
|
||||
VStack(spacing:0){
|
||||
Text("\(i)")
|
||||
|
||||
if i.isMultiple(of: 3) { Text("Fizz")}
|
||||
if i.isMultiple(of: 4) { Text("Buzz")}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,5 +99,5 @@ struct RangeView: TabContent {
|
|||
|
||||
|
||||
#Preview {
|
||||
RangeView()
|
||||
RangeView()
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -20,9 +20,6 @@ struct UnicycleView: View {
|
|||
Text("Einrad von \(uni.createdAt.description)")
|
||||
}.onDelete {
|
||||
for index in $0 {
|
||||
|
||||
|
||||
|
||||
modelContext.delete(unis[index])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue