// // ContentView.swift // Memorize // // Created by ching on 2023/2/12. // import SwiftUI struct ContentView: View { var emojis = ["🚌", "🚙", "🚗", "🚕", "🏎", "🚎", "🚓"] @State var emojiCount = 2 var body: some View { VStack { ScrollView { LazyVGrid(columns: [GridItem(.adaptive(minimum: 65))]) { ForEach(emojis[0.. 1{ emojiCount -= 1 } }, label: { Image(systemName: "minus.circle") }) } var add: some View { Button(action: { if emojiCount < emojis.count { emojiCount += 1 } }, label: { Image(systemName: "plus.circle") }) } } struct CardView: View { @State var isFaceUp: Bool = true var content: String var body: some View { ZStack { let shape = RoundedRectangle(cornerRadius: 20.0) if isFaceUp { shape .fill() .foregroundColor(.white) shape .strokeBorder(lineWidth: 3) Text(content) .font(.largeTitle) } else { shape .fill() } } .onTapGesture { isFaceUp = !isFaceUp } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .preferredColorScheme(.dark) ContentView() .preferredColorScheme(.light) } }