зеркало из https://github.com/nextcloud/talk-ios.git
User AccountTableViewCell for account selector.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
6d3b5508f5
Коммит
6d0d991c1d
|
@ -30,6 +30,11 @@
|
|||
@property (nonatomic, assign) BOOL selected;
|
||||
@end
|
||||
|
||||
typedef enum DetailedOptionsSelectorType {
|
||||
DetailedOptionsSelectorTypeDefault = 0,
|
||||
DetailedOptionsSelectorTypeAccounts
|
||||
} DetailedOptionsSelectorType;
|
||||
|
||||
@class DetailedOptionsSelectorTableViewController;
|
||||
@protocol DetailedOptionsSelectorTableViewControllerDelegate <NSObject>
|
||||
- (void)detailedOptionsSelector:(DetailedOptionsSelectorTableViewController *)viewController didSelectOptionWithIdentifier:(DetailedOption *)option;
|
||||
|
@ -41,9 +46,10 @@
|
|||
@property (nonatomic, weak) id<DetailedOptionsSelectorTableViewControllerDelegate> delegate;
|
||||
@property (nonatomic, strong) NSArray *options;
|
||||
@property (nonatomic, strong) NSString *senderId;
|
||||
@property (nonatomic, strong) NSString *title;
|
||||
@property (nonatomic, assign) DetailedOptionsSelectorType type;
|
||||
|
||||
- (instancetype)initWithOptions:(NSArray *)options forSenderIdentifier:(NSString *)senderId andTitle:(NSString *)title;
|
||||
- (instancetype)initWithOptions:(NSArray *)options forSenderIdentifier:(NSString *)senderId;
|
||||
- (instancetype)initWithAccounts:(NSArray *)accounts;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#import "DetailedOptionsSelectorTableViewController.h"
|
||||
|
||||
#import "NCAppBranding.h"
|
||||
#import "NextcloudTalk-Swift.h"
|
||||
|
||||
@interface DetailedOptionsSelectorTableViewController ()
|
||||
|
||||
|
@ -33,13 +34,23 @@
|
|||
|
||||
@implementation DetailedOptionsSelectorTableViewController
|
||||
|
||||
- (instancetype)initWithOptions:(NSArray *)options forSenderIdentifier:(NSString *)senderId andTitle:(NSString *)title
|
||||
- (instancetype)initWithOptions:(NSArray *)options forSenderIdentifier:(NSString *)senderId
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
|
||||
|
||||
self.options = options;
|
||||
self.senderId = senderId;
|
||||
self.title = title;
|
||||
self.type = DetailedOptionsSelectorTypeDefault;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAccounts:(NSArray *)accounts
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
|
||||
self.options = accounts;
|
||||
self.type = DetailedOptionsSelectorTypeAccounts;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -64,7 +75,8 @@
|
|||
self.navigationItem.compactAppearance = appearance;
|
||||
self.navigationItem.scrollEdgeAppearance = appearance;
|
||||
|
||||
self.navigationController.title = self.title;
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[AccountTableViewCell class]];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"AccountTableViewCell" bundle:bundle] forCellReuseIdentifier:@"AccountTableViewCellIdentifier"];
|
||||
|
||||
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
|
||||
target:self action:@selector(cancelButtonPressed)];
|
||||
|
@ -87,7 +99,16 @@
|
|||
{
|
||||
DetailedOption *option = [_options objectAtIndex:indexPath.row];
|
||||
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"DetailOptionIdentifier"];
|
||||
|
||||
|
||||
if (_type == DetailedOptionsSelectorTypeAccounts) {
|
||||
AccountTableViewCell *accountCell = [tableView dequeueReusableCellWithIdentifier:@"AccountTableViewCellIdentifier" forIndexPath:indexPath];
|
||||
accountCell.accountNameLabel.text = option.title;
|
||||
accountCell.accountServerLabel.text = [option.subtitle stringByReplacingOccurrencesOfString:@"https://" withString:@""];
|
||||
accountCell.accountImageView.image = option.image;
|
||||
accountCell.accountImageView.backgroundColor = [UIColor systemBackgroundColor];
|
||||
return accountCell;
|
||||
}
|
||||
|
||||
[cell.imageView setImage:option.image];
|
||||
cell.textLabel.text = option.title;
|
||||
cell.detailTextLabel.text = option.subtitle;
|
||||
|
|
|
@ -275,15 +275,18 @@
|
|||
|
||||
- (void)presentImportedAccountsSelector
|
||||
{
|
||||
NSMutableArray *importedAccountsOptions = [NSMutableArray new];
|
||||
NSMutableArray *importedAccounts = [NSMutableArray new];
|
||||
for (NKDataAccountFile *filesAccount in _importedFilesAccount) {
|
||||
DetailedOption *option = [[DetailedOption alloc] init];
|
||||
option.title = filesAccount.user;
|
||||
option.subtitle = filesAccount.url;
|
||||
[importedAccountsOptions addObject:option];
|
||||
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:filesAccount.avatar]];
|
||||
option.image = [UIImage imageWithData:imageData];
|
||||
[importedAccounts addObject:option];
|
||||
}
|
||||
|
||||
DetailedOptionsSelectorTableViewController *accountSelectorVC = [[DetailedOptionsSelectorTableViewController alloc] initWithOptions:importedAccountsOptions forSenderIdentifier:nil andTitle:NSLocalizedString(@"Import account", nil)];
|
||||
DetailedOptionsSelectorTableViewController *accountSelectorVC = [[DetailedOptionsSelectorTableViewController alloc] initWithAccounts:importedAccounts];
|
||||
accountSelectorVC.title = NSLocalizedString(@"Import account", nil);
|
||||
accountSelectorVC.delegate = self;
|
||||
NCNavigationController *accountSelectorNC = [[NCNavigationController alloc] initWithRootViewController:accountSelectorVC];
|
||||
[self presentViewController:accountSelectorNC animated:YES completion:nil];
|
||||
|
|
|
@ -244,8 +244,9 @@ extension UserProfileTableViewController {
|
|||
options.append(publishedOption)
|
||||
}
|
||||
|
||||
let optionSelectorVC = DetailedOptionsSelectorTableViewController(options: options, forSenderIdentifier: field, andTitle: title)
|
||||
let optionSelectorVC = DetailedOptionsSelectorTableViewController(options: options, forSenderIdentifier: field)
|
||||
if let optionSelectorVC = optionSelectorVC {
|
||||
optionSelectorVC.title = title
|
||||
optionSelectorVC.delegate = self
|
||||
let optionSelectorNC = UINavigationController(rootViewController: optionSelectorVC)
|
||||
self.present(optionSelectorNC, animated: true, completion: nil)
|
||||
|
|
|
@ -102,8 +102,9 @@ class UserStatusTableViewController: UITableViewController, DetailedOptionsSelec
|
|||
options.append(dndOption)
|
||||
options.append(invisibleOption)
|
||||
|
||||
let optionSelectorVC = DetailedOptionsSelectorTableViewController(options: options, forSenderIdentifier: nil, andTitle: NSLocalizedString("Online status", comment: ""))
|
||||
let optionSelectorVC = DetailedOptionsSelectorTableViewController(options: options, forSenderIdentifier: nil)
|
||||
if let optionSelectorVC = optionSelectorVC {
|
||||
optionSelectorVC.title = NSLocalizedString("Online status", comment: "")
|
||||
optionSelectorVC.delegate = self
|
||||
let optionSelectorNC = NCNavigationController(rootViewController: optionSelectorVC)
|
||||
self.present(optionSelectorNC, animated: true, completion: nil)
|
||||
|
|
Загрузка…
Ссылка в новой задаче