diff --git a/src/App/Pages/Generator/GeneratorPage.xaml b/src/App/Pages/Generator/GeneratorPage.xaml
index 45e4f2fc1..e4be260f2 100644
--- a/src/App/Pages/Generator/GeneratorPage.xaml
+++ b/src/App/Pages/Generator/GeneratorPage.xaml
@@ -35,7 +35,7 @@
Text="{Binding Password}"
Margin="0, 20"
StyleClass="text-lg"
- HorizontalOptions="Center"
+ HorizontalTextAlignment="Center"
LineBreakMode="CharacterWrap" />
@@ -108,8 +108,8 @@
StyleClass="box-value"
VerticalOptions="CenterAndExpand"
HorizontalOptions="FillAndExpand"
- Minimum="0"
- Maximum="128" />
+ Maximum="128"
+ Minimum="5" />
@@ -171,8 +171,8 @@
VerticalTextAlignment="Center" />
@@ -191,8 +191,8 @@
VerticalTextAlignment="Center" />
diff --git a/src/App/Pages/Generator/GeneratorPage.xaml.cs b/src/App/Pages/Generator/GeneratorPage.xaml.cs
index 90d0219d4..a31c5fa35 100644
--- a/src/App/Pages/Generator/GeneratorPage.xaml.cs
+++ b/src/App/Pages/Generator/GeneratorPage.xaml.cs
@@ -5,12 +5,22 @@ namespace Bit.App.Pages
public partial class GeneratorPage : BaseContentPage
{
private GeneratorPageViewModel _vm;
+ private readonly Action _selectAction;
public GeneratorPage()
+ : this(null)
+ { }
+
+ public GeneratorPage(Action selectAction)
{
InitializeComponent();
_vm = BindingContext as GeneratorPageViewModel;
_vm.Page = this;
+ _selectAction = selectAction;
+ if(selectAction == null)
+ {
+ ToolbarItems.Remove(_selectItem);
+ }
}
protected async override void OnAppearing()
@@ -31,7 +41,7 @@ namespace Bit.App.Pages
private void Select_Clicked(object sender, EventArgs e)
{
-
+ _selectAction?.Invoke(_vm.Password);
}
private void History_Clicked(object sender, EventArgs e)
diff --git a/src/App/Pages/Generator/GeneratorPageViewModel.cs b/src/App/Pages/Generator/GeneratorPageViewModel.cs
index faef96ffe..32a7014b9 100644
--- a/src/App/Pages/Generator/GeneratorPageViewModel.cs
+++ b/src/App/Pages/Generator/GeneratorPageViewModel.cs
@@ -22,8 +22,8 @@ namespace Bit.App.Pages
private bool _avoidAmbiguous;
private int _minNumber;
private int _minSpecial;
- private int _length;
- private int _numWords;
+ private int _length = 5;
+ private int _numWords = 3;
private string _wordSeparator;
private int _typeSelectedIndex;
private bool _doneIniting;
@@ -173,9 +173,10 @@ namespace Bit.App.Pages
get => _wordSeparator;
set
{
- if(SetProperty(ref _wordSeparator, value))
+ var val = value.Trim();
+ if(SetProperty(ref _wordSeparator, val))
{
- _options.WordSeparator = value;
+ _options.WordSeparator = val;
var task = SaveOptionsAsync();
}
}
@@ -244,6 +245,7 @@ namespace Bit.App.Pages
WordSeparator = _options.WordSeparator;
Uppercase = _options.Uppercase.GetValueOrDefault();
Lowercase = _options.Lowercase.GetValueOrDefault();
+ Length = _options.Length.GetValueOrDefault(5);
}
private void SetOptions()
@@ -258,6 +260,7 @@ namespace Bit.App.Pages
_options.WordSeparator = WordSeparator;
_options.Uppercase = Uppercase;
_options.Lowercase = Lowercase;
+ _options.Length = Length;
}
}
}
diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs
index 61143d660..5d6378dbd 100644
--- a/src/App/Pages/Vault/AddEditPageViewModel.cs
+++ b/src/App/Pages/Vault/AddEditPageViewModel.cs
@@ -418,9 +418,24 @@ namespace Bit.App.Pages
return false;
}
- public void GeneratePassword()
+ public async void GeneratePassword()
{
- // TODO: push modal for generate page
+ if(!string.IsNullOrWhiteSpace(Cipher?.Login?.Password))
+ {
+ var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.PasswordOverrideAlert,
+ null, AppResources.Yes, AppResources.No);
+ if(!confirmed)
+ {
+ return;
+ }
+ }
+ var page = new GeneratorPage(async (password) =>
+ {
+ Cipher.Login.Password = password;
+ TriggerCipherChanged();
+ await Page.Navigation.PopModalAsync();
+ });
+ await Page.Navigation.PushModalAsync(new NavigationPage(page));
}
public async void UriOptions(LoginUriView uri)