1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

[PM-3340] Change settings screen vault timeout action cell UI.

This commit is contained in:
André Bispo
2023-09-13 17:28:03 +01:00
parent 3e2005e5ed
commit 2dd6a3f294
7 changed files with 76 additions and 16 deletions

View File

@@ -49,6 +49,38 @@
AutomationId="{Binding AutomationIdSettingStatus}" />
</controls:ExtendedStackLayout>
</DataTemplate>
<DataTemplate
x:Key="regularWithDescriptionTemplate"
x:DataType="pages:SettingsPageListItem">
<controls:ExtendedStackLayout Orientation="Horizontal"
StyleClass="list-row, list-row-platform">
<StackLayout
HorizontalOptions="StartAndExpand"
VerticalOptions="Center">
<controls:CustomLabel
Text="{Binding Name, Mode=OneWay}"
LineBreakMode="{Binding LineBreakMode}"
StyleClass="list-title"
TextColor="{Binding NameColor}"
AutomationId="{Binding AutomationIdSettingName}" />
<controls:CustomLabel
Text="{Binding Description, Mode=OneWay}"
LineBreakMode="{Binding LineBreakMode}"
TextColor="{DynamicResource MutedColor}"
FontSize="Micro"
StyleClass="list-sub"/>
</StackLayout>
<controls:CustomLabel Text="{Binding SubLabel, Mode=OneWay}"
IsVisible="{Binding ShowSubLabel}"
HorizontalOptions="End"
HorizontalTextAlignment="End"
VerticalOptions="CenterAndExpand"
VerticalTextAlignment="Start"
TextColor="{Binding SubLabelColor}"
StyleClass="list-sub"
AutomationId="{Binding AutomationIdSettingStatus}" />
</controls:ExtendedStackLayout>
</DataTemplate>
<DataTemplate
x:Key="timePickerTemplate"
x:DataType="pages:SettingsPageListItem">
@@ -107,6 +139,7 @@
x:Key="listItemDataTemplateSelector"
HeaderTemplate="{StaticResource headerTemplate}"
RegularTemplate="{StaticResource regularTemplate}"
RegularWithDescriptionTemplate="{StaticResource regularWithDescriptionTemplate}"
TimePickerTemplate="{StaticResource timePickerTemplate}" />
</ResourceDictionary>
</ContentPage.Resources>

View File

@@ -64,7 +64,7 @@ namespace Bit.App.Pages
private void RowSelected(object sender, SelectionChangedEventArgs e)
{
((ExtendedCollectionView)sender).SelectedItem = null;
if (e.CurrentSelection?.FirstOrDefault() is SettingsPageListItem item)
if (e.CurrentSelection?.FirstOrDefault() is SettingsPageListItem item && item.Enabled)
{
_vm?.ExecuteSettingItemCommand.Execute(item);
}

View File

@@ -13,8 +13,10 @@ namespace Bit.App.Pages
public string Icon { get; set; }
public string Name { get; set; }
public string SubLabel { get; set; }
public string Description { get; set; }
public TimeSpan? Time { get; set; }
public bool UseFrame { get; set; }
public bool Enabled { get; set; } = true;
public Func<Task> ExecuteAsync { get; set; }
public bool SubLabelTextEnabled => SubLabel == AppResources.On;
@@ -24,6 +26,9 @@ namespace Bit.App.Pages
public Color SubLabelColor => SubLabelTextEnabled ?
ThemeManager.GetResourceColor("SuccessColor") :
ThemeManager.GetResourceColor("MutedColor");
public Color NameColor => Enabled ?
ThemeManager.GetResourceColor("TextColor") :
ThemeManager.GetResourceColor("MutedColor");
public string AutomationIdSettingName
{

View File

@@ -7,6 +7,7 @@ namespace Bit.App.Pages
public DataTemplate HeaderTemplate { get; set; }
public DataTemplate RegularTemplate { get; set; }
public DataTemplate TimePickerTemplate { get; set; }
public DataTemplate RegularWithDescriptionTemplate { get; set; }
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
@@ -16,6 +17,10 @@ namespace Bit.App.Pages
}
if (item is SettingsPageListItem listItem)
{
if (!string.IsNullOrEmpty(listItem.Description))
{
return RegularWithDescriptionTemplate;
}
return listItem.ShowTimeInput ? TimePickerTemplate : RegularTemplate;
}
return null;

View File

@@ -567,6 +567,8 @@ namespace Bit.App.Pages
{
Name = AppResources.VaultTimeoutAction,
SubLabel = _vaultTimeoutActionDisplayValue,
Description = IsVaultTimeoutActionLockAllowed ? null : AppResources.SetUpAnUnlockMethodToChangeYourVaultTimeoutAction,
Enabled = IsVaultTimeoutActionLockAllowed,
ExecuteAsync = () => VaultTimeoutActionAsync()
},
new SettingsPageListItem
@@ -582,16 +584,19 @@ namespace Bit.App.Pages
ExecuteAsync = () => ApproveLoginRequestsAsync()
},
new SettingsPageListItem
{
Name = AppResources.LockNow,
ExecuteAsync = () => LockAsync()
},
new SettingsPageListItem
{
Name = AppResources.TwoStepLogin,
ExecuteAsync = () => TwoStepAsync()
}
};
if (IsVaultTimeoutActionLockAllowed)
{
securityItems.Insert(4, new SettingsPageListItem
{
Name = AppResources.LockNow,
ExecuteAsync = () => LockAsync()
});
}
if (_approvePasswordlessLoginRequests)
{
manageItems.Add(new SettingsPageListItem

View File

@@ -418,6 +418,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to addy.io.
/// </summary>
public static string AddyIo {
get {
return ResourceManager.GetString("AddyIo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Admin approval requested.
/// </summary>
@@ -508,15 +517,6 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to addy.io.
/// </summary>
public static string AddyIo {
get {
return ResourceManager.GetString("AddyIo", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to A notification has been sent to your device..
/// </summary>
@@ -6002,6 +6002,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Set up an unlock method to change your vault timeout action..
/// </summary>
public static string SetUpAnUnlockMethodToChangeYourVaultTimeoutAction {
get {
return ResourceManager.GetString("SetUpAnUnlockMethodToChangeYourVaultTimeoutAction", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set up TOTP.
/// </summary>
@@ -6751,7 +6760,7 @@ namespace Bit.App.Resources {
}
/// <summary>
/// Looks up a localized string similar to Unlocking may fail due to insufficient memory. Decrease your KDF memory settings to resolve..
/// Looks up a localized string similar to Unlocking may fail due to insufficient memory. Decrease your KDF memory settings or set up biometric unlock to resolve..
/// </summary>
public static string UnlockingMayFailDueToInsufficientMemoryDecreaseYourKDFMemorySettingsToResolve {
get {

View File

@@ -2762,4 +2762,7 @@ Do you want to switch to this account?</value>
<data name="LoggingInOn" xml:space="preserve">
<value>Logging in on</value>
</data>
<data name="SetUpAnUnlockMethodToChangeYourVaultTimeoutAction" xml:space="preserve">
<value>Set up an unlock method to change your vault timeout action.</value>
</data>
</root>