Better management of added contacts list horizontal scrolling

This commit is contained in:
Benjamin Reis 2017-10-04 17:13:27 +02:00
parent 13d6d9f76b
commit 213e444e82
10 changed files with 158 additions and 33 deletions

View file

@ -104,13 +104,15 @@
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rBc-dQ-eIj" userLabel="nextButton" customClass="UIIconButton">
<rect key="frame" x="300" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<accessibility key="accessibilityConfiguration" label="Back">
<bool key="isElement" value="YES"/>
</accessibility>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="next_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="back_disabled.png"/>
<state key="disabled" image="next_disabled.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
<connections>
<action selector="onNextClick:" destination="-1" eventType="touchUpInside" id="yFF-js-mRx"/>
@ -172,5 +174,6 @@
<image name="contacts_sip_disabled.png" width="38" height="30"/>
<image name="contacts_sip_selected.png" width="38" height="30"/>
<image name="next_default.png" width="24" height="22"/>
<image name="next_disabled.png" width="24" height="22"/>
</resources>
</document>

View file

@ -0,0 +1,12 @@
//
// ChatConversationCreateConfirmView.h
// linphone
//
// Created by REIS Benjamin on 04/10/2017.
//
#import <UIKit/UIKit.h>
#import "UICompositeView.h"
@interface ChatConversationCreateConfirmView : UIViewController <UICompositeViewDelegate>
@end

View file

