mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-22 11:35:21 +01:00
Added stepper cell to password generator settings page. Conditionally show sync indicator on pages.
This commit is contained in:
parent
f2893e788d
commit
822a14e56c
@ -55,6 +55,7 @@
|
|||||||
<Compile Include="Controls\ExtendedEditor.cs" />
|
<Compile Include="Controls\ExtendedEditor.cs" />
|
||||||
<Compile Include="Controls\ExtendedNavigationPage.cs" />
|
<Compile Include="Controls\ExtendedNavigationPage.cs" />
|
||||||
<Compile Include="Controls\ExtendedContentPage.cs" />
|
<Compile Include="Controls\ExtendedContentPage.cs" />
|
||||||
|
<Compile Include="Controls\StepperCell.cs" />
|
||||||
<Compile Include="Controls\ExtendedTableView.cs" />
|
<Compile Include="Controls\ExtendedTableView.cs" />
|
||||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||||
|
@ -9,22 +9,26 @@ namespace Bit.App.Controls
|
|||||||
{
|
{
|
||||||
private ISyncService _syncService;
|
private ISyncService _syncService;
|
||||||
|
|
||||||
public ExtendedContentPage()
|
public ExtendedContentPage(bool syncIndicator = true)
|
||||||
{
|
{
|
||||||
_syncService = Resolver.Resolve<ISyncService>();
|
_syncService = Resolver.Resolve<ISyncService>();
|
||||||
|
|
||||||
BackgroundColor = Color.FromHex("efeff4");
|
BackgroundColor = Color.FromHex("efeff4");
|
||||||
IsBusy = _syncService.SyncInProgress;
|
|
||||||
|
|
||||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
if(syncIndicator)
|
||||||
{
|
{
|
||||||
IsBusy = _syncService.SyncInProgress;
|
IsBusy = _syncService.SyncInProgress;
|
||||||
});
|
|
||||||
|
|
||||||
MessagingCenter.Subscribe<Application>(Application.Current, "SyncStarted", (sender) =>
|
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||||
{
|
{
|
||||||
IsBusy = _syncService.SyncInProgress;
|
IsBusy = _syncService.SyncInProgress;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MessagingCenter.Subscribe<Application>(Application.Current, "SyncStarted", (sender) =>
|
||||||
|
{
|
||||||
|
IsBusy = _syncService.SyncInProgress;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
src/App/Controls/StepperCell.cs
Normal file
57
src/App/Controls/StepperCell.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public class StepperCell : ExtendedViewCell
|
||||||
|
{
|
||||||
|
public StepperCell(string labelText, double value, double min, double max, double increment)
|
||||||
|
{
|
||||||
|
Label = new Label
|
||||||
|
{
|
||||||
|
Text = labelText,
|
||||||
|
HorizontalOptions = LayoutOptions.Start,
|
||||||
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
||||||
|
};
|
||||||
|
|
||||||
|
StepperValueLabel = new Label
|
||||||
|
{
|
||||||
|
HorizontalOptions = LayoutOptions.FillAndExpand,
|
||||||
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
|
HorizontalTextAlignment = TextAlignment.Start,
|
||||||
|
Text = value.ToString(),
|
||||||
|
Style = (Style)Application.Current.Resources["text-muted"]
|
||||||
|
};
|
||||||
|
|
||||||
|
Stepper = new Stepper
|
||||||
|
{
|
||||||
|
HorizontalOptions = LayoutOptions.End,
|
||||||
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
|
Minimum = min,
|
||||||
|
Maximum = max,
|
||||||
|
Increment = increment,
|
||||||
|
Value = value
|
||||||
|
};
|
||||||
|
|
||||||
|
Stepper.ValueChanged += Stepper_ValueChanged;
|
||||||
|
|
||||||
|
var stackLayout = new StackLayout
|
||||||
|
{
|
||||||
|
Orientation = StackOrientation.Horizontal,
|
||||||
|
Children = { Label, StepperValueLabel, Stepper },
|
||||||
|
Spacing = 15,
|
||||||
|
Padding = new Thickness(15, 8)
|
||||||
|
};
|
||||||
|
|
||||||
|
View = stackLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Stepper_ValueChanged(object sender, ValueChangedEventArgs e)
|
||||||
|
{
|
||||||
|
StepperValueLabel.Text = e.NewValue.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Label Label { get; private set; }
|
||||||
|
public Label StepperValueLabel { get; private set; }
|
||||||
|
public Stepper Stepper { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@ namespace Bit.App.Pages
|
|||||||
private readonly bool _checkFingerprintImmediately;
|
private readonly bool _checkFingerprintImmediately;
|
||||||
|
|
||||||
public LockFingerprintPage(bool checkFingerprintImmediately)
|
public LockFingerprintPage(bool checkFingerprintImmediately)
|
||||||
|
: base(false)
|
||||||
{
|
{
|
||||||
_checkFingerprintImmediately = checkFingerprintImmediately;
|
_checkFingerprintImmediately = checkFingerprintImmediately;
|
||||||
_fingerprint = Resolver.Resolve<IFingerprint>();
|
_fingerprint = Resolver.Resolve<IFingerprint>();
|
||||||
|
@ -18,6 +18,7 @@ namespace Bit.App.Pages
|
|||||||
private readonly ISettings _settings;
|
private readonly ISettings _settings;
|
||||||
|
|
||||||
public LockPinPage()
|
public LockPinPage()
|
||||||
|
: base(false)
|
||||||
{
|
{
|
||||||
_authService = Resolver.Resolve<IAuthService>();
|
_authService = Resolver.Resolve<IAuthService>();
|
||||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||||
|
@ -153,6 +153,7 @@ namespace Bit.App.Pages
|
|||||||
_userDialogs.SuccessToast(string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
|
_userDialogs.SuccessToast(string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to standalone reusable control
|
||||||
public class SliderViewCell : ExtendedViewCell
|
public class SliderViewCell : ExtendedViewCell
|
||||||
{
|
{
|
||||||
private readonly ToolsPasswordGeneratorPage _page;
|
private readonly ToolsPasswordGeneratorPage _page;
|
||||||
@ -200,7 +201,7 @@ namespace Bit.App.Pages
|
|||||||
Orientation = StackOrientation.Horizontal,
|
Orientation = StackOrientation.Horizontal,
|
||||||
Spacing = 15,
|
Spacing = 15,
|
||||||
Children = { label, LengthSlider, Value },
|
Children = { label, LengthSlider, Value },
|
||||||
Padding = new Thickness(15)
|
Padding = new Thickness(15, 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
View = stackLayout;
|
View = stackLayout;
|
||||||
|
@ -29,8 +29,8 @@ namespace Bit.App.Pages
|
|||||||
public ExtendedSwitchCell SpecialCell { get; set; }
|
public ExtendedSwitchCell SpecialCell { get; set; }
|
||||||
public ExtendedSwitchCell NumbersCell { get; set; }
|
public ExtendedSwitchCell NumbersCell { get; set; }
|
||||||
public ExtendedSwitchCell AvoidAmbiguousCell { get; set; }
|
public ExtendedSwitchCell AvoidAmbiguousCell { get; set; }
|
||||||
public EntryCell SpecialMinCell { get; set; }
|
public StepperCell SpecialMinCell { get; set; }
|
||||||
public EntryCell NumbersMinCell { get; set; }
|
public StepperCell NumbersMinCell { get; set; }
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
@ -69,19 +69,10 @@ namespace Bit.App.Pages
|
|||||||
};
|
};
|
||||||
AvoidAmbiguousCell.OnChanged += AvoidAmbiguousCell_OnChanged; ;
|
AvoidAmbiguousCell.OnChanged += AvoidAmbiguousCell_OnChanged; ;
|
||||||
|
|
||||||
NumbersMinCell = new EntryCell
|
NumbersMinCell = new StepperCell("Minimum Numbers",
|
||||||
{
|
_settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, 1), 0, 5, 1);
|
||||||
Label = "Minimum Numbers",
|
SpecialMinCell = new StepperCell("Minimum Special",
|
||||||
Text = _settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, 1).ToString(),
|
_settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, 1), 0, 5, 1);
|
||||||
Keyboard = Keyboard.Numeric
|
|
||||||
};
|
|
||||||
|
|
||||||
SpecialMinCell = new EntryCell
|
|
||||||
{
|
|
||||||
Label = "Minimum Special",
|
|
||||||
Text = _settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, 1).ToString(),
|
|
||||||
Keyboard = Keyboard.Numeric
|
|
||||||
};
|
|
||||||
|
|
||||||
var table = new ExtendedTableView
|
var table = new ExtendedTableView
|
||||||
{
|
{
|
||||||
@ -122,17 +113,11 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
int minNumber;
|
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinNumbers,
|
||||||
if(int.TryParse(NumbersMinCell.Text, out minNumber))
|
Convert.ToInt32(NumbersMinCell.Stepper.Value));
|
||||||
{
|
|
||||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinNumbers, minNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
int minSpecial;
|
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinSpecial,
|
||||||
if(int.TryParse(SpecialMinCell.Text, out minSpecial))
|
Convert.ToInt32(SpecialMinCell.Stepper.Value));
|
||||||
{
|
|
||||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinSpecial, minSpecial);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AvoidAmbiguousCell_OnChanged(object sender, ToggledEventArgs e)
|
private void AvoidAmbiguousCell_OnChanged(object sender, ToggledEventArgs e)
|
||||||
|
@ -322,7 +322,6 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
_page = page;
|
_page = page;
|
||||||
|
|
||||||
// Adding whitespace to Delete action to account for the negative margin offset on the listview
|
|
||||||
var deleteAction = new MenuItem { Text = AppResources.Delete, IsDestructive = true };
|
var deleteAction = new MenuItem { Text = AppResources.Delete, IsDestructive = true };
|
||||||
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
|
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
|
||||||
deleteAction.Clicked += page.DeleteClickedAsync;
|
deleteAction.Clicked += page.DeleteClickedAsync;
|
||||||
|
@ -53,10 +53,13 @@ namespace Bit.iOS
|
|||||||
// Appearance stuff
|
// Appearance stuff
|
||||||
|
|
||||||
var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
|
var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
|
||||||
|
var grayLight = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);
|
||||||
|
|
||||||
UINavigationBar.Appearance.ShadowImage = new UIImage();
|
UINavigationBar.Appearance.ShadowImage = new UIImage();
|
||||||
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
||||||
UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
|
UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
|
||||||
|
UIStepper.Appearance.TintColor = grayLight;
|
||||||
|
UISlider.Appearance.TintColor = primaryColor;
|
||||||
|
|
||||||
MessagingCenter.Subscribe<Xamarin.Forms.Application, ToolsExtensionPage>(Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
|
MessagingCenter.Subscribe<Xamarin.Forms.Application, ToolsExtensionPage>(Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user