1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-03 00:53:27 +00:00

Added icons for iOS. Broke out data access into repositories. Added syncing service.

This commit is contained in:
Kyle Spearrin
2016-05-06 00:17:38 -04:00
parent 24a5a16723
commit decd3fc24e
46 changed files with 773 additions and 150 deletions

View File

@@ -1,5 +1,4 @@
using System;
using Bit.App.Abstractions;
using Xamarin.Forms;
namespace Bit.App.Pages
@@ -8,18 +7,21 @@ namespace Bit.App.Pages
{
public MainPage()
{
var vaultNavigation = new NavigationPage(new VaultListPage());
vaultNavigation.BarBackgroundColor = Color.FromHex("3c8dbc");
vaultNavigation.BarTextColor = Color.FromHex("ffffff");
vaultNavigation.Title = "My Vault";
var settingsNavigation = new NavigationPage(new SettingsPage());
settingsNavigation.BarBackgroundColor = Color.FromHex("3c8dbc");
settingsNavigation.BarTextColor = Color.FromHex("ffffff");
var vaultNavigation = new NavigationPage(new VaultListPage());
var syncPage = new SyncPage();
vaultNavigation.BarBackgroundColor = settingsNavigation.BarBackgroundColor = Color.FromHex("3c8dbc");
vaultNavigation.BarTextColor = settingsNavigation.BarTextColor = Color.FromHex("ffffff");
vaultNavigation.Title = "My Vault";
vaultNavigation.Icon = "fa-lock";
settingsNavigation.Title = "Settings";
settingsNavigation.Icon = "fa-cogs";
Children.Add(vaultNavigation);
Children.Add(new SyncPage());
Children.Add(syncPage);
Children.Add(settingsNavigation);
}
}

View File

@@ -1,14 +1,54 @@
using System;
using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Abstractions;
using Xamarin.Forms;
using XLabs.Ioc;
namespace Bit.App.Pages
{
public class SyncPage : ContentPage
{
private readonly ISyncService _syncService;
private readonly IUserDialogs _userDialogs;
public SyncPage()
{
_syncService = Resolver.Resolve<ISyncService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
Init();
}
public void Init()
{
var syncButton = new Button
{
Text = "Sync Vault",
Command = new Command(async () => await SyncAsync())
};
var stackLayout = new StackLayout { };
stackLayout.Children.Add(syncButton);
Title = "Sync";
Content = null;
Content = stackLayout;
Icon = "fa-refresh";
}
public async Task SyncAsync()
{
_userDialogs.ShowLoading("Syncing...", MaskType.Black);
var succeeded = await _syncService.SyncAsync();
_userDialogs.HideLoading();
if(succeeded)
{
_userDialogs.SuccessToast("Syncing complete.");
}
else
{
_userDialogs.ErrorToast("Syncing failed.");
}
}
}
}

View File

@@ -31,21 +31,14 @@ namespace Bit.App.Pages
{
ToolbarItems.Add(new AddSiteToolBarItem(this));
var moreAction = new MenuItem { Text = "More" };
moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
moreAction.Clicked += MoreClickedAsync;
var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true };
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
deleteAction.Clicked += DeleteClickedAsync;
var listView = new ListView { IsGroupingEnabled = true, ItemsSource = Folders };
listView.GroupDisplayBinding = new Binding("Name");
listView.ItemSelected += SiteSelected;
listView.ItemTemplate = new DataTemplate(() => new VaultListViewCell(moreAction, deleteAction));
listView.ItemTemplate = new DataTemplate(() => new VaultListViewCell(this));
Title = "My Vault";
Content = listView;
NavigationPage.SetBackButtonTitle(this, string.Empty);
}
protected override void OnAppearing()
@@ -122,7 +115,7 @@ namespace Bit.App.Pages
{
_page = page;
Text = "Add";
Icon = "";
Icon = "fa-plus";
Clicked += ClickedItem;
}
@@ -144,12 +137,20 @@ namespace Bit.App.Pages
private class VaultListViewCell : TextCell
{
public VaultListViewCell(MenuItem moreMenuItem, MenuItem deleteMenuItem)
public VaultListViewCell(VaultListPage page)
{
var moreAction = new MenuItem { Text = "More" };
moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
moreAction.Clicked += page.MoreClickedAsync;
var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true };
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
deleteAction.Clicked += page.DeleteClickedAsync;
this.SetBinding<VaultView.Site>(TextProperty, s => s.Name);
this.SetBinding<VaultView.Site>(DetailProperty, s => s.Username);
ContextActions.Add(moreMenuItem);
ContextActions.Add(deleteMenuItem);
ContextActions.Add(moreAction);
ContextActions.Add(deleteAction);
}
}
}