File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 454454 "$(inherited)",
455455 "@executable_path/Frameworks",
456456 );
457- MARKETING_VERSION = 0.2.3 ;
457+ MARKETING_VERSION = 0.2.4 ;
458458 PRODUCT_BUNDLE_IDENTIFIER = me.kuhlti.iOSSC;
459459 PRODUCT_NAME = "$(TARGET_NAME)";
460460 PROVISIONING_PROFILE_SPECIFIER = "";
479479 "$(inherited)",
480480 "@executable_path/Frameworks",
481481 );
482- MARKETING_VERSION = 0.2.3 ;
482+ MARKETING_VERSION = 0.2.4 ;
483483 PRODUCT_BUNDLE_IDENTIFIER = me.kuhlti.iOSSC;
484484 PRODUCT_NAME = "$(TARGET_NAME)";
485485 PROVISIONING_PROFILE_SPECIFIER = "";
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class APIManager: ObservableObject {
1818 @Published var data : ResponseData ?
1919 @Published var loginState : LoginState = . loggedOut
2020
21- private let environment : Environment
21+ private var environment : Environment
2222 private var username : String ?
2323 private var password : String ?
2424
@@ -188,6 +188,11 @@ class APIManager: ObservableObject {
188188 }
189189 }
190190
191+ func switchEnv( ) {
192+ logout ( )
193+ environment = environment == . production ? . development : . production
194+ }
195+
191196 private func getHeaders( _ username: String , _ password: String ) -> HTTPHeaders {
192197 let credentialData = " \( username) : \( password) " . data ( using: . utf8)
193198 guard let cred = credentialData else { return [ " " : " " ] }
@@ -209,6 +214,18 @@ class APIManager: ObservableObject {
209214 }
210215 }
211216
217+ var env : Environment {
218+ return environment
219+ }
220+
221+ var inProduction : Bool {
222+ return environment == . production
223+ }
224+
225+ var inDevelopment : Bool {
226+ return environment == . development
227+ }
228+
212229 /**
213230 Sets the environment the application should run in
214231 */
Original file line number Diff line number Diff line change @@ -83,17 +83,32 @@ struct LoginView: View {
8383 VStack {
8484 Text ( " Nur HTTPS erlaubt! " )
8585 . foregroundColor ( . white)
86+
87+ Button ( devModeButtonText) {
88+ manager. switchEnv ( )
89+ }
90+ . foregroundColor ( . hsd)
91+ . padding ( )
92+
8693 InputField ( manager. baseUrl, text: $customUrl)
8794 }
8895 . padding ( . bottom, 8 )
8996 }
9097
91- InputField ( " Benutzername " , text: $username)
92- . padding ( . bottom, 8 )
93- InputField ( " Password " , text: $password, isSecure: true )
98+ Group {
99+ InputField ( " Benutzername " , text: $username)
100+ . padding ( . bottom, 8 )
101+ InputField ( " Password " , text: $password, isSecure: true )
102+ }
103+ . disabled ( manager. inDevelopment)
104+ . blur ( radius: manager. inDevelopment ? 3 : 0 )
94105 }
95106 }
96107
108+ private var devModeButtonText : String {
109+ return manager. inProduction ? " Aktiviere Entwickler Modus " : " Deaktiviere Entwickler Modus "
110+ }
111+
97112 private var footer : some View {
98113 VStack {
99114 Button ( " Login " ) {
Original file line number Diff line number Diff line change 88import SwiftUI
99import SFSafeSymbols
1010
11- let env : APIManager . Environment = . production
12-
1311@main
1412struct iOSSCApp : App {
1513
1614 @ObservedObject
17- private var manager = APIManager ( enviorment: env )
15+ private var manager = APIManager ( enviorment: . production )
1816
1917 var body : some Scene {
2018 WindowGroup {
@@ -30,9 +28,10 @@ struct iOSSCApp: App {
3028 }
3129
3230 // Development Label
33- if ( env == . development ) {
31+ if ( manager . inDevelopment ) {
3432 VStack {
3533 HStack {
34+ Spacer ( )
3635 Text ( " Development Mode " )
3736 . foregroundColor ( . red)
3837 . font ( . caption)
You can’t perform that action at this time.
0 commit comments