mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 11:02:48 +02:00
Organize views by feature
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
// We add here a protocol to handle title view layout update.
|
||||
@class RoomMemberTitleView;
|
||||
@protocol RoomMemberTitleViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
/**
|
||||
Tells the delegate that the layout has been updated.
|
||||
|
||||
@param titleView the room member title view.
|
||||
*/
|
||||
- (void)roomMemberTitleViewDidLayoutSubview:(RoomMemberTitleView*)titleView;
|
||||
|
||||
@end
|
||||
|
||||
@interface RoomMemberTitleView : MXKView
|
||||
|
||||
/**
|
||||
* Returns the `UINib` object initialized for the room member title view.
|
||||
*
|
||||
* @return The initialized `UINib` object or `nil` if there were errors during
|
||||
* initialization or the nib file could not be located.
|
||||
*/
|
||||
+ (UINib *)nib;
|
||||
|
||||
/**
|
||||
Creates and returns a new `RoomMemberTitleView-inherited` object.
|
||||
|
||||
@discussion This is the designated initializer for programmatic instantiation.
|
||||
@return An initialized `RoomMemberTitleView-inherited` object if successful, `nil` otherwise.
|
||||
*/
|
||||
+ (instancetype)roomMemberTitleView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *memberAvatarMask;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *memberBadge;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *memberAvatarMaskCenterXConstraint;
|
||||
|
||||
/**
|
||||
The delegate.
|
||||
*/
|
||||
@property (nonatomic) id<RoomMemberTitleViewDelegate> delegate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "RoomMemberTitleView.h"
|
||||
|
||||
@implementation RoomMemberTitleView
|
||||
|
||||
+ (UINib *)nib
|
||||
{
|
||||
return [UINib nibWithNibName:NSStringFromClass([self class])
|
||||
bundle:[NSBundle bundleForClass:[self class]]];
|
||||
}
|
||||
|
||||
+ (instancetype)roomMemberTitleView
|
||||
{
|
||||
return [[[self class] nib] instantiateWithOwner:nil options:nil].firstObject;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
if (self.superview)
|
||||
{
|
||||
if (@available(iOS 11.0, *))
|
||||
{
|
||||
// Force the title view layout by adding 2 new constraints on the UINavigationBarContentView instance.
|
||||
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self
|
||||
attribute:NSLayoutAttributeTop
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.superview
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0f
|
||||
constant:0.0f];
|
||||
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:self
|
||||
attribute:NSLayoutAttributeCenterX
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.superview
|
||||
attribute:NSLayoutAttributeCenterX
|
||||
multiplier:1.0f
|
||||
constant:0.0f];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[topConstraint, centerXConstraint]];
|
||||
|
||||
// Do not crop the avatar
|
||||
self.superview.clipsToBounds = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Center horizontally the avatar into the navigation bar
|
||||
CGRect frame = self.superview.frame;
|
||||
UINavigationBar *navigationBar;
|
||||
UIView *superView = self;
|
||||
while (superView.superview)
|
||||
{
|
||||
if ([superView.superview isKindOfClass:[UINavigationBar class]])
|
||||
{
|
||||
navigationBar = (UINavigationBar*)superView.superview;
|
||||
break;
|
||||
}
|
||||
|
||||
superView = superView.superview;
|
||||
}
|
||||
|
||||
if (navigationBar)
|
||||
{
|
||||
CGSize navBarSize = navigationBar.frame.size;
|
||||
CGFloat superviewCenterX = frame.origin.x + (frame.size.width / 2);
|
||||
|
||||
self.memberAvatarMaskCenterXConstraint.constant = (navBarSize.width / 2) - superviewCenterX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(roomMemberTitleViewDidLayoutSubview:)])
|
||||
{
|
||||
[_delegate roomMemberTitleViewDidLayoutSubview:self];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="BkF-x3-7fX" customClass="RoomMemberTitleView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="f6h-pw-FvU">
|
||||
<rect key="frame" x="209" y="6" width="30" height="32"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="MemberBadge"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="30" id="Rz8-gR-gAm"/>
|
||||
<constraint firstAttribute="height" constant="32" id="dHM-zo-WVT"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VJM-ib-LUP">
|
||||
<rect key="frame" x="132" y="11" width="110" height="33"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="RoomMemberDetailsVCAvatarMask"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="110" id="IYH-gQ-dbK"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="RoomMemberTitleView"/>
|
||||
<constraints>
|
||||
<constraint firstItem="f6h-pw-FvU" firstAttribute="top" secondItem="VJM-ib-LUP" secondAttribute="top" constant="-5" id="0pn-Nk-1zK"/>
|
||||
<constraint firstAttribute="bottom" secondItem="VJM-ib-LUP" secondAttribute="bottom" id="5EZ-YP-0he"/>
|
||||
<constraint firstItem="VJM-ib-LUP" firstAttribute="centerX" secondItem="BkF-x3-7fX" secondAttribute="centerX" id="I5C-UZ-BnC"/>
|
||||
<constraint firstItem="VJM-ib-LUP" firstAttribute="top" secondItem="BkF-x3-7fX" secondAttribute="top" constant="11" id="gGL-UL-DHn"/>
|
||||
<constraint firstItem="f6h-pw-FvU" firstAttribute="trailing" secondItem="VJM-ib-LUP" secondAttribute="trailing" constant="-3" id="ilt-qd-gIW"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<connections>
|
||||
<outlet property="memberAvatarMask" destination="VJM-ib-LUP" id="cnl-NC-4DH"/>
|
||||
<outlet property="memberAvatarMaskCenterXConstraint" destination="I5C-UZ-BnC" id="rc9-oe-GrK"/>
|
||||
<outlet property="memberBadge" destination="f6h-pw-FvU" id="pDM-O6-238"/>
|
||||
</connections>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user