Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8738969
covert to core data
May 7, 2015
b7d51ca
test git
May 8, 2015
3642837
login fix
May 8, 2015
5543ae2
fix logout & table view
May 9, 2015
b78f6f1
detail view autolayout
May 10, 2015
c9c1da5
add image and label
May 11, 2015
ee21d50
contact and core data update
May 23, 2015
325a37e
added image display for detail view. need debug
dandanlau May 24, 2015
29a21a9
store contact list into parse
May 24, 2015
ae992d8
fix detail view
dandanlau May 24, 2015
b42dfb7
Merge branch 'core_data' of https://github.com/kiddjacky/BLE-chat int…
dandanlau May 24, 2015
5fdde95
fixed title view layout
dandanlau May 25, 2015
b520660
added icons, changed contactDetailsVC.m but not complete
dandanlau Jun 2, 2015
ca9e2dd
recheckin
dandanlau Jun 2, 2015
799aded
modify chat button size
dandanlau Jun 2, 2015
aa120f6
changed image name
dandanlau Jun 2, 2015
a4ef129
change image name
dandanlau Jun 2, 2015
de6fefa
changed image size
dandanlau Jun 2, 2015
f34f039
updated project image settings
dandanlau Jun 2, 2015
e70f9db
add limit to discover user list
Jun 6, 2015
b7c86d4
changed contactDetails to display user data
dandanlau Jun 7, 2015
c51ac16
changed prepare segue
dandanlau Jun 7, 2015
414186d
Merge branch 'core_data' of https://github.com/kiddjacky/BLE-chat int…
dandanlau Jun 7, 2015
d118de3
bluetooth connect
Jun 13, 2015
12b8f7d
fix ble connect
Jun 14, 2015
6838482
add thumbnail
Jun 26, 2015
ee26ec2
update to get user picture, does not work yet
dandanlau Jun 26, 2015
f582158
thumbnail
Jul 8, 2015
2a22a4e
contact thumbnail
Jul 8, 2015
9544cc5
discover cell
Jul 17, 2015
8f74944
add refresh control
Jul 18, 2015
f09781b
discovercell
Jul 18, 2015
1b4a868
Removed line between cell, increased height
dandanlau Jul 20, 2015
a201c4d
contact view update
Jul 21, 2015
f312eb4
changed cell width
dandanlau Jul 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Classes/Tabs/01_Groups/GroupsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#import "GroupsView.h"
#import "ChatView.h"
#import "DatabaseAvailability.h"

//-------------------------------------------------------------------------------------------------------------------------------------------------
@interface GroupsView()
Expand Down Expand Up @@ -65,6 +66,7 @@ - (void)viewDidAppear:(BOOL)animated
//---------------------------------------------------------------------------------------------------------------------------------------------
if ([PFUser currentUser] != nil)
{
[[NSNotificationCenter defaultCenter] postNotificationName:PFUSER_READY object:nil];
[self loadGroups];
}
else LoginUser(self);
Expand Down
2 changes: 2 additions & 0 deletions Classes/Tabs/02_Messages/MessagesView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import "AddressBookView.h"
#import "FacebookFriendsView.h"
#import "NavigationController.h"
#import "DatabaseAvailability.h"

//-------------------------------------------------------------------------------------------------------------------------------------------------
@interface MessagesView()
Expand Down Expand Up @@ -86,6 +87,7 @@ - (void)viewDidAppear:(BOOL)animated
//---------------------------------------------------------------------------------------------------------------------------------------------
if ([PFUser currentUser] != nil)
{
[[NSNotificationCenter defaultCenter] postNotificationName:PFUSER_READY object:nil];
[self loadMessages];
}
else LoginUser(self);
Expand Down
135 changes: 128 additions & 7 deletions Classes/Tabs/03_Profile/ProfileView.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,41 @@
#import "utilities.h"

#import "ProfileView.h"

#import "DatabaseAvailability.h"
//-------------------------------------------------------------------------------------------------------------------------------------------------
@interface ProfileView()
@interface ProfileView() <UIPickerViewDataSource, UIPickerViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *viewHeader;
@property (strong, nonatomic) IBOutlet PFImageView *imageUser;

@property (strong, nonatomic) IBOutlet UITableViewCell *cellName;

@property (strong, nonatomic) IBOutlet UITableViewCell *cellSex;
@property (strong, nonatomic) IBOutlet UITableViewCell *cellDate;
@property (strong, nonatomic) IBOutlet UITableViewCell *cellInterest;
@property (strong, nonatomic) IBOutlet UITableViewCell *cellSelfDescription;

@property (strong, nonatomic) NSArray *sexArray;


@property (strong, nonatomic) IBOutlet UITableViewCell *cellButton;

@property (strong, nonatomic) IBOutlet UITextField *fieldName;
@property (strong, nonatomic) IBOutlet UITextField *fieldSex;
@property (strong, nonatomic) IBOutlet UITextField *fieldInterest;
@property (strong, nonatomic) IBOutlet UITextField *fieldSelfDescription;
@property (strong, nonatomic) IBOutlet UITextField *fieldDate;


@end
//-------------------------------------------------------------------------------------------------------------------------------------------------

@implementation ProfileView

@synthesize viewHeader, imageUser;
@synthesize cellName, cellButton;
@synthesize fieldName;
@synthesize cellName, cellButton, cellSex, cellDate, cellInterest, cellSelfDescription;
@synthesize fieldName, fieldDate, fieldInterest, fieldSelfDescription, fieldSex;


