From c80ad228ef68f4e0e18fc9897c825a0af6c1baa9 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Wed, 2 Nov 2022 23:47:49 +0100 Subject: [PATCH] Reworked UICollectionView for displaying selected contacts in group chat and group calls --- .../Base.lproj/ChatConversationCreateView.xib | 8 +-- Classes/ChatConversationCreateView.m | 7 ++- .../UIChatCreateCollectionViewCell.xib | 41 ------------- .../UIChatCreateCollectionViewCell.h | 3 +- .../UIChatCreateCollectionViewCell.m | 38 ++++++------ .../UIChatCreateCollectionViewCell.strings | Bin 206 -> 0 bytes .../UIChatCreateCollectionViewCell.strings | Bin 214 -> 0 bytes .../Swift/Extensions/IOS/SnapkitBridge.swift | 54 ++++++++++++++++++ 8 files changed, 85 insertions(+), 66 deletions(-) delete mode 100644 Classes/LinphoneUI/Base.lproj/UIChatCreateCollectionViewCell.xib delete mode 100644 Classes/LinphoneUI/fr.lproj/UIChatCreateCollectionViewCell.strings delete mode 100644 Classes/LinphoneUI/hu.lproj/UIChatCreateCollectionViewCell.strings create mode 100644 Classes/Swift/Extensions/IOS/SnapkitBridge.swift diff --git a/Classes/Base.lproj/ChatConversationCreateView.xib b/Classes/Base.lproj/ChatConversationCreateView.xib index a3a8d83cd..bbf38c238 100644 --- a/Classes/Base.lproj/ChatConversationCreateView.xib +++ b/Classes/Base.lproj/ChatConversationCreateView.xib @@ -1,9 +1,9 @@ - + - + @@ -175,13 +175,13 @@ - + - + diff --git a/Classes/ChatConversationCreateView.m b/Classes/ChatConversationCreateView.m index af346de40..2f9bb36d7 100644 --- a/Classes/ChatConversationCreateView.m +++ b/Classes/ChatConversationCreateView.m @@ -69,7 +69,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self.view addGestureRecognizer:tap]; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; - layout.itemSize = CGSizeMake(100.0 , 50.0); + layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize; _collectionController.collectionView = _collectionView; _collectionController = (ChatConversationCreateCollectionViewController *)[[UICollectionViewController alloc] initWithCollectionViewLayout:layout]; _collectionView.dataSource = self; @@ -286,7 +286,7 @@ typedef enum { ContactsAll, ContactsLinphone, ContactsMAX } ContactsCategory; return NO; } -#pragma mark - UICollectionViewDataSource +#pragma mark - UICollectionViewDataSource & Delegate - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return _tableController.contactsGroup.count; } @@ -308,9 +308,10 @@ typedef enum { ContactsAll, ContactsLinphone, ContactsMAX } ContactsCategory; ms_free(phone); } else addr = linphone_address_new(uri.UTF8String); - cell = [cell initWithName:[FastAddressBook displayNameForAddress:addr]]; + [cell.nameLabel setText:[FastAddressBook displayNameForAddress:addr]]; linphone_address_unref(addr); return cell; } + @end diff --git a/Classes/LinphoneUI/Base.lproj/UIChatCreateCollectionViewCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatCreateCollectionViewCell.xib deleted file mode 100644 index cc1ea47a9..000000000 --- a/Classes/LinphoneUI/Base.lproj/UIChatCreateCollectionViewCell.xib +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.h b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.h index e52fa8187..a3e2c565e 100644 --- a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.h +++ b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.h @@ -21,9 +21,8 @@ #import "ChatConversationCreateView.h" @interface UIChatCreateCollectionViewCell : UICollectionViewCell -@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property UILabel *nameLabel; @property (strong, nonatomic) ChatConversationCreateView *controller; @property (strong, nonatomic) NSString *uri; -- (id)initWithName:(NSString *)identifier; - (void)onDelete; @end diff --git a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m index a9b6b2f5d..1ae4bf5d9 100644 --- a/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m +++ b/Classes/LinphoneUI/UIChatCreateCollectionViewCell.m @@ -18,27 +18,31 @@ */ #import "UIChatCreateCollectionViewCell.h" +#import "linphoneapp-Swift.h" @implementation UIChatCreateCollectionViewCell -- (void)awakeFromNib { - [super awakeFromNib]; -} - -- (id)initWithName:(NSString *)identifier { - if (self != nil) { - NSArray *arrayOfViews = - [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil]; - if ([arrayOfViews count] >= 1) { - UIChatCreateCollectionViewCell *sub = ((UIChatCreateCollectionViewCell *)[arrayOfViews objectAtIndex:0]); - [self addSubview:sub]; - _nameLabel = sub.nameLabel; - } - } - [_nameLabel setText:identifier]; +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + self.contentView.translatesAutoresizingMaskIntoConstraints = false; + [SnapkitBridge matchParentDimensionsWithView:self.contentView topInset:10]; + + self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + self.nameLabel.numberOfLines = 1; + [self.contentView addSubview:self.nameLabel]; + [SnapkitBridge matchParentDimensionsWithView:self.nameLabel leftInset:20]; + [SnapkitBridge heightWithView:self heiht:50]; + + UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"conference_delete"]]; + image.contentMode = UIViewContentModeScaleAspectFit; + [self.contentView addSubview:image]; + [SnapkitBridge squareWithView:image size:15]; + [SnapkitBridge alignParentLeftWithView:image]; + [SnapkitBridge centerYWithView:image]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onDelete)]; tap.numberOfTouchesRequired = 1; - [self addGestureRecognizer:tap]; + [image addGestureRecognizer:tap]; + image.userInteractionEnabled = true; return self; } @@ -60,4 +64,6 @@ [_controller.tableController.tableView reloadData]; _controller.nextButton.enabled = (_controller.tableController.contactsGroup.count > 0) || _controller.isForEditing; } + + @end diff --git a/Classes/LinphoneUI/fr.lproj/UIChatCreateCollectionViewCell.strings b/Classes/LinphoneUI/fr.lproj/UIChatCreateCollectionViewCell.strings deleted file mode 100644 index c4186dcaa445e34304e704e7189447b464cefafc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 206 zcmezWkBdQ{L5o3w!I>e4A(5dN2o)G?fmn$ll);n12Pl@rkP4JjVz35^mH^omKoX|L ziy@yOgCP&dcLB0ep{o3Wda{7LWS~knW)@lI*9V>gQTIbF$m(EL2+eff;LhD#. + */ + +import UIKit +import Photos +import linphonesw + + +@objc class SnapkitBridge: NSObject { + @objc static func matchParentDimensions(view:UIView) { + view.matchParentDimmensions().done() + } + + @objc static func matchParentDimensions(view:UIView,leftInset:CGFloat) { + view.matchParentDimmensions(insetedBy: UIEdgeInsets(top: 0, left: leftInset, bottom: 0, right: 0)).done() + } + + @objc static func matchParentDimensions(view:UIView,topInset:CGFloat) { + view.matchParentDimmensions(insetedBy: UIEdgeInsets(top: topInset, left: 0, bottom: 0, right: 0)).done() + } + + @objc static func height(view:UIView,heiht:Int) { + view.height(heiht).done() + } + @objc static func square(view:UIView,size:Int) { + view.square(size).done() + } + + @objc static func alignParentLeft(view:UIView) { + view.alignParentLeft().done() + } + + @objc static func centerY(view:UIView) { + view.centerY().done() + } + +} +