1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-07 11:03:54 +00:00

adjust bottom paddings on listviews/tableviews

This commit is contained in:
Kyle Spearrin
2017-12-30 21:18:24 -05:00
parent fbe1a6d4c5
commit f0662bb878
23 changed files with 175 additions and 47 deletions

View File

@@ -0,0 +1,16 @@
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class ExtendedListView : ListView
{
public static readonly BindableProperty BottomPaddingProperty =
BindableProperty.Create(nameof(BottomPadding), typeof(int), typeof(ExtendedTableView), 0);
public ExtendedListView() { }
public ExtendedListView(ListViewCachingStrategy cachingStrategy)
: base(cachingStrategy) { }
public int BottomPadding { get; set; }
}
}

View File

@@ -1,8 +1,4 @@
using System;
using Xamarin.Forms;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using Xamarin.Forms;
using XLabs.Ioc;
using Bit.App.Abstractions;
@@ -19,6 +15,9 @@ namespace Bit.App.Controls
public static readonly BindableProperty SeparatorColorProperty =
BindableProperty.Create(nameof(SeparatorColor), typeof(Color), typeof(ExtendedTableView), Color.FromHex("d2d6de"));
public static readonly BindableProperty BottomPaddingProperty =
BindableProperty.Create(nameof(BottomPadding), typeof(int), typeof(ExtendedTableView), 0);
public bool EnableScrolling
{
get { return (bool)GetValue(EnableScrollingProperty); }
@@ -40,6 +39,7 @@ namespace Bit.App.Controls
public int EstimatedRowHeight { get; set; }
public bool NoHeader { get; set; }
public bool NoFooter { get; set; }
public int BottomPadding { get; set; }
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{

View File

@@ -123,6 +123,10 @@ namespace Bit.App.Pages
MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
}));
}
else if(Device.RuntimePlatform == Device.Android)
{
table2.BottomPadding = 50;
}
ToolbarItems.Add(toolbarItem);
Title = AppResources.Settings;

View File

@@ -54,6 +54,10 @@ namespace Bit.App.Pages
table.RowHeight = -1;
table.EstimatedRowHeight = 70;
}
else if(Device.RuntimePlatform == Device.Android)
{
table.BottomPadding = 50;
}
var saveToolBarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async () =>
{

View File

@@ -71,6 +71,10 @@ namespace Bit.App.Pages
mainTable.RowHeight = -1;
mainTable.EstimatedRowHeight = 70;
}
else if(Device.RuntimePlatform == Device.Android)
{
mainTable.BottomPadding = 50;
}
var saveToolBarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async () =>
{

View File

@@ -23,13 +23,13 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<SettingsFolderPageModel> Folders { get; private set; }
= new ExtendedObservableCollection<SettingsFolderPageModel>();
public ListView ListView { get; set; }
public ExtendedListView ListView { get; set; }
private AddFolderToolBarItem AddItem { get; set; }
public Fab Fab { get; set; }
private void Init()
{
ListView = new ListView
ListView = new ExtendedListView
{
ItemsSource = Folders,
ItemTemplate = new DataTemplate(() => new SettingsFolderListViewCell(this))
@@ -47,6 +47,7 @@ namespace Bit.App.Pages
{
await Navigation.PushForDeviceAsync(new SettingsAddFolderPage());
});
ListView.BottomPadding = 50;
}
else
{

View File

@@ -488,6 +488,10 @@ namespace Bit.App.Pages
RowHeight = -1;
EstimatedRowHeight = 44;
}
else if(Device.RuntimePlatform == Device.Android)
{
BottomPadding = 50;
}
}
}

View File

@@ -71,6 +71,10 @@ namespace Bit.App.Pages
table.RowHeight = -1;
table.EstimatedRowHeight = 100;
}
else if(Device.RuntimePlatform == Device.Android)
{
table.BottomPadding = 50;
}
Title = AppResources.Tools;
Content = table;

View File

@@ -158,6 +158,10 @@ namespace Bit.App.Pages
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
}
}
else if(Device.RuntimePlatform == Device.Android)
{
table.BottomPadding = 50;
}
var stackLayout = new StackLayout
{

View File

@@ -564,6 +564,10 @@ namespace Bit.App.Pages
Table.RowHeight = -1;
Table.EstimatedRowHeight = 70;
}
else if(Device.RuntimePlatform == Device.Android)
{
Table.BottomPadding = 50;
}
}
private void InitSave()

View File

@@ -43,7 +43,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<VaultAttachmentsPageModel.Attachment> PresentationAttchments { get; private set; }
= new ExtendedObservableCollection<VaultAttachmentsPageModel.Attachment>();
public ListView ListView { get; set; }
public ExtendedListView ListView { get; set; }
public StackLayout NoDataStackLayout { get; set; }
public StackLayout AddNewStackLayout { get; set; }
public Label FileLabel { get; set; }
@@ -101,7 +101,7 @@ namespace Bit.App.Pages
}
};
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
{
ItemsSource = PresentationAttchments,
HasUnevenRows = true,
@@ -196,6 +196,10 @@ namespace Bit.App.Pages
ListView.BackgroundColor = Color.Transparent;
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
}
else if(Device.RuntimePlatform == Device.Android)
{
ListView.BottomPadding = 50;
}
}
protected async override void OnAppearing()

View File