//-------------------------------------------------------------------------------------------------------------------------------------------------
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
Expand Down Expand Up @@ -70,6 +85,21 @@ - (void)viewDidLoad
//---------------------------------------------------------------------------------------------------------------------------------------------
imageUser.layer.cornerRadius = imageUser.frame.size.width / 2;
imageUser.layer.masksToBounds = YES;

//setup sex picker
UIPickerView *sexPicker = [[UIPickerView alloc] init];
//[sexPicker numberOfRowsInComponent:1];
[sexPicker setDataSource:self];
[sexPicker setDelegate:self];
sexPicker.showsSelectionIndicator = YES;
[fieldSex setInputView:sexPicker];
self.sexArray = [[NSArray alloc] initWithObjects:@"Male",@"Female",@"Unknown",nil];

//setup date picker
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker addTarget:self action:@selector(updateDateField:) forControlEvents:UIControlEventValueChanged];
[fieldDate setInputView:datePicker];
}

//-------------------------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -80,6 +110,7 @@ - (void)viewDidAppear:(BOOL)animated
//---------------------------------------------------------------------------------------------------------------------------------------------
if ([PFUser currentUser] != nil)
{
[[NSNotificationCenter defaultCenter] postNotificationName:PFUSER_READY object:nil];
[self loadUser];
}
else LoginUser(self);
Expand All @@ -92,6 +123,41 @@ - (void)dismissKeyboard
[self.view endEditing:YES];
}

#pragma mark - Picker view
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 3;
}

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [self.sexArray objectAtIndex:row];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(@"Selected Row %ld", (long)row);
switch (row) {
case 0:
self.fieldSex.text = @"Male";
break;
case 1:
self.fieldSex.text = @"Female";
break;
case 2:
self.fieldSex.text = @"Unknown";
break;

default:
break;
}
}

#pragma mark - Backend actions

//-------------------------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -104,30 +170,45 @@ - (void)loadUser
[imageUser loadInBackground];

fieldName.text = user[PF_USER_FULLNAME];
}
fieldSex.text = user[PF_USER_SEX];
fieldDate.text = user[PF_USER_BIRTHDAY];
fieldInterest.text = user[PF_USER_INTEREST];
fieldSelfDescription.text = user[PF_USER_SELF_DESCRIPTION];
}

//-------------------------------------------------------------------------------------------------------------------------------------------------
- (void)saveUser
//-------------------------------------------------------------------------------------------------------------------------------------------------
{
NSString *fullname = fieldName.text;
NSString *sex = fieldSex.text;
NSString *interest = fieldInterest.text;
NSString *selfDescription = fieldSelfDescription.text;
NSString *birthday = fieldDate.text;
if ([fullname length] != 0)
{
PFUser *user = [PFUser currentUser];
user[PF_USER_FULLNAME] = fullname;
user[PF_USER_FULLNAME_LOWER] = [fullname lowercaseString];
user[PF_USER_SEX] = sex;
user[PF_USER_INTEREST] = interest;
user[PF_USER_SELF_DESCRIPTION] = selfDescription;
user[PF_USER_BIRTHDAY] = birthday;
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (error == nil)
{
[ProgressHUD showSuccess:@"Saved."];
[[NSNotificationCenter defaultCenter] postNotificationName:PFUSER_READY object:nil];
}
else [ProgressHUD showError:@"Network error."];

}];
}
else [ProgressHUD showError:@"Name field must be set."];
}


#pragma mark - User actions

//-------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -159,6 +240,8 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
ParsePushUserResign();
PostNotification(NOTIFICATION_USER_LOGGED_OUT);
[self actionCleanup];
[[NSNotificationCenter defaultCenter] postNotificationName:PFUSER_LOGOUT object:nil];
[self dismissViewControllerAnimated:YES completion:nil];
LoginUser(self);
}
}
Expand All @@ -178,6 +261,14 @@ - (IBAction)actionSave:(id)sender
[self saveUser];
}


-(void)updateDateField:(id)sender
{
UIDatePicker *picker = (UIDatePicker *)self.fieldDate.inputView;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"dd-MMM-yyyy";
self.fieldDate.text = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:picker.date]];
}
#pragma mark - UIImagePickerControllerDelegate

//-------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -220,7 +311,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//-------------------------------------------------------------------------------------------------------------------------------------------------
{
return 2;
return 6;
}

//-------------------------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -235,8 +326,38 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
//-------------------------------------------------------------------------------------------------------------------------------------------------
{
if (indexPath.section == 0) return cellName;
if (indexPath.section == 1) return cellButton;
if (indexPath.section == 1) return cellSex;
if (indexPath.section == 2) return cellDate;
if (indexPath.section == 3) return cellInterest;
if (indexPath.section == 4) return cellSelfDescription;
if (indexPath.section == 5) return cellButton;
return nil;
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *sectionName;
switch (section) {
case 0:
sectionName = NSLocalizedString(@"Name", @"user Name");
break;
case 1:
sectionName = NSLocalizedString(@"Sex", @"sex");
break;
case 2:
sectionName = NSLocalizedString(@"Birthday", @"birthday");
break;
case 3:
sectionName = NSLocalizedString(@"Interest", @"interest");
break;
case 4:
sectionName = NSLocalizedString(@"Self Description", @"selfDescription");
break;
default:
sectionName = @"";
break;
}
return sectionName;
}

@end
Loading