Oddbean new post about | logout
β–² β–Ό
 Imagine needing a middleman to use your Bitcoin
https://media.tenor.com/jDJkh3w0wTAAAAAC/gregzaj1-ln_strike.gif 
β–² β–Ό
 I dont wanna zap devs so Im afraid to zap the wrong one I better sit here and look at my feet 🦢🦢 
β–² β–Ό
 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")
        }
    }
} 
β–² β–Ό
 πŸ˜‚