Reworked UICollectionView for displaying selected contacts in group chat and group calls

This commit is contained in:
Christophe Deschamps 2022-11-02 23:47:49 +01:00
parent 70b2671f19
commit c80ad228ef
8 changed files with 85 additions and 66 deletions

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -175,13 +175,13 @@
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
</view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KRQ-Fm-3cQ" userLabel="addedContacts" customClass="UICollectionView">
<rect key="frame" x="8" y="110" width="398" height="70"/>
<rect key="frame" x="8" y="110" width="398" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<accessibility key="accessibilityConfiguration" label="addedContacts"/>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" style="plain" separatorStyle="default" allowsSelectionDuringEditing="YES" allowsMultipleSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="6">
<rect key="frame" x="5" y="178" width="403" height="610"/>
<rect key="frame" x="5" y="158" width="403" height="610"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<color key="separatorColor" red="0.67030966281890869" green="0.71867996454238892" blue="0.75078284740447998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

View file

@ -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

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="UIChatCreateCollectionViewCell">
<rect key="frame" x="0.0" y="0.0" width="100" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="100" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="John Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fHV-en-AZD" userLabel="displayNameLabel">
<rect key="frame" x="14" y="18" width="92" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" fixedFrame="YES" image="conference_delete.png" translatesAutoresizingMaskIntoConstraints="NO" id="yfP-hQ-SXb" userLabel="selectedImage">
<rect key="frame" x="1" y="23" width="10" height="10"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
</view>
<size key="customSize" width="170" height="45"/>
<connections>
<outlet property="nameLabel" destination="fHV-en-AZD" id="gOU-sp-v0V"/>
</connections>
<point key="canvasLocation" x="2" y="86"/>
</collectionViewCell>
</objects>
<resources>
<image name="conference_delete.png" width="17.600000381469727" height="17.600000381469727"/>
</resources>
</document>

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2010-2020 Belledonne Communications SARL.
*
* This file is part of linphone-iphone
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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()
}
}