Skip to content

Commit

Permalink
Groups: self-management of membership of groups
Browse files Browse the repository at this point in the history
- Improve group details display

element-hq/riot-meta#114
  • Loading branch information
giomfo committed Dec 20, 2017
1 parent 255f2fc commit 427eca8
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 357 deletions.
6 changes: 3 additions & 3 deletions Riot/Categories/MXGroup+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ @implementation MXGroup (Riot)
- (void)setGroupAvatarImageIn:(MXKImageView*)mxkImageView matrixSession:(MXSession*)mxSession
{
// Use the group display name to prepare the default avatar image.
NSString *avatarDisplayName = self.summary.profile.name;
NSString *avatarDisplayName = self.profile.name;
UIImage* avatarImage = [AvatarGenerator generateAvatarForMatrixItem:self.groupId withDisplayName:avatarDisplayName];

if (self.summary.profile.avatarUrl && mxSession)
if (self.profile.avatarUrl && mxSession)
{
mxkImageView.enableInMemoryCache = YES;

[mxkImageView setImageURL:[mxSession.matrixRestClient urlOfContentThumbnail:self.summary.profile.avatarUrl toFitViewSize:mxkImageView.frame.size withMethod:MXThumbnailingMethodCrop] withType:nil andImageOrientation:UIImageOrientationUp previewImage:avatarImage];
[mxkImageView setImageURL:[mxSession.matrixRestClient urlOfContentThumbnail:self.profile.avatarUrl toFitViewSize:mxkImageView.frame.size withMethod:MXThumbnailingMethodCrop] withType:nil andImageOrientation:UIImageOrientationUp previewImage:avatarImage];
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion Riot/Model/Contact/Contact.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@

@property (nonatomic) MXRoomThirdPartyInvite* mxThirdPartyInvite;

@end
@property (nonatomic) MXGroupUser* mxGroupUser;

@end
23 changes: 20 additions & 3 deletions Riot/ViewController/GroupHomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ - (void)viewWillAppear:(BOOL)animated

if (_group)
{
// Force refresh
// Force a screen refresh
[self refreshDisplayWithGroup:[self.mxSession groupWithGroupId:_group.groupId]];

// Trigger a refresh on the group summary.
[self.mxSession updateGroupSummary:_group success:nil failure:^(NSError *error) {

NSLog(@"[GroupHomeViewController] viewWillAppear: group summary update failed %@", _group.groupId);

}];
}
}

Expand Down Expand Up @@ -200,7 +207,7 @@ - (void)registerOnGroupChangeNotifications
{
[self cancelRegistrationOnGroupChangeNotifications];

//@TODO
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didUpdateGroupSummary:) name:kMXSessionDidUpdateGroupSummaryNotification object:self.mxSession];
}

- (void)cancelRegistrationOnGroupChangeNotifications
Expand All @@ -209,6 +216,11 @@ - (void)cancelRegistrationOnGroupChangeNotifications
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)didUpdateGroupSummary:(NSNotification *)notif
{
[self refreshDisplayWithGroup:[self.mxSession groupWithGroupId:_group.groupId]];
}

- (void)refreshDisplayWithGroup:(MXGroup*)group
{
_group = group;
Expand Down Expand Up @@ -261,7 +273,12 @@ - (void)refreshDisplayWithGroup:(MXGroup*)group
_separatorViewTopConstraint.constant = 0;
}

