Skip to content
Snippets Groups Projects
Commit a6850328 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

account: add name server settings

Change-Id: I2c23f58a92cc84ce70f8f0fbe792161ae70a2846
parent a3acbf43
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,8 @@ internal enum L10n { ...@@ -153,6 +153,8 @@ internal enum L10n {
internal static let linkedDevices = L10n.tr("Localizable", "accountPage.linkedDevices", fallback: "Linked devices") internal static let linkedDevices = L10n.tr("Localizable", "accountPage.linkedDevices", fallback: "Linked devices")
/// Manage account /// Manage account
internal static let manageAccount = L10n.tr("Localizable", "accountPage.manageAccount", fallback: "Manage account") internal static let manageAccount = L10n.tr("Localizable", "accountPage.manageAccount", fallback: "Manage account")
/// Name server
internal static let nameServer = L10n.tr("Localizable", "accountPage.nameServer", fallback: "Name server")
/// Confirm new password /// Confirm new password
internal static let newPasswordConfirmPlaceholder = L10n.tr("Localizable", "accountPage.newPasswordConfirmPlaceholder", fallback: "Confirm new password") internal static let newPasswordConfirmPlaceholder = L10n.tr("Localizable", "accountPage.newPasswordConfirmPlaceholder", fallback: "Confirm new password")
/// Enter new password /// Enter new password
......
...@@ -47,6 +47,8 @@ class AccountSettings: ObservableObject { ...@@ -47,6 +47,8 @@ class AccountSettings: ObservableObject {
@Published var bootstrap = "" @Published var bootstrap = ""
@Published var serverName = ""
var notificationsPermitted: Bool = LocalNotificationsHelper.isEnabled() var notificationsPermitted: Bool = LocalNotificationsHelper.isEnabled()
let accountService: AccountsService let accountService: AccountsService
let account: AccountModel let account: AccountModel
...@@ -110,6 +112,7 @@ class AccountSettings: ObservableObject { ...@@ -110,6 +112,7 @@ class AccountSettings: ObservableObject {
// MARK: - Jami account // MARK: - Jami account
extension AccountSettings { extension AccountSettings {
private func setUPJamiParameters() { private func setUPJamiParameters() {
self.serverName = self.getStringState(for: .ringNsURI)
self.proxyEnabled = self.getBoolState(for: .proxyEnabled) self.proxyEnabled = self.getBoolState(for: .proxyEnabled)
self.proxyListUrl = self.getStringState(for: ConfigKey.dhtProxyListUrl) self.proxyListUrl = self.getStringState(for: ConfigKey.dhtProxyListUrl)
self.bootstrap = self.getStringState(for: ConfigKey.accountHostname) self.bootstrap = self.getStringState(for: ConfigKey.accountHostname)
...@@ -197,6 +200,11 @@ extension AccountSettings { ...@@ -197,6 +200,11 @@ extension AccountSettings {
let property = ConfigKeyModel(withKey: .dhtProxyListUrl) let property = ConfigKeyModel(withKey: .dhtProxyListUrl)
self.accountService.setAccountProperty(property: property, value: self.proxyListUrl, accountId: account.id) self.accountService.setAccountProperty(property: property, value: self.proxyListUrl, accountId: account.id)
} }
func saveNameServer() {
let property = ConfigKeyModel(withKey: ConfigKey.ringNsURI)
self.accountService.setAccountProperty(property: property, value: self.serverName, accountId: account.id)
}
} }
// MARK: - SIP account // MARK: - SIP account
......
...@@ -125,6 +125,26 @@ struct NotificationsSettingsView: View { ...@@ -125,6 +125,26 @@ struct NotificationsSettingsView: View {
} }
} }
struct NameServerView: View {
@StateObject var model: AccountSettings
init(injectionBag: InjectionBag, account: AccountModel) {
_model = StateObject(wrappedValue: AccountSettings(account: account, injectionBag: injectionBag))
}
var body: some View {
List {
NavigationLink(destination: EditableFieldView(value: $model.serverName, title: L10n.AccountPage.nameServer, placeholder: L10n.Account.serverLabel, onDisappearAction: {
model.saveNameServer()
})) {
FieldRowView(label: L10n.AccountPage.nameServer, value: model.serverName)
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(L10n.AccountPage.notificationTitle)
}
}
struct ConnectivitySettingsView: View { struct ConnectivitySettingsView: View {
@StateObject var model: AccountSettings @StateObject var model: AccountSettings
......
...@@ -37,6 +37,10 @@ struct SettingsSummaryView: View { ...@@ -37,6 +37,10 @@ struct SettingsSummaryView: View {
NavigationLink(destination: NotificationsSettingsView(injectionBag: model.injectionBag, account: model.account)) { NavigationLink(destination: NotificationsSettingsView(injectionBag: model.injectionBag, account: model.account)) {
SettingsRow(iconName: "bell", title: L10n.AccountPage.notificationsHeader) SettingsRow(iconName: "bell", title: L10n.AccountPage.notificationsHeader)
} }
NavigationLink(destination: NameServerView(injectionBag: model.injectionBag, account: model.account)) {
SettingsRow(iconName: "server.rack", title: L10n.AccountPage.nameServer)
}
} }
NavigationLink(destination: ConnectivitySettingsView(injectionBag: model.injectionBag, account: model.account)) { NavigationLink(destination: ConnectivitySettingsView(injectionBag: model.injectionBag, account: model.account)) {
SettingsRow(iconName: "link", title: L10n.AccountPage.connectivityAndConfiguration) SettingsRow(iconName: "link", title: L10n.AccountPage.connectivityAndConfiguration)
......
...@@ -387,6 +387,7 @@ ...@@ -387,6 +387,7 @@
"accountPage.accountIdentity" = "Account identity"; "accountPage.accountIdentity" = "Account identity";
"accountPage.bootstrap" = "Bootstrap"; "accountPage.bootstrap" = "Bootstrap";
"accountPage.dhtConfiguration" = "OpenDHT configuration"; "accountPage.dhtConfiguration" = "OpenDHT configuration";
"accountPage.nameServer" = "Name server";
// Backup Account // Backup Account
"backupAccount.explanation" = "This Jami account exists only on this device. The account will be lost if this device is lost or if the application is uninstalled. It is recommended to make a backup of this account."; "backupAccount.explanation" = "This Jami account exists only on this device. The account will be lost if this device is lost or if the application is uninstalled. It is recommended to make a backup of this account.";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment