-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckerView.swift
86 lines (69 loc) · 2.28 KB
/
CheckerView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// CheckerView.swift
// WordPlay
//
// Created by Sanay Fatullayeva on 07.12.21.
//
import SwiftUI
enum ViewChoice{
case palindrome, anagram, pangram
}
enum ViewVisibility: CaseIterable {
case visible,
invisible,
gone
}
extension View {
@ViewBuilder func visibility(_ visibility: ViewVisibility) -> some View {
if visibility != .gone {
if visibility == .visible {
self
} else {
hidden()
}
}
}
}
struct CheckerView: View {
@State private var toView: ViewChoice = .anagram
@State var viewTitle = ""
@State private var redVisibility: ViewVisibility = .visible
@State var viewingGame: Bool = true
var body: some View {
ZStack(alignment: Alignment.bottom){
switch(toView) {
case .palindrome:
PalindromeView()
case .anagram:
AnagramView(viewingGame: $viewingGame)
case .pangram:
PangramView()
}
if !viewingGame {
Picker("Word Play Picker", selection: $toView){
Text("Palindrome").tag(ViewChoice.palindrome)
Text("Anagram").tag(ViewChoice.anagram)
Text("Pangram").tag(ViewChoice.pangram)
}
.pickerStyle(SegmentedPickerStyle())
.visibility(.gone)
} else if viewingGame{
Picker("Word Play Picker", selection: $toView){
Text("Anagram").tag(ViewChoice.anagram)
Text("Palindrome").tag(ViewChoice.palindrome)
Text("Pangram").tag(ViewChoice.pangram)
}
//.frame(width: 350, height: 70)
.frame(width: UIScreen.main.bounds.width-10, height: 70)
.pickerStyle(SegmentedPickerStyle())
.visibility(.visible)
.accessibilityLabel("Picker")
}
}//.frame(width: UIScreen.main.bounds.width-10)
}
}
struct CheckerView_Previews: PreviewProvider {
static var previews: some View {
CheckerView()
}
}