File tree Expand file tree Collapse file tree
GoogleSignInSwift/Sources
Samples/Swift/DaysUntilBirthday/Shared/Views Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,29 +51,35 @@ let googleImageName = "google"
5151///
5252/// The minimum size of the button depends on the language used for text.
5353@available ( iOS 13 . 0 , macOS 10 . 15 , * )
54- public enum GoogleSignInButtonStyle {
54+ public enum GoogleSignInButtonStyle : String , Identifiable , CaseIterable {
5555 case standard
5656 case wide
5757 case icon
58+
59+ public var id : String { rawValue }
5860}
5961
6062// MARK: - Button Color Scheme
6163
6264/// The color schemes supported by the sign-in button.
6365@available ( iOS 13 . 0 , macOS 10 . 15 , * )
64- public enum GoogleSignInButtonColorScheme {
66+ public enum GoogleSignInButtonColorScheme : String , Identifiable , CaseIterable {
6567 case dark
6668 case light
69+
70+ public var id : String { rawValue }
6771}
6872
6973// MARK: - Button State
7074
7175/// The state of the sign-in button.
7276@available ( iOS 13 . 0 , macOS 10 . 15 , * )
73- public enum GoogleSignInButtonState {
77+ public enum GoogleSignInButtonState : String , Identifiable , CaseIterable {
7478 case normal
7579 case disabled
7680 case pressed
81+
82+ public var id : String { rawValue }
7783}
7884
7985// MARK: - Colors
Original file line number Diff line number Diff line change @@ -19,13 +19,54 @@ import GoogleSignInSwift
1919
2020struct SignInView : View {
2121 @EnvironmentObject var authViewModel : AuthenticationViewModel
22+ @ObservedObject var vm = GoogleSignInButtonViewModel ( )
2223
2324 var body : some View {
2425 VStack {
2526 HStack {
26- GoogleSignInButton ( action: authViewModel. signIn)
27- . accessibility ( hint: Text ( " Sign in with Google button. " ) )
28- . padding ( )
27+ VStack {
28+ GoogleSignInButton ( viewModel: vm, action: authViewModel. signIn)
29+ . accessibility ( hint: Text ( " Sign in with Google button. " ) )
30+ . padding ( )
31+ VStack {
32+ HStack {
33+ Text ( " Button style: " )
34+ . padding ( . leading)
35+ Picker ( " " , selection: $vm. style) {
36+ ForEach ( GoogleSignInButtonStyle . allCases) { style in
37+ Text ( style. rawValue. capitalized)
38+ . tag ( GoogleSignInButtonStyle ( rawValue: style. rawValue) !)
39+ }
40+ }
41+ Spacer ( )
42+ }
43+ HStack {
44+ Text ( " Button color: " )
45+ . padding ( . leading)
46+ Picker ( " " , selection: $vm. scheme) {
47+ ForEach ( GoogleSignInButtonColorScheme . allCases) { scheme in
48+ Text ( scheme. rawValue. capitalized)
49+ . tag ( GoogleSignInButtonColorScheme ( rawValue: scheme. rawValue) !)
50+ }
51+ }
52+ Spacer ( )
53+ }
54+ HStack {
55+ Text ( " Button state: " )
56+ . padding ( . leading)
57+ Picker ( " " , selection: $vm. state) {
58+ ForEach ( GoogleSignInButtonState . allCases) { state in
59+ Text ( state. rawValue. capitalized)
60+ . tag ( GoogleSignInButtonState ( rawValue: state. rawValue) !)
61+ }
62+ }
63+ Spacer ( )
64+ }
65+ }
66+ #if os(iOS)
67+ . pickerStyle( . automatic)
68+ #endif
69+ }
2970 }
3071 Spacer ( )
3172 }
You can’t perform that action at this time.
0 commit comments