mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
material icons. stub out ciphers search page
This commit is contained in:
parent
59e412ea09
commit
2553938380
17 changed files with 239 additions and 39 deletions
|
@ -99,6 +99,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AndroidAsset Include="Assets\FontAwesome.ttf" />
|
<AndroidAsset Include="Assets\FontAwesome.ttf" />
|
||||||
<AndroidAsset Include="Assets\RobotoMono_Regular.ttf" />
|
<AndroidAsset Include="Assets\RobotoMono_Regular.ttf" />
|
||||||
|
<AndroidAsset Include="Assets\MaterialIcons_Regular.ttf" />
|
||||||
<None Include="Properties\AndroidManifest.xml" />
|
<None Include="Properties\AndroidManifest.xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
BIN
src/Android/Assets/MaterialIcons_Regular.ttf
Normal file
BIN
src/Android/Assets/MaterialIcons_Regular.ttf
Normal file
Binary file not shown.
|
@ -37,6 +37,9 @@
|
||||||
<Compile Update="Pages\Generator\GeneratorPage.xaml.cs">
|
<Compile Update="Pages\Generator\GeneratorPage.xaml.cs">
|
||||||
<DependentUpon>GeneratorPage.xaml</DependentUpon>
|
<DependentUpon>GeneratorPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Pages\Vault\CiphersPage.xaml.cs">
|
||||||
|
<DependentUpon>CiphersPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Pages\Vault\PasswordHistoryPage.xaml.cs">
|
<Compile Update="Pages\Vault\PasswordHistoryPage.xaml.cs">
|
||||||
<DependentUpon>PasswordHistoryPage.xaml</DependentUpon>
|
<DependentUpon>PasswordHistoryPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -58,25 +58,28 @@
|
||||||
StyleClass="list-subtitle, list-subtitle-platform"
|
StyleClass="list-subtitle, list-subtitle-platform"
|
||||||
Text="{Binding Cipher.SubTitle, Mode=OneWay}" />
|
Text="{Binding Cipher.SubTitle, Mode=OneWay}" />
|
||||||
|
|
||||||
<controls:FaLabel Grid.Column="2"
|
<controls:FaLabel
|
||||||
Grid.Row="0"
|
Grid.Column="2"
|
||||||
HorizontalOptions="Start"
|
Grid.Row="0"
|
||||||
VerticalOptions="Center"
|
HorizontalOptions="Start"
|
||||||
StyleClass="list-title-icon"
|
VerticalOptions="Center"
|
||||||
Margin="5, 0, 0, 0"
|
StyleClass="list-title-icon"
|
||||||
Text=""
|
Margin="5, 0, 0, 0"
|
||||||
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
|
Text=""
|
||||||
<controls:FaLabel Grid.Column="3"
|
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
|
||||||
Grid.Row="0"
|
<controls:FaLabel
|
||||||
HorizontalOptions="Start"
|
Grid.Column="3"
|
||||||
VerticalOptions="Center"
|
Grid.Row="0"
|
||||||
StyleClass="list-title-icon"
|
HorizontalOptions="Start"
|
||||||
Margin="5, 0, 0, 0"
|
VerticalOptions="Center"
|
||||||
Text=""
|
StyleClass="list-title-icon"
|
||||||
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
|
Margin="5, 0, 0, 0"
|
||||||
<ImageButton
|
Text=""
|
||||||
Source="more.png"
|
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
|
||||||
StyleClass="list-button, list-button-platform"
|
|
||||||
|
<controls:MiButton
|
||||||
|
Text=""
|
||||||
|
StyleClass="list-row-button, list-row-button-platform, btn-disabled"
|
||||||
Clicked="ImageButton_Clicked"
|
Clicked="ImageButton_Clicked"
|
||||||
Grid.Column="4"
|
Grid.Column="4"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
|
|
@ -49,14 +49,23 @@ namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
string icon = null;
|
string icon = null;
|
||||||
string image = null;
|
string image = null;
|
||||||
|
|
||||||
_image.Source = null;
|
_image.Source = null;
|
||||||
if(BindingContext is GroupingsPageListItem groupingsPageListItem && groupingsPageListItem.Cipher != null)
|
|
||||||
|
CipherView cipher = null;
|
||||||
|
if(BindingContext is GroupingsPageListItem groupingsPageListItem)
|
||||||
{
|
{
|
||||||
switch(groupingsPageListItem.Cipher.Type)
|
cipher = groupingsPageListItem.Cipher;
|
||||||
|
}
|
||||||
|
else if(BindingContext is CipherView cv)
|
||||||
|
{
|
||||||
|
cipher = cv;
|
||||||
|
}
|
||||||
|
if(cipher != null)
|
||||||
|
{
|
||||||
|
switch(cipher.Type)
|
||||||
{
|
{
|
||||||
case CipherType.Login:
|
case CipherType.Login:
|
||||||
var loginIconImage = GetLoginIconImage(groupingsPageListItem.Cipher);
|
var loginIconImage = GetLoginIconImage(cipher);
|
||||||
icon = loginIconImage.Item1;
|
icon = loginIconImage.Item1;
|
||||||
image = loginIconImage.Item2;
|
image = loginIconImage.Item2;
|
||||||
break;
|
break;
|
||||||
|
|
21
src/App/Controls/MiButton.cs
Normal file
21
src/App/Controls/MiButton.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public class MiButton : Button
|
||||||
|
{
|
||||||
|
public MiButton()
|
||||||
|
{
|
||||||
|
Padding = 0;
|
||||||
|
switch(Device.RuntimePlatform)
|
||||||
|
{
|
||||||
|
case Device.iOS:
|
||||||
|
FontFamily = "Material Icons";
|
||||||
|
break;
|
||||||
|
case Device.Android:
|
||||||
|
FontFamily = "MaterialIcons_Regular.ttf#Material Icons";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
src/App/Controls/MiLabel.cs
Normal file
20
src/App/Controls/MiLabel.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public class MiLabel : Label
|
||||||
|
{
|
||||||
|
public MiLabel()
|
||||||
|
{
|
||||||
|
switch(Device.RuntimePlatform)
|
||||||
|
{
|
||||||
|
case Device.iOS:
|
||||||
|
FontFamily = "Material Icons";
|
||||||
|
break;
|
||||||
|
case Device.Android:
|
||||||
|
FontFamily = "MaterialIcons_Regular.ttf#Material Icons";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/App/Pages/Vault/CiphersPage.xaml
Normal file
49
src/App/Pages/Vault/CiphersPage.xaml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<pages:BaseContentPage
|
||||||
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Bit.App.Pages.CiphersPage"
|
||||||
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
|
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
||||||
|
x:DataType="pages:CiphersPageViewModel"
|
||||||
|
x:Name="_page"
|
||||||
|
Title="{Binding PageTitle}">
|
||||||
|
|
||||||
|
<ContentPage.BindingContext>
|
||||||
|
<pages:CiphersPageViewModel />
|
||||||
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||||
|
<u:DateTimeConverter x:Key="dateTime" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
|
<StackLayout x:Name="_mainLayout">
|
||||||
|
<Label IsVisible="{Binding ShowNoData}"
|
||||||
|
Text="{Binding NoDataText}"
|
||||||
|
Margin="20, 0"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
HorizontalTextAlignment="Center"></Label>
|
||||||
|
<ListView x:Name="_listView"
|
||||||
|
IsVisible="{Binding ShowNoData, Converter={StaticResource inverseBool}}"
|
||||||
|
ItemsSource="{Binding Ciphers}"
|
||||||
|
VerticalOptions="FillAndExpand"
|
||||||
|
HasUnevenRows="true"
|
||||||
|
CachingStrategy="RecycleElement"
|
||||||
|
StyleClass="list, list-platform">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="views:CipherView">
|
||||||
|
<controls:CipherViewCell
|
||||||
|
Cipher="{Binding .}"
|
||||||
|
ButtonCommand="{Binding BindingContext.CipherOptionsCommand, Source={x:Reference _page}}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
|
||||||
|
</pages:BaseContentPage>
|
25
src/App/Pages/Vault/CiphersPage.xaml.cs
Normal file
25
src/App/Pages/Vault/CiphersPage.xaml.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public partial class CiphersPage : BaseContentPage
|
||||||
|
{
|
||||||
|
private CiphersPageViewModel _vm;
|
||||||
|
|
||||||
|
public CiphersPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
SetActivityIndicator();
|
||||||
|
_vm = BindingContext as CiphersPageViewModel;
|
||||||
|
_vm.Page = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
await LoadOnAppearedAsync(_mainLayout, true, async () => {
|
||||||
|
await _vm.LoadAsync();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
67
src/App/Pages/Vault/CiphersPageViewModel.cs
Normal file
67
src/App/Pages/Vault/CiphersPageViewModel.cs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
using Bit.App.Resources;
|
||||||
|
using Bit.Core.Abstractions;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Pages
|
||||||
|
{
|
||||||
|
public class CiphersPageViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
|
private readonly ICipherService _cipherService;
|
||||||
|
|
||||||
|
private string _searchText;
|
||||||
|
private string _noDataText;
|
||||||
|
private bool _showNoData;
|
||||||
|
|
||||||
|
public CiphersPageViewModel()
|
||||||
|
{
|
||||||
|
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||||
|
_cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||||
|
|
||||||
|
PageTitle = AppResources.SearchVault;
|
||||||
|
Ciphers = new ExtendedObservableCollection<CipherView>();
|
||||||
|
CipherOptionsCommand = new Command<CipherView>(CipherOptionsAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Command CipherOptionsCommand { get; set; }
|
||||||
|
public ExtendedObservableCollection<CipherView> Ciphers { get; set; }
|
||||||
|
|
||||||
|
public string SearchText
|
||||||
|
{
|
||||||
|
get => _searchText;
|
||||||
|
set => SetProperty(ref _searchText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NoDataText
|
||||||
|
{
|
||||||
|
get => _noDataText;
|
||||||
|
set => SetProperty(ref _noDataText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowNoData
|
||||||
|
{
|
||||||
|
get => _showNoData;
|
||||||
|
set => SetProperty(ref _showNoData, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadAsync()
|
||||||
|
{
|
||||||
|
var ciphers = await _cipherService.GetAllDecryptedAsync();
|
||||||
|
Ciphers.ResetWithRange(ciphers);
|
||||||
|
ShowNoData = Ciphers.Count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CipherOptionsAsync(CipherView cipher)
|
||||||
|
{
|
||||||
|
var option = await Page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, "1", "2");
|
||||||
|
if(option == AppResources.Cancel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: process options
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,10 @@
|
||||||
<pages:GroupingsPageViewModel />
|
<pages:GroupingsPageViewModel />
|
||||||
</ContentPage.BindingContext>
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<ToolbarItem Text="" Clicked="Search_Clicked" />
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<DataTemplate x:Key="cipherTemplate"
|
<DataTemplate x:Key="cipherTemplate"
|
||||||
|
@ -53,7 +57,7 @@
|
||||||
<StackLayout VerticalOptions="CenterAndExpand"
|
<StackLayout VerticalOptions="CenterAndExpand"
|
||||||
Padding="20, 0"
|
Padding="20, 0"
|
||||||
Spacing="20"
|
Spacing="20"
|
||||||
IsVisible="{Binding ShowNoData}">
|
IsVisible="{Binding ShowNoData}">
|
||||||
<Label Text="{Binding NoDataText}"
|
<Label Text="{Binding NoDataText}"
|
||||||
HorizontalTextAlignment="Center"></Label>
|
HorizontalTextAlignment="Center"></Label>
|
||||||
<Button Text="{u:I18n AddAnItem}"
|
<Button Text="{u:I18n AddAnItem}"
|
||||||
|
|
|
@ -95,5 +95,10 @@ namespace Bit.App.Pages
|
||||||
await _viewModel.SelectTypeAsync(item.Type.Value);
|
await _viewModel.SelectTypeAsync(item.Type.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void Search_Clicked(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
await Navigation.PushModalAsync(new CiphersPage(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,6 @@
|
||||||
<Style TargetType="Grid"
|
<Style TargetType="Grid"
|
||||||
Class="list-row-platform">
|
Class="list-row-platform">
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="ImageButton"
|
|
||||||
Class="list-button-platform">
|
|
||||||
</Style>
|
|
||||||
<Style TargetType="Button"
|
<Style TargetType="Button"
|
||||||
ApplyToDerivedTypes="True"
|
ApplyToDerivedTypes="True"
|
||||||
Class="list-row-button-platform">
|
Class="list-row-button-platform">
|
||||||
|
|
|
@ -62,6 +62,12 @@
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource MutedColor}" />
|
Value="{StaticResource MutedColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style TargetType="Button"
|
||||||
|
Class="btn-disabled"
|
||||||
|
ApplyToDerivedTypes="True">
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource DisabledIconColor}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
<!-- List -->
|
<!-- List -->
|
||||||
|
@ -150,18 +156,6 @@
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource MutedColor}" />
|
Value="{StaticResource MutedColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="ImageButton"
|
|
||||||
ApplyToDerivedTypes="True"
|
|
||||||
Class="list-button">
|
|
||||||
<Setter Property="BackgroundColor"
|
|
||||||
Value="Transparent" />
|
|
||||||
<Setter Property="Padding"
|
|
||||||
Value="0" />
|
|
||||||
<Setter Property="HorizontalOptions"
|
|
||||||
Value="End" />
|
|
||||||
<Setter Property="VerticalOptions"
|
|
||||||
Value="CenterAndExpand" />
|
|
||||||
</Style>
|
|
||||||
<Style TargetType="Button"
|
<Style TargetType="Button"
|
||||||
ApplyToDerivedTypes="True"
|
ApplyToDerivedTypes="True"
|
||||||
Class="list-row-button">
|
Class="list-row-button">
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<key>UIAppFonts</key>
|
<key>UIAppFonts</key>
|
||||||
<array>
|
<array>
|
||||||
<string>FontAwesome.ttf</string>
|
<string>FontAwesome.ttf</string>
|
||||||
|
<string>MaterialIcons_Regular.ttf</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
BIN
src/iOS/Resources/MaterialIcons_Regular.ttf
Normal file
BIN
src/iOS/Resources/MaterialIcons_Regular.ttf
Normal file
Binary file not shown.
|
@ -97,6 +97,7 @@
|
||||||
<None Include="Info.plist" />
|
<None Include="Info.plist" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<BundleResource Include="Resources\FontAwesome.ttf" />
|
<BundleResource Include="Resources\FontAwesome.ttf" />
|
||||||
|
<BundleResource Include="Resources\MaterialIcons_Regular.ttf" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
|
||||||
|
|
Loading…
Reference in a new issue