Change AssistantView

This commit is contained in:
Benoit Martins 2023-09-26 16:10:06 +02:00
parent 392be31c5c
commit fb212eeb9f
4 changed files with 108 additions and 48 deletions

View file

@ -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"

View file

@ -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<String>) {
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)
}
}
}
}

View file

@ -17,15 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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() {}

View file

@ -29,6 +29,7 @@ struct ContentView: View {
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
AssistantView(accountLoginViewModel: AccountLoginViewModel())
}