I dont wanna zap devs so Im afraid to zap the wrong one I better sit here and look at my feet 🦢🦢

Reply to this note

Please Login to reply.

Discussion

Yes. Looking at my feet. Much safer. Nostr will thrive if I look at my feet πŸ˜‚πŸ˜‚πŸ’€

--

// ContentView.swift

// Trivia_App

//

// Created by Maciej Zak on 12/05/19.

//

import SwiftUI

struct ContentView: View {

@State private var score = 0

@State private var isCorrect = false

let categories = ["Science", "History", "Geography", "Art", "Music"]

var body: some View {

NavigationView {

ScrollView {

VStack(spacing: 10) {

Text("Welcome to Trivia App!")

.font(.title)

.padding()

ForEach(categories, id: \.self) { category in

SectionHeader(category: category)

ScrollView {

ForEach(questionsByCategory[category] ?? [], id: \.0) { (index, question) in

QuestionView(question: question, isCorrect: $isCorrect, score: $score)

.onReceive(isCorrect.$isCorrect) { _ in

if isCorrect {

score += 1

isCorrect = false

}

}

.padding()

}

}

}

Text("\(score) out of \(categories.count)")

.font(.title2)

.padding()

}

.onAppear {

isCorrect = false

}

}

.navigationBarTitle("Trivia App")

}

}

}

πŸ˜‚