_groupLongDescription.text = _group.summary.profile.longDescription;
if (_group.summary.profile.longDescription.length)
{
//@TODO: implement a specific html renderer to support h1/h2 and handle the Matrix media content URI (in the form of "mxc://...").
MXKEventFormatter *eventFormatter = [[MXKEventFormatter alloc] initWithMatrixSession:self.mxSession];
_groupLongDescription.attributedText = [eventFormatter renderHTMLString:_group.summary.profile.longDescription forEvent:nil];
}
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions Riot/ViewController/GroupHomeViewController.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" 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="13527"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -36,10 +36,10 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AKb-7n-nhQ">
<rect key="frame" x="0.0" y="0.0" width="375" height="110"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="100"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kYc-LP-Nip">
<rect key="frame" x="8" y="20" width="80" height="80"/>
<rect key="frame" x="8" y="10" width="80" height="80"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="ehl-88-DfA" customClass="MXKImageView">
<rect key="frame" x="10" y="10" width="60" height="60"/>
Expand All @@ -61,30 +61,30 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5UX-lR-Ac5">
<rect key="frame" x="92" y="28" width="45" height="21.5"/>
<rect key="frame" x="92" y="18" width="45" height="21.5"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jXh-2B-Bso">
<rect key="frame" x="92" y="55.5" width="36" height="17"/>
<rect key="frame" x="92" y="45.5" width="36" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="RoomTopic"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mKE-ro-fuy">
<rect key="frame" x="87" y="25" width="55" height="26.5"/>
<rect key="frame" x="87" y="15" width="55" height="26.5"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="ContactDetailsVCNameLabelMask"/>
</view>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="jXh-2B-Bso" secondAttribute="bottom" constant="8" id="6hl-pO-UX7"/>
<constraint firstItem="5UX-lR-Ac5" firstAttribute="top" secondItem="AKb-7n-nhQ" secondAttribute="top" constant="28" id="FlH-ol-0TP"/>
<constraint firstItem="5UX-lR-Ac5" firstAttribute="top" secondItem="AKb-7n-nhQ" secondAttribute="top" constant="18" id="FlH-ol-0TP"/>
<constraint firstItem="mKE-ro-fuy" firstAttribute="centerX" secondItem="5UX-lR-Ac5" secondAttribute="centerX" id="G8w-Th-eCj"/>
<constraint firstItem="kYc-LP-Nip" firstAttribute="top" secondItem="AKb-7n-nhQ" secondAttribute="top" constant="20" id="IJD-FB-fWm"/>
<constraint firstItem="kYc-LP-Nip" firstAttribute="top" secondItem="AKb-7n-nhQ" secondAttribute="top" constant="10" id="IJD-FB-fWm"/>
<constraint firstAttribute="bottom" secondItem="kYc-LP-Nip" secondAttribute="bottom" priority="250" constant="10" id="Kkx-2w-Yo2"/>
<constraint firstItem="jXh-2B-Bso" firstAttribute="leading" secondItem="kYc-LP-Nip" secondAttribute="trailing" constant="4" id="Ot2-58-G82"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="jXh-2B-Bso" secondAttribute="trailing" constant="8" id="QeR-3r-KrK"/>
Expand All @@ -98,7 +98,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nR4-eE-qJo">
<rect key="frame" x="0.0" y="110" width="375" height="97.5"/>
<rect key="frame" x="0.0" y="100" width="375" height="97.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UHk-6Y-MSO">
<rect key="frame" x="167" y="8" width="41" height="19.5"/>
Expand Down Expand Up @@ -161,15 +161,15 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dlP-kX-cll">
<rect key="frame" x="0.0" y="208" width="375" height="1"/>
<rect key="frame" x="0.0" y="198" width="375" height="1"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<accessibility key="accessibilityConfiguration" identifier="BottomBorderView"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="tUj-3s-NIW"/>
</constraints>
</view>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oUL-bJ-tfM">
<rect key="frame" x="8" y="209" width="359" height="450"/>
<rect key="frame" x="8" y="199" width="359" height="460"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
Expand Down
7 changes: 0 additions & 7 deletions Riot/ViewController/GroupParticipantsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
limitations under the License.
*/

//#import "SegmentedViewController.h"

#import "ContactsTableViewController.h"

@class Contact;
Expand All @@ -42,11 +40,6 @@
The current list of invited members.
*/
NSMutableArray<Contact*> *invitedParticipants;

/**
The contact used to describe the current user (nil if the user is not a participant of the group).
*/
Contact *userParticipant;
}

@property (weak, nonatomic) IBOutlet UITableView *tableView;
Expand Down
Loading

0 comments on commit 427eca8

Please sign in to comment.