mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
better text fiel management
This commit is contained in:
parent
a25f95dd4e
commit
e77ad93331
7 changed files with 89 additions and 7 deletions
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// ChatConversationCreateConfirmCollectionViewController.h
|
||||
// linphone
|
||||
//
|
||||
// Created by REIS Benjamin on 05/10/2017.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ChatConversationCreateConfirmCollectionViewController : UICollectionViewController
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// ChatConversationCreateConfirmCollectionViewController.m
|
||||
// linphone
|
||||
//
|
||||
// Created by REIS Benjamin on 05/10/2017.
|
||||
//
|
||||
|
||||
#import "ChatConversationCreateConfirmCollectionViewController.h"
|
||||
#import "UIChatCreateConfirmCollectionViewCell.h"
|
||||
|
||||
@interface ChatConversationCreateConfirmCollectionViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ChatConversationCreateConfirmCollectionViewController
|
||||
|
||||
static NSString * const reuseIdentifier = @"Cell";
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Register cell classes
|
||||
[self.collectionView registerClass:[UIChatCreateConfirmCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -7,11 +7,15 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "UICompositeView.h"
|
||||
#import "ChatConversationCreateConfirmCollectionViewController.h"
|
||||
|
||||
@interface ChatConversationCreateConfirmView : UIViewController <UICompositeViewDelegate, UITextFieldDelegate, UIGestureRecognizerDelegate, UICollectionViewDataSource>
|
||||
@property (weak, nonatomic) IBOutlet UITextField *nameField;
|
||||
@property (weak, nonatomic) IBOutlet UIIconButton *validateButton;
|
||||
@property(nonatomic, strong) NSMutableDictionary *contacts;
|
||||
@property(nonatomic, strong) NSMutableArray *contactsGroup;
|
||||
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
|
||||
@property(strong, nonatomic) IBOutlet ChatConversationCreateConfirmCollectionViewController *collectionController;
|
||||
- (IBAction)onBackClick:(id)sender;
|
||||
- (IBAction)onValidateClick:(id)sender;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,34 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_contactsGroup = [[NSMutableArray alloc] init];
|
||||
_nameField.delegate = self;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
|
||||
initWithTarget:self
|
||||
action:@selector(dismissKeyboards)];
|
||||
tap.delegate = self;
|
||||
[self.view addGestureRecognizer:tap];
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||||
layout.itemSize = CGSizeMake(100.0 , 50.0);
|
||||
_collectionController.collectionView = _collectionView;
|
||||
_collectionController = (ChatConversationCreateConfirmCollectionViewController *)[[UICollectionViewController alloc] initWithCollectionViewLayout:layout];
|
||||
_collectionView.dataSource = self;
|
||||
[_collectionView setCollectionViewLayout:layout];
|
||||
}
|
||||
|
||||
- (void) viewWillAppear:(BOOL)animated {
|
||||
for(id uri in _contacts.allKeys) {
|
||||
[_collectionController.collectionView registerClass:UIChatCreateConfirmCollectionViewCell.class forCellWithReuseIdentifier:uri];
|
||||
if(![_contactsGroup containsObject:_contacts[uri]])
|
||||
[_contactsGroup addObject:_contacts[uri]];
|
||||
}
|
||||
[_collectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[_contactsGroup removeAllObjects];
|
||||
[_contacts removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)dismissKeyboards {
|
||||
|
|
@ -51,12 +73,14 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
- (IBAction)onValidateClick:(id)sender {
|
||||
[_collectionView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField {
|
||||
_validateButton.enabled = (textField.text.length > 0 && textField.text != nil && ![textField.text isEqual:@""]);
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
||||
_validateButton.enabled = !((string.length == 0 || string == nil || [string isEqual:@""]) && (textField.text.length == 1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDataSource
|
||||
|
|
@ -70,7 +94,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
- (UIChatCreateConfirmCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return NULL;
|
||||
NSString *uri = _contactsGroup[indexPath.item];
|
||||
UIChatCreateConfirmCollectionViewCell *cell = (UIChatCreateConfirmCollectionViewCell *)[_collectionView dequeueReusableCellWithReuseIdentifier:uri forIndexPath:indexPath];
|
||||
cell.uri = uri;
|
||||
cell = [cell initWithName:_contacts[uri]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChatConversationCreateConfirmView">
|
||||
<connections>
|
||||
<outlet property="collectionView" destination="vxZ-Pk-gLv" id="Tl3-qq-DIh"/>
|
||||
<outlet property="nameField" destination="5uU-sb-Hle" id="XjS-4y-ooZ"/>
|
||||
<outlet property="validateButton" destination="aZ4-Rl-kUQ" id="H8t-tQ-Kjg"/>
|
||||
<outlet property="view" destination="GFA-Ly-0cJ" id="pRe-As-q8O"/>
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (IBAction)onNextClick:(id)sender {
|
||||
ChatConversationCreateConfirmView *view = VIEW(ChatConversationCreateConfirmView);
|
||||
view.contacts = _tableController.contactsDict;
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
|
|
@ -132,11 +133,11 @@ typedef enum { ContactsAll, ContactsLinphone, ContactsMAX } ContactsCategory;
|
|||
}
|
||||
|
||||
- (UIChatCreateCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSString *name = _tableController.contactsGroup[indexPath.item];
|
||||
UIChatCreateCollectionViewCell *cell = (UIChatCreateCollectionViewCell *)[_collectionView dequeueReusableCellWithReuseIdentifier:name forIndexPath:indexPath];
|
||||
NSString *uri = _tableController.contactsGroup[indexPath.item];
|
||||
UIChatCreateCollectionViewCell *cell = (UIChatCreateCollectionViewCell *)[_collectionView dequeueReusableCellWithReuseIdentifier:uri forIndexPath:indexPath];
|
||||
cell.controller = self;
|
||||
cell.uri = name;
|
||||
cell = [cell initWithName:_tableController.contactsDict[name]];
|
||||
cell.uri = uri;
|
||||
cell = [cell initWithName:_tableController.contactsDict[uri]];
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -689,6 +689,7 @@
|
|||
8CB2B8FA1F86229E0015CEE2 /* next_disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2B8F71F86229C0015CEE2 /* next_disabled.png */; };
|
||||
8CB2B8FB1F86229E0015CEE2 /* next_disabled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8CB2B8F81F86229D0015CEE2 /* next_disabled@2x.png */; };
|
||||
8CD3F5AC1F86632100680C98 /* UIChatCreateConfirmCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD3F5AB1F86632100680C98 /* UIChatCreateConfirmCollectionViewCell.m */; };
|
||||
8CD3F5B71F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD3F5B61F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.m */; };
|
||||
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 */; };
|
||||
|
|
@ -1701,6 +1702,8 @@
|
|||
8CB2B8F81F86229D0015CEE2 /* next_disabled@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "next_disabled@2x.png"; sourceTree = "<group>"; };
|
||||
8CD3F5AA1F86632100680C98 /* UIChatCreateConfirmCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIChatCreateConfirmCollectionViewCell.h; sourceTree = "<group>"; };
|
||||
8CD3F5AB1F86632100680C98 /* UIChatCreateConfirmCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIChatCreateConfirmCollectionViewCell.m; sourceTree = "<group>"; };
|
||||
8CD3F5B51F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChatConversationCreateConfirmCollectionViewController.h; sourceTree = "<group>"; };
|
||||
8CD3F5B61F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChatConversationCreateConfirmCollectionViewController.m; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
|
|
@ -2038,6 +2041,8 @@
|
|||
6336715E1BCBAAD200BFCBDE /* ChatConversationCreateView.h */,
|
||||
6336715F1BCBAAD200BFCBDE /* ChatConversationCreateView.m */,
|
||||
63B8D68E1BCBE65600C12B09 /* ChatConversationCreateView.xib */,
|
||||
8CD3F5B51F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.h */,
|
||||
8CD3F5B61F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.m */,
|
||||
8CDC61981F84EAC10087CF7F /* ChatConversationCreateConfirmView.h */,
|
||||
8CDC61991F84EAC10087CF7F /* ChatConversationCreateConfirmView.m */,
|
||||
8CDC619B1F84EAFD0087CF7F /* ChatConversationCreateConfirmView.xib */,
|
||||
|
|
@ -4045,6 +4050,7 @@
|
|||
D3807FF815C2894A005BE9BC /* IASKPSSliderSpecifierViewCell.m in Sources */,
|
||||
D3807FFA15C2894A005BE9BC /* IASKPSTextFieldSpecifierViewCell.m in Sources */,
|
||||
D3807FFC15C2894A005BE9BC /* IASKPSTitleValueSpecifierViewCell.m in Sources */,
|
||||
8CD3F5B71F867A1400680C98 /* ChatConversationCreateConfirmCollectionViewController.m in Sources */,
|
||||
D3807FFE15C2894A005BE9BC /* IASKSlider.m in Sources */,
|
||||
D380800015C2894A005BE9BC /* IASKSwitch.m in Sources */,
|
||||
D380800215C2894A005BE9BC /* IASKTextField.m in Sources */,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue