krz/daybyday

iOS learning games for young children: days, months, seasons, numbers, letters, animals and more. education ios kids swift https://krz.sh/apps/daybyday/

DayByDay/Parent/GatedView.swift

062549ad26607ce9e973ed2a9a7ef6f853885f83
daybyday/DayByDay/Parent/GatedView.swift history · blame · raw

22 lines · 453 bytes

1 symbol in this file
 1//
 2//  GatedView.swift
 3//  DayByDay
 4//
 5
 6import SwiftUI
 7
 8/// Shows the parent gate first, then `content` once it is passed.
 9struct GatedView<Content: View>: View {
10    let onCancel: () -> Void
11    @ViewBuilder let content: () -> Content
12
13    @State private var passed = false
14
15    var body: some View {
16        if passed {
17            content()
18        } else {
19            ParentGateView(onPass: { passed = true }, onCancel: onCancel)
20        }
21    }
22}