From fcd81ced69bf9fa1f721532b4e6b3b27fafbe9a2 Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 21 Jun 2022 09:46:28 +0100 Subject: [PATCH] Add spacing between the Jitsi and Threads toolbar buttons. --- Riot/Categories/UIView.swift | 10 ++++++ Riot/Modules/Room/RoomViewController.m | 45 +++++++++++++++++++------- changelog.d/6033.bugfix | 1 + 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 changelog.d/6033.bugfix diff --git a/Riot/Categories/UIView.swift b/Riot/Categories/UIView.swift index 47b99e93d..2d6679eef 100644 --- a/Riot/Categories/UIView.swift +++ b/Riot/Categories/UIView.swift @@ -42,6 +42,16 @@ extension UIView { subView.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor).isActive = true } + /// Add a subview matching parent view with additional insets using autolayout + @objc func vc_addSubViewMatchingParent(_ subView: UIView, withInsets insets: UIEdgeInsets) { + self.addSubview(subView) + subView.translatesAutoresizingMaskIntoConstraints = false + subView.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor, constant: insets.left).isActive = true + subView.topAnchor.constraint(equalTo: self.safeAreaLayoutGuide.topAnchor, constant: insets.top).isActive = true + subView.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor, constant: insets.right).isActive = true + subView.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor, constant: insets.bottom).isActive = true + } + @objc func vc_removeAllSubviews() { for subView in self.subviews { subView.removeFromSuperview() diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 8778b6a88..fce9546f5 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1547,6 +1547,38 @@ static CGSize kThreadListBarButtonItemImageSize; return item; } +- (UIBarButtonItem *)joinJitsiBarButtonItem +{ + CallTileActionButton *button = [CallTileActionButton new]; + [button setImage:AssetImages.callVideoIcon.image + forState:UIControlStateNormal]; + [button setTitle:[VectorL10n roomJoinGroupCall] + forState:UIControlStateNormal]; + [button addTarget:self + action:@selector(onVideoCallPressed:) + forControlEvents:UIControlEventTouchUpInside]; + button.contentEdgeInsets = UIEdgeInsetsMake(4, 12, 4, 12); + + UIBarButtonItem *item; + + if (RiotSettings.shared.enableThreads) + { + // Add some spacing when there is a threads button + UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectZero]; + [buttonContainer vc_addSubViewMatchingParent:button withInsets:UIEdgeInsetsMake(0, 0, 0, -12)]; + + item = [[UIBarButtonItem alloc] initWithCustomView:buttonContainer]; + } + else + { + item = [[UIBarButtonItem alloc] initWithCustomView:button]; + } + + item.accessibilityLabel = [VectorL10n roomAccessibilityVideoCall]; + + return item; +} + - (UIBarButtonItem *)threadMoreBarButtonItem { UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:AssetImages.roomContextMenuMore.image @@ -1751,18 +1783,7 @@ static CGSize kThreadListBarButtonItemImageSize; } else { - // show Join button - CallTileActionButton *button = [CallTileActionButton new]; - [button setImage:AssetImages.callVideoIcon.image - forState:UIControlStateNormal]; - [button setTitle:[VectorL10n roomJoinGroupCall] - forState:UIControlStateNormal]; - [button addTarget:self - action:@selector(onVideoCallPressed:) - forControlEvents:UIControlEventTouchUpInside]; - button.contentEdgeInsets = UIEdgeInsetsMake(4, 12, 4, 12); - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button]; - item.accessibilityLabel = [VectorL10n roomAccessibilityVideoCall]; + UIBarButtonItem *item = [self joinJitsiBarButtonItem]; [rightBarButtonItems addObject:item]; hasCustomJoinButton = YES; diff --git a/changelog.d/6033.bugfix b/changelog.d/6033.bugfix new file mode 100644 index 000000000..3411c5466 --- /dev/null +++ b/changelog.d/6033.bugfix @@ -0,0 +1 @@ +Room: Add some additional spacing between the Jitsi and Threads buttons.