mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-23 11:45:38 +01:00
floating action button on android
This commit is contained in:
parent
2235f1f7af
commit
fbe1a6d4c5
@ -868,5 +868,20 @@
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\bottom_nav_bg.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-hdpi\pencil.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable\pencil.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-xhdpi\pencil.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-xxhdpi\pencil.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\drawable-xxxhdpi\pencil.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
@ -101,6 +101,7 @@ namespace Bit.Android
|
||||
|
||||
public static void SetIoc(Application application)
|
||||
{
|
||||
Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init();
|
||||
CachedImageRenderer.Init();
|
||||
ZXing.Net.Mobile.Forms.Android.Platform.Init();
|
||||
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
|
||||
|
2840
src/Android/Resources/Resource.Designer.cs
generated
2840
src/Android/Resources/Resource.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
BIN
src/Android/Resources/drawable-hdpi/pencil.png
Normal file
BIN
src/Android/Resources/drawable-hdpi/pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 495 B |
BIN
src/Android/Resources/drawable-xhdpi/pencil.png
Normal file
BIN
src/Android/Resources/drawable-xhdpi/pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 359 B |
BIN
src/Android/Resources/drawable-xxhdpi/pencil.png
Normal file
BIN
src/Android/Resources/drawable-xxhdpi/pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 571 B |
BIN
src/Android/Resources/drawable-xxxhdpi/pencil.png
Normal file
BIN
src/Android/Resources/drawable-xxxhdpi/pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 681 B |
BIN
src/Android/Resources/drawable/pencil.png
Normal file
BIN
src/Android/Resources/drawable/pencil.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 339 B |
@ -20,6 +20,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||
<PackageReference Include="PCLCrypto" Version="2.0.147" />
|
||||
<PackageReference Include="Plugin.Fingerprint" Version="1.4.6-beta4" />
|
||||
<PackageReference Include="Refractored.FloatingActionButtonForms" Version="2.1.0" />
|
||||
<PackageReference Include="sqlite-net-pcl" Version="1.5.166-beta" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.3" />
|
||||
<PackageReference Include="Xam.Plugin.Connectivity" Version="3.0.3" />
|
||||
|
24
src/App/Controls/Fab.cs
Normal file
24
src/App/Controls/Fab.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Refractored.FabControl;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class Fab : FloatingActionButtonView
|
||||
{
|
||||
public Fab(FabLayout fabLayout, string icon, Action<object, EventArgs> clickedAction)
|
||||
{
|
||||
ImageName = icon;
|
||||
ColorNormal = Color.FromHex("3c8dbc");
|
||||
ColorPressed = Color.FromHex("3883af");
|
||||
ColorRipple = Color.FromHex("3883af");
|
||||
Clicked = clickedAction;
|
||||
|
||||
AbsoluteLayout.SetLayoutFlags(this, AbsoluteLayoutFlags.PositionProportional);
|
||||
AbsoluteLayout.SetLayoutBounds(this, new Rectangle(1, 1, AbsoluteLayout.AutoSize,
|
||||
AbsoluteLayout.AutoSize));
|
||||
|
||||
fabLayout.Children.Add(this);
|
||||
}
|
||||
}
|
||||
}
|
16
src/App/Controls/FabLayout.cs
Normal file
16
src/App/Controls/FabLayout.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class FabLayout : AbsoluteLayout
|
||||
{
|
||||
public FabLayout(View mainView)
|
||||
{
|
||||
VerticalOptions = LayoutOptions.FillAndExpand;
|
||||
HorizontalOptions = LayoutOptions.FillAndExpand;
|
||||
SetLayoutFlags(mainView, AbsoluteLayoutFlags.All);
|
||||
SetLayoutBounds(mainView, new Rectangle(0, 0, 1, 1));
|
||||
Children.Add(mainView);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,12 +25,10 @@ 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,
|
||||
@ -42,15 +40,29 @@ namespace Bit.App.Pages
|
||||
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()
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user