mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
select focus inputs in table cells. load folders into picker cell.
This commit is contained in:
parent
4723e6a101
commit
ae79eb6a96
5 changed files with 58 additions and 15 deletions
|
@ -3,7 +3,7 @@ using UIKit;
|
||||||
|
|
||||||
namespace Bit.iOS.Core.Views
|
namespace Bit.iOS.Core.Views
|
||||||
{
|
{
|
||||||
public class FormEntryTableViewCell : UITableViewCell
|
public class FormEntryTableViewCell : UITableViewCell, ISelectable
|
||||||
{
|
{
|
||||||
public FormEntryTableViewCell(
|
public FormEntryTableViewCell(
|
||||||
string labelName = null,
|
string labelName = null,
|
||||||
|
@ -107,5 +107,17 @@ namespace Bit.iOS.Core.Views
|
||||||
public UILabel Label { get; set; }
|
public UILabel Label { get; set; }
|
||||||
public UITextField TextField { get; set; }
|
public UITextField TextField { get; set; }
|
||||||
public UITextView TextView { get; set; }
|
public UITextView TextView { get; set; }
|
||||||
|
|
||||||
|
public void Select()
|
||||||
|
{
|
||||||
|
if(TextView != null)
|
||||||
|
{
|
||||||
|
TextView.BecomeFirstResponder();
|
||||||
|
}
|
||||||
|
else if(TextField != null)
|
||||||
|
{
|
||||||
|
TextField.BecomeFirstResponder();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
src/iOS.Core/Views/ISelectable.cs
Normal file
7
src/iOS.Core/Views/ISelectable.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace Bit.iOS.Core.Views
|
||||||
|
{
|
||||||
|
public interface ISelectable
|
||||||
|
{
|
||||||
|
void Select();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,10 @@ using UIKit;
|
||||||
|
|
||||||
namespace Bit.iOS.Core.Views
|
namespace Bit.iOS.Core.Views
|
||||||
{
|
{
|
||||||
public class PickerTableViewCell : UITableViewCell
|
public class PickerTableViewCell : UITableViewCell, ISelectable
|
||||||
{
|
{
|
||||||
private List<string> _items = new List<string>();
|
private List<string> _items = new List<string>();
|
||||||
private int _selectedIndex = -1;
|
private int _selectedIndex = 0;
|
||||||
|
|
||||||
public PickerTableViewCell(
|
public PickerTableViewCell(
|
||||||
string labelName,
|
string labelName,
|
||||||
|
@ -35,8 +35,6 @@ namespace Bit.iOS.Core.Views
|
||||||
TranslatesAutoresizingMaskIntoConstraints = false,
|
TranslatesAutoresizingMaskIntoConstraints = false,
|
||||||
Font = UIFont.FromDescriptor(descriptor, pointSize)
|
Font = UIFont.FromDescriptor(descriptor, pointSize)
|
||||||
};
|
};
|
||||||
TextField.Started += Entry_Started;
|
|
||||||
TextField.Ended += Entry_Ended;
|
|
||||||
|
|
||||||
var width = (float)UIScreen.MainScreen.Bounds.Width;
|
var width = (float)UIScreen.MainScreen.Bounds.Width;
|
||||||
var toolbar = new UIToolbar(new RectangleF(0, 0, width, 44))
|
var toolbar = new UIToolbar(new RectangleF(0, 0, width, 44))
|
||||||
|
@ -134,14 +132,9 @@ namespace Bit.iOS.Core.Views
|
||||||
Picker.Select(Math.Max(formsIndex, 0), 0, true);
|
Picker.Select(Math.Max(formsIndex, 0), 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Entry_Ended(object sender, EventArgs e)
|
public void Select()
|
||||||
{
|
{
|
||||||
//throw new NotImplementedException();
|
TextField?.BecomeFirstResponder();
|
||||||
}
|
|
||||||
|
|
||||||
private void Entry_Started(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NoCaretField : UITextField
|
private class NoCaretField : UITextField
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
<Compile Include="Services\Settings.cs" />
|
<Compile Include="Services\Settings.cs" />
|
||||||
<Compile Include="Services\SqlService.cs" />
|
<Compile Include="Services\SqlService.cs" />
|
||||||
<Compile Include="Utilities\Dialogs.cs" />
|
<Compile Include="Utilities\Dialogs.cs" />
|
||||||
|
<Compile Include="Views\ISelectable.cs" />
|
||||||
<Compile Include="Views\PickerTableViewCell.cs" />
|
<Compile Include="Views\PickerTableViewCell.cs" />
|
||||||
<Compile Include="Views\SwitchTableViewCell.cs" />
|
<Compile Include="Views\SwitchTableViewCell.cs" />
|
||||||
<Compile Include="Views\FormEntryTableViewCell.cs" />
|
<Compile Include="Views\FormEntryTableViewCell.cs" />
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace Bit.iOS.Extension
|
||||||
public partial class SiteAddViewController : UITableViewController
|
public partial class SiteAddViewController : UITableViewController
|
||||||
{
|
{
|
||||||
private ISiteService _siteService;
|
private ISiteService _siteService;
|
||||||
|
private IFolderService _folderService;
|
||||||
private IConnectivity _connectivity;
|
private IConnectivity _connectivity;
|
||||||
|
private IEnumerable<Folder> _folders;
|
||||||
|
|
||||||
public SiteAddViewController(IntPtr handle) : base(handle)
|
public SiteAddViewController(IntPtr handle) : base(handle)
|
||||||
{ }
|
{ }
|
||||||
|
@ -46,6 +48,7 @@ namespace Bit.iOS.Extension
|
||||||
{
|
{
|
||||||
_siteService = Resolver.Resolve<ISiteService>();
|
_siteService = Resolver.Resolve<ISiteService>();
|
||||||
_connectivity = Resolver.Resolve<IConnectivity>();
|
_connectivity = Resolver.Resolve<IConnectivity>();
|
||||||
|
_folderService = Resolver.Resolve<IFolderService>();
|
||||||
|
|
||||||
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
||||||
|
|
||||||
|
@ -88,12 +91,15 @@ namespace Bit.iOS.Extension
|
||||||
GeneratePasswordCell.TextLabel.Text = "Generate Password";
|
GeneratePasswordCell.TextLabel.Text = "Generate Password";
|
||||||
GeneratePasswordCell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
|
GeneratePasswordCell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
|
||||||
|
|
||||||
FolderCell.Items = new List<string> { "Folder 1", "Folder 2" };
|
_folders = _folderService.GetAllAsync().GetAwaiter().GetResult();
|
||||||
FolderCell.SelectedIndex = 1;
|
var folderNames = _folders.Select(s => s.Name.Decrypt()).OrderBy(s => s).ToList();
|
||||||
|
folderNames.Insert(0, AppResources.FolderNone);
|
||||||
|
FolderCell.Items = folderNames;
|
||||||
|
|
||||||
TableView.RowHeight = UITableView.AutomaticDimension;
|
TableView.RowHeight = UITableView.AutomaticDimension;
|
||||||
TableView.EstimatedRowHeight = 70;
|
TableView.EstimatedRowHeight = 70;
|
||||||
TableView.Source = new TableSource(this);
|
TableView.Source = new TableSource(this);
|
||||||
|
TableView.AllowsSelection = true;
|
||||||
|
|
||||||
base.ViewDidLoad();
|
base.ViewDidLoad();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +145,8 @@ namespace Bit.iOS.Extension
|
||||||
Username = string.IsNullOrWhiteSpace(UsernameCell.TextField.Text) ? null : UsernameCell.TextField.Text.Encrypt(),
|
Username = string.IsNullOrWhiteSpace(UsernameCell.TextField.Text) ? null : UsernameCell.TextField.Text.Encrypt(),
|
||||||
Password = string.IsNullOrWhiteSpace(PasswordCell.TextField.Text) ? null : PasswordCell.TextField.Text.Encrypt(),
|
Password = string.IsNullOrWhiteSpace(PasswordCell.TextField.Text) ? null : PasswordCell.TextField.Text.Encrypt(),
|
||||||
Notes = string.IsNullOrWhiteSpace(NotesCell.TextView.Text) ? null : NotesCell.TextView.Text.Encrypt(),
|
Notes = string.IsNullOrWhiteSpace(NotesCell.TextView.Text) ? null : NotesCell.TextView.Text.Encrypt(),
|
||||||
Favorite = FavoriteCell.Switch.On
|
Favorite = FavoriteCell.Switch.On,
|
||||||
|
FolderId = FolderCell.SelectedIndex == 0 ? null : _folders.ElementAtOrDefault(FolderCell.SelectedIndex - 1)?.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
var saveTask = _siteService.SaveAsync(site);
|
var saveTask = _siteService.SaveAsync(site);
|
||||||
|
@ -260,6 +267,29 @@ namespace Bit.iOS.Extension
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
|
||||||
|
{
|
||||||
|
tableView.DeselectRow(indexPath, true);
|
||||||
|
tableView.EndEditing(true);
|
||||||
|
|
||||||
|
if(indexPath.Section == 0 && indexPath.Row == 4)
|
||||||
|
{
|
||||||
|
// Generate password selected
|
||||||
|
}
|
||||||
|
|
||||||
|
var cell = tableView.CellAt(indexPath);
|
||||||
|
if(cell == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectableCell = cell as ISelectable;
|
||||||
|
if(selectableCell != null)
|
||||||
|
{
|
||||||
|
selectableCell.Select();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue