|
@@ -9,7 +9,7 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
|
|
|
|
|
|
private var selectedIndex: Int = 0
|
|
|
|
|
|
- private func getQrCodeHint() -> String {
|
|
|
+ private var qrCodeHint: String {
|
|
|
var qrCodeHint = ""
|
|
|
if dcContext.isConfigured() {
|
|
|
// we cannot use dc_contact_get_displayname() as this would result in "Me" instead of the real name
|
|
@@ -55,7 +55,7 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
|
|
|
delegate = self
|
|
|
navigationItem.titleView = qrSegmentControl
|
|
|
|
|
|
- let qrController = QrViewController(dcContext: dcContext, qrCodeHint: getQrCodeHint())
|
|
|
+ let qrController = QrViewController(dcContext: dcContext, qrCodeHint: qrCodeHint)
|
|
|
setViewControllers(
|
|
|
[qrController],
|
|
|
direction: .forward,
|
|
@@ -69,6 +69,7 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
|
|
|
if let qrCodeReaderController = self.qrCodeReaderController {
|
|
|
qrCodeReaderController.startSession()
|
|
|
}
|
|
|
+ updateHintTextIfNeeded() // needed in case user changes profile name
|
|
|
}
|
|
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
@@ -83,7 +84,7 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
|
|
|
// MARK: - actions
|
|
|
@objc private func qrSegmentControlChanged(_ sender: UISegmentedControl) {
|
|
|
if sender.selectedSegmentIndex == 0 {
|
|
|
- let qrController = QrViewController(dcContext: dcContext, qrCodeHint: getQrCodeHint())
|
|
|
+ let qrController = QrViewController(dcContext: dcContext, qrCodeHint: qrCodeHint)
|
|
|
setViewControllers([qrController], direction: .reverse, animated: true, completion: nil)
|
|
|
} else {
|
|
|
let qrCodeReaderController = makeQRReader()
|
|
@@ -99,6 +100,16 @@ class QrPageController: UIPageViewController, ProgressAlertHandler {
|
|
|
return qrReader
|
|
|
}
|
|
|
|
|
|
+ // MARK: - update
|
|
|
+ private func updateHintTextIfNeeded() {
|
|
|
+ for case let qrViewController as QrViewController in self.viewControllers ?? [] {
|
|
|
+ let newHint = qrCodeHint
|
|
|
+ if qrCodeHint != qrViewController.qrCodeHint {
|
|
|
+ qrViewController.qrCodeHint = newHint
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: - coordinator
|
|
|
private func showChats() {
|
|
|
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
|
|
@@ -119,7 +130,7 @@ extension QrPageController: UIPageViewControllerDataSource, UIPageViewController
|
|
|
if viewController is QrViewController {
|
|
|
return nil
|
|
|
}
|
|
|
- return QrViewController(dcContext: dcContext, qrCodeHint: getQrCodeHint())
|
|
|
+ return QrViewController(dcContext: dcContext, qrCodeHint: qrCodeHint)
|
|
|
}
|
|
|
|
|
|
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|