From 031cd8708434f206adfbe4b6829fe038a4ea5fac Mon Sep 17 00:00:00 2001 From: Arnfried Griesert Date: Fri, 8 Sep 2023 06:41:40 +0000 Subject: [PATCH] MESSENGER-4807 new add room menu --- Config/BWIBuildSettings.swift | 3 + .../BuM-Beta/BWIBuildSettings+BuM-Beta.swift | 3 +- .../Button-new-dark.svg | 17 +++++ .../button_new_dark.imageset/Contents.json | 12 ++++ .../Button-new-light.svg | 17 +++++ .../button_new_light.imageset/Contents.json | 12 ++++ .../AllChats/AllChatsViewController.swift | 63 +++++++++++++++++-- 7 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Button-new-dark.svg create mode 100644 Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Contents.json create mode 100644 Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Button-new-light.svg create mode 100644 Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Contents.json diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index 30cd1b34e..f7462cc74 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -669,4 +669,7 @@ class BWIBuildSettings: NSObject { // MARK: OIDC var isOIDCEnabled = true + + // MARK: Create Room Menu + var enableAllChatsToolbar = true } diff --git a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift index 023974a5f..1ffd4cb99 100644 --- a/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift +++ b/Config/BuM-Beta/BWIBuildSettings+BuM-Beta.swift @@ -39,7 +39,8 @@ extension BWIBuildSettings { enableLabFeatureWYSIWYG = true showMaintenanceInfoMessageType = true ignoreBlockingMaintenance = true - + enableAllChatsToolbar = false + itunesAppLink = "itms://itunes.apple.com/app/bundesmessenger-beta/id1617068656?mt=8" } diff --git a/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Button-new-dark.svg b/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Button-new-dark.svg new file mode 100644 index 000000000..ef0537d90 --- /dev/null +++ b/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Button-new-dark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Contents.json b/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Contents.json new file mode 100644 index 000000000..342061223 --- /dev/null +++ b/Riot/Assets/Images.xcassets/BWI/button_new_dark.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Button-new-dark.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Button-new-light.svg b/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Button-new-light.svg new file mode 100644 index 000000000..f30c515a5 --- /dev/null +++ b/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Button-new-light.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Contents.json b/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Contents.json new file mode 100644 index 000000000..77ef7c0ca --- /dev/null +++ b/Riot/Assets/Images.xcassets/BWI/button_new_light.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "Button-new-light.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index b0fcfb848..3d526fab7 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -77,6 +77,9 @@ class AllChatsViewController: HomeViewController { private var isOnboardingCoordinatorPreparing: Bool = false + // bwi: 4807 + private var floatingButton: UIButton? + private var theme: Theme { ThemeService.shared().theme } @@ -92,10 +95,11 @@ class AllChatsViewController: HomeViewController { } private func setToolbarHidden(_ isHidden: Bool, animated: Bool) { - UIView.animate(withDuration: animated ? 0.3 : 0) { - self.isToolbarHidden = isHidden + if BWIBuildSettings.shared.enableAllChatsToolbar { + UIView.animate(withDuration: animated ? 0.3 : 0) { + self.isToolbarHidden = isHidden + } } - } // MARK: - SplitViewMasterViewControllerProtocol @@ -144,6 +148,23 @@ class AllChatsViewController: HomeViewController { } else { toolbar.tintColor = theme.colors.accent } + + // bwi: 4807 - hide the toolbar and show a floating button for room create instead + if !BWIBuildSettings.shared.enableAllChatsToolbar { + // no toolbar then use a floating button instead + floatingButton = UIButton(frame: CGRect(x: 50, y: 50, width: 50, height: 50)) + updateFloatingButton() + if let floatingButton = floatingButton { + view.addSubview(floatingButton) + } + + // set constraint to make the floating button stay in the lower right corner + floatingButton?.translatesAutoresizingMaskIntoConstraints = false + floatingButton?.widthAnchor.constraint(equalToConstant: 50).isActive = true + floatingButton?.heightAnchor.constraint(equalToConstant: 50).isActive = true + floatingButton?.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -10).isActive = true + floatingButton?.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -40).isActive = true + } if BWIBuildSettings.shared.roomFiltersToggle { updateNewFilterSearchAndToggleButton() @@ -248,6 +269,12 @@ class AllChatsViewController: HomeViewController { self.toolbar.tintColor = theme.colors.accent } + // bwi: 4807 - hide the toolbar and show a floating button for room create instead + if !BWIBuildSettings.shared.enableAllChatsToolbar { + toolbar.transform = CGAffineTransform(translationX: 0, y: 2 * toolbarHeight) + self.view.layoutIfNeeded() + } + if BWIBuildSettings.shared.roomFiltersToggle { if ThemeService.shared().isCurrentThemeDark() { roomFilterButton?.setImage(Asset.Images.roomFilterToggleDarkOff.image, for: .normal) @@ -668,6 +695,17 @@ class AllChatsViewController: HomeViewController { } else { self.navigationController?.toolbar?.tintColor = theme.colors.accent } + + // bwi: 4807 + updateFloatingButton() + } + + private func updateFloatingButton() { + if ThemeService.shared().isCurrentThemeDark() { + floatingButton?.setImage(Asset.Images.buttonNewDark.image, for: .normal) + } else { + floatingButton?.setImage(Asset.Images.buttonNewLight.image, for: .normal) + } } // MARK: - Private @@ -699,9 +737,22 @@ class AllChatsViewController: HomeViewController { self.title = currentSpace?.summary?.displayName ?? VectorL10n.allChatsTitle setupEditOptions() - updateToolbar(with: editActionProvider.updateMenu(with: mainSession, parentSpace: currentSpace, completion: { [weak self] menu in - self?.updateToolbar(with: menu) - })) + + let menu = editActionProvider.updateMenu(with: mainSession, parentSpace: currentSpace, completion: { [weak self] menu in + if BWIBuildSettings.shared.enableAllChatsToolbar { + self?.updateToolbar(with: menu) + } else { + } + }) + + if BWIBuildSettings.shared.enableAllChatsToolbar { + updateToolbar(with: menu) + } else { + updateFloatingButton() + self.floatingButton?.menu = menu + self.floatingButton?.showsMenuAsPrimaryAction = true + } + updateEmptyView() updateBadgeButton() }