1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-23 11:45:38 +01:00

material icons. stub out ciphers search page

This commit is contained in:
Kyle Spearrin 2019-05-02 21:25:26 -04:00
parent 59e412ea09
commit 2553938380
17 changed files with 239 additions and 39 deletions

View File

@ -99,6 +99,7 @@
<ItemGroup>
<AndroidAsset Include="Assets\FontAwesome.ttf" />
<AndroidAsset Include="Assets\RobotoMono_Regular.ttf" />
<AndroidAsset Include="Assets\MaterialIcons_Regular.ttf" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
<ItemGroup>

Binary file not shown.

View File

@ -37,6 +37,9 @@
<Compile Update="Pages\Generator\GeneratorPage.xaml.cs">
<DependentUpon>GeneratorPage.xaml</DependentUpon>
</Compile>
<Compile Update="Pages\Vault\CiphersPage.xaml.cs">
<DependentUpon>CiphersPage.xaml</DependentUpon>
</Compile>
<Compile Update="Pages\Vault\PasswordHistoryPage.xaml.cs">
<DependentUpon>PasswordHistoryPage.xaml</DependentUpon>
</Compile>

View File

@ -58,25 +58,28 @@
StyleClass="list-subtitle, list-subtitle-platform"
Text="{Binding Cipher.SubTitle, Mode=OneWay}" />
<controls:FaLabel Grid.Column="2"
Grid.Row="0"
HorizontalOptions="Start"
VerticalOptions="Center"
StyleClass="list-title-icon"
Margin="5, 0, 0, 0"
Text="&#xf1e0;"
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
<controls:FaLabel Grid.Column="3"
Grid.Row="0"
HorizontalOptions="Start"
VerticalOptions="Center"
StyleClass="list-title-icon"
Margin="5, 0, 0, 0"
Text="&#xf0c6;"
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
<ImageButton
Source="more.png"
StyleClass="list-button, list-button-platform"
<controls:FaLabel
Grid.Column="2"
Grid.Row="0"
HorizontalOptions="Start"
VerticalOptions="Center"
StyleClass="list-title-icon"
Margin="5, 0, 0, 0"
Text="&#xf1e0;"
IsVisible="{Binding Cipher.Shared, Mode=OneWay}" />
<controls:FaLabel
Grid.Column="3"
Grid.Row="0"
HorizontalOptions="Start"
VerticalOptions="Center"
StyleClass="list-title-icon"
Margin="5, 0, 0, 0"
Text="&#xf0c6;"
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
<controls:MiButton
Text="&#xe5d4;"
StyleClass="list-row-button, list-row-button-platform, btn-disabled"
Clicked="ImageButton_Clicked"
Grid.Column="4"
Grid.Row="0"

View File

@ -49,14 +49,23 @@ namespace Bit.App.Controls
{
string icon = null;
string image = 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:
var loginIconImage = GetLoginIconImage(groupingsPageListItem.Cipher);
var loginIconImage = GetLoginIconImage(cipher);
icon = loginIconImage.Item1;
image = loginIconImage.Item2;
break;

View 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;
}
}
}
}

View 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;
}
}
}
}

View 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>

View 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();
});
}
}
}

View 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
}
}
}

View File

@ -13,6 +13,10 @@
<pages:GroupingsPageViewModel />
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<ToolbarItem Text="&#xf002;" Clicked="Search_Clicked" />
</ContentPage.ToolbarItems>
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="cipherTemplate"
@ -53,7 +57,7 @@
<StackLayout VerticalOptions="CenterAndExpand"
Padding="20, 0"
Spacing="20"
IsVisible="{Binding ShowNoData}">
IsVisible="{Binding ShowNoData}">
<Label Text="{Binding NoDataText}"
HorizontalTextAlignment="Center"></Label>
<Button Text="{u:I18n AddAnItem}"

View File

@ -95,5 +95,10 @@ namespace Bit.App.Pages
await _viewModel.SelectTypeAsync(item.Type.Value);
}
}
private async void Search_Clicked(object sender, System.EventArgs e)
{
await Navigation.PushModalAsync(new CiphersPage(), false);
}
}
}

View File

@ -41,9 +41,6 @@
<Style TargetType="Grid"
Class="list-row-platform">
</Style>
<Style TargetType="ImageButton"
Class="list-button-platform">
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
Class="list-row-button-platform">

View File

@ -62,6 +62,12 @@
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
</Style>
<Style TargetType="Button"
Class="btn-disabled"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource DisabledIconColor}" />
</Style>
<!-- List -->
@ -150,18 +156,6 @@
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
</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"
ApplyToDerivedTypes="True"
Class="list-row-button">

View File

@ -39,6 +39,7 @@
<key>UIAppFonts</key>
<array>
<string>FontAwesome.ttf</string>
<string>MaterialIcons_Regular.ttf</string>
</array>
</dict>
</plist>

Binary file not shown.

View File

@ -97,6 +97,7 @@
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
<BundleResource Include="Resources\FontAwesome.ttf" />
<BundleResource Include="Resources\MaterialIcons_Regular.ttf" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />