From fb212eeb9f409f12b0ecd5d4d4e81719ff90d9e0 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Tue, 26 Sep 2023 16:10:06 +0200 Subject: [PATCH] Change AssistantView --- Linphone/Localizable.xcstrings | 15 -- Linphone/ui/assistant/AssistantView.swift | 135 ++++++++++++++---- .../viewmodel/AccountLoginViewModel.swift | 5 +- Linphone/ui/main/ContentView.swift | 1 + 4 files changed, 108 insertions(+), 48 deletions(-) diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 9bff8abe8..e80c25f45 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -79,9 +79,6 @@ }, "Create & \nlog in account" : { - }, - "Domain:" : { - }, "Log out & \ndelete account" : { @@ -108,21 +105,12 @@ } } } - }, - "Password:" : { - }, "TCP" : { }, "TLS" : { - }, - "Transport:" : { - - }, - "UDP" : { - }, "Unregistered" : { @@ -143,9 +131,6 @@ } } } - }, - "Username:" : { - } }, "version" : "1.0" diff --git a/Linphone/ui/assistant/AssistantView.swift b/Linphone/ui/assistant/AssistantView.swift index 534a76a32..c44ca1eb8 100644 --- a/Linphone/ui/assistant/AssistantView.swift +++ b/Linphone/ui/assistant/AssistantView.swift @@ -29,40 +29,78 @@ struct AssistantView: View { ZStack { Image("Mountain") .resizable() - .frame(width: 1084, height: 108) + .frame(width: 1080, height: 108) Text("assistant_account_login") - .font(Font.custom("Noto Sans", size: 20)) + .font(Font.custom("NotoSans-ExtraBold", size: 20)) .foregroundColor(.white) } - .padding(.top, 36) - .padding(.bottom, 16) - HStack { - Text("Username:") - .font(.title) - TextField("", text : $accountLoginViewModel.username) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .disabled(coreContext.loggedIn) - } - HStack { - Text("Password:") - .font(.title) - - SecureField("", text : $accountLoginViewModel.passwd) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .disabled(coreContext.loggedIn) - } - HStack { - Text("Domain:") - .font(.title) - TextField("", text : $accountLoginViewModel.domain) - .textFieldStyle(RoundedBorderTextFieldStyle()) - .disabled(coreContext.loggedIn) - } - Picker(selection: $accountLoginViewModel.transportType, label: Text("Transport:")) { - Text("TLS").tag("TLS") - Text("TCP").tag("TCP") - Text("UDP").tag("UDP") - }.pickerStyle(SegmentedPickerStyle()).padding() + .padding(.top, 35) + + HStack(alignment: .center, spacing: 0) { + VStack(alignment: .leading, spacing: 0) { + Text(String(localized: "username")+"*") + .font(Font.custom("Noto Sans", size: 15) + .weight(.bold)) + .padding(.bottom, 5) + + TextField("username", text : $accountLoginViewModel.username) + .font(Font.custom("Noto Sans", size: 15)) + .disabled(coreContext.loggedIn) + .frame(height: 20) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(red: 0.98, green: 0.98, blue: 0.98)) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 63) + .inset(by: 0.5) + .stroke(Color(red: 0.93, green: 0.93, blue: 0.93), lineWidth: 1) + ) + .padding(.bottom, 15) + + Text(String(localized: "password")+"*") + .font(Font.custom("Noto Sans", size: 15) + .weight(.bold)) + .padding(.bottom, 5) + + SecureInputView(String(localized: "password"), text: $accountLoginViewModel.passwd) + .disabled(coreContext.loggedIn) + .frame(height: 20) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color(red: 0.98, green: 0.98, blue: 0.98)) + .cornerRadius(63) + .overlay( + RoundedRectangle(cornerRadius: 63) + .inset(by: 0.5) + .stroke(Color(red: 0.93, green: 0.93, blue: 0.93), lineWidth: 1) + ) + .padding(.bottom, 32) + + Button(action: accountLoginViewModel.login) { + Text("assistant_account_login") + .font(Font.custom("NotoSans-ExtraBold", size: 20)) + .foregroundColor(.white) + } + .disabled(coreContext.loggedIn) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .frame(maxWidth: .infinity, alignment: .center) + .background(Color(red: 1, green: 0.37, blue: 0)) + .cornerRadius(63) + .overlay( + RoundedRectangle(cornerRadius: 63) + .inset(by: 0.5) + .stroke(Color(red: 1, green: 0.37, blue: 0), lineWidth: 1) + ) + + } + } + .padding(.top, 5) + .padding(.bottom, 20) + VStack { HStack { Button(action: { @@ -101,7 +139,42 @@ struct AssistantView: View { } struct AssistantView_Previews: PreviewProvider { + static var previews: some View { AssistantView(accountLoginViewModel: AccountLoginViewModel()) } } + + +struct SecureInputView: View { + + @Binding private var text: String + @State private var isSecured: Bool = true + private var title: String + + init(_ title: String, text: Binding) { + self.title = title + self._text = text + } + + var body: some View { + ZStack(alignment: .trailing) { + Group { + if isSecured { + SecureField(title, text: $text) + .font(Font.custom("Noto Sans", size: 15)) + } else { + TextField(title, text: $text) + .font(Font.custom("Noto Sans", size: 15)) + } + }.padding(.trailing, 32) + + Button(action: { + isSecured.toggle() + }) { + Image(systemName: self.isSecured ? "eye.slash" : "eye") + .accentColor(.gray) + } + } + } +} diff --git a/Linphone/ui/assistant/viewmodel/AccountLoginViewModel.swift b/Linphone/ui/assistant/viewmodel/AccountLoginViewModel.swift index 605b42032..184a8e713 100644 --- a/Linphone/ui/assistant/viewmodel/AccountLoginViewModel.swift +++ b/Linphone/ui/assistant/viewmodel/AccountLoginViewModel.swift @@ -17,15 +17,16 @@ * along with this program. If not, see . */ +import SwiftUI import linphonesw class AccountLoginViewModel : ObservableObject { private var coreContext = CoreContext.shared - @Published var username : String = "user" + @Published var username : String = "" @Published var passwd : String = "" - @Published var domain : String = "sip.example.org" + @Published var domain : String = "sip.linphone.org" @Published var transportType : String = "TLS" init() {} diff --git a/Linphone/ui/main/ContentView.swift b/Linphone/ui/main/ContentView.swift index 140bf99ee..dd80aa860 100644 --- a/Linphone/ui/main/ContentView.swift +++ b/Linphone/ui/main/ContentView.swift @@ -29,6 +29,7 @@ struct ContentView: View { } struct ContentView_Previews: PreviewProvider { + static var previews: some View { AssistantView(accountLoginViewModel: AccountLoginViewModel()) }