Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions NextcloudTalk/Calls/CallViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ class CallViewController: UIViewController,
self.titleView.titleTextColor = .white
self.titleView.update(for: room)

// The titleView uses the themeColor as a background for the userStatusImage
// As we always have a black background, we need to change that
self.titleView.userStatusBackgroundColor = .black

self.titleView.delegate = self
self.collectionView.delegate = self
self.applyInitialSnapshot()
Expand Down
6 changes: 2 additions & 4 deletions NextcloudTalk/Chat/Chat views/NCChatTitleView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import "NCRoom.h"

@class AvatarImageView;
@class AvatarView;
@class NCChatTitleView;
@class NCThread;

Expand All @@ -21,11 +21,9 @@

@property (nonatomic, weak) id<NCChatTitleViewDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITextView *titleTextView;
@property (weak, nonatomic) IBOutlet AvatarImageView *avatarimage;
@property (weak, nonatomic) IBOutlet UIImageView *userStatusImage;
@property (weak, nonatomic) IBOutlet AvatarView *avatarView;
@property (assign, nonatomic) BOOL showSubtitle;
@property (strong, nonatomic) UIColor *titleTextColor;
@property (strong, nonatomic) UIColor *userStatusBackgroundColor;
@property (strong, nonatomic) UILongPressGestureRecognizer *longPressGestureRecognizer;

- (void)updateForRoom:(NCRoom *)room;
Expand Down
45 changes: 6 additions & 39 deletions NextcloudTalk/Chat/Chat views/NCChatTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ - (void)commonInit
[self addSubview:self.contentView];
self.contentView.frame = self.bounds;

self.avatarimage.layer.cornerRadius = self.avatarimage.bounds.size.width / 2;
self.avatarimage.clipsToBounds = YES;
self.avatarimage.backgroundColor = [UIColor systemGray3Color];

self.titleTextView.textContainer.lineFragmentPadding = 0;
self.titleTextView.textContainerInset = UIEdgeInsetsZero;

Expand All @@ -64,10 +60,8 @@ - (void)commonInit
self.showSubtitle = YES;

if (@available(iOS 26.0, *)) {
self.userStatusBackgroundColor = [UIColor clearColor];
self.titleTextColor = [UIColor labelColor];
} else {
self.userStatusBackgroundColor = [NCAppBranding themeColor];
self.titleTextColor = [NCAppBranding themeTextColor];
}

Expand All @@ -83,20 +77,18 @@ - (void)commonInit
- (void)layoutSubviews
{
[super layoutSubviews];
self.avatarimage.layer.cornerRadius = self.avatarimage.bounds.size.width / 2;
self.userStatusImage.layer.cornerRadius = self.userStatusImage.bounds.size.width / 2;
}

