mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
TableView to add site page
This commit is contained in:
parent
15be1cbf43
commit
6fd81fc40e
11 changed files with 133 additions and 156 deletions
|
@ -45,7 +45,6 @@
|
||||||
<Compile Include="Behaviors\ConnectivityBehavior.cs" />
|
<Compile Include="Behaviors\ConnectivityBehavior.cs" />
|
||||||
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
|
<Compile Include="Behaviors\RequiredValidationBehavior.cs" />
|
||||||
<Compile Include="Controls\EntryLabel.cs" />
|
<Compile Include="Controls\EntryLabel.cs" />
|
||||||
<Compile Include="Controls\BottomBorderEntry.cs" />
|
|
||||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||||
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
<Compile Include="Controls\ExtendedTabbedPage.cs" />
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
using Xamarin.Forms;
|
|
||||||
|
|
||||||
namespace Bit.App.Controls
|
|
||||||
{
|
|
||||||
public class BottomBorderEntry : ExtendedEntry
|
|
||||||
{
|
|
||||||
public BottomBorderEntry()
|
|
||||||
{
|
|
||||||
HasBorder = HasOnlyBottomBorder = true;
|
|
||||||
BottomBorderColor = Color.FromHex("d2d6de");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,28 +8,10 @@ namespace Bit.App.Controls
|
||||||
public static readonly BindableProperty HasBorderProperty =
|
public static readonly BindableProperty HasBorderProperty =
|
||||||
BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(ExtendedEntry), true);
|
BindableProperty.Create(nameof(HasBorder), typeof(bool), typeof(ExtendedEntry), true);
|
||||||
|
|
||||||
public static readonly BindableProperty HasOnlyBottomBorderProperty =
|
|
||||||
BindableProperty.Create(nameof(HasOnlyBottomBorder), typeof(bool), typeof(ExtendedEntry), false);
|
|
||||||
|
|
||||||
public static readonly BindableProperty BottomBorderColorProperty =
|
|
||||||
BindableProperty.Create(nameof(BottomBorderColor), typeof(Color), typeof(ExtendedEntry), Color.Default);
|
|
||||||
|
|
||||||
public bool HasBorder
|
public bool HasBorder
|
||||||
{
|
{
|
||||||
get { return (bool)GetValue(HasBorderProperty); }
|
get { return (bool)GetValue(HasBorderProperty); }
|
||||||
set { SetValue(HasBorderProperty, value); }
|
set { SetValue(HasBorderProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasOnlyBottomBorder
|
|
||||||
{
|
|
||||||
get { return (bool)GetValue(HasOnlyBottomBorderProperty); }
|
|
||||||
set { SetValue(HasOnlyBottomBorderProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color BottomBorderColor
|
|
||||||
{
|
|
||||||
get { return (Color)GetValue(BottomBorderColorProperty); }
|
|
||||||
set { SetValue(BottomBorderColorProperty, value); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,12 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
var foldersLayout = new StackLayout { Orientation = StackOrientation.Horizontal };
|
var foldersCell = new TextCell { Text = "Folders" };
|
||||||
foldersLayout.Children.Add(new Label
|
|
||||||
{
|
|
||||||
Text = "Folders",
|
|
||||||
HorizontalOptions = LayoutOptions.StartAndExpand,
|
|
||||||
VerticalOptions = LayoutOptions.Center,
|
|
||||||
Margin = new Thickness(10, 0, 0, 0)
|
|
||||||
});
|
|
||||||
foldersLayout.Children.Add(new Image
|
|
||||||
{
|
|
||||||
Source = ImageSource.FromFile("ion-chevron-right.png"),
|
|
||||||
Opacity = 0.3,
|
|
||||||
HorizontalOptions = LayoutOptions.End,
|
|
||||||
VerticalOptions = LayoutOptions.Center,
|
|
||||||
Margin = new Thickness(0, 0, 10, 0)
|
|
||||||
});
|
|
||||||
var foldersCell = new ViewCell { View = foldersLayout };
|
|
||||||
foldersCell.Tapped += FoldersCell_Tapped;
|
foldersCell.Tapped += FoldersCell_Tapped;
|
||||||
|
|
||||||
var table = new TableView
|
var table = new TableView
|
||||||
{
|
{
|
||||||
|
Intent = TableIntent.Menu,
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection("Manage Folders")
|
new TableSection("Manage Folders")
|
||||||
|
|
|
@ -32,41 +32,77 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name?.Decrypt());
|
var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name?.Decrypt());
|
||||||
|
|
||||||
var uriEntry = new BottomBorderEntry { Keyboard = Keyboard.Url };
|
var uriEntry = new ExtendedEntry { Keyboard = Keyboard.Url, HasBorder = false };
|
||||||
var nameEntry = new BottomBorderEntry();
|
var nameEntry = new ExtendedEntry { HasBorder = false };
|
||||||
var folderPicker = new ExtendedPicker
|
var folderPicker = new ExtendedPicker { Title = AppResources.Folder, HasBorder = false };
|
||||||
{
|
|
||||||
Title = AppResources.Folder,
|
|
||||||
BottomBorderColor = Color.FromHex( "d2d6de" ),
|
|
||||||
HasOnlyBottomBorder = true
|
|
||||||
};
|
|
||||||
folderPicker.Items.Add(AppResources.FolderNone);
|
folderPicker.Items.Add(AppResources.FolderNone);
|
||||||
folderPicker.SelectedIndex = 0;
|
folderPicker.SelectedIndex = 0;
|
||||||
foreach(var folder in folders)
|
foreach(var folder in folders)
|
||||||
{
|
{
|
||||||
folderPicker.Items.Add(folder.Name.Decrypt());
|
folderPicker.Items.Add(folder.Name.Decrypt());
|
||||||
}
|
}
|
||||||
var usernameEntry = new BottomBorderEntry();
|
var usernameEntry = new ExtendedEntry { HasBorder = false };
|
||||||
var passwordEntry = new BottomBorderEntry { IsPassword = true };
|
var passwordEntry = new ExtendedEntry { IsPassword = true, HasBorder = false };
|
||||||
var notesEditor = new Editor { HeightRequest = 75 };
|
var notesEditor = new Editor { HeightRequest = 75 };
|
||||||
|
|
||||||
var stackLayout = new StackLayout { Padding = new Thickness( 15 ) };
|
var uriStackLayout = new FormEntryStackLayout();
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.URI } );
|
uriStackLayout.Children.Add(new EntryLabel { Text = AppResources.URI });
|
||||||
stackLayout.Children.Add( uriEntry );
|
uriStackLayout.Children.Add(uriEntry);
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Name, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
var uriCell = new ViewCell();
|
||||||
stackLayout.Children.Add( nameEntry );
|
uriCell.View = uriStackLayout;
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Folder, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
|
||||||
stackLayout.Children.Add( folderPicker );
|
var nameStackLayout = new FormEntryStackLayout();
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Username, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
nameStackLayout.Children.Add(new EntryLabel { Text = AppResources.Name });
|
||||||
stackLayout.Children.Add( usernameEntry );
|
nameStackLayout.Children.Add(nameEntry);
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Password, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
var nameCell = new ViewCell();
|
||||||
stackLayout.Children.Add( passwordEntry );
|
nameCell.View = nameStackLayout;
|
||||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Notes, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
|
||||||
stackLayout.Children.Add( notesEditor );
|
var folderStackLayout = new FormEntryStackLayout();
|
||||||
|
folderStackLayout.Children.Add(new EntryLabel { Text = AppResources.Folder });
|
||||||
|
folderStackLayout.Children.Add(folderPicker);
|
||||||
|
var folderCell = new ViewCell();
|
||||||
|
folderCell.View = folderStackLayout;
|
||||||
|
|
||||||
|
var usernameStackLayout = new FormEntryStackLayout();
|
||||||
|
usernameStackLayout.Children.Add(new EntryLabel { Text = AppResources.Username });
|
||||||
|
usernameStackLayout.Children.Add(usernameEntry);
|
||||||
|
var usernameCell = new ViewCell();
|
||||||
|
usernameCell.View = usernameStackLayout;
|
||||||
|
|
||||||
|
var passwordStackLayout = new FormEntryStackLayout();
|
||||||
|
passwordStackLayout.Children.Add(new EntryLabel { Text = AppResources.Password });
|
||||||
|
passwordStackLayout.Children.Add(passwordEntry);
|
||||||
|
var passwordCell = new ViewCell();
|
||||||
|
passwordCell.View = passwordStackLayout;
|
||||||
|
|
||||||
|
var notesStackLayout = new FormEntryStackLayout();
|
||||||
|
notesStackLayout.Children.Add(new EntryLabel { Text = AppResources.Notes });
|
||||||
|
notesStackLayout.Children.Add(notesEditor);
|
||||||
|
var notesCell = new ViewCell();
|
||||||
|
notesCell.View = notesStackLayout;
|
||||||
|
|
||||||
|
var table = new TableView
|
||||||
|
{
|
||||||
|
Intent = TableIntent.Form,
|
||||||
|
RowHeight = 65,
|
||||||
|
HasUnevenRows = true,
|
||||||
|
Root = new TableRoot
|
||||||
|
{
|
||||||
|
new TableSection
|
||||||
|
{
|
||||||
|
uriCell,
|
||||||
|
nameCell,
|
||||||
|
folderCell,
|
||||||
|
usernameCell,
|
||||||
|
passwordCell,
|
||||||
|
notesCell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var scrollView = new ScrollView
|
var scrollView = new ScrollView
|
||||||
{
|
{
|
||||||
Content = stackLayout,
|
Content = table,
|
||||||
Orientation = ScrollOrientation.Vertical
|
Orientation = ScrollOrientation.Vertical
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,6 +163,14 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class FormEntryStackLayout : StackLayout
|
||||||
|
{
|
||||||
|
public FormEntryStackLayout()
|
||||||
|
{
|
||||||
|
Padding = new Thickness(15, 15, 15, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
Model.Update(site);
|
Model.Update(site);
|
||||||
|
|
||||||
|
base.OnAppearing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Copy(string copyText, string alertLabel)
|
private void Copy(string copyText, string alertLabel)
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Bit.App.Controls;
|
using Bit.App.Controls;
|
||||||
using Bit.iOS.Controls;
|
using Bit.iOS.Controls;
|
||||||
using CoreAnimation;
|
|
||||||
using CoreGraphics;
|
|
||||||
using UIKit;
|
using UIKit;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.iOS;
|
using Xamarin.Forms.Platform.iOS;
|
||||||
|
@ -30,9 +28,7 @@ namespace Bit.iOS.Controls
|
||||||
|
|
||||||
var view = (ExtendedPicker)Element;
|
var view = (ExtendedPicker)Element;
|
||||||
|
|
||||||
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName
|
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName)
|
||||||
|| e.PropertyName == ExtendedPicker.HasOnlyBottomBorderProperty.PropertyName
|
|
||||||
|| e.PropertyName == ExtendedPicker.BottomBorderColorProperty.PropertyName)
|
|
||||||
{
|
{
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
}
|
}
|
||||||
|
@ -40,25 +36,7 @@ namespace Bit.iOS.Controls
|
||||||
|
|
||||||
private void SetBorder(ExtendedPicker view)
|
private void SetBorder(ExtendedPicker view)
|
||||||
{
|
{
|
||||||
if(view.HasOnlyBottomBorder)
|
Control.BorderStyle = view.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None;
|
||||||
{
|
|
||||||
var borderLayer = new CALayer();
|
|
||||||
borderLayer.MasksToBounds = true;
|
|
||||||
borderLayer.Frame = new CGRect( 0f, Frame.Height / 2, Frame.Width * 2, 1f );
|
|
||||||
borderLayer.BorderColor = view.BottomBorderColor.ToCGColor();
|
|
||||||
borderLayer.BorderWidth = 1f;
|
|
||||||
|
|
||||||
Control.Layer.AddSublayer( borderLayer );
|
|
||||||
Control.BorderStyle = UITextBorderStyle.None;
|
|
||||||
}
|
|
||||||
else if(view.HasBorder)
|
|
||||||
{
|
|
||||||
Control.BorderStyle = UITextBorderStyle.RoundedRect;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Control.BorderStyle = UITextBorderStyle.None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue