mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
Merge MatrixKit develop with commit hash: b85b736313bec0592bd1cabc68035d97f5331137
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2015 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 "MXKTableViewCell.h"
|
||||
|
||||
#import "MXKImageView.h"
|
||||
#import "MXKAccount.h"
|
||||
|
||||
/**
|
||||
MXKAccountTableViewCell instance is a table view cell used to display a matrix user.
|
||||
*/
|
||||
@interface MXKAccountTableViewCell : MXKTableViewCell
|
||||
|
||||
/**
|
||||
The displayed account
|
||||
*/
|
||||
@property (nonatomic) MXKAccount* mxAccount;
|
||||
|
||||
/**
|
||||
The default account picture displayed when no picture is defined.
|
||||
*/
|
||||
@property (nonatomic) UIImage *picturePlaceholder;
|
||||
|
||||
@property (strong, nonatomic) IBOutlet MXKImageView* accountPicture;
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UILabel* accountDisplayName;
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UISwitch* accountSwitchToggle;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2018 New Vector 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 "MXKAccountTableViewCell.h"
|
||||
|
||||
@import MatrixSDK.MXMediaManager;
|
||||
|
||||
#import "NSBundle+MatrixKit.h"
|
||||
|
||||
@implementation MXKAccountTableViewCell
|
||||
|
||||
- (void)customizeTableViewCellRendering
|
||||
{
|
||||
[super customizeTableViewCellRendering];
|
||||
|
||||
self.accountPicture.defaultBackgroundColor = [UIColor clearColor];
|
||||
}
|
||||
|
||||
- (void)setMxAccount:(MXKAccount *)mxAccount
|
||||
{
|
||||
UIColor *presenceColor = nil;
|
||||
|
||||
_accountDisplayName.text = mxAccount.fullDisplayName;
|
||||
|
||||
if (mxAccount.mxSession)
|
||||
{
|
||||
_accountPicture.mediaFolder = kMXMediaManagerAvatarThumbnailFolder;
|
||||
_accountPicture.enableInMemoryCache = YES;
|
||||
[_accountPicture setImageURI:mxAccount.userAvatarUrl
|
||||
withType:nil
|
||||
andImageOrientation:UIImageOrientationUp
|
||||
toFitViewSize:_accountPicture.frame.size
|
||||
withMethod:MXThumbnailingMethodCrop
|
||||
previewImage:self.picturePlaceholder
|
||||
mediaManager:mxAccount.mxSession.mediaManager];
|
||||
|
||||
presenceColor = [MXKAccount presenceColor:mxAccount.userPresence];
|
||||
}
|
||||
else
|
||||
{
|
||||
_accountPicture.image = self.picturePlaceholder;
|
||||
}
|
||||
|
||||
if (presenceColor)
|
||||
{
|
||||
_accountPicture.layer.borderWidth = 2;
|
||||
_accountPicture.layer.borderColor = presenceColor.CGColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
_accountPicture.layer.borderWidth = 0;
|
||||
}
|
||||
|
||||
_accountSwitchToggle.on = !mxAccount.disabled;
|
||||
if (mxAccount.disabled)
|
||||
{
|
||||
_accountDisplayName.textColor = [UIColor lightGrayColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
_accountDisplayName.textColor = [UIColor blackColor];
|
||||
}
|
||||
|
||||
_mxAccount = mxAccount;
|
||||
}
|
||||
|
||||
- (UIImage*)picturePlaceholder
|
||||
{
|
||||
return [NSBundle mxk_imageFromMXKAssetsBundleWithName:@"default-profile"];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
// Round image view
|
||||
[_accountPicture.layer setCornerRadius:_accountPicture.frame.size.width / 2];
|
||||
_accountPicture.clipsToBounds = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
<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"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="odA-la-SwE" customClass="MXKAccountTableViewCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="odA-la-SwE" id="Ice-YN-Ffy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="49"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="v7q-rw-kph" customClass="MXKImageView">
|
||||
<rect key="frame" x="5" y="5" width="39" height="39"/>
|
||||
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="v7q-rw-kph" secondAttribute="height" multiplier="1:1" id="FNp-g0-6gK"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rfi-Fa-7Uq">
|
||||
<rect key="frame" x="54" y="14" width="536" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<switch hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="k0G-KZ-5ft">
|
||||
<rect key="frame" x="543" y="9" width="51" height="31"/>
|
||||
</switch>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="rfi-Fa-7Uq" secondAttribute="trailing" constant="10" id="TxZ-NW-Qjo"/>
|
||||
<constraint firstAttribute="centerY" secondItem="rfi-Fa-7Uq" secondAttribute="centerY" id="Z4K-cO-leY"/>
|
||||
<constraint firstAttribute="bottom" secondItem="v7q-rw-kph" secondAttribute="bottom" constant="5" id="ddM-yA-zDv"/>
|
||||
<constraint firstItem="v7q-rw-kph" firstAttribute="leading" secondItem="Ice-YN-Ffy" secondAttribute="leading" constant="5" id="gWc-fO-98S"/>
|
||||
<constraint firstAttribute="centerY" secondItem="k0G-KZ-5ft" secondAttribute="centerY" id="iEh-VQ-sVC"/>
|
||||
<constraint firstAttribute="trailing" secondItem="k0G-KZ-5ft" secondAttribute="trailing" constant="8" id="msS-z1-wdL"/>
|
||||
<constraint firstItem="rfi-Fa-7Uq" firstAttribute="leading" secondItem="v7q-rw-kph" secondAttribute="trailing" constant="10" id="p61-62-Veh"/>
|
||||
<constraint firstItem="v7q-rw-kph" firstAttribute="top" secondItem="Ice-YN-Ffy" secondAttribute="top" constant="5" id="yf2-Mb-AeI"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="accountDisplayName" destination="rfi-Fa-7Uq" id="Tfu-Fo-eWp"/>
|
||||
<outlet property="accountPicture" destination="v7q-rw-kph" id="Ss6-iD-9vq"/>
|
||||
<outlet property="accountSwitchToggle" destination="k0G-KZ-5ft" id="k4E-FL-XyR"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user