mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-22 16:18: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\ExtendedNavigationPage.cs" />
|
||||
<Compile Include="Controls\ExtendedContentPage.cs" />
|
||||
<Compile Include="Controls\StepperCell.cs" />
|
||||
<Compile Include="Controls\ExtendedTableView.cs" />
|
||||
<Compile Include="Controls\ExtendedPicker.cs" />
|
||||
<Compile Include="Controls\ExtendedEntry.cs" />
|
||||
|
@ -9,22 +9,26 @@ namespace Bit.App.Controls
|
||||
{
|
||||
private ISyncService _syncService;
|
||||
|
||||
public ExtendedContentPage()
|
||||
public ExtendedContentPage(bool syncIndicator = true)
|
||||
{
|
||||
_syncService = Resolver.Resolve<ISyncService>();
|
||||
|
||||
BackgroundColor = Color.FromHex("efeff4");
|
||||
IsBusy = _syncService.SyncInProgress;
|
||||
|
||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||
if(syncIndicator)
|
||||
{
|
||||
IsBusy = _syncService.SyncInProgress;
|
||||
});
|
||||
|
||||
MessagingCenter.Subscribe<Application>(Application.Current, "SyncStarted", (sender) =>
|
||||
{
|
||||
IsBusy = _syncService.SyncInProgress;
|
||||
});
|
||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||
{
|
||||
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;
|
||||
|
||||
public LockFingerprintPage(bool checkFingerprintImmediately)
|
||||
: base(false)
|
||||
{
|
||||
_checkFingerprintImmediately = checkFingerprintImmediately;
|
||||
_fingerprint = Resolver.Resolve<IFingerprint>();
|
||||
|
@ -18,6 +18,7 @@ namespace Bit.App.Pages
|
||||
private readonly ISettings _settings;
|
||||
|
||||
public LockPinPage()
|
||||
: base(false)
|
||||
{
|
||||
_authService = Resolver.Resolve<IAuthService>();
|
||||
_userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||
|
@ -153,6 +153,7 @@ namespace Bit.App.Pages
|
||||
_userDialogs.SuccessToast(string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
|
||||
}
|
||||
|
||||
// TODO: move to standalone reusable control
|
||||
public class SliderViewCell : ExtendedViewCell
|
||||
{
|
||||
private readonly ToolsPasswordGeneratorPage _page;
|
||||
@ -200,7 +201,7 @@ namespace Bit.App.Pages
|
||||
Orientation = StackOrientation.Horizontal,
|
||||
Spacing = 15,
|
||||
Children = { label, LengthSlider, Value },
|
||||
Padding = new Thickness(15)
|
||||
Padding = new Thickness(15, 8)
|
||||
};
|
||||
|
||||
View = stackLayout;
|
||||
|
@ -29,8 +29,8 @@ namespace Bit.App.Pages
|
||||
public ExtendedSwitchCell SpecialCell { get; set; }
|
||||
public ExtendedSwitchCell NumbersCell { get; set; }
|
||||
public ExtendedSwitchCell AvoidAmbiguousCell { get; set; }
|
||||
public EntryCell SpecialMinCell { get; set; }
|
||||
public EntryCell NumbersMinCell { get; set; }
|
||||
public StepperCell SpecialMinCell { get; set; }
|
||||
public StepperCell NumbersMinCell { get; set; }
|
||||
|
||||
public void Init()
|
||||
{
|
||||
@ -69,19 +69,10 @@ namespace Bit.App.Pages
|
||||
};
|
||||
AvoidAmbiguousCell.OnChanged += AvoidAmbiguousCell_OnChanged; ;
|
||||
|
||||
NumbersMinCell = new EntryCell
|
||||
{
|
||||
Label = "Minimum Numbers",
|
||||
Text = _settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, 1).ToString(),
|
||||
Keyboard = Keyboard.Numeric
|
||||
};
|
||||
|
||||
SpecialMinCell = new EntryCell
|
||||
{
|
||||
Label = "Minimum Special",
|
||||
Text = _settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, 1).ToString(),
|
||||
Keyboard = Keyboard.Numeric
|
||||
};
|
||||
NumbersMinCell = new StepperCell("Minimum Numbers",
|
||||
_settings.GetValueOrDefault(Constants.PasswordGeneratorMinNumbers, 1), 0, 5, 1);
|
||||
SpecialMinCell = new StepperCell("Minimum Special",
|
||||
_settings.GetValueOrDefault(Constants.PasswordGeneratorMinSpecial, 1), 0, 5, 1);
|
||||
|
||||
var table = new ExtendedTableView
|
||||
{
|
||||
@ -122,17 +113,11 @@ namespace Bit.App.Pages
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
int minNumber;
|
||||
if(int.TryParse(NumbersMinCell.Text, out minNumber))
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinNumbers, minNumber);
|
||||
}
|
||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinNumbers,
|
||||
Convert.ToInt32(NumbersMinCell.Stepper.Value));
|
||||
|
||||
int minSpecial;
|
||||
if(int.TryParse(SpecialMinCell.Text, out minSpecial))
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinSpecial, minSpecial);
|
||||
}
|
||||
_settings.AddOrUpdateValue(Constants.PasswordGeneratorMinSpecial,
|
||||
Convert.ToInt32(SpecialMinCell.Stepper.Value));
|
||||
}
|
||||
|
||||
private void AvoidAmbiguousCell_OnChanged(object sender, ToggledEventArgs e)
|
||||
|
@ -322,7 +322,6 @@ namespace Bit.App.Pages
|
||||
{
|
||||
_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 };
|
||||
deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
|
||||
deleteAction.Clicked += page.DeleteClickedAsync;
|
||||
|
@ -53,10 +53,13 @@ namespace Bit.iOS
|
||||
// Appearance stuff
|
||||
|
||||
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.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
||||
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) =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user