diff --git a/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate b/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..1f00a6c Binary files /dev/null and b/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Nextcloud Cookbook iOS Client.xcodeproj/xcuserdata/vincie.xcuserdatad/xcschemes/xcschememanagement.plist b/Nextcloud Cookbook iOS Client.xcodeproj/xcuserdata/vincie.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..caa45f8 --- /dev/null +++ b/Nextcloud Cookbook iOS Client.xcodeproj/xcuserdata/vincie.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Nextcloud Cookbook iOS Client.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/Nextcloud Cookbook iOS Client/Localizable.xcstrings b/Nextcloud Cookbook iOS Client/Localizable.xcstrings index 733f767..8a68a9a 100644 --- a/Nextcloud Cookbook iOS Client/Localizable.xcstrings +++ b/Nextcloud Cookbook iOS Client/Localizable.xcstrings @@ -2828,6 +2828,9 @@ } } } + }, + "Use a non-standard port" : { + }, "Validate" : { "localizations" : { diff --git a/Nextcloud Cookbook iOS Client/Views/Onboarding/OnboardingView.swift b/Nextcloud Cookbook iOS Client/Views/Onboarding/OnboardingView.swift index 34b5a2a..02aff48 100644 --- a/Nextcloud Cookbook iOS Client/Views/Onboarding/OnboardingView.swift +++ b/Nextcloud Cookbook iOS Client/Views/Onboarding/OnboardingView.swift @@ -137,6 +137,28 @@ struct LoginLabel: View { } } +struct BorderedLoginTextField: View { + var example: String + @Binding var text: String + @State var color: Color = .white + + var body: some View { + TextField(example, text: $text) + .textFieldStyle(.plain) + .autocorrectionDisabled() + .textInputAutocapitalization(.never) + .foregroundColor(color) + .accentColor(color) + .padding() + .background( + RoundedRectangle(cornerRadius: 10) + .stroke(.white, lineWidth: 2) + .foregroundColor(.clear) + ) + + } +} + struct LoginTextField: View { var example: String @Binding var text: String @@ -152,8 +174,84 @@ struct LoginTextField: View { .padding() .background( RoundedRectangle(cornerRadius: 10) - .stroke(color, lineWidth: 2) - .foregroundColor(.clear) + .foregroundColor(Color.white.opacity(0.2)) ) } } + + +struct ServerAddressField: View { + @Binding var addressString: String + @State var serverAddress: String = "" + @State var serverProtocol: ServerProtocol = .https + @State var serverPort: String = "" + @State var useNonStandardPort: Bool = false + + enum ServerProtocol: String { + case https="https://", http="http://" + + static let all = [https, http] + } + + var body: some View { + VStack(alignment: .leading) { + LoginLabel(text: "Server address") + VStack(alignment: .leading) { + HStack { + Picker(ServerProtocol.https.rawValue, selection: $serverProtocol) { + ForEach(ServerProtocol.all, id: \.self) { + Text($0.rawValue) + } + }.pickerStyle(.menu) + .tint(.white) + .font(.headline) + + LoginTextField(example: "e.g.: example.com", text: $serverAddress) + } + + Toggle("Use a non-standard port", isOn: $useNonStandardPort) + .tint(.white.opacity(0.2)) + .foregroundStyle(.white) + .font(.headline) + .padding(.top) + if useNonStandardPort { + LoginTextField(example: "e.g.: 80", text: $serverPort) + } + + LoginLabel(text: "Full server address") + .padding(.top) + Text(createServerAddressString()) + .foregroundColor(.white) + .padding(.vertical, 5) + } + .padding() + .background( + RoundedRectangle(cornerRadius: 10) + .stroke(.white, lineWidth: 2) + .foregroundColor(.clear) + ) + }.animation(.easeInOut, value: useNonStandardPort) + } + + func createServerAddressString() -> String { + if useNonStandardPort && serverPort != "" { + addressString = serverProtocol.rawValue + serverAddress + ":" + serverPort + } else { + addressString = serverProtocol.rawValue + serverAddress + } + return addressString + } +} + +struct ServerAddressField_Preview: PreviewProvider { + static var previews: some View { + ServerAddressField(addressString: .constant(""), + serverAddress: "example.com", + serverProtocol: .https, + serverPort: "80", + useNonStandardPort: true) + .previewLayout(.sizeThatFits) + .padding() + .background(Color.nextcloudBlue) + } +} diff --git a/Nextcloud Cookbook iOS Client/Views/Onboarding/TokenLoginView.swift b/Nextcloud Cookbook iOS Client/Views/Onboarding/TokenLoginView.swift index e974a05..d112349 100644 --- a/Nextcloud Cookbook iOS Client/Views/Onboarding/TokenLoginView.swift +++ b/Nextcloud Cookbook iOS Client/Views/Onboarding/TokenLoginView.swift @@ -8,6 +8,8 @@ import Foundation import SwiftUI + + struct TokenLoginView: View { @Binding var showAlert: Bool @Binding var alertMessage: String @@ -24,15 +26,16 @@ struct TokenLoginView: View { var body: some View { VStack(alignment: .leading) { - LoginLabel(text: "Server address") + /*LoginLabel(text: "Server address") LoginTextField(example: "e.g.: example.com", text: $userSettings.serverAddress) .focused($focusedField, equals: .server) .textContentType(.URL) .submitLabel(.next) .padding(.bottom) - + */ + ServerAddressField(addressString: $userSettings.serverAddress) LoginLabel(text: "User name") - LoginTextField(example: "username", text: $userSettings.username) + BorderedLoginTextField(example: "username", text: $userSettings.username) .focused($focusedField, equals: .username) .textContentType(.username) .submitLabel(.next) @@ -40,7 +43,7 @@ struct TokenLoginView: View { LoginLabel(text: "App Token") - LoginTextField(example: "can be generated in security settings of your nextcloud", text: $userSettings.token) + BorderedLoginTextField(example: "can be generated in security settings of your nextcloud", text: $userSettings.token) .focused($focusedField, equals: .token) .textContentType(.password) .submitLabel(.join) diff --git a/Nextcloud Cookbook iOS Client/Views/Onboarding/V2LoginView.swift b/Nextcloud Cookbook iOS Client/Views/Onboarding/V2LoginView.swift index 79d6180..f974a7d 100644 --- a/Nextcloud Cookbook iOS Client/Views/Onboarding/V2LoginView.swift +++ b/Nextcloud Cookbook iOS Client/Views/Onboarding/V2LoginView.swift @@ -50,7 +50,7 @@ struct V2LoginView: View { var body: some View { ScrollView { VStack(alignment: .leading) { - LoginLabel(text: "Server address") + /*LoginLabel(text: "Server address") .padding() LoginTextField(example: "e.g.: example.com", text: $userSettings.serverAddress, color: loginStage == .serverAddress ? .white : .secondary) .focused($focusedField, equals: .server) @@ -62,7 +62,8 @@ struct V2LoginView: View { loginStage = loginStage.next() } } - + */ + ServerAddressField(addressString: $userSettings.serverAddress) CollapsibleView { VStack(alignment: .leading) { Text("Make sure to enter the server address in the form 'example.com'. Currently, only servers using the 'https' protocol are supported.")