зеркало из https://github.com/nextcloud/talk-ios.git
Show unread messages in Conversations view.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
46c13c1f62
Коммит
85f237f0fb
|
@ -20,6 +20,7 @@
|
|||
2C06BF5D20A89F510031EB46 /* NCRoomsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C06BF5C20A89F510031EB46 /* NCRoomsManager.m */; };
|
||||
2C06BF6420AC64370031EB46 /* DateHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C06BF6320AC64370031EB46 /* DateHeaderView.xib */; };
|
||||
2C06BF6720AC647A0031EB46 /* DateHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C06BF6620AC647A0031EB46 /* DateHeaderView.m */; };
|
||||
2C06BF6C20AEB0030031EB46 /* RoundedNumberView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C06BF6A20AEB0030031EB46 /* RoundedNumberView.m */; };
|
||||
2C2E64251F3462AF00D39CE8 /* NCSignalingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C2E64241F3462AF00D39CE8 /* NCSignalingMessage.m */; };
|
||||
2C3F6AA81FBB1ACD00E2705C /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3F6AA71FBB1ACD00E2705C /* NotificationService.m */; };
|
||||
2C3F6AAC1FBB1ACD00E2705C /* NotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 2C3F6AA41FBB1ACC00E2705C /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
|
@ -143,6 +144,8 @@
|
|||
2C06BF6320AC64370031EB46 /* DateHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DateHeaderView.xib; sourceTree = "<group>"; };
|
||||
2C06BF6520AC647A0031EB46 /* DateHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateHeaderView.h; sourceTree = "<group>"; };
|
||||
2C06BF6620AC647A0031EB46 /* DateHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DateHeaderView.m; sourceTree = "<group>"; };
|
||||
2C06BF6A20AEB0030031EB46 /* RoundedNumberView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoundedNumberView.m; sourceTree = "<group>"; };
|
||||
2C06BF6B20AEB0030031EB46 /* RoundedNumberView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedNumberView.h; sourceTree = "<group>"; };
|
||||
2C2E64231F3462AF00D39CE8 /* NCSignalingMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCSignalingMessage.h; sourceTree = "<group>"; };
|
||||
2C2E64241F3462AF00D39CE8 /* NCSignalingMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NCSignalingMessage.m; sourceTree = "<group>"; };
|
||||
2C3F6AA41FBB1ACC00E2705C /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -473,6 +476,8 @@
|
|||
2C5521661F7D47A50077E587 /* Rooms */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2C06BF6B20AEB0030031EB46 /* RoundedNumberView.h */,
|
||||
2C06BF6A20AEB0030031EB46 /* RoundedNumberView.m */,
|
||||
2CA1CCC11F166CC5002FE6A2 /* NCRoom.h */,
|
||||
2CA1CCC21F166CC5002FE6A2 /* NCRoom.m */,
|
||||
2CA1CCA21F025F64002FE6A2 /* RoomsTableViewController.h */,
|
||||
|
@ -1021,6 +1026,7 @@
|
|||
2CA15548208EA1EA00CE8EF0 /* ChatMessageTableViewCell.m in Sources */,
|
||||
2CBF82C11FD5AE3F00636459 /* NCPushProxySessionManager.m in Sources */,
|
||||
2C78EF951F7E70EB008AFA74 /* NCPeerConnection.m in Sources */,
|
||||
2C06BF6C20AEB0030031EB46 /* RoundedNumberView.m in Sources */,
|
||||
2C7A1236200E0A5700864818 /* UserSettingsTableViewCell.m in Sources */,
|
||||
2C78EFA01F828C41008AFA74 /* CallViewController.m in Sources */,
|
||||
2CA1CCD61F1E664C002FE6A2 /* ContactsTableViewCell.m in Sources */,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="17" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="L2w-ad-rRt">
|
||||
<rect key="frame" x="72" y="15" width="287" height="28"/>
|
||||
<rect key="frame" x="72" y="15" width="250" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="19"/>
|
||||
<nil key="textColor"/>
|
||||
|
@ -42,12 +42,16 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FDH-Ta-zgI">
|
||||
<rect key="frame" x="72" y="45" width="287" height="18"/>
|
||||
<rect key="frame" x="72" y="45" width="250" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5Rh-hW-M4x">
|
||||
<rect key="frame" x="330" y="27" width="45" height="26"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
</view>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
|
@ -55,6 +59,7 @@
|
|||
<outlet property="labelTitle" destination="L2w-ad-rRt" id="CNq-cb-Kc7"/>
|
||||
<outlet property="roomImage" destination="eGM-8o-ipF" id="Ae7-yR-KGf"/>
|
||||
<outlet property="roomPasswordImage" destination="HP4-mZ-FCq" id="qJQ-6b-p3H"/>
|
||||
<outlet property="unreadMessagesView" destination="5Rh-hW-M4x" id="KyZ-Ei-g4k"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef enum NCParticipantType {
|
|||
@property (nonatomic, assign) NCParticipantType participantType;
|
||||
@property (nonatomic, assign) NSInteger lastPing;
|
||||
@property (nonatomic, assign) NSInteger numGuests;
|
||||
@property (nonatomic, assign) NSInteger unreadMessages;
|
||||
@property (nonatomic, copy) NSString *guestList;
|
||||
@property (nonatomic, copy) NSDictionary *participants;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
room.participantType = (NCParticipantType)[[roomDict objectForKey:@"participantType"] integerValue];
|
||||
room.lastPing = [[roomDict objectForKey:@"lastPing"] integerValue];
|
||||
room.numGuests = [[roomDict objectForKey:@"numGuests"] integerValue];
|
||||
room.unreadMessages = [[roomDict objectForKey:@"unreadMessages"] integerValue];
|
||||
room.guestList = [roomDict objectForKey:@"guestList"];
|
||||
room.participants = [roomDict objectForKey:@"participants"];
|
||||
|
||||
|
|
|
@ -16,5 +16,6 @@ extern NSString *const kRoomCellIdentifier;
|
|||
@property(nonatomic, weak) IBOutlet UIImageView *roomPasswordImage;
|
||||
@property(nonatomic, weak) IBOutlet UILabel *labelTitle;
|
||||
@property(nonatomic, weak) IBOutlet UILabel *labelSubTitle;
|
||||
@property (weak, nonatomic) IBOutlet UIView *unreadMessagesView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -36,6 +36,10 @@ NSString *const kRoomCellIdentifier = @"RoomCellIdentifier";
|
|||
|
||||
self.roomImage.image = nil;
|
||||
self.roomPasswordImage.image = nil;
|
||||
|
||||
for (UIView *subview in [self.unreadMessagesView subviews]) {
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#import "UIImageView+AFNetworking.h"
|
||||
#import "NCChatViewController.h"
|
||||
#import "NCRoomsManager.h"
|
||||
#import "RoundedNumberView.h"
|
||||
|
||||
typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
||||
|
||||
|
@ -780,13 +781,20 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
|||
// Set last ping
|
||||
NSDate *date = [[NSDate alloc] initWithTimeIntervalSince1970:room.lastPing];
|
||||
cell.labelSubTitle.text = [date timeAgoSinceNow];
|
||||
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
|
||||
if (room.lastPing == 0) {
|
||||
cell.labelSubTitle.text = @"Never joined";
|
||||
}
|
||||
|
||||
// Set unread messages
|
||||
if (room.unreadMessages > 0) {
|
||||
RoundedNumberView *unreadMessagesView = [[RoundedNumberView alloc] init];
|
||||
unreadMessagesView.number = room.unreadMessages;
|
||||
unreadMessagesView.frame = CGRectMake(cell.unreadMessagesView.frame.size.width - unreadMessagesView.frame.size.width,
|
||||
unreadMessagesView.frame.origin.y,
|
||||
unreadMessagesView.frame.size.width, unreadMessagesView.frame.size.height);
|
||||
[cell.unreadMessagesView addSubview:unreadMessagesView];
|
||||
}
|
||||
|
||||
// Set room image
|
||||
switch (room.type) {
|
||||
case kNCRoomTypeOneToOneCall:
|
||||
|
@ -815,6 +823,8 @@ typedef void (^FetchRoomsCompletionBlock)(BOOL success);
|
|||
break;
|
||||
}
|
||||
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// RoundedNumberView.h
|
||||
// VideoCalls
|
||||
//
|
||||
// Created by Ivan Sein on 18.05.18.
|
||||
// Copyright © 2018 struktur AG. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface RoundedNumberView : UIView
|
||||
|
||||
@property (nonatomic, assign) NSInteger number;
|
||||
@property (nonatomic, strong) UIColor *numberColor;
|
||||
|
||||
@end
|
|
@ -0,0 +1,104 @@
|
|||
//
|
||||
// RoundedNumberView.m
|
||||
// VideoCalls
|
||||
//
|
||||
// Created by Ivan Sein on 18.05.18.
|
||||
// Copyright © 2018 struktur AG. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RoundedNumberView.h"
|
||||
|
||||
#define kRoundedNumberViewDefaultBackgroundColor [UIColor colorWithRed:0.00 green:0.51 blue:0.79 alpha:1.0]; //#0082C9
|
||||
#define kRoundedNumberViewDefaultTextColor [UIColor whiteColor]
|
||||
#define kRoundedNumberViewCounterLimit 99
|
||||
|
||||
@interface RoundedNumberView ()
|
||||
@property (nonatomic, strong) UILabel *numberLabel;
|
||||
@end
|
||||
|
||||
@implementation RoundedNumberView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
return [self initWithNumber:0];
|
||||
}
|
||||
|
||||
|
||||
- (id)init
|
||||
{
|
||||
return [self initWithNumber:0];
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self) {
|
||||
_number = 0;
|
||||
[self addNecessaryViews];
|
||||
[self setup];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithNumber:(NSInteger)number
|
||||
{
|
||||
self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 1.0f, 1.0f)];
|
||||
if (self) {
|
||||
_number = 0;
|
||||
[self addNecessaryViews];
|
||||
[self setup];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
// This method should be called only once
|
||||
- (void)addNecessaryViews
|
||||
{
|
||||
self.backgroundColor = kRoundedNumberViewDefaultBackgroundColor;
|
||||
self.numberLabel = [[UILabel alloc] init];
|
||||
self.numberLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.numberLabel.backgroundColor = [UIColor clearColor];
|
||||
_numberColor = kRoundedNumberViewDefaultTextColor;
|
||||
[self addSubview:self.numberLabel];
|
||||
}
|
||||
|
||||
|
||||
- (void)setup
|
||||
{
|
||||
NSInteger counter = _number;
|
||||
self.numberLabel.textColor = _numberColor;
|
||||
self.numberLabel.text = [NSString stringWithFormat:@"%ld", (long)counter];
|
||||
if (counter > kRoundedNumberViewCounterLimit) {
|
||||
self.numberLabel.text = [NSString stringWithFormat:@"%d+", kRoundedNumberViewCounterLimit];
|
||||
}
|
||||
[self.numberLabel sizeToFit];
|
||||
BOOL wider = self.numberLabel.frame.size.width >= self.numberLabel.frame.size.height;
|
||||
CGFloat frameWidth = self.numberLabel.frame.size.width * 5/3;
|
||||
CGFloat frameHeight = self.numberLabel.frame.size.height + self.numberLabel.frame.size.height / 2;
|
||||
self.frame = CGRectMake(0, 0, (wider) ? frameWidth : frameHeight, frameHeight);
|
||||
self.layer.cornerRadius = self.frame.size.height / 2;
|
||||
[self.numberLabel setCenter:CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2)];
|
||||
}
|
||||
|
||||
|
||||
- (void)setNumber:(NSInteger)number
|
||||
{
|
||||
if (_number != number) {
|
||||
_number = number;
|
||||
[self setup];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setNumberColor:(UIColor *)numberColor
|
||||
{
|
||||
if (_numberColor != numberColor) {
|
||||
_numberColor = numberColor;
|
||||
self.numberLabel.textColor = _numberColor;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
Загрузка…
Ссылка в новой задаче