mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Feature/4041 new layout new feature banner
This commit is contained in:
@@ -81,10 +81,10 @@
|
||||
constraintWithItem:topBannerViewController.view
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.view
|
||||
toItem:self.view.safeAreaLayoutGuide
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0
|
||||
constant:statusBarHeight + navigationBarHeight];
|
||||
constant:0];
|
||||
[[self view] addConstraint:alignTopConstraint];
|
||||
|
||||
NSLayoutConstraint *alignLeadingConstraint = [NSLayoutConstraint
|
||||
@@ -131,7 +131,7 @@
|
||||
FeatureBannerVisibilityService *service = [[FeatureBannerVisibilityService alloc] initWithMxSession:session];
|
||||
[service isUnreadWithVersion:version completion:^(BOOL unread) {
|
||||
if (unread) {
|
||||
//[bannerControllers addObject:[[FeatureBannerViewController alloc] initWithSession:session version:version]];
|
||||
// [bannerControllers addObject:[[FeatureBannerViewController alloc] initWithSession:session version:version]];
|
||||
|
||||
self->topBannerViewController = [[TopBannerViewController alloc] initWithControllers: bannerControllers];
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
|
||||
// this notification will be called either if the user clicked on the banner or wants to hide it using a swipe gesture
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:@"de.bwi.messenger.mark_top_banner_as_read" object:NULL queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
|
||||
shouldHideBanner = TRUE;
|
||||
self->shouldHideBanner = TRUE;
|
||||
}];
|
||||
|
||||
self->bannersInitialized = TRUE;
|
||||
|
||||
@@ -141,7 +141,19 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
}
|
||||
|
||||
func pinUnlocked() {
|
||||
let serverDownTime = ServerDowntimeDefaultService()
|
||||
// bwi: bwi specific
|
||||
if BWIBuildSettings.shared.useTestDataForDowntime {
|
||||
serverDownTime.fetchDowntimes(completion: {
|
||||
self.createLeftButtonItem(for: self.allChatsViewController)
|
||||
})
|
||||
} else {
|
||||
if let session = self.currentMatrixSession {
|
||||
serverDownTime.fetchDowntimes(session: session, completion: {
|
||||
self.createLeftButtonItem(for: self.allChatsViewController)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func bwiOnUnlockedByPin() {
|
||||
@@ -374,7 +386,7 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
view.backgroundColor = .clear
|
||||
|
||||
let avatarInsets: UIEdgeInsets = .init(top: 7, left: 7, bottom: 7, right: 7)
|
||||
let button: UIButton = .init(frame: view.bounds.inset(by: avatarInsets))
|
||||
var button: UIButton = .init(frame: view.bounds.inset(by: avatarInsets))
|
||||
button.setImage(Asset.Images.tabPeople.image, for: .normal)
|
||||
|
||||
if BWIBuildSettings.shared.enableSideMenu {
|
||||
@@ -385,6 +397,14 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
}
|
||||
button.autoresizingMask = [.flexibleHeight, .flexibleWidth]
|
||||
button.accessibilityLabel = VectorL10n.allChatsUserMenuAccessibilityLabel
|
||||
|
||||
let serverDownTime = ServerDowntimeDefaultService()
|
||||
if serverDownTime.isDowntimePresentable() {
|
||||
button = ServerDowntimeBadge().applyBadgeToButton(button: button, color: serverDownTime.downtimeColor())
|
||||
} else if BWIBuildSettings.shared.bwiCheckAppVersion && ValidAppVersionsDefaultService().isCurrentAppVersionOutdated() {
|
||||
button = ServerDowntimeBadge().applyBadgeToButton(button: button, color: .yellow)
|
||||
}
|
||||
|
||||
view.addSubview(button)
|
||||
self.avatarMenuButton = button
|
||||
|
||||
@@ -393,6 +413,8 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
avatarView.update(theme: ThemeService.shared().theme)
|
||||
avatarView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
|
||||
view.addSubview(avatarView)
|
||||
view.bringSubviewToFront(button)
|
||||
|
||||
self.avatarMenuView = avatarView
|
||||
updateAvatarButtonItem()
|
||||
viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: view)
|
||||
|
||||
@@ -1006,6 +1006,7 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
|
||||
|
||||
func bwiOnUnlockedByPin() {
|
||||
// bwi specific
|
||||
self.setupTopBanner()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "RecentsViewController.h"
|
||||
#import "RecentsBannerViewController.h"
|
||||
#import "RecentsDataSource.h"
|
||||
|
||||
/**
|
||||
The `HomeViewController` screen is the main app screen.
|
||||
*/
|
||||
@interface HomeViewController : RecentsViewController <UITableViewDataSource, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
|
||||
@interface HomeViewController : RecentsBannerViewController <UITableViewDataSource, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
|
||||
|
||||
+ (instancetype)instantiate;
|
||||
|
||||
|
||||
@@ -18,18 +18,10 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
func addBadge(button: MXKBarButtonItem) {
|
||||
|
||||
}
|
||||
|
||||
@objcMembers class ServerDowntimeBadge : NSObject {
|
||||
func createBadgeBarButton(color: UIColor, target: AnyObject, selector:Selector) -> UIBarButtonItem {
|
||||
|
||||
let button = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 30, height: 30))
|
||||
button.setImage(Asset.Images.settingsIcon.image, for: .normal)
|
||||
button.addTarget(target, action: selector, for: .touchUpInside)
|
||||
|
||||
let badge = UILabel.init(frame: CGRect.init(x: 20, y: 0, width: 15, height: 15))
|
||||
|
||||
func applyBadgeToButton(button: UIButton, color: UIColor) -> UIButton {
|
||||
let badge = UILabel.init(frame: CGRect.init(x: 15, y: 0, width: 15, height: 15))
|
||||
badge.backgroundColor = color
|
||||
badge.clipsToBounds = true
|
||||
badge.layer.cornerRadius = 7
|
||||
@@ -37,7 +29,17 @@ func addBadge(button: MXKBarButtonItem) {
|
||||
badge.textAlignment = .center
|
||||
|
||||
button.addSubview(badge)
|
||||
button.bringSubviewToFront(badge)
|
||||
|
||||
return UIBarButtonItem.init(customView: button)
|
||||
return button
|
||||
}
|
||||
|
||||
func createBadgeBarButton(color: UIColor, target: AnyObject, selector:Selector) -> UIBarButtonItem {
|
||||
|
||||
let button = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 30, height: 30))
|
||||
button.setImage(Asset.Images.settingsIcon.image, for: .normal)
|
||||
button.addTarget(target, action: selector, for: .touchUpInside)
|
||||
|
||||
return UIBarButtonItem.init(customView: self.applyBadgeToButton(button: button, color: color))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,12 @@ public extension MXRestClient {
|
||||
@discardableResult
|
||||
func getAccountData(forType type: String,
|
||||
completion: @escaping (_ jsonResponse: Dictionary<AnyHashable, Any>?, _ error: Error?) -> Void) -> MXHTTPOperation? {
|
||||
guard let userID = credentials.userId, let httpClient = httpClient else {
|
||||
guard let userID = credentials.userId else {
|
||||
completion(nil, "No user set")
|
||||
return nil
|
||||
}
|
||||
guard let httpClient = httpClient else {
|
||||
completion(nil, "HTTPClient not available")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user