Commit d4ab002f authored by Pierre SAGASPE's avatar Pierre SAGASPE

UI Connect to server : moving connect button in navigation bar

parent f1adc8cc
......@@ -18,11 +18,10 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
VLCNetworkServerLoginIndexPort,
VLCNetworkServerLoginIndexUsername,
VLCNetworkServerLoginIndexPassword,
VLCNetworkServerLoginIndexConnect,
VLCNetworkServerLoginIndexSave,
VLCNetworkServerLoginIndexCount,
VLCNetworkServerLoginIndexFieldCount = VLCNetworkServerLoginIndexConnect
VLCNetworkServerLoginIndexFieldCount = VLCNetworkServerLoginIndexSave
};
@interface VLCNetworkLoginDataSourceLogin () <VLCNetworkLoginViewFieldCellDelegate>
......@@ -53,9 +52,7 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
NSString *labelString = nil;
NSUInteger additionalFieldsCount = self.loginInformation.additionalFields.count;
NSUInteger buttonRowIndex = row-additionalFieldsCount;
if (buttonRowIndex == VLCNetworkServerLoginIndexConnect) {
labelString = NSLocalizedString(@"BUTTON_CONNECT", nil);
} else if (buttonRowIndex == VLCNetworkServerLoginIndexSave) {
if (buttonRowIndex == VLCNetworkServerLoginIndexSave) {
labelString = NSLocalizedString(@"BUTTON_SAVE", nil);
}
buttonCell.titleString = labelString;
......@@ -173,7 +170,7 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
}
NSUInteger additionalFieldsCount = self.loginInformation.additionalFields.count;
NSUInteger buttonRowIndex = row-additionalFieldsCount;
if (buttonRowIndex == VLCNetworkServerLoginIndexConnect || buttonRowIndex == VLCNetworkServerLoginIndexSave) {
if (buttonRowIndex == VLCNetworkServerLoginIndexSave) {
return kVLCNetworkLoginViewButtonCellIdentifier;
} else {
return kVLCNetworkLoginViewFieldCellIdentifier;
......@@ -205,9 +202,7 @@ typedef NS_ENUM(NSUInteger, VLCNetworkServerLoginIndex) {
{
NSUInteger additionalFieldsCount = self.loginInformation.additionalFields.count;
NSUInteger buttonRowIndex = row-additionalFieldsCount;
if (buttonRowIndex == VLCNetworkServerLoginIndexConnect) {
[self.delegate connectLoginDataSource:self];
} else if (buttonRowIndex == VLCNetworkServerLoginIndexSave) {
if (buttonRowIndex == VLCNetworkServerLoginIndexSave) {
[self.delegate saveLoginDataSource:self];
}
}
......
......@@ -66,6 +66,8 @@
dataSource.dataSources = @[self.protocolDataSource, self.loginDataSource, self.savedLoginsDataSource];
[dataSource configureWithTableView:self.tableView];
self.dataSource = dataSource;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CONNECT", nil) style:UIBarButtonItemStyleDone target:self action:@selector(connectLoginDataSource)];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -174,6 +176,16 @@
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
}
- (void)connectLoginDataSource
{
if (!self.protocolSelected)
return;
[self.delegate loginWithLoginViewController:self loginInfo:self.loginInformation];
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
}
- (BOOL)protocolSelected
{
if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) {
......
......@@ -198,7 +198,7 @@
[self presentViewController:navCon animated:YES completion:nil];
if (loginViewController.navigationItem.leftBarButtonItem == nil)
loginViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_DONE", nil) style:UIBarButtonItemStyleDone target:self action:@selector(_dismissLogin)];
loginViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) style:UIBarButtonItemStylePlain target:self action:@selector(_dismissLogin)];
}
#pragma mark - table view handling
......@@ -294,7 +294,7 @@
[self presentViewController:navCon animated:YES completion:nil];
if (loginViewController.navigationItem.leftBarButtonItem == nil)
loginViewController.navigationItem.leftBarButtonItem = [UIBarButtonItem themedDarkToolbarButtonWithTitle:NSLocalizedString(@"BUTTON_DONE", nil) target:self andSelector:@selector(_dismissLogin)];
loginViewController.navigationItem.leftBarButtonItem = [UIBarButtonItem themedDarkToolbarButtonWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) target:self andSelector:@selector(_dismissLogin)];
} else {
[self.navigationController pushViewController:loginViewController animated:YES];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment