mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-20 14:42:09 +02:00
room_photo_selection
Display the room photo in the settings
This commit is contained in:
@@ -131,6 +131,7 @@
|
||||
|
||||
// Room Details
|
||||
"room_details_title" = "Room Details";
|
||||
"room_details_photo" = "Photo";
|
||||
"room_details_room_name" = "Room Name";
|
||||
"room_details_topic" = "Topic";
|
||||
"room_details_people" = "People";
|
||||
|
||||
@@ -18,17 +18,22 @@
|
||||
|
||||
#import "TableViewCellWithLabelAndTextField.h"
|
||||
#import "TableViewCellWithLabelAndLargeTextView.h"
|
||||
#import "TableViewCellWithLabelAndMXKImageView.h"
|
||||
|
||||
#import "TableViewCellSeparator.h"
|
||||
|
||||
#import "RageShakeManager.h"
|
||||
|
||||
#import "VectorDesignValues.h"
|
||||
|
||||
#import "AvatarGenerator.h"
|
||||
|
||||
#define ROOM_SECTION 0
|
||||
|
||||
#define ROOM_SECTION_NAME 0
|
||||
#define ROOM_SECTION_TOPIC 1
|
||||
#define ROOM_SECTION_COUNT 2
|
||||
#define ROOM_SECTION_PHOTO 0
|
||||
#define ROOM_SECTION_NAME 1
|
||||
#define ROOM_SECTION_TOPIC 2
|
||||
#define ROOM_SECTION_COUNT 3
|
||||
|
||||
#define ROOM_TOPIC_CELL_HEIGHT 99
|
||||
|
||||
@@ -430,7 +435,66 @@
|
||||
// retrieve row as a ROOM_SECTION_XX index
|
||||
row = (row - 1) / 2;
|
||||
|
||||
if (row == ROOM_SECTION_TOPIC)
|
||||
if (row == ROOM_SECTION_PHOTO)
|
||||
{
|
||||
TableViewCellWithLabelAndMXKImageView *roomPhotoCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]];
|
||||
|
||||
if (!roomPhotoCell)
|
||||
{
|
||||
roomPhotoCell = [[TableViewCellWithLabelAndMXKImageView alloc] init];
|
||||
}
|
||||
|
||||
roomPhotoCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_photo", @"Vector", nil);
|
||||
|
||||
if (updatedItemsDict && [updatedItemsDict objectForKey:@"ROOM_SECTION_PHOTO"])
|
||||
{
|
||||
roomPhotoCell.mxkImageView.image = (UIImage*)[updatedItemsDict objectForKey:@"ROOM_SECTION_PHOTO"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* roomAvatarUrl = mxRoomState.avatar;
|
||||
|
||||
// detect if it is a room with no more than 2 members (i.e. an alone or a 1:1 chat)
|
||||
if (!roomAvatarUrl)
|
||||
{
|
||||
NSString* myUserId = mxRoom.mxSession.myUser.userId;
|
||||
|
||||
NSArray* members = mxRoomState.members;
|
||||
|
||||
if (members.count < 3)
|
||||
{
|
||||
// use the member avatar only it is an active member
|
||||
for (MXRoomMember *roomMember in members)
|
||||
{
|
||||
if ((MXMembershipJoin == roomMember.membership) && ((members.count == 1) || ![roomMember.userId isEqualToString:myUserId]))
|
||||
{
|
||||
roomAvatarUrl = roomMember.avatarUrl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UIImage* avatarImage = [AvatarGenerator generateRoomAvatar:mxRoom];
|
||||
|
||||
if (roomAvatarUrl)
|
||||
{
|
||||
roomPhotoCell.mxkImageView.enableInMemoryCache = YES;
|
||||
|
||||
[roomPhotoCell.mxkImageView setImageURL:[mxRoom.mxSession.matrixRestClient urlOfContentThumbnail:roomAvatarUrl toFitViewSize:roomPhotoCell.mxkImageView.frame.size withMethod:MXThumbnailingMethodCrop] withType:nil andImageOrientation:UIImageOrientationUp previewImage:avatarImage];
|
||||
}
|
||||
else
|
||||
{
|
||||
roomPhotoCell.mxkImageView.image = avatarImage;
|
||||
}
|
||||
}
|
||||
|
||||
[roomPhotoCell.mxkImageView.layer setCornerRadius:roomPhotoCell.mxkImageView.frame.size.width / 2];
|
||||
roomPhotoCell.mxkImageView.clipsToBounds = YES;
|
||||
|
||||
cell = roomPhotoCell;
|
||||
}
|
||||
else if (row == ROOM_SECTION_TOPIC)
|
||||
{
|
||||
TableViewCellWithLabelAndLargeTextView *roomTopicCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithLabelAndLargeTextView defaultReuseIdentifier]];
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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 <MatrixSDK/MatrixSDK.h>
|
||||
|
||||
#import "MXKTableViewCell.h"
|
||||
#import "MXKImageView.h"
|
||||
|
||||
@interface TableViewCellWithLabelAndMXKImageView : MXKTableViewCell
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UILabel *mxkLabel;
|
||||
@property (strong, nonatomic) IBOutlet MXKImageView *mxkImageView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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 "TableViewCellWithLabelAndMXKImageView.h"
|
||||
|
||||
@implementation TableViewCellWithLabelAndMXKImageView
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9051"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="aCf-VI-ocb" customClass="TableViewCellWithLabelAndMXKImageView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="aCf-VI-ocb" id="Eg5-vl-rni">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xx4-AP-OQs">
|
||||
<rect key="frame" x="10" y="11" width="544" height="21"/>
|
||||
<animations/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7Ts-eR-MZV" userLabel="Mxk ImageView" customClass="MXKImageView">
|
||||
<rect key="frame" x="560" y="5" width="34" height="34"/>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="34" id="Ejk-bJ-0MB"/>
|
||||
<constraint firstAttribute="height" constant="34" id="m9S-XK-OTa"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<animations/>
|
||||
<constraints>
|
||||
<constraint firstItem="Xx4-AP-OQs" firstAttribute="leading" secondItem="Eg5-vl-rni" secondAttribute="leading" constant="10" id="Wih-ke-1dd"/>
|
||||
<constraint firstItem="7Ts-eR-MZV" firstAttribute="leading" secondItem="Xx4-AP-OQs" secondAttribute="trailing" constant="6" id="fSB-ec-jkJ"/>
|
||||
<constraint firstAttribute="centerY" secondItem="Xx4-AP-OQs" secondAttribute="centerY" id="v6O-QC-moW"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<animations/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="7Ts-eR-MZV" secondAttribute="trailing" constant="6" id="JNP-da-JzI"/>
|
||||
<constraint firstItem="7Ts-eR-MZV" firstAttribute="centerY" secondItem="aCf-VI-ocb" secondAttribute="centerY" id="lgB-TU-fX3"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="mxkImageView" destination="7Ts-eR-MZV" id="fP1-hq-oEh"/>
|
||||
<outlet property="mxkLabel" destination="Xx4-AP-OQs" id="Va7-zb-8uX"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user