@ -0,0 +1,36 @@
//
// ChatConversationCreateConfirmView.m
// linphone
//
// Created by REIS Benjamin on 04/10/2017.
//
#import "ChatConversationCreateConfirmView.h"
#import "PhoneMainView.h"
@implementation ChatConversationCreateConfirmView
static UICompositeViewDescription *compositeDescription = nil;
+ (UICompositeViewDescription *)compositeViewDescription {
if (compositeDescription == nil) {
compositeDescription = [[UICompositeViewDescription alloc] init:self.class
statusBar:StatusBarView.class
tabBar:TabBarView.class
sideMenu:SideMenuView.class
fullscreen:false
isLeftFragment:NO
fragmentWith:ChatsListView.class];
}
return compositeDescription;
}
- (UICompositeViewDescription *)compositeViewDescription {
return self.class.compositeViewDescription;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
@end

View file

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" 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="13173"/>
<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"/>
<view contentMode="scaleToFill" id="GvQ-4h-gI1">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2Kg-fP-a78" userLabel="topBar" customClass="ChatConversationCreateConfirmView">
<rect key="frame" x="0.0" y="0.0" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="color_F.png" translatesAutoresizingMaskIntoConstraints="NO" id="hFd-RB-VGm" userLabel="backgroundColor">
<rect key="frame" x="0.0" y="0.0" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Evf-57-b9t" userLabel="backButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="back_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="back_disabled.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aZ4-Rl-kUQ" userLabel="nextButton" customClass="UIIconButton">
<rect key="frame" x="300" y="0.0" width="75" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="valid_default.png">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<state key="disabled" image="valid_disabled.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
</subviews>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</objects>
<resources>
<image name="back_default.png" width="24" height="22"/>
<image name="back_disabled.png" width="24" height="22"/>
<image name="color_E.png" width="2" height="2"/>
<image name="color_F.png" width="2" height="2"/>
<image name="valid_default.png" width="28" height="19"/>
<image name="valid_disabled.png" width="28" height="19"/>
</resources>
</document>

View file

@ -14,6 +14,8 @@
@property(nonatomic, strong) NSMutableArray *contactsGroup;
@property(nonatomic, strong) NSMutableDictionary *contactsDict;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIIconButton *controllerNextButton;
- (void) loadData;
@end

View file

@ -102,6 +102,7 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIChatCreateCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSInteger index = 0;
if(cell.selectedImage.hidden) {
if(![_contactsGroup containsObject:cell.addressLabel.text]) {
[_contactsGroup addObject:cell.addressLabel.text];
@ -109,11 +110,26 @@
[_collectionView registerClass:UIChatCreateCollectionViewCell.class forCellWithReuseIdentifier:cell.addressLabel.text];
}
} else if([_contactsGroup containsObject:cell.addressLabel.text]) {
index = (NSInteger)[_contactsGroup indexOfObject:cell.addressLabel.text];
[_contactsGroup removeObject:cell.addressLabel.text];
if(index == _contactsGroup.count) index = index-1;
[_contactsDict removeObjectForKey:cell.addressLabel.text];
}
cell.selectedImage.hidden = !cell.selectedImage.hidden;
[_collectionView reloadData];
if(!cell.selectedImage.hidden) {
index = _contactsGroup.count-1;
}
dispatch_async(dispatch_get_main_queue(), ^{
if(index > 0) {
NSIndexPath *path = [NSIndexPath indexPathForItem:index inSection:0];
[_collectionView scrollToItemAtIndexPath:path
atScrollPosition:(UICollectionViewScrollPositionCenteredHorizontally | UICollectionViewScrollPositionCenteredVertically)
animated:YES];
}
});
_controllerNextButton.enabled = (_contactsGroup.count > 0);
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {

View file

@ -52,6 +52,8 @@ static UICompositeViewDescription *compositeDescription = nil;
_collectionView.dataSource = self;
[_collectionView setCollectionViewLayout:layout];
_tableController.collectionView = _collectionView;
_tableController.controllerNextButton = _nextButton;
_nextButton.enabled = FALSE;
}
- (void)viewWillAppear:(BOOL)animated {
@ -67,38 +69,8 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onNextClick:(id)sender {
/*NSString *uri;
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_contacts.allKeys objectAtIndex:indexPath.row]];
if (addr) {
uri = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(addr)];
} else {
uri = [_contacts.allKeys objectAtIndex:indexPath.row];
}
LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, uri.UTF8String);
if (!room) {
[PhoneMainView.instance popCurrentView];
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid address", nil)
message:NSLocalizedString(@"Please specify the entire SIP address for the chat",
nil)
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
defaultAction.accessibilityLabel = @"OK";
[errView addAction:defaultAction];
[PhoneMainView.instance presentViewController:errView animated:YES completion:nil];
} else {
ChatConversationView *view = VIEW(ChatConversationView);
[view setChatRoom:room];
[PhoneMainView.instance popCurrentView];
ChatConversationCreateConfirmView *view = VIEW(ChatConversationCreateConfirmView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
// refresh list of chatrooms if we are using fragment
if (IPAD) {
ChatsListView *listView = VIEW(ChatsListView);
[listView.tableController loadData];
}
}*/
}
- (void)dismissKeyboards {

View file

@ -35,5 +35,6 @@
[_controller.tableController.contactsDict removeObjectForKey:_uri];
[_controller.collectionView reloadData];
[_controller.tableController.tableView reloadData];
_controller.tableController.controllerNextButton.enabled = (_controller.tableController.contactsGroup.count > 0);
}
@end

View file

@ -31,6 +31,7 @@
#import "CallSideMenuView.h"
#import "CallView.h"
#import "ChatConversationCreateView.h"
#import "ChatConversationCreateConfirmView.h"
#import "ChatConversationView.h"
#import "ChatsListView.h"
#import "ContactDetailsView.h"

View file

@ -687,6 +687,10 @@
8CA2004C1D8158440095F859 /* PushKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CA2004B1D8158440095F859 /* PushKit.framework */; };
8CDC61951F84D89B0087CF7F /* check_selected.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CDC618C1F84D89B0087CF7F /* check_selected.png */; };
8CDC61971F84D9270087CF7F /* check_selected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CDC61961F84D9270087CF7F /* check_selected@2x.png */; };
8CDC619A1F84EAC10087CF7F /* ChatConversationCreateConfirmView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CDC61991F84EAC10087CF7F /* ChatConversationCreateConfirmView.m */; };
8CDC619C1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8CDC619B1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib */; };
8CDC619F1F8500B90087CF7F /* next_disabled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CDC619D1F8500B70087CF7F /* next_disabled@2x.png */; };
8CDC61A01F8500B90087CF7F /* next_disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CDC619E1F8500B80087CF7F /* next_disabled.png */; };
8CE24F4B1F8234A30077AC0A /* next_default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CE24F491F8234A20077AC0A /* next_default.png */; };
8CE24F4C1F8234A30077AC0A /* next_default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CE24F4A1F8234A30077AC0A /* next_default@2x.png */; };
8CE24F571F8268850077AC0A /* conference_delete.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CE24F551F8268840077AC0A /* conference_delete.png */; };
@ -1692,6 +1696,11 @@
8CA2004B1D8158440095F859 /* PushKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PushKit.framework; path = System/Library/Frameworks/PushKit.framework; sourceTree = SDKROOT; };
8CDC618C1F84D89B0087CF7F /* check_selected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = check_selected.png; path = "../../../ressources 27.07.17/check_selected.png"; sourceTree = "<group>"; };
8CDC61961F84D9270087CF7F /* check_selected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "check_selected@2x.png"; path = "../../../ressources 27.07.17/check_selected@2x.png"; sourceTree = "<group>"; };
8CDC61981F84EAC10087CF7F /* ChatConversationCreateConfirmView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChatConversationCreateConfirmView.h; sourceTree = "<group>"; };
8CDC61991F84EAC10087CF7F /* ChatConversationCreateConfirmView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChatConversationCreateConfirmView.m; sourceTree = "<group>"; };
8CDC619B1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ChatConversationCreateConfirmView.xib; sourceTree = "<group>"; };
8CDC619D1F8500B70087CF7F /* next_disabled@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "next_disabled@2x.png"; path = "../../../next_disabled@2x.png"; sourceTree = "<group>"; };
8CDC619E1F8500B80087CF7F /* next_disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = next_disabled.png; path = ../../../next_disabled.png; sourceTree = "<group>"; };
8CE24F491F8234A20077AC0A /* next_default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = next_default.png; sourceTree = "<group>"; };
8CE24F4A1F8234A30077AC0A /* next_default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "next_default@2x.png"; sourceTree = "<group>"; };
8CE24F551F8268840077AC0A /* conference_delete.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = conference_delete.png; sourceTree = "<group>"; };
@ -2024,6 +2033,9 @@
6336715E1BCBAAD200BFCBDE /* ChatConversationCreateView.h */,
6336715F1BCBAAD200BFCBDE /* ChatConversationCreateView.m */,
63B8D68E1BCBE65600C12B09 /* ChatConversationCreateView.xib */,
8CDC61981F84EAC10087CF7F /* ChatConversationCreateConfirmView.h */,
8CDC61991F84EAC10087CF7F /* ChatConversationCreateConfirmView.m */,
8CDC619B1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib */,
D32B6E2715A5BC430033019F /* ChatConversationTableView.h */,
D32B6E2815A5BC430033019F /* ChatConversationTableView.m */,
D3F795D315A582800077328B /* ChatConversationView.h */,
@ -2412,6 +2424,8 @@
633FEBE11D3CD5570014B822 /* images */ = {
isa = PBXGroup;
children = (
8CDC619E1F8500B80087CF7F /* next_disabled.png */,
8CDC619D1F8500B70087CF7F /* next_disabled@2x.png */,
8CDC61961F84D9270087CF7F /* check_selected@2x.png */,
8CDC618C1F84D89B0087CF7F /* check_selected.png */,
8CE24F551F8268840077AC0A /* conference_delete.png */,
@ -3306,6 +3320,7 @@
633FEEC61D3CD55A0014B822 /* numpad_5_over@2x.png in Resources */,
633FEF021D3CD55A0014B822 /* options_disabled.png in Resources */,
633FEDC81D3CD5590014B822 /* call_missed.png in Resources */,
8CDC61A01F8500B90087CF7F /* next_disabled.png in Resources */,
633FEF4B1D3CD55A0014B822 /* splashscreen@2x.png in Resources */,
8C300D9A1E40E0CC00728EF3 /* lime_ko.png in Resources */,
633FEE311D3CD5590014B822 /* color_I.png in Resources */,
@ -3605,6 +3620,7 @@
633FEF4F1D3CD55A0014B822 /* valid_default@2x.png in Resources */,
633FEE241D3CD5590014B822 /* chat_start_body_over~ipad.png in Resources */,
633FEE091D3CD5590014B822 /* chat_add_disabled@2x.png in Resources */,
8CDC619F1F8500B90087CF7F /* next_disabled@2x.png in Resources */,
633FEE191D3CD5590014B822 /* chat_send_over@2x.png in Resources */,
633FEF181D3CD55A0014B822 /* pause_small_over_selected.png in Resources */,
633FEE001D3CD5590014B822 /* camera_switch_over.png in Resources */,
@ -3646,6 +3662,7 @@
633FEF1D1D3CD55A0014B822 /* presence_offline@2x.png in Resources */,
24A3459E1D95797700881A5C /* UIShopTableCell.xib in Resources */,
633FEE231D3CD5590014B822 /* chat_start_body_over@2x.png in Resources */,
8CDC619C1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib in Resources */,
633FEEBE1D3CD55A0014B822 /* numpad_4_over@2x.png in Resources */,
633FEF471D3CD55A0014B822 /* speaker_disabled@2x.png in Resources */,
633FEEFE1D3CD55A0014B822 /* options_add_call_disabled.png in Resources */,
@ -3961,6 +3978,7 @@
D32648441588F6FC00930C67 /* UIToggleButton.m in Sources */,
D36FB2D51589EF7C0036F6F2 /* UIPauseButton.m in Sources */,
D31C9C98158A1CDF00756B45 /* UIHistoryCell.m in Sources */,
8CDC619A1F84EAC10087CF7F /* ChatConversationCreateConfirmView.m in Sources */,
D35E7597159460580066B1C1 /* ChatsListView.m in Sources */,
D35E759F159460B70066B1C1 /* SettingsView.m in Sources */,
63B81A101B57DA33009604A6 /* UIScrollView+TPKeyboardAvoidingAdditions.m in Sources */,