- (void)updateForRoom:(NCRoom *)room
{
// Set room image
[self.avatarimage setAvatarFor:room];
[self.avatarView setAvatarFor:room];

NSString *subtitle = nil;

if ([[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilitySingleConvStatus]) {
// User status
[self setStatusImageForUserStatus:room.status];
[self.avatarView setStatusFor:room allowCustomStatusIcon:NO];

// User status message
if (!room.statusMessage || [room.statusMessage isEqualToString:@""]) {
Expand Down Expand Up @@ -127,35 +119,13 @@ - (void)updateForRoom:(NCRoom *)room
- (void)updateForThread:(NCThread *)thread
{
// Set thread image
TalkAccount *account = [[NCDatabaseManager sharedInstance] talkAccountForAccountId:thread.accountId];
[self.avatarimage setThreadAvatarForThread:thread];
[self.avatarView setThreadAvatarForThread:thread];

// Set thread title and number of replies
NSString *repliesString = [NSString localizedStringWithFormat:NSLocalizedString(@"%ld replies", @"Replies in a thread"), (long)thread.numReplies];
[self setTitle:thread.title withSubtitle:repliesString];
}

- (void)setStatusImageForUserStatus:(NSString *)userStatus
{
UIImage *statusImage = nil;
if ([userStatus isEqualToString:@"online"]) {
statusImage = [NCUtils renderAspectImageWithImage:[NCUserStatus getOnlineSFIcon] ofSize:CGSizeMake(10, 10) centerImage:NO];
} else if ([userStatus isEqualToString:@"away"]) {
statusImage = [NCUtils renderAspectImageWithImage:[NCUserStatus getAwaySFIcon] ofSize:CGSizeMake(10, 10) centerImage:NO];
} else if ([userStatus isEqualToString:@"busy"]) {
statusImage = [NCUtils renderAspectImageWithImage:[NCUserStatus getBusySFIcon] ofSize:CGSizeMake(10, 10) centerImage:NO];
} else if ([userStatus isEqualToString:@"dnd"]) {
statusImage = [NCUtils renderAspectImageWithImage:[NCUserStatus getDoNotDisturbSFIcon] ofSize:CGSizeMake(10, 10) centerImage:NO];
}

if (statusImage) {
[_userStatusImage setImage:statusImage];
_userStatusImage.contentMode = UIViewContentModeCenter;
_userStatusImage.clipsToBounds = YES;
_userStatusImage.backgroundColor = _userStatusBackgroundColor;
}
}

- (void)setTitle:(NSString *)title withSubtitle:(NSString *)subtitle
{
if (!title) {
Expand Down Expand Up @@ -195,18 +165,15 @@ -(void)handlGestureRecognizer:(UILongPressGestureRecognizer *)gestureRecognizer
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
// Simulate a pressed stated. Don't use self.alpha here as it will interfere with NavigationController transitions
self.titleTextView.alpha = 0.7;
self.avatarimage.alpha = 0.7;
self.userStatusImage.alpha = 0.7;
self.avatarView.alpha = 0.7;
} else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
// Call delegate & reset the pressed state -> use dispatch after to give the UI time to show the actual pressed state
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.titleTextView.alpha = 1.0;
self.avatarimage.alpha = 1.0;
self.userStatusImage.alpha = 1.0;

self.avatarView.alpha = 1.0;

[self.delegate chatTitleViewTapped:self];
});

}
}

Expand Down
46 changes: 16 additions & 30 deletions NextcloudTalk/Chat/Chat views/NCChatTitleView.xib
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24412" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="landscape" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24405"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NCChatTitleView">
<connections>
<outlet property="avatarimage" destination="IxN-fr-8tD" id="vfr-Ig-iBi"/>
<outlet property="avatarView" destination="Owz-Tc-8Jc" id="B9q-YV-PQP"/>
<outlet property="contentView" destination="iN0-l3-epB" id="Ubk-5l-dVr"/>
<outlet property="titleTextView" destination="iXw-ly-0h6" id="6aa-7m-Yai"/>
<outlet property="userStatusImage" destination="6PH-NC-M0F" id="jwk-DI-i5s"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="left" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="290" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="IxN-fr-8tD" userLabel="AvatarImageView" customClass="AvatarImageView" customModule="NextcloudTalk" customModuleProvider="target">
<rect key="frame" x="0.0" y="7" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" secondItem="IxN-fr-8tD" secondAttribute="height" multiplier="1:1" id="JYW-6K-xTq"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="30" id="fLM-v7-beS"/>
</constraints>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="6PH-NC-M0F" userLabel="UserStatusImageView">
<rect key="frame" x="22" y="29" width="12" height="12"/>
<constraints>
<constraint firstAttribute="width" priority="750" constant="12" id="7he-r6-ppR"/>
<constraint firstAttribute="width" secondItem="6PH-NC-M0F" secondAttribute="height" multiplier="1:1" id="Dmi-zu-h9S"/>
<constraint firstAttribute="height" priority="750" constant="12" id="qvI-6m-Hy5"/>
</constraints>
</imageView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" bounces="NO" scrollEnabled="NO" bouncesZoom="NO" editable="NO" usesAttributedText="YES" selectable="NO" layoutManager="textKit1" translatesAutoresizingMaskIntoConstraints="NO" id="iXw-ly-0h6">
<rect key="frame" x="40" y="5.5" width="250" height="33"/>
<rect key="frame" x="44" y="5.5" width="246" height="33"/>
<attributedString key="attributedText">
<fragment content="Lorem ipsum dolor sit er elit">
<attributes>
Expand All @@ -56,21 +40,23 @@
</attributedString>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Owz-Tc-8Jc" customClass="AvatarView" customModule="NextcloudTalk" customModuleProvider="target">
<rect key="frame" x="0.0" y="4" width="36" height="36"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="30" id="QvV-ox-7ER"/>
<constraint firstAttribute="width" secondItem="Owz-Tc-8Jc" secondAttribute="height" id="YwW-Zy-fbF"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="IxN-fr-8tD" secondAttribute="bottom" priority="750" constant="7" id="1Ih-4p-ulE"/>
<constraint firstItem="IxN-fr-8tD" firstAttribute="bottom" secondItem="6PH-NC-M0F" secondAttribute="bottom" priority="750" constant="-4" id="26i-Iq-lHO"/>
<constraint firstItem="iXw-ly-0h6" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="2BL-Kl-7lg"/>
<constraint firstItem="6PH-NC-M0F" firstAttribute="trailing" secondItem="IxN-fr-8tD" secondAttribute="trailing" constant="4" id="Bbu-wt-u4J"/>
<constraint firstItem="IxN-fr-8tD" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="V8v-Q7-D6r"/>
<constraint firstItem="IxN-fr-8tD" firstAttribute="top" relation="greaterThanOrEqual" secondItem="vUN-kp-3ea" secondAttribute="top" id="aw0-kd-xYR"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="6PH-NC-M0F" secondAttribute="bottom" id="bSL-rZ-FxA"/>
<constraint firstItem="IxN-fr-8tD" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="bfS-1h-ijV"/>
<constraint firstItem="iXw-ly-0h6" firstAttribute="leading" secondItem="IxN-fr-8tD" secondAttribute="trailing" constant="10" id="eu7-ZM-bS4"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="IxN-fr-8tD" secondAttribute="bottom" id="j06-qO-wp3"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Owz-Tc-8Jc" secondAttribute="bottom" constant="4" id="3Xs-dl-n60"/>
<constraint firstItem="Owz-Tc-8Jc" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="MlT-PT-vFg"/>
<constraint firstItem="iXw-ly-0h6" firstAttribute="leading" secondItem="Owz-Tc-8Jc" secondAttribute="trailing" constant="8" id="hj7-Sv-mLw"/>
<constraint firstItem="iXw-ly-0h6" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="qGs-Ee-w9L"/>
<constraint firstItem="IxN-fr-8tD" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" priority="750" constant="7" id="yax-W8-R8c"/>
<constraint firstItem="Owz-Tc-8Jc" firstAttribute="top" relation="greaterThanOrEqual" secondItem="vUN-kp-3ea" secondAttribute="top" constant="4" id="uof-O2-Mw3"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="-83.200000000000003" y="-265.36731634182911"/>
Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/Rooms/RoomsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)rc
RoomTableViewCell *cell = (RoomTableViewCell *)rcell;
NCRoom *room = [_rooms objectAtIndex:indexPath.row];

[cell.avatarView setStatusFor:room];
[cell.avatarView setStatusFor:room allowCustomStatusIcon:YES];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down
8 changes: 8 additions & 0 deletions NextcloudTalk/User Interface/AvatarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@ import SDWebImage
self.setImage(image, for: .normal)
}
}

// MARK: Thread avatars

public func setThreadAvatar(forThread thread: NCThread) {
if let image = AvatarManager.shared.getThreadAvatar(for: thread, with: self.traitCollection.userInterfaceStyle) {
self.setImage(image, for: .normal)
}
}
}
3 changes: 3 additions & 0 deletions NextcloudTalk/User Interface/AvatarProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ protocol AvatarProtocol {
func setActorAvatar(forMessage message: NCChatMessage, withAccount account: TalkAccount)
func setActorAvatar(forId actorId: String?, withType actorType: String?, withDisplayName actorDisplayName: String?, withRoomToken roomToken: String?, using account: TalkAccount)

// MARK: - Thread avatars
func setThreadAvatar(forThread thread: NCThread)

}
Loading
Loading