@@ -51,13 +51,14 @@ namespace Bit.App.Pages
Init();
}
public ContentView ContentView { get; set; }
public Fab Fab { get; set; }
public ExtendedObservableCollection<Section<AutofillCipher>> PresentationCiphersGroup { get; private set; }
= new ExtendedObservableCollection<Section<AutofillCipher>>();
public StackLayout NoDataStackLayout { get; set; }
public ListView ListView { get; set; }
public ExtendedListView ListView { get; set; }
public ActivityIndicator LoadingIndicator { get; set; }
private SearchToolBarItem SearchItem { get; set; }
private AddCipherToolBarItem AddCipherItem { get; set; }
private IGoogleAnalyticsService GoogleAnalyticsService { get; set; }
private IDeviceActionService DeviceActionService { get; set; }
private string Uri { get; set; }
@@ -87,12 +88,10 @@ namespace Bit.App.Pages
Spacing = 20
};
AddCipherItem = new AddCipherToolBarItem(this);
ToolbarItems.Add(AddCipherItem);
SearchItem = new SearchToolBarItem(this);
ToolbarItems.Add(SearchItem);
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
{
IsGroupingEnabled = true,
ItemsSource = PresentationCiphersGroup,
@@ -117,14 +116,22 @@ namespace Bit.App.Pages
HorizontalOptions = LayoutOptions.Center
};
Content = LoadingIndicator;
ContentView = new ContentView
{
Content = LoadingIndicator
};
var fabLayout = new FabLayout(ContentView);
Fab = new Fab(fabLayout, "plus.png", async (sender, args) => await AddCipherAsync());
ListView.BottomPadding = 170;
Content = fabLayout;
}
protected override void OnAppearing()
{
base.OnAppearing();
ListView.ItemSelected += CipherSelected;
AddCipherItem.InitEvents();
SearchItem.InitEvents();
_filterResultsCancellationTokenSource = FetchAndLoadVault();
}
@@ -133,7 +140,6 @@ namespace Bit.App.Pages
{
base.OnDisappearing();
ListView.ItemSelected -= CipherSelected;
AddCipherItem.Dispose();
SearchItem.Dispose();
}
@@ -148,11 +154,11 @@ namespace Bit.App.Pages
{
if(PresentationCiphersGroup.Count > 0)
{
Content = ListView;
ContentView.Content = ListView;
}
else
{
Content = NoDataStackLayout;
ContentView.Content = NoDataStackLayout;
}
}
@@ -249,7 +255,7 @@ namespace Bit.App.Pages
((ListView)sender).SelectedItem = null;
}
private async void AddCipherAsync()
private async Task AddCipherAsync()
{
if(_appOptions.FillType.HasValue && _appOptions.FillType != CipherType.Login)
{
@@ -262,17 +268,6 @@ namespace Bit.App.Pages
await Navigation.PushForDeviceAsync(pageForLogin);
}
private class AddCipherToolBarItem : ExtendedToolbarItem
{
public AddCipherToolBarItem(VaultAutofillListCiphersPage page)
: base(() => page.AddCipherAsync())
{
Text = AppResources.Add;
Icon = "plus.png";
Priority = 2;
}
}
private class SearchToolBarItem : ExtendedToolbarItem
{
private readonly VaultAutofillListCiphersPage _page;

View File

@@ -140,6 +140,10 @@ namespace Bit.App.Pages
Table.RowHeight = -1;
Table.EstimatedRowHeight = 44;
}
else if(Device.RuntimePlatform == Device.Android)
{
Table.BottomPadding = 50;
}
}
protected async override void OnAppearing()

View File

@@ -433,6 +433,10 @@ namespace Bit.App.Pages
Table.RowHeight = -1;
Table.EstimatedRowHeight = 70;
}
else if(Device.RuntimePlatform == Device.Android)
{
Table.BottomPadding = 50;
}
}
private void InitSave()

View File

@@ -59,7 +59,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<Section<Cipher>> PresentationSections { get; private set; }
= new ExtendedObservableCollection<Section<Cipher>>();
public Cipher[] Ciphers { get; set; } = new Cipher[] { };
public ListView ListView { get; set; }
public ExtendedListView ListView { get; set; }
public SearchBar Search { get; set; }
public ActivityIndicator LoadingIndicator { get; set; }
public StackLayout NoDataStackLayout { get; set; }
@@ -70,7 +70,7 @@ namespace Bit.App.Pages
private void Init()
{
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
{
IsGroupingEnabled = true,
ItemsSource = PresentationSections,
@@ -179,6 +179,7 @@ namespace Bit.App.Pages
{
if(Device.RuntimePlatform == Device.Android)
{
ListView.BottomPadding = 170;
Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, _folderId));
}
else
@@ -187,6 +188,10 @@ namespace Bit.App.Pages
ToolbarItems.Add(AddCipherItem);
}
}
else if(Device.RuntimePlatform == Device.Android)
{
ListView.BottomPadding = 50;
}
Content = fabLayout;
}

View File

@@ -50,7 +50,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<Section<GroupingOrCipher>> PresentationSections { get; private set; }
= new ExtendedObservableCollection<Section<GroupingOrCipher>>();
public ListView ListView { get; set; }
public ExtendedListView ListView { get; set; }
public StackLayout NoDataStackLayout { get; set; }
public ActivityIndicator LoadingIndicator { get; set; }
private AddCipherToolBarItem AddCipherItem { get; set; }
@@ -63,7 +63,7 @@ namespace Bit.App.Pages
SearchItem = new SearchToolBarItem(this);
ToolbarItems.Add(SearchItem);
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
{
IsGroupingEnabled = true,
ItemsSource = PresentationSections,
@@ -121,6 +121,7 @@ namespace Bit.App.Pages
if(Device.RuntimePlatform == Device.Android)
{
Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, null));
ListView.BottomPadding = 170;
}
else
{

View File

@@ -265,6 +265,10 @@ namespace Bit.App.Pages
Table.RowHeight = -1;
Table.EstimatedRowHeight = 70;
}
else if(Device.RuntimePlatform == Device.Android)
{
Table.BottomPadding = 170;
}
}
protected async override void OnAppearing()