1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-06 02:23:57 +00:00

floating action button on android

This commit is contained in:
Kyle Spearrin
2017-12-30 14:05:51 -05:00
parent 2235f1f7af
commit fbe1a6d4c5
15 changed files with 2682 additions and 328 deletions

View File

@@ -25,32 +25,44 @@ namespace Bit.App.Pages
= new ExtendedObservableCollection<SettingsFolderPageModel>();
public ListView ListView { get; set; }
private AddFolderToolBarItem AddItem { get; set; }
public Fab Fab { get; set; }
private void Init()
{
AddItem = new AddFolderToolBarItem(this);
ToolbarItems.Add(AddItem);
ListView = new ListView
{
ItemsSource = Folders,
ItemTemplate = new DataTemplate(() => new SettingsFolderListViewCell(this))
};
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
{
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
}
var fabLayout = new FabLayout(ListView);
if(Device.RuntimePlatform == Device.Android)
{
Fab = new Fab(fabLayout, "plus.png", async (sender, args) =>
{
await Navigation.PushForDeviceAsync(new SettingsAddFolderPage());
});
}
else
{
AddItem = new AddFolderToolBarItem(this);
ToolbarItems.Add(AddItem);
}
Title = AppResources.Folders;
Content = ListView;
Content = fabLayout;
}
protected override void OnAppearing()
{
base.OnAppearing();
ListView.ItemSelected += FolderSelected;
AddItem.InitEvents();
AddItem?.InitEvents();
LoadFoldersAsync().Wait();
}
@@ -58,7 +70,7 @@ namespace Bit.App.Pages
{
base.OnDisappearing();
ListView.ItemSelected -= FolderSelected;
AddItem.Dispose();
AddItem?.Dispose();
}
private async Task LoadFoldersAsync()

View File

@@ -65,15 +65,11 @@ namespace Bit.App.Pages
public StackLayout NoDataStackLayout { get; set; }
public StackLayout ResultsStackLayout { get; set; }
private AddCipherToolBarItem AddCipherItem { get; set; }
public ContentView ContentView { get; set; }
public Fab Fab { get; set; }
private void Init()
{
if(!string.IsNullOrWhiteSpace(_uri) || _folder || !string.IsNullOrWhiteSpace(_folderId))
{
AddCipherItem = new AddCipherToolBarItem(this, _folderId);
ToolbarItems.Add(AddCipherItem);
}
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
{
IsGroupingEnabled = true,
@@ -173,7 +169,26 @@ namespace Bit.App.Pages
LoadingIndicator.HorizontalOptions = LayoutOptions.Center;
}
Content = LoadingIndicator;
ContentView = new ContentView
{
Content = LoadingIndicator
};
var fabLayout = new FabLayout(ContentView);
if(!string.IsNullOrWhiteSpace(_uri) || _folder || !string.IsNullOrWhiteSpace(_folderId))
{
if(Device.RuntimePlatform == Device.Android)
{
Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, _folderId));
}
else
{
AddCipherItem = new AddCipherToolBarItem(this, _folderId);
ToolbarItems.Add(AddCipherItem);
}
}
Content = fabLayout;
}
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
@@ -350,7 +365,7 @@ namespace Bit.App.Pages
PresentationSections.ResetWithRange(sections);
if(PresentationSections.Count > 0 || !string.IsNullOrWhiteSpace(Search.Text))
{
Content = ResultsStackLayout;
ContentView.Content = ResultsStackLayout;
if(string.IsNullOrWhiteSpace(_uri) && !_folder && string.IsNullOrWhiteSpace(_folderId) &&
string.IsNullOrWhiteSpace(_collectionId) && !_favorites)
@@ -360,11 +375,11 @@ namespace Bit.App.Pages
}
else if(_syncService.SyncInProgress)
{
Content = LoadingIndicator;
ContentView.Content = LoadingIndicator;
}
else
{
Content = NoDataStackLayout;
ContentView.Content = NoDataStackLayout;
}
});
}

View File

@@ -55,13 +55,13 @@ namespace Bit.App.Pages
public ActivityIndicator LoadingIndicator { get; set; }
private AddCipherToolBarItem AddCipherItem { get; set; }
private SearchToolBarItem SearchItem { get; set; }
public ContentView ContentView { get; set; }
public Fab Fab { get; set; }
private void Init()
{
SearchItem = new SearchToolBarItem(this);
AddCipherItem = new AddCipherToolBarItem(this, null);
ToolbarItems.Add(SearchItem);
ToolbarItems.Add(AddCipherItem);
ListView = new ListView(ListViewCachingStrategy.RecycleElement)
{
@@ -112,7 +112,23 @@ namespace Bit.App.Pages
LoadingIndicator.HorizontalOptions = LayoutOptions.Center;
}
Content = LoadingIndicator;
ContentView = new ContentView
{
Content = LoadingIndicator
};
var fabLayout = new FabLayout(ContentView);
if(Device.RuntimePlatform == Device.Android)
{
Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, null));
}
else
{
AddCipherItem = new AddCipherToolBarItem(this, null);
ToolbarItems.Add(AddCipherItem);
}
Content = fabLayout;
Title = AppResources.MyVault;
}
@@ -254,15 +270,15 @@ namespace Bit.App.Pages
if(ciphers.Any() || folders.Any())
{
Content = ListView;
ContentView.Content = ListView;
}
else if(_syncService.SyncInProgress)
{
Content = LoadingIndicator;
ContentView.Content = LoadingIndicator;
}
else
{
Content = NoDataStackLayout;
ContentView.Content = NoDataStackLayout;
}
});
}, cts.Token);

View File

@@ -34,6 +34,7 @@ namespace Bit.App.Pages
Init();
}
public Fab Fab { get; set; }
private VaultViewCipherPageModel Model { get; set; } = new VaultViewCipherPageModel();
private ExtendedTableView Table { get; set; }
private TableSection ItemInformationSection { get; set; }
@@ -71,16 +72,29 @@ namespace Bit.App.Pages
private void Init()
{
EditItem = new EditCipherToolBarItem(this, _cipherId);
ToolbarItems.Add(EditItem);
if(Device.RuntimePlatform == Device.iOS)
{
ToolbarItems.Add(new DismissModalToolBarItem(this));
}
InitProps();
var fabLayout = new FabLayout(Table);
if(Device.RuntimePlatform == Device.Android)
{
Fab = new Fab(fabLayout, "pencil.png", async (sender, args) =>
{
await Navigation.PushForDeviceAsync(new VaultEditCipherPage(_cipherId));
});
}
else
{
EditItem = new EditCipherToolBarItem(this, _cipherId);
ToolbarItems.Add(EditItem);
}
Content = fabLayout;
Title = AppResources.ViewItem;
Content = Table;
BindingContext = Model;
}
@@ -257,7 +271,7 @@ namespace Bit.App.Pages
{
_pageDisappeared = false;
NotesCell.Tapped += NotesCell_Tapped;
EditItem.InitEvents();
EditItem?.InitEvents();
var cipher = await _cipherService.GetByIdAsync(_cipherId);
if(cipher == null)
@@ -275,7 +289,7 @@ namespace Bit.App.Pages
{
_pageDisappeared = true;
NotesCell.Tapped -= NotesCell_Tapped;
EditItem.Dispose();
EditItem?.Dispose();
CleanupAttachmentCells();
}