Skip to content

Commit

Permalink
move 'password and account' to advanced
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed May 7, 2024
1 parent 022709f commit 8e6f36f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
17 changes: 16 additions & 1 deletion deltachat-ios/Controller/Settings/AdvancedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
case manageKeys
case videoChat
case viewLog
case accountSettings
}

private var dcContext: DcContext
Expand Down Expand Up @@ -59,6 +60,14 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
return cell
}()

private lazy var accountSettingsCell: UITableViewCell = {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.textLabel?.text = String.localized("pref_password_and_account_settings")
cell.accessoryType = .disclosureIndicator
cell.tag = CellTags.accountSettings.rawValue
return cell
}()

lazy var sentboxWatchCell: SwitchCell = {
return SwitchCell(
textLabel: String.localized("pref_watch_sent_folder"),
Expand Down Expand Up @@ -212,7 +221,7 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
let serverSection = SectionConfigs(
headerTitle: String.localized("pref_imap_folder_handling"),
footerTitle: String.localized("pref_only_fetch_mvbox_explain"),
cells: [sentboxWatchCell, sendCopyToSelfCell, mvboxMoveCell, onlyFetchMvboxCell])
cells: [accountSettingsCell, sentboxWatchCell, sendCopyToSelfCell, mvboxMoveCell, onlyFetchMvboxCell])
return [viewLogSection, experimentalSection, appAccessSection, autocryptSection, serverSection]
}()

Expand Down Expand Up @@ -280,6 +289,7 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
case .manageKeys: showManageKeysDialog()
case .videoChat: showVideoChatInstance()
case .viewLog: showLogViewController()
case .accountSettings: showAccountSettingsController()
}
}

Expand Down Expand Up @@ -333,6 +343,11 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
navigationController?.pushViewController(controller, animated: true)
}

private func showAccountSettingsController() {
let controller = AccountSetupController(dcAccounts: dcAccounts, editView: true)
navigationController?.pushViewController(controller, animated: true)
}

private func showManageKeysDialog() {
let alert = UIAlertController(title: String.localized("pref_manage_keys"), message: nil, preferredStyle: .safeActionSheet)

Expand Down
34 changes: 4 additions & 30 deletions deltachat-ios/Controller/Settings/SelfProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ class SelfProfileViewController: UITableViewController, MediaPickerDelegate {
private let section1Status = 2
private let section1RowCount = 3

private let section2 = 1
private let section2AccountSettings = 0
private let section2RowCount = 1

private let sectionCount = 2

private let tagAccountSettingsCell = 1
private let sectionCount = 1

private lazy var mediaPicker: MediaPicker? = {
let mediaPicker = MediaPicker(dcContext: dcContext, navigationController: navigationController)
Expand All @@ -32,14 +26,6 @@ class SelfProfileViewController: UITableViewController, MediaPickerDelegate {
return cell
}()

private lazy var accountSettingsCell: UITableViewCell = {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.textLabel?.text = String.localized("pref_password_and_account_settings")
cell.accessoryType = .disclosureIndicator
cell.tag = tagAccountSettingsCell
return cell
}()

private lazy var avatarSelectionCell: AvatarSelectionCell = {
return AvatarSelectionCell(image: dcContext.getSelfAvatarImage())
}()
Expand Down Expand Up @@ -85,9 +71,8 @@ class SelfProfileViewController: UITableViewController, MediaPickerDelegate {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == section1 {
return section1RowCount
} else {
return section2RowCount
}
return 0
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
Expand All @@ -100,11 +85,10 @@ class SelfProfileViewController: UITableViewController, MediaPickerDelegate {
case section1Status:
return statusCell
default:
return UITableViewCell()
break
}
} else {
return accountSettingsCell
}
return UITableViewCell()
}

override func tableView(_: UITableView, titleForFooterInSection section: Int) -> String? {
Expand All @@ -115,16 +99,6 @@ class SelfProfileViewController: UITableViewController, MediaPickerDelegate {
}
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let cell = tableView.cellForRow(at: indexPath) else { return }
if cell.tag == tagAccountSettingsCell {
tableView.deselectRow(at: indexPath, animated: false)
guard let nc = navigationController else { return }
let accountSetupVC = AccountSetupController(dcAccounts: dcAccounts, editView: true)
nc.pushViewController(accountSetupVC, animated: true)
}
}

// MARK: - actions
private func galleryButtonPressed(_ action: UIAlertAction) {
mediaPicker?.showPhotoGallery()
Expand Down

0 comments on commit 8e6f36f

Please sign in to comment.