Server protocol update (unfinished)
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>Nextcloud Cookbook iOS Client.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -2828,6 +2828,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Use a non-standard port" : {
|
||||
|
||||
},
|
||||
"Validate" : {
|
||||
"localizations" : {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user