mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +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\RequiredValidationBehavior.cs" />
|
||||
<Compile Include="Controls\EntryLabel.cs" />
|
||||
<Compile Include="Controls\BottomBorderEntry.cs" />
|
||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||
<Compile Include="Controls\ExtendedEntry.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 =
|
||||
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
|
||||
{
|
||||
get { return (bool)GetValue(HasBorderProperty); }
|
||||
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()
|
||||
{
|
||||
var foldersLayout = new StackLayout { Orientation = StackOrientation.Horizontal };
|
||||
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 };
|
||||
var foldersCell = new TextCell { Text = "Folders" };
|
||||
foldersCell.Tapped += FoldersCell_Tapped;
|
||||
|
||||
var table = new TableView
|
||||
{
|
||||
Intent = TableIntent.Menu,
|
||||
Root = new TableRoot
|
||||
{
|
||||
new TableSection("Manage Folders")
|
||||
|
|
|
@ -32,41 +32,77 @@ namespace Bit.App.Pages
|
|||
{
|
||||
var folders = _folderService.GetAllAsync().GetAwaiter().GetResult().OrderBy(f => f.Name?.Decrypt());
|
||||
|
||||
var uriEntry = new BottomBorderEntry { Keyboard = Keyboard.Url };
|
||||
var nameEntry = new BottomBorderEntry();
|
||||
var folderPicker = new ExtendedPicker
|
||||
{
|
||||
Title = AppResources.Folder,
|
||||
BottomBorderColor = Color.FromHex( "d2d6de" ),
|
||||
HasOnlyBottomBorder = true
|
||||
};
|
||||
var uriEntry = new ExtendedEntry { Keyboard = Keyboard.Url, HasBorder = false };
|
||||
var nameEntry = new ExtendedEntry { HasBorder = false };
|
||||
var folderPicker = new ExtendedPicker { Title = AppResources.Folder, HasBorder = false };
|
||||
folderPicker.Items.Add(AppResources.FolderNone);
|
||||
folderPicker.SelectedIndex = 0;
|
||||
foreach(var folder in folders)
|
||||
{
|
||||
folderPicker.Items.Add(folder.Name.Decrypt());
|
||||
}
|
||||
var usernameEntry = new BottomBorderEntry();
|
||||
var passwordEntry = new BottomBorderEntry { IsPassword = true };
|
||||
var usernameEntry = new ExtendedEntry { HasBorder = false };
|
||||
var passwordEntry = new ExtendedEntry { IsPassword = true, HasBorder = false };
|
||||
var notesEditor = new Editor { HeightRequest = 75 };
|
||||
|
||||
var stackLayout = new StackLayout { Padding = new Thickness( 15 ) };
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.URI } );
|
||||
stackLayout.Children.Add( uriEntry );
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Name, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( nameEntry );
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Folder, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( folderPicker );
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Username, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( usernameEntry );
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Password, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( passwordEntry );
|
||||
stackLayout.Children.Add( new EntryLabel { Text = AppResources.Notes, Margin = new Thickness( 0, 15, 0, 0 ) } );
|
||||
stackLayout.Children.Add( notesEditor );
|
||||
var uriStackLayout = new FormEntryStackLayout();
|
||||
uriStackLayout.Children.Add(new EntryLabel { Text = AppResources.URI });
|
||||
uriStackLayout.Children.Add(uriEntry);
|
||||
var uriCell = new ViewCell();
|
||||
uriCell.View = uriStackLayout;
|
||||
|
||||
var nameStackLayout = new FormEntryStackLayout();
|
||||
nameStackLayout.Children.Add(new EntryLabel { Text = AppResources.Name });
|
||||
nameStackLayout.Children.Add(nameEntry);
|
||||
var nameCell = new ViewCell();
|
||||
nameCell.View = nameStackLayout;
|
||||
|
||||
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
|
||||
{
|
||||
Content = stackLayout,
|
||||
Content = table,
|
||||
Orientation = ScrollOrientation.Vertical
|
||||
};
|
||||
|
||||
|
@ -127,6 +163,14 @@ namespace Bit.App.Pages
|
|||
{
|
||||
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);
|
||||
|
||||
base.OnAppearing();
|
||||
}
|
||||
|
||||
private void Copy(string copyText, string alertLabel)
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
using System.ComponentModel;
|
||||
using Bit.App.Controls;
|
||||
using Bit.iOS.Controls;
|
||||
using CoreAnimation;
|
||||
using CoreGraphics;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
@ -30,9 +28,7 @@ namespace Bit.iOS.Controls
|
|||
|
||||
var view = (ExtendedPicker)Element;
|
||||
|
||||
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedPicker.HasOnlyBottomBorderProperty.PropertyName
|
||||
|| e.PropertyName == ExtendedPicker.BottomBorderColorProperty.PropertyName)
|
||||
if(e.PropertyName == ExtendedPicker.HasBorderProperty.PropertyName)
|
||||
{
|
||||
SetBorder(view);
|
||||
}
|
||||
|
@ -40,25 +36,7 @@ namespace Bit.iOS.Controls
|
|||
|
||||
private void SetBorder(ExtendedPicker view)
|
||||
{
|
||||
if(view.HasOnlyBottomBorder)
|
||||
{
|
||||
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;
|
||||
}
|
||||
Control.BorderStyle = view.HasBorder ? UITextBorderStyle.RoundedRect : UITextBorderStyle.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue