mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
fab padding and clicked action
This commit is contained in:
parent
2a5739dfdc
commit
0495c17fc8
7 changed files with 98 additions and 8 deletions
|
@ -82,6 +82,7 @@
|
|||
<Compile Include="Renderers\CustomPickerBarRenderer.cs" />
|
||||
<Compile Include="Renderers\CustomEntryBarRenderer.cs" />
|
||||
<Compile Include="Renderers\CustomSearchBarRenderer.cs" />
|
||||
<Compile Include="Renderers\ExtendedListViewRenderer.cs" />
|
||||
<Compile Include="SplashActivity.cs" />
|
||||
<Compile Include="Renderers\BoxedView\BoxedViewRecyclerAdapter.cs" />
|
||||
<Compile Include="Renderers\BoxedView\BoxedViewRenderer.cs" />
|
||||
|
|
29
src/Android/Renderers/ExtendedListViewRenderer.cs
Normal file
29
src/Android/Renderers/ExtendedListViewRenderer.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using Android.Content;
|
||||
using Android.Views;
|
||||
using Bit.App.Controls;
|
||||
using Bit.Droid.Renderers;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ExportRenderer(typeof(ExtendedListView), typeof(ExtendedListViewRenderer))]
|
||||
namespace Bit.Droid.Renderers
|
||||
{
|
||||
public class ExtendedListViewRenderer : ListViewRenderer
|
||||
{
|
||||
public ExtendedListViewRenderer(Context context)
|
||||
: base(context)
|
||||
{ }
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
if(Control != null && e.NewElement != null && e.NewElement is ExtendedListView listView)
|
||||
{
|
||||
// Pad for FAB
|
||||
Control.SetPadding(0, 0, 0, 170);
|
||||
Control.SetClipToPadding(false);
|
||||
Control.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
src/App/Controls/ExtendedListView.cs
Normal file
12
src/App/Controls/ExtendedListView.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class ExtendedListView : ListView
|
||||
{
|
||||
public ExtendedListView() { }
|
||||
|
||||
public ExtendedListView(ListViewCachingStrategy cachingStrategy)
|
||||
: base(cachingStrategy) { }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using Xamarin.Forms;
|
||||
using Bit.Core.Enums;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
|
@ -8,6 +9,7 @@ namespace Bit.App.Pages
|
|||
|
||||
public AddEditPage(
|
||||
string cipherId = null,
|
||||
CipherType? type = null,
|
||||
string folderId = null,
|
||||
string collectionId = null,
|
||||
string organizationId = null)
|
||||
|
@ -18,6 +20,7 @@ namespace Bit.App.Pages
|
|||
_vm.CipherId = cipherId;
|
||||
_vm.FolderId = folderId;
|
||||
_vm.OrganizationId = organizationId;
|
||||
_vm.Type = type;
|
||||
_vm.Init();
|
||||
SetActivityIndicator();
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
<pages:GroupingsPageListItemSelector x:Key="listItemDataTemplateSelector"
|
||||
CipherTemplate="{StaticResource cipherTemplate}"
|
||||
GroupTemplate="{StaticResource groupTemplate}" />
|
||||
|
@ -68,7 +68,7 @@
|
|||
IsVisible="{Binding ShowAddCipherButton}"></Button>
|
||||
</StackLayout>
|
||||
|
||||
<ListView
|
||||
<controls:ExtendedListView
|
||||
IsVisible="{Binding ShowList}"
|
||||
ItemsSource="{Binding GroupedItems}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
|
@ -76,11 +76,14 @@
|
|||
RefreshCommand="{Binding RefreshCommand}"
|
||||
IsPullToRefreshEnabled="true"
|
||||
IsRefreshing="{Binding Refreshing}"
|
||||
CachingStrategy="RecycleElement"
|
||||
ItemTemplate="{StaticResource listItemDataTemplateSelector}"
|
||||
IsGroupingEnabled="True"
|
||||
ItemSelected="RowSelected"
|
||||
StyleClass="list, list-platform">
|
||||
<x:Arguments>
|
||||
<ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
|
||||
</x:Arguments>
|
||||
|
||||
<ListView.GroupHeaderTemplate>
|
||||
<DataTemplate x:DataType="pages:GroupingsPageListGroup">
|
||||
<ViewCell>
|
||||
|
@ -95,7 +98,7 @@
|
|||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.GroupHeaderTemplate>
|
||||
</ListView>
|
||||
</controls:ExtendedListView>
|
||||
</StackLayout>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bit.Core.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -38,6 +39,10 @@ namespace Bit.App.Pages
|
|||
{
|
||||
_absLayout.Children.Remove(_fab);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fab.Clicked = AddButton_Clicked;
|
||||
}
|
||||
}
|
||||
|
||||
protected async override void OnAppearing()
|
||||
|
@ -116,5 +121,41 @@ namespace Bit.App.Pages
|
|||
await Navigation.PushModalAsync(new NavigationPage(page), false);
|
||||
}
|
||||
}
|
||||
|
||||
private async void AddButton_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
var type = await DisplayActionSheet(AppResources.SelectTypeAdd, AppResources.Cancel, null,
|
||||
AppResources.TypeLogin, AppResources.TypeCard, AppResources.TypeIdentity,
|
||||
AppResources.TypeSecureNote);
|
||||
|
||||
var selectedType = CipherType.SecureNote;
|
||||
if(type == null || type == AppResources.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(type == AppResources.TypeLogin)
|
||||
{
|
||||
selectedType = CipherType.Login;
|
||||
}
|
||||
else if(type == AppResources.TypeCard)
|
||||
{
|
||||
selectedType = CipherType.Card;
|
||||
}
|
||||
else if(type == AppResources.TypeIdentity)
|
||||
{
|
||||
selectedType = CipherType.Identity;
|
||||
}
|
||||
else if(type == AppResources.TypeSecureNote)
|
||||
{
|
||||
selectedType = CipherType.SecureNote;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var page = new AddEditPage(null, selectedType);
|
||||
await Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,10 @@
|
|||
</Style>
|
||||
|
||||
<!-- List -->
|
||||
|
||||
|
||||
<Style TargetType="ListView"
|
||||
Class="list-platform">
|
||||
Class="list-platform"
|
||||
ApplyToDerivedTypes="True">
|
||||
<Setter Property="SeparatorColor"
|
||||
Value="Transparent" />
|
||||
</Style>
|
||||
|
|
Loading…
Reference in a new issue