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

update settings UI

Gitlab: #294

Change-Id: Ia2ab6a35e0f9b630ab4820949dc4cc6401254bcf
parent aced8afc
No related branches found
No related tags found
No related merge requests found
Showing
with 193 additions and 136 deletions
...@@ -99,6 +99,8 @@ internal enum L10n { ...@@ -99,6 +99,8 @@ internal enum L10n {
internal static let enableBoothMode = L10n.tr("Localizable", "accountPage.enableBoothMode", fallback: "Enable Booth Mode") internal static let enableBoothMode = L10n.tr("Localizable", "accountPage.enableBoothMode", fallback: "Enable Booth Mode")
/// Enable Notifications /// Enable Notifications
internal static let enableNotifications = L10n.tr("Localizable", "accountPage.enableNotifications", fallback: "Enable Notifications") internal static let enableNotifications = L10n.tr("Localizable", "accountPage.enableNotifications", fallback: "Enable Notifications")
/// Invite friends
internal static let inviteFriends = L10n.tr("Localizable", "accountPage.inviteFriends", fallback: "Invite friends")
/// Link another device /// Link another device
internal static let linkDeviceTitle = L10n.tr("Localizable", "accountPage.linkDeviceTitle", fallback: "Link another device") internal static let linkDeviceTitle = L10n.tr("Localizable", "accountPage.linkDeviceTitle", fallback: "Link another device")
/// Confirm new password /// Confirm new password
...@@ -109,6 +111,8 @@ internal enum L10n { ...@@ -109,6 +111,8 @@ internal enum L10n {
internal static let noBoothMode = L10n.tr("Localizable", "accountPage.noBoothMode", fallback: "To enable Booth mode you need to create account password first.") internal static let noBoothMode = L10n.tr("Localizable", "accountPage.noBoothMode", fallback: "To enable Booth mode you need to create account password first.")
/// Your device won't receive notifications when proxy is disabled /// Your device won't receive notifications when proxy is disabled
internal static let noProxyExplanationLabel = L10n.tr("Localizable", "accountPage.noProxyExplanationLabel", fallback: "Your device won't receive notifications when proxy is disabled") internal static let noProxyExplanationLabel = L10n.tr("Localizable", "accountPage.noProxyExplanationLabel", fallback: "Your device won't receive notifications when proxy is disabled")
/// Notifications
internal static let notificationsHeader = L10n.tr("Localizable", "accountPage.notificationsHeader", fallback: "Notifications")
/// Enter old password /// Enter old password
internal static let oldPasswordPlaceholder = L10n.tr("Localizable", "accountPage.oldPasswordPlaceholder", fallback: "Enter old password") internal static let oldPasswordPlaceholder = L10n.tr("Localizable", "accountPage.oldPasswordPlaceholder", fallback: "Enter old password")
/// Other /// Other
...@@ -141,8 +145,6 @@ internal enum L10n { ...@@ -141,8 +145,6 @@ internal enum L10n {
internal static let revokeDeviceTitle = L10n.tr("Localizable", "accountPage.revokeDeviceTitle", fallback: "Revoke device") internal static let revokeDeviceTitle = L10n.tr("Localizable", "accountPage.revokeDeviceTitle", fallback: "Revoke device")
/// Settings /// Settings
internal static let settingsHeader = L10n.tr("Localizable", "accountPage.settingsHeader", fallback: "Settings") internal static let settingsHeader = L10n.tr("Localizable", "accountPage.settingsHeader", fallback: "Settings")
/// Share Account Details
internal static let shareAccountDetails = L10n.tr("Localizable", "accountPage.shareAccountDetails", fallback: "Share Account Details")
/// Enable TURN /// Enable TURN
internal static let turnEnabled = L10n.tr("Localizable", "accountPage.turnEnabled", fallback: "Enable TURN") internal static let turnEnabled = L10n.tr("Localizable", "accountPage.turnEnabled", fallback: "Enable TURN")
/// TURN password /// TURN password
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
* Author: Quentin Muret <quentin.muret@savoirfairelinux.com> * Author: Quentin Muret <quentin.muret@savoirfairelinux.com>
* Author: Alireza Toghiani Khorasgani <alireza.toghiani@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Copyright (C) 2017-2019 Savoir-faire Linux Inc. * Copyright (C) 2017-2019 Savoir-faire Linux Inc.
* *
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
* Author: Alireza Toghiani Khorasgani <alireza.toghiani@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
......
...@@ -174,13 +174,19 @@ extension UIView { ...@@ -174,13 +174,19 @@ extension UIView {
} }
func roundTopCorners(radius: CGFloat) { func roundTopCorners(radius: CGFloat) {
// DispatchQueue.main.async { [weak self] in
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: radius, height: radius)) let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer() let mask = CAShapeLayer()
mask.path = path.cgPath mask.path = path.cgPath
mask.frame = bounds mask.frame = self.bounds
layer.mask = mask
}
func roundAllCorners(radius: CGFloat) {
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.bottomLeft, .bottomRight, .topRight, .topLeft], cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
mask.frame = self.bounds
layer.mask = mask layer.mask = mask
// }
} }
func removeCorners() { func removeCorners() {
......
...@@ -156,13 +156,13 @@ extension UIViewController { ...@@ -156,13 +156,13 @@ extension UIViewController {
.disposed(by: disposeBag) .disposed(by: disposeBag)
} }
func configureNavigationBar(isTransparent: Bool = false) { func configureNavigationBar(isTransparent: Bool = false, backgroundColor: UIColor = .systemBackground) {
let appearance = UINavigationBarAppearance() let appearance = UINavigationBarAppearance()
if isTransparent { if isTransparent {
appearance.configureWithTransparentBackground() appearance.configureWithTransparentBackground()
} else { } else {
appearance.configureWithOpaqueBackground() appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor.systemBackground appearance.backgroundColor = backgroundColor
} }
// Explicitly set shadow properties to none // Explicitly set shadow properties to none
......
...@@ -28,7 +28,7 @@ class AccountHeader: GSKStretchyHeaderView { ...@@ -28,7 +28,7 @@ class AccountHeader: GSKStretchyHeaderView {
override func willMove(toWindow newWindow: UIWindow?) { override func willMove(toWindow newWindow: UIWindow?) {
super.willMove(toWindow: newWindow) super.willMove(toWindow: newWindow)
background.backgroundColor = UIColor.jamiBackgroundColor background.backgroundColor = UIColor.clear
} }
override func didChangeStretchFactor(_ stretchFactor: CGFloat) { override func didChangeStretchFactor(_ stretchFactor: CGFloat) {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/> <device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -17,19 +17,19 @@ ...@@ -17,19 +17,19 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Device ID" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OQs-TS-z4j"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Device ID" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OQs-TS-z4j">
<rect key="frame" x="15" y="45.5" width="54" height="14.5"/> <rect key="frame" x="16" y="45.5" width="54" height="14.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/> <fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/> <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Emx-P1-xQc"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Emx-P1-xQc">
<rect key="frame" x="15" y="10" width="42" height="20.5"/> <rect key="frame" x="16" y="10" width="41.5" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xNp-cR-95I"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xNp-cR-95I">
<rect key="frame" x="330" y="25" width="30" height="30"/> <rect key="frame" x="329" y="25" width="30" height="30"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="30" id="PBa-iQ-J9e"/> <constraint firstAttribute="height" constant="30" id="PBa-iQ-J9e"/>
<constraint firstAttribute="width" constant="30" id="tgl-mD-JbM"/> <constraint firstAttribute="width" constant="30" id="tgl-mD-JbM"/>
......
...@@ -26,6 +26,7 @@ class DisposableCell: UITableViewCell { ...@@ -26,6 +26,7 @@ class DisposableCell: UITableViewCell {
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
self.backgroundColor = .systemBackground
self.disposeBag = DisposeBag() self.disposeBag = DisposeBag()
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="RuW-kz-iBP"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="RuW-kz-iBP">
<device id="retina4_7" orientation="portrait" appearance="light"/> <device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes>
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" contentInsetAdjustmentBehavior="never" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" estimatedSectionHeaderHeight="40" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eg8-N7-lDA" customClass="SettingsTableView" customModule="Ring" customModuleProvider="target"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" contentInsetAdjustmentBehavior="never" dataMode="prototypes" style="insetGrouped" rowHeight="44" sectionHeaderHeight="18" estimatedSectionHeaderHeight="40" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="eg8-N7-lDA" customClass="SettingsTableView" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView> </tableView>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Author: Edric Ladent-Milaret <edric.ladent-milaret@savoirfairelinux.com> * Author: Edric Ladent-Milaret <edric.ladent-milaret@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
* Author: Quentin Muret <quentin.muret@savoirfairelinux.com> * Author: Quentin Muret <quentin.muret@savoirfairelinux.com>
* Author: Alireza Toghiani Khorasgani <alireza.toghiani@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -47,15 +48,14 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -47,15 +48,14 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
private let accountStateCell = "accountStateCell" private let accountStateCell = "accountStateCell"
var loadingViewPresenter = LoadingViewPresenter() var loadingViewPresenter = LoadingViewPresenter()
// MARK: - functions // MARK: - functio
override func viewDidLoad() { override func viewDidLoad() {
self.view.backgroundColor = UIColor.jamiBackgroundColor self.view.backgroundColor = .secondarySystemBackground
self.settingsTable.backgroundColor = UIColor.jamiBackgroundColor setupTableView()
self.addHeaderView() self.addHeaderView()
super.viewDidLoad() super.viewDidLoad()
self.applyL10n() self.applyL10n()
self.configureBindings() self.configureBindings()
self.configureNavigationBar()
self.calculateSipCredentialsMargin() self.calculateSipCredentialsMargin()
self.calculateConnectivityMargin() self.calculateConnectivityMargin()
self.adaptTableToKeyboardState(for: self.settingsTable, self.adaptTableToKeyboardState(for: self.settingsTable,
...@@ -79,8 +79,22 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -79,8 +79,22 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
super.viewWillAppear(animated) super.viewWillAppear(animated)
self.navigationController?.navigationBar.layer.shadowColor = UIColor.clear.cgColor self.navigationController?.navigationBar.layer.shadowColor = UIColor.clear.cgColor
self.navigationController?.navigationBar self.navigationController?.navigationBar
.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18, weight: .medium), .titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18, weight: .medium)]
NSAttributedString.Key.foregroundColor: UIColor.jamiLabelColor] self.configureNavigationBar(backgroundColor: .secondarySystemBackground)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.configureNavigationBar()
}
func setupTableView() {
self.settingsTable.backgroundColor = .secondarySystemBackground
self.settingsTable.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
self.settingsTable.alwaysBounceHorizontal = false
if #available(iOS 15.0, *) {
self.settingsTable.sectionHeaderTopPadding = 0
}
} }
func applyL10n() { func applyL10n() {
...@@ -98,7 +112,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -98,7 +112,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
supportEditProfile() supportEditProfile()
return return
} }
headerView.backgroundColor = UIColor.jamiBackgroundColor headerView.backgroundColor = .secondarySystemBackground
self.stretchyHeader = headerView self.stretchyHeader = headerView
let point = CGPoint(x: 0, y: 120) let point = CGPoint(x: 0, y: 120)
self.stretchyHeader.frame.origin = point self.stretchyHeader.frame.origin = point
...@@ -274,9 +288,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -274,9 +288,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
switch dataSource[indexPath] { switch dataSource[indexPath] {
case .autoRegistration: case .autoRegistration:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.autoRegistration cell.textLabel?.text = L10n.AccountPage.autoRegistration
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -296,10 +310,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -296,10 +310,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
return cell return cell
case .device(let device): case .device(let device):
let cell = tableView.dequeueReusableCell(for: indexPath, cellType: DeviceCell.self) let cell = tableView.dequeueReusableCell(for: indexPath, cellType: DeviceCell.self)
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.deviceIdLabel.text = device.deviceId cell.deviceIdLabel.text = device.deviceId
cell.deviceIdLabel.font = UIFont.preferredFont(forTextStyle: .caption1) cell.deviceIdLabel.font = UIFont.preferredFont(forTextStyle: .caption1)
cell.deviceIdLabel.sizeToFit() cell.deviceIdLabel.sizeToFit()
...@@ -317,17 +329,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -317,17 +329,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.sizeToFit() cell.sizeToFit()
return cell return cell
case .linkNew: case .linkNew:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.linkDeviceTitle cell.textLabel?.text = L10n.AccountPage.linkDeviceTitle
cell.textLabel?.textColor = UIColor.jamiMain cell.textLabel?.textColor = UIColor.jamiButtonDark
cell.textLabel?.textAlignment = .center cell.textLabel?.textAlignment = .center
cell.selectionStyle = .none cell.selectionStyle = .none
cell.sizeToFit() cell.sizeToFit()
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height) let size = CGSize(width: self.settingsTable.frame.width, height: button.frame.height)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.addSubview(button)
button.rx.tap button.rx.tap
...@@ -335,8 +345,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -335,8 +345,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
self?.viewModel.linkDevice() self?.viewModel.linkDevice()
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.backgroundColor = .clear
cell.contentView.backgroundColor = .systemBackground
return cell return cell
case .blockedList: case .blockedList:
let cell = DisposableCell() let cell = DisposableCell()
cell.textLabel?.text = L10n.AccountPage.blockedContacts cell.textLabel?.text = L10n.AccountPage.blockedContacts
...@@ -345,8 +356,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -345,8 +356,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
cell.selectionStyle = .none cell.selectionStyle = .none
cell.sizeToFit() cell.sizeToFit()
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
cell.backgroundColor = UIColor.jamiBackgroundColor let size = CGSize(width: self.settingsTable.frame.width, height: button.frame.height)
let size = CGSize(width: self.view.frame.width, height: button.frame.height)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.addSubview(button)
button.rx.tap button.rx.tap
...@@ -355,23 +365,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -355,23 +365,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
return cell return cell
case .sectionHeader(let title):
let cell = UITableViewCell()
cell.textLabel?.text = title
cell.backgroundColor = UIColor.jamiBackgroundSecondaryColor
cell.selectionStyle = .none
return cell
case .removeAccount: case .removeAccount:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.Global.removeAccount cell.textLabel?.text = L10n.Global.removeAccount
cell.textLabel?.textColor = UIColor.jamiMain cell.textLabel?.textColor = UIColor.systemRed
cell.textLabel?.textAlignment = .center cell.textLabel?.textAlignment = .center
cell.selectionStyle = .none cell.selectionStyle = .none
cell.sizeToFit() cell.sizeToFit()
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height) let size = CGSize(width: self.settingsTable.frame.width, height: 25)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.addSubview(button)
button.rx.tap button.rx.tap
...@@ -379,6 +381,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -379,6 +381,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
self?.confirmRemoveAccountAlert() self?.confirmRemoveAccountAlert()
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.backgroundColor = .clear
cell.contentView.backgroundColor = .clear
return cell return cell
case .jamiUserName(let label): case .jamiUserName(let label):
if !label.isEmpty { if !label.isEmpty {
...@@ -388,12 +392,12 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -388,12 +392,12 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
} }
let cell = DisposableCell() let cell = DisposableCell()
cell.textLabel?.text = L10n.Global.registerAUsername cell.textLabel?.text = L10n.Global.registerAUsername
cell.textLabel?.textColor = UIColor.jamiMain cell.textLabel?.textColor = UIColor.jamiButtonDark
cell.textLabel?.textAlignment = .center cell.textLabel?.textAlignment = .center
cell.sizeToFit() cell.sizeToFit()
cell.selectionStyle = .none cell.selectionStyle = .none
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height) let size = CGSize(width: self.settingsTable.frame.width, height: button.frame.height)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.addSubview(button)
button.rx.tap button.rx.tap
...@@ -408,22 +412,20 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -408,22 +412,20 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
style: .footnote) style: .footnote)
case .ordinary(let label): case .ordinary(let label):
let cell = UITableViewCell() let cell = UITableViewCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = label cell.textLabel?.text = label
cell.selectionStyle = .none cell.selectionStyle = .none
return cell return cell
case .shareAccountDetails: case .shareAccountDetails:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor cell.textLabel?.text = L10n.AccountPage.inviteFriends
cell.textLabel?.text = L10n.AccountPage.shareAccountDetails cell.textLabel?.textColor = UIColor.jamiButtonDark
cell.textLabel?.textColor = UIColor.jamiMain
cell.textLabel?.textAlignment = .center cell.textLabel?.textAlignment = .center
cell.sizeToFit() cell.sizeToFit()
cell.selectionStyle = .none cell.selectionStyle = .none
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height) let size = CGSize(width: cell.contentView.bounds.width, height: button.frame.height)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.contentView.addSubview(button)
button.rx.tap button.rx.tap
.subscribe(onNext: { [weak self] in .subscribe(onNext: { [weak self] in
self?.shareAccountInfo() self?.shareAccountInfo()
...@@ -432,16 +434,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -432,16 +434,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .changePassword: case .changePassword:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
let title = self.viewModel.hasPassword() ? let title = self.viewModel.hasPassword() ?
L10n.AccountPage.changePassword : L10n.AccountPage.createPassword L10n.AccountPage.changePassword : L10n.AccountPage.createPassword
cell.textLabel?.text = title cell.textLabel?.text = title
cell.textLabel?.textColor = UIColor.jamiMain cell.textLabel?.textColor = UIColor.jamiButtonDark
cell.textLabel?.textAlignment = .center cell.textLabel?.textAlignment = .center
cell.sizeToFit() cell.sizeToFit()
cell.selectionStyle = .none cell.selectionStyle = .none
let button = UIButton.init(frame: cell.frame) let button = UIButton.init(frame: cell.frame)
let size = CGSize(width: self.view.frame.width, height: button.frame.height) let size = CGSize(width: self.settingsTable.frame.width, height: button.frame.height)
button.frame.size = size button.frame.size = size
cell.addSubview(button) cell.addSubview(button)
button.rx.tap button.rx.tap
...@@ -452,9 +453,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -452,9 +453,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .notifications: case .notifications:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.enableNotifications cell.textLabel?.text = L10n.AccountPage.enableNotifications
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -475,9 +476,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -475,9 +476,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .peerDiscovery: case .peerDiscovery:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.peerDiscovery cell.textLabel?.text = L10n.AccountPage.peerDiscovery
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -540,10 +541,10 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -540,10 +541,10 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .boothMode: case .boothMode:
let cell = DisposableCell(style: .subtitle, reuseIdentifier: self.jamiIDCell) let cell = DisposableCell(style: .subtitle, reuseIdentifier: self.jamiIDCell)
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.enableBoothMode cell.textLabel?.text = L10n.AccountPage.enableBoothMode
cell.textLabel?.sizeToFit() cell.textLabel?.sizeToFit()
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -575,9 +576,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -575,9 +576,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .enableAccount: case .enableAccount:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.Account.enableAccount cell.textLabel?.text = L10n.Account.enableAccount
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -600,9 +601,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -600,9 +601,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .turnEnabled: case .turnEnabled:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.turnEnabled cell.textLabel?.text = L10n.AccountPage.turnEnabled
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -624,9 +625,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -624,9 +625,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
return cell return cell
case .upnpEnabled: case .upnpEnabled:
let cell = DisposableCell() let cell = DisposableCell()
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.textLabel?.text = L10n.AccountPage.upnpEnabled cell.textLabel?.text = L10n.AccountPage.upnpEnabled
let switchView = UISwitch() let switchView = UISwitch()
switchView.onTintColor = .jamiButtonDark
cell.selectionStyle = .none cell.selectionStyle = .none
cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
cell.accessoryView = switchView cell.accessoryView = switchView
...@@ -670,6 +671,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -670,6 +671,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
} }
let settingsItemDataSource = RxTableViewSectionedReloadDataSource<SettingsSection>(configureCell: configureCell) let settingsItemDataSource = RxTableViewSectionedReloadDataSource<SettingsSection>(configureCell: configureCell)
settingsItemDataSource.titleForHeaderInSection = { dataSource, sectionIndex in
return dataSource[sectionIndex].title
}
self.viewModel.settings self.viewModel.settings
.bind(to: self.settingsTable.rx.items(dataSource: settingsItemDataSource)) .bind(to: self.settingsTable.rx.items(dataSource: settingsItemDataSource))
.disposed(by: disposeBag) .disposed(by: disposeBag)
...@@ -720,7 +724,6 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -720,7 +724,6 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
func configureTurnCell(cellType: SettingsSection.SectionRow, func configureTurnCell(cellType: SettingsSection.SectionRow,
value: String) -> UITableViewCell { value: String) -> UITableViewCell {
let cell = DisposableCell(style: .value1, reuseIdentifier: accountStateCell) let cell = DisposableCell(style: .value1, reuseIdentifier: accountStateCell)
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.selectionStyle = .none cell.selectionStyle = .none
let textField = UITextField() let textField = UITextField()
textField.tag = self.sipCredentialsTAG textField.tag = self.sipCredentialsTAG
...@@ -772,15 +775,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -772,15 +775,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
cell.detailTextLabel?.textColor = UIColor.clear cell.detailTextLabel?.textColor = UIColor.clear
var frame = CGRect(x: self.connectivityMargin, y: 0, var frame = CGRect(x: self.connectivityMargin, y: 0,
width: self.view.frame.width - self.connectivityMargin, width: self.settingsTable.frame.width - self.connectivityMargin,
height: cell.frame.height) height: cell.frame.height)
if cell.isRightToLeft { if cell.isRightToLeft {
frame = CGRect(x: 0, y: 0, frame = CGRect(x: 0, y: 0,
width: self.view.frame.width - self.connectivityMargin - 10, width: self.settingsTable.frame.width - self.connectivityMargin - 10,
height: cell.frame.height) height: cell.frame.height)
} }
if self.view.frame.width - self.connectivityMargin < textField.frame.size.width { if self.settingsTable.frame.width - self.connectivityMargin < textField.frame.size.width {
let origin = CGPoint(x: 10, y: cell.textLabel!.frame.size.height + 25) let origin = CGPoint(x: 10, y: cell.textLabel!.frame.size.height + 25)
let size = textField.frame.size let size = textField.frame.size
frame.origin = origin frame.origin = origin
...@@ -800,15 +803,14 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -800,15 +803,14 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
func configureSipCredentialsCell(cellType: SettingsSection.SectionRow, func configureSipCredentialsCell(cellType: SettingsSection.SectionRow,
value: String) -> UITableViewCell { value: String) -> UITableViewCell {
let cell = DisposableCell(style: .value1, reuseIdentifier: sipAccountCredentialsCell) let cell = DisposableCell(style: .value1, reuseIdentifier: sipAccountCredentialsCell)
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.selectionStyle = .none cell.selectionStyle = .none
let text = UITextField() let textField = UITextField()
text.tag = self.sipCredentialsTAG textField.tag = self.sipCredentialsTAG
text.font = UIFont.preferredFont(forTextStyle: .callout) textField.font = UIFont.preferredFont(forTextStyle: .callout)
text.returnKeyType = .done textField.returnKeyType = .done
text.text = value textField.text = value
text.sizeToFit() textField.sizeToFit()
text.rx.controlEvent(.editingDidEndOnExit) textField.rx.controlEvent(.editingDidEndOnExit)
.observe(on: MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] _ in .subscribe(onNext: { [weak self] _ in
self?.viewModel.updateSipSettings() self?.viewModel.updateSipSettings()
...@@ -816,17 +818,17 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -816,17 +818,17 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
switch cellType { switch cellType {
case .port: case .port:
text.rx.text.orEmpty.distinctUntilChanged() textField.rx.text.orEmpty.distinctUntilChanged()
.bind(to: self.viewModel.port) .bind(to: self.viewModel.port)
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.textLabel?.text = L10n.Account.port cell.textLabel?.text = L10n.Account.port
case .proxyServer: case .proxyServer:
text.rx.text.orEmpty.distinctUntilChanged() textField.rx.text.orEmpty.distinctUntilChanged()
.bind(to: self.viewModel.proxyServer) .bind(to: self.viewModel.proxyServer)
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.textLabel?.text = L10n.Account.proxyServer cell.textLabel?.text = L10n.Account.proxyServer
case .sipServer: case .sipServer:
text.rx.text.orEmpty.distinctUntilChanged() textField.rx.text.orEmpty.distinctUntilChanged()
.bind(to: self.viewModel.sipServer) .bind(to: self.viewModel.sipServer)
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.textLabel?.text = L10n.Account.sipServer cell.textLabel?.text = L10n.Account.sipServer
...@@ -835,13 +837,13 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -835,13 +837,13 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
// show password button // show password button
let rightButton = UIButton(type: .custom) let rightButton = UIButton(type: .custom)
var insets = rightButton.contentEdgeInsets var insets = rightButton.contentEdgeInsets
insets.right = 20.0 insets.right = 60
rightButton.contentEdgeInsets = insets rightButton.contentEdgeInsets = insets
self.viewModel.secureTextEntry self.viewModel.secureTextEntry
.asObservable() .asObservable()
.observe(on: MainScheduler.instance) .observe(on: MainScheduler.instance)
.subscribe(onNext: { (secure) in .subscribe(onNext: { (secure) in
text.isSecureTextEntry = secure textField.isSecureTextEntry = secure
if secure { if secure {
rightButton.setImage(UIImage(asset: Asset.icHideInput), rightButton.setImage(UIImage(asset: Asset.icHideInput),
for: .normal) for: .normal)
...@@ -852,15 +854,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -852,15 +854,15 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
rightButton.tintColor = UIColor.darkGray rightButton.tintColor = UIColor.darkGray
text.rightViewMode = .always textField.rightViewMode = .always
text.rightView = rightButton textField.rightView = rightButton
rightButton.rx.tap rightButton.rx.tap
.subscribe(onNext: { [weak self] _ in .subscribe(onNext: { [weak self] _ in
self?.viewModel.secureTextEntry self?.viewModel.secureTextEntry
.onNext(!text.isSecureTextEntry) .onNext(!textField.isSecureTextEntry)
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
text.rx.text.orEmpty.distinctUntilChanged() textField.rx.text.orEmpty.distinctUntilChanged()
.bind { [weak self, weak rightButton] newText in .bind { [weak self, weak rightButton] newText in
self?.viewModel.sipPassword.accept(newText) self?.viewModel.sipPassword.accept(newText)
rightButton?.isHidden = newText.isEmpty rightButton?.isHidden = newText.isEmpty
...@@ -868,7 +870,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -868,7 +870,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
} }
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
case .sipUserName: case .sipUserName:
text.rx.text.orEmpty.distinctUntilChanged() textField.rx.text.orEmpty.distinctUntilChanged()
.bind(to: self.viewModel.sipUsername) .bind(to: self.viewModel.sipUsername)
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
cell.textLabel?.text = L10n.Account.sipUsername cell.textLabel?.text = L10n.Account.sipUsername
...@@ -880,11 +882,11 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -880,11 +882,11 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .callout) cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .callout)
cell.detailTextLabel?.textColor = UIColor.clear cell.detailTextLabel?.textColor = UIColor.clear
var frame = CGRect(x: self.sipCredentialsMargin, y: 0, var frame = CGRect(x: self.sipCredentialsMargin, y: 0,
width: self.view.frame.width - self.sipCredentialsMargin, width: self.settingsTable.frame.width - self.sipCredentialsMargin,
height: cell.frame.height) height: cell.frame.height)
if self.view.frame.width - self.sipCredentialsMargin < text.frame.size.width { if self.settingsTable.frame.width - self.sipCredentialsMargin < textField.frame.size.width {
let origin = CGPoint(x: 10, y: cell.textLabel!.frame.size.height + 25) let origin = CGPoint(x: 10, y: cell.textLabel!.frame.size.height + 25)
let size = text.frame.size let size = textField.frame.size
frame.origin = origin frame.origin = origin
frame.size = size frame.size = size
cell.detailTextLabel?.text = value cell.detailTextLabel?.text = value
...@@ -892,8 +894,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -892,8 +894,8 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
cell.detailTextLabel?.text = "" cell.detailTextLabel?.text = ""
} }
cell.detailTextLabel?.sizeToFit() cell.detailTextLabel?.sizeToFit()
text.frame = frame textField.frame = frame
cell.contentView.addSubview(text) cell.contentView.addSubview(textField)
cell.sizeToFit() cell.sizeToFit()
return cell return cell
} }
...@@ -1242,6 +1244,25 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -1242,6 +1244,25 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
} }
extension MeViewController: UITableViewDelegate { extension MeViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if let dataSourceProxy = tableView.dataSource as? RxTableViewDataSourceProxy,
let actualDataSource = dataSourceProxy.forwardToDelegate() as? RxTableViewSectionedReloadDataSource<SettingsSection> {
let headerTitle = actualDataSource[section].title
if headerTitle == nil || headerTitle == .some("") {
return 10
}
}
return 50
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNonzeroMagnitude
}
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
let navigationHeight = self.navigationController?.navigationBar.bounds.height let navigationHeight = self.navigationController?.navigationBar.bounds.height
var size = self.view.bounds.size var size = self.view.bounds.size
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Author: Thibault Wittemberg <thibault.wittemberg@savoirfairelinux.com> * Author: Thibault Wittemberg <thibault.wittemberg@savoirfairelinux.com>
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
* Author: Quentin Muret <quentin.muret@savoirfairelinux.com> * Author: Quentin Muret <quentin.muret@savoirfairelinux.com>
* Author: Alireza Toghiani Khorasgani <alireza.toghiani@savoirfairelinux.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,9 +32,12 @@ enum SettingsSection: SectionModelType { ...@@ -31,9 +32,12 @@ enum SettingsSection: SectionModelType {
typealias Item = SectionRow typealias Item = SectionRow
case linkedDevices(items: [SectionRow]) case linkedDevices(items: [SectionRow])
case linkNewDevice(items: [SectionRow])
case accountSettings(items: [SectionRow]) case accountSettings(items: [SectionRow])
case notificationSettings(items: [SectionRow])
case connectivitySettings(items: [SectionRow])
case credentials(items: [SectionRow]) case credentials(items: [SectionRow])
case otherSettings(items: [SectionRow])
case removeAccountSettings(items: [SectionRow])
enum SectionRow { enum SectionRow {
case device(device: DeviceModel) case device(device: DeviceModel)
...@@ -41,7 +45,6 @@ enum SettingsSection: SectionModelType { ...@@ -41,7 +45,6 @@ enum SettingsSection: SectionModelType {
case blockedList case blockedList
case removeAccount case removeAccount
case shareAccountDetails case shareAccountDetails
case sectionHeader(title: String)
case ordinary(label: String) case ordinary(label: String)
case jamiID(label: String) case jamiID(label: String)
case jamiUserName(label: String) case jamiUserName(label: String)
...@@ -68,27 +71,46 @@ enum SettingsSection: SectionModelType { ...@@ -68,27 +71,46 @@ enum SettingsSection: SectionModelType {
var items: [SectionRow] { var items: [SectionRow] {
switch self { switch self {
case .linkedDevices(let items): case .linkedDevices(let items), .removeAccountSettings(items: let items), .notificationSettings(let items), .connectivitySettings(let items), .credentials(let items), .otherSettings(items: let items), .accountSettings(items: let items):
return items
case .linkNewDevice(let items):
return items
case .accountSettings(let items):
return items
case .credentials(let items):
return items return items
} }
} }
var title: String? {
switch self {
case .linkedDevices:
return L10n.AccountPage.devicesListHeader
case .otherSettings:
return L10n.AccountPage.other
case .removeAccountSettings:
return nil
case .notificationSettings:
return L10n.AccountPage.notificationsHeader
case .connectivitySettings:
return L10n.AccountPage.connectivityHeader
case .credentials:
return L10n.AccountPage.credentialsHeader
case .accountSettings(items: let items):
return nil
}
}
init(original: SettingsSection, items: [SectionRow]) { init(original: SettingsSection, items: [SectionRow]) {
switch original { switch original {
case .accountSettings(items: let items):
self = .accountSettings(items: items)
case .linkedDevices: case .linkedDevices:
self = .linkedDevices(items: items) self = .linkedDevices(items: items)
case .linkNewDevice: case .notificationSettings:
self = .linkNewDevice(items: items) self = .notificationSettings(items: items)
case .accountSettings: case .connectivitySettings:
self = .accountSettings(items: items) self = .connectivitySettings(items: items)
case .credentials: case .credentials:
self = .credentials(items: items) self = .credentials(items: items)
case .otherSettings(items: let items):
self = .otherSettings(items: items)
case .removeAccountSettings(items: let items):
self = .removeAccountSettings(items: items)
} }
} }
} }
...@@ -134,8 +156,7 @@ class MeViewModel: ViewModel, Stateable { ...@@ -134,8 +156,7 @@ class MeViewModel: ViewModel, Stateable {
lazy var accountCredentials: Observable<SettingsSection> = { lazy var accountCredentials: Observable<SettingsSection> = {
return Observable return Observable
.combineLatest(userName.startWith(""), ringId.startWith("")) { (name, ringID) in .combineLatest(userName.startWith(""), ringId.startWith("")) { (name, ringID) in
var items: [SettingsSection.SectionRow] = [.sectionHeader(title: L10n.AccountPage.credentialsHeader), var items: [SettingsSection.SectionRow] = [.jamiID(label: ringID)]
.jamiID(label: ringID)]
items.append(.jamiUserName(label: name)) items.append(.jamiUserName(label: name))
items.append(.shareAccountDetails) items.append(.shareAccountDetails)
return SettingsSection return SettingsSection
...@@ -147,14 +168,9 @@ class MeViewModel: ViewModel, Stateable { ...@@ -147,14 +168,9 @@ class MeViewModel: ViewModel, Stateable {
return self.accountService.accountInfoToShare return self.accountService.accountInfoToShare
} }
lazy var linkNewDevice: Observable<SettingsSection> = {
return Observable.just(.linkNewDevice(items: [.linkNew]))
}()
lazy var removeAccount: Observable<SettingsSection> = { lazy var removeAccount: Observable<SettingsSection> = {
return Observable return Observable
.just(.accountSettings( items: [.sectionHeader(title: ""), .just(.removeAccountSettings( items: [.ordinary(label: L10n.Global.removeAccount)]))
.ordinary(label: L10n.Global.removeAccount)]))
}() }()
lazy var accountStatus: BehaviorRelay<String> = { lazy var accountStatus: BehaviorRelay<String> = {
...@@ -188,8 +204,7 @@ class MeViewModel: ViewModel, Stateable { ...@@ -188,8 +204,7 @@ class MeViewModel: ViewModel, Stateable {
lazy var accountJamiSettings: Observable<SettingsSection> = { lazy var accountJamiSettings: Observable<SettingsSection> = {
return Observable return Observable
.just(.accountSettings( items: [.sectionHeader(title: L10n.AccountPage.settingsHeader), .just(.notificationSettings( items: [.notifications]))
.notifications]))
}() }()
lazy var connectivitySettings: Observable<SettingsSection> = { lazy var connectivitySettings: Observable<SettingsSection> = {
...@@ -209,8 +224,7 @@ class MeViewModel: ViewModel, Stateable { ...@@ -209,8 +224,7 @@ class MeViewModel: ViewModel, Stateable {
self.turnRealm.accept(realm) self.turnRealm.accept(realm)
} }
return Observable return Observable
.just(.accountSettings(items: [.sectionHeader(title: L10n.AccountPage.connectivityHeader), .just(.connectivitySettings(items: [.turnEnabled,
.turnEnabled,
.turnServer, .turnServer,
.turnUsername, .turnUsername,
.turnPassword, .turnPassword,
...@@ -219,14 +233,12 @@ class MeViewModel: ViewModel, Stateable { ...@@ -219,14 +233,12 @@ class MeViewModel: ViewModel, Stateable {
}() }()
lazy var otherJamiSettings: Observable<SettingsSection> = { lazy var otherJamiSettings: Observable<SettingsSection> = {
let items: [SettingsSection.SectionRow] = [.sectionHeader(title: L10n.AccountPage.other), let items: [SettingsSection.SectionRow] = [.peerDiscovery,
.peerDiscovery,
.blockedList, .blockedList,
.accountState(state: self.accountStatus), .accountState(state: self.accountStatus),
.enableAccount, .enableAccount,
.changePassword, .changePassword,
.boothMode, .boothMode]
.removeAccount]
return Observable.combineLatest(Observable.just(items), return Observable.combineLatest(Observable.just(items),
self.accountService.currentAccountChanged.asObservable().startWith(nil), self.accountService.currentAccountChanged.asObservable().startWith(nil),
...@@ -237,7 +249,7 @@ class MeViewModel: ViewModel, Stateable { ...@@ -237,7 +249,7 @@ class MeViewModel: ViewModel, Stateable {
items.remove(at: items.count - 2) // remove .boothMode items.remove(at: items.count - 2) // remove .boothMode
items.remove(at: items.count - 2) // remove .changePassword items.remove(at: items.count - 2) // remove .changePassword
} }
return SettingsSection.accountSettings(items: items) return SettingsSection.otherSettings(items: items)
}) })
}() }()
...@@ -248,12 +260,12 @@ class MeViewModel: ViewModel, Stateable { ...@@ -248,12 +260,12 @@ class MeViewModel: ViewModel, Stateable {
lazy var jamiSettings: Observable<[SettingsSection]> = { lazy var jamiSettings: Observable<[SettingsSection]> = {
Observable.combineLatest(accountCredentials, Observable.combineLatest(accountCredentials,
linkNewDevice,
linkedDevices, linkedDevices,
accountJamiSettings, accountJamiSettings,
connectivitySettings, connectivitySettings,
otherJamiSettings) { (credentials, linkNew, devices, settings, connectivity, other) in otherJamiSettings,
return [credentials, devices, linkNew, settings, connectivity, other] removeAccountSettings) { (credentials, devices, settings, connectivity, other, removeAccount) in
return [credentials, devices, settings, connectivity, other, removeAccount]
} }
}() }()
...@@ -262,11 +274,14 @@ class MeViewModel: ViewModel, Stateable { ...@@ -262,11 +274,14 @@ class MeViewModel: ViewModel, Stateable {
lazy var otherSipSettings: Observable<SettingsSection> = { lazy var otherSipSettings: Observable<SettingsSection> = {
return Observable return Observable
.just(SettingsSection.accountSettings( items: [.sectionHeader(title: ""), .just(SettingsSection.accountSettings( items: [.accountState(state: self.accountStatus),
.accountState(state: self.accountStatus),
.enableAccount, .enableAccount,
.autoRegistration, .autoRegistration]))
.removeAccount])) }()
lazy var removeAccountSettings: Observable<SettingsSection> = {
return Observable
.just(SettingsSection.removeAccountSettings( items: [.removeAccount]))
}() }()
lazy var sipCredentials: Observable<SettingsSection> = { lazy var sipCredentials: Observable<SettingsSection> = {
...@@ -292,14 +307,12 @@ class MeViewModel: ViewModel, Stateable { ...@@ -292,14 +307,12 @@ class MeViewModel: ViewModel, Stateable {
} }
// isIP2IP // isIP2IP
if server.isEmpty { if server.isEmpty {
return .accountSettings( items: [.sectionHeader(title: ""), return .accountSettings( items: [.sipUserName(value: username),
.sipUserName(value: username),
.sipPassword(value: password), .sipPassword(value: password),
.sipServer(value: server), .sipServer(value: server),
.shareAccountDetails]) .shareAccountDetails])
} }
return .accountSettings( items: [.sectionHeader(title: ""), return .accountSettings( items: [.sipUserName(value: username),
.sipUserName(value: username),
.sipPassword(value: password), .sipPassword(value: password),
.sipServer(value: server), .sipServer(value: server),
.port(value: port), .port(value: port),
...@@ -624,9 +637,11 @@ class MeViewModel: ViewModel, Stateable { ...@@ -624,9 +637,11 @@ class MeViewModel: ViewModel, Stateable {
isCurrent: true))] isCurrent: true))]
} }
if rows != nil { if rows != nil {
rows?.insert(.sectionHeader(title: L10n.AccountPage.devicesListHeader), at: 0) rows!.append(.linkNew)
let devicesSection: SettingsSection = .linkedDevices(items: rows!) let devicesSection: SettingsSection = .linkedDevices(items: rows!)
return devicesSection return devicesSection
} else {
rows = [.linkNew]
} }
return empptySection return empptySection
} }
......
...@@ -235,6 +235,7 @@ ...@@ -235,6 +235,7 @@
//Account Page //Account Page
"accountPage.devicesListHeader" = "Devices"; "accountPage.devicesListHeader" = "Devices";
"accountPage.settingsHeader" = "Settings"; "accountPage.settingsHeader" = "Settings";
"accountPage.notificationsHeader" = "Notifications";
"accountPage.usernameNotRegistered" = "username: not registered"; "accountPage.usernameNotRegistered" = "username: not registered";
"accountPage.credentialsHeader" = "Account Details"; "accountPage.credentialsHeader" = "Account Details";
"accountPage.blockedContacts" = "Blocked contacts"; "accountPage.blockedContacts" = "Blocked contacts";
...@@ -260,7 +261,7 @@ ...@@ -260,7 +261,7 @@
"accountPage.other" = "Other"; "accountPage.other" = "Other";
"accountPage.removeAccountMessage" = "By clicking \"Remove\" you will remove this account on this device! This action can not be undone. Also, your registered name can be lost."; "accountPage.removeAccountMessage" = "By clicking \"Remove\" you will remove this account on this device! This action can not be undone. Also, your registered name can be lost.";
"accountPage.removeAccountButton" = "Remove"; "accountPage.removeAccountButton" = "Remove";
"accountPage.shareAccountDetails" = "Share Account Details"; "accountPage.inviteFriends" = "Invite friends";
"accountPage.contactMeOnJamiTitle" = "Contact me on Jami!"; "accountPage.contactMeOnJamiTitle" = "Contact me on Jami!";
"accountPage.contactMeOnJamiContant" = "Contact me using \"%s\" on the Jami distributed communication platform: https://jami.net"; "accountPage.contactMeOnJamiContant" = "Contact me using \"%s\" on the Jami distributed communication platform: https://jami.net";
"accountPage.passwordPlaceholder" = "Enter account password"; "accountPage.passwordPlaceholder" = "Enter account password";
......
...@@ -24,6 +24,16 @@ ...@@ -24,6 +24,16 @@
*/ */
final class SettingsTableView: UITableView { final class SettingsTableView: UITableView {
override var contentOffset: CGPoint {
didSet {
if contentOffset.x != 0 && !alwaysBounceHorizontal {
print("********* Unexpected horizontal scroll detected!")
contentOffset.x = 0
}
}
}
override func scrollRectToVisible(_ rect: CGRect, animated: Bool) { override func scrollRectToVisible(_ rect: CGRect, animated: Bool) {
// Don'd do anything here to prevent autoscrolling. // Don'd do anything here to prevent autoscrolling.
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment