1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-29 12:45:20 +01:00

options expander for send (#1265)

This commit is contained in:
Matt Portune 2021-02-16 15:24:51 -05:00 committed by GitHub
parent 7cf64ff088
commit 233319a0a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 287 additions and 219 deletions

View File

@ -89,22 +89,27 @@
StyleClass="box-footer-label" StyleClass="box-footer-label"
Margin="0,5,0,0" /> Margin="0,5,0,0" />
</StackLayout> </StackLayout>
<StackLayout StyleClass="box-row" <StackLayout
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}"> StyleClass="box-row"
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}">
<Label <Label
Text="{u:I18n Type}" Text="{u:I18n Type}"
StyleClass="box-label" /> StyleClass="box-label" />
<Grid RowSpacing="0" ColumnSpacing="0" Margin="{Binding SegmentedButtonMargins}"> <Grid
RowSpacing="0"
ColumnSpacing="0"
Margin="{Binding SegmentedButtonMargins}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Text="{u:I18n TypeFile}" <Button
IsEnabled="{Binding IsText}" Text="{u:I18n TypeFile}"
Clicked="FileType_Clicked" IsEnabled="{Binding IsText}"
AutomationProperties.IsInAccessibleTree="True" Clicked="FileType_Clicked"
AutomationProperties.Name="{u:I18n File}" AutomationProperties.IsInAccessibleTree="True"
Grid.Column="0"> AutomationProperties.Name="{u:I18n File}"
Grid.Column="0">
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<!-- Rider users, if the x:Name values below are red, it's a known issue: --> <!-- Rider users, if the x:Name values below are red, it's a known issue: -->
<!-- https://youtrack.jetbrains.com/issue/RSRP-479388 --> <!-- https://youtrack.jetbrains.com/issue/RSRP-479388 -->
@ -124,12 +129,13 @@
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
</Button> </Button>
<Button Text="{u:I18n TypeText}" <Button
IsEnabled="{Binding IsFile}" Text="{u:I18n TypeText}"
Clicked="TextType_Clicked" IsEnabled="{Binding IsFile}"
AutomationProperties.IsInAccessibleTree="True" Clicked="TextType_Clicked"
AutomationProperties.Name="{u:I18n Text}" AutomationProperties.IsInAccessibleTree="True"
Grid.Column="1"> AutomationProperties.Name="{u:I18n Text}"
Grid.Column="1">
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<!-- Rider users, if the x:Name values below are red, it's a known issue: --> <!-- Rider users, if the x:Name values below are red, it's a known issue: -->
<!-- https://youtrack.jetbrains.com/issue/RSRP-479388 --> <!-- https://youtrack.jetbrains.com/issue/RSRP-479388 -->
@ -151,36 +157,9 @@
</Button> </Button>
</Grid> </Grid>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box-row" <StackLayout
IsVisible="{Binding IsText}"> StyleClass="box-row"
<Label IsVisible="{Binding IsFile}">
Text="{u:I18n TypeText}"
StyleClass="box-label" />
<Editor
x:Name="_textEditor"
AutoSize="TextChanges"
Text="{Binding Send.Text.Text}"
StyleClass="box-value"
Margin="{Binding EditorMargins}" />
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowEditorSeparators}" />
<Label
Text="{u:I18n TypeTextInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,10" />
<StackLayout StyleClass="box-row, box-row-switch">
<Label
Text="{u:I18n HideTextByDefault}"
StyleClass="box-label-regular"
VerticalOptions="Center"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding Send.Text.Hidden}"
HorizontalOptions="End"
Margin="10,0,0,0" />
</StackLayout>
</StackLayout>
<StackLayout StyleClass="box-row"
IsVisible="{Binding IsFile}">
<Label <Label
Text="{u:I18n TypeFile}" Text="{u:I18n TypeFile}"
StyleClass="box-label" /> StyleClass="box-label" />
@ -205,9 +184,10 @@
StyleClass="text-sm, text-muted" StyleClass="text-sm, text-muted"
HorizontalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center" /> HorizontalTextAlignment="Center" />
<Button Text="{u:I18n ChooseFile}" <Button
StyleClass="box-button-row" Text="{u:I18n ChooseFile}"
Clicked="ChooseFile_Clicked" /> StyleClass="box-button-row"
Clicked="ChooseFile_Clicked" />
<Label <Label
Margin="0, 5, 0, 0" Margin="0, 5, 0, 0"
Text="{u:I18n MaxFileSize}" Text="{u:I18n MaxFileSize}"
@ -220,185 +200,38 @@
StyleClass="box-footer-label" StyleClass="box-footer-label"
Margin="0,5,0,0" /> Margin="0,5,0,0" />
</StackLayout> </StackLayout>
<StackLayout StyleClass="box-row-header"> <StackLayout
<Label Text="{u:I18n Options, Header=True}" StyleClass="box-row"
StyleClass="box-header, box-header-platform" /> IsVisible="{Binding IsText}">
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,10,0,0">
<Label <Label
Text="{u:I18n DeletionDate}" Text="{u:I18n TypeText}"
StyleClass="box-label" />
<Picker
x:Name="_deletionDateTypePicker"
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding DeletionTypeOptions, Mode=OneTime}"
SelectedIndex="{Binding DeletionDateTypeSelectedIndex}"
StyleClass="box-value"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionTime}" />
<Grid
IsVisible="{Binding ShowDeletionCustomPickers}"
Margin="0,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:ExtendedDatePicker
NullableDate="{Binding DeletionDate, Mode=TwoWay}"
Format="d"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionDate}"
Grid.Column="0" />
<controls:ExtendedTimePicker
NullableTime="{Binding DeletionTime, Mode=TwoWay}"
Format="t"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionTime}"
Grid.Column="1" />
</Grid>
<Label
Text="{u:I18n DeletionDateInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,0" />
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,5,0,0">
<Label
Text="{u:I18n ExpirationDate}"
StyleClass="box-label" />
<Picker
x:Name="_expirationDateTypePicker"
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding ExpirationTypeOptions, Mode=OneTime}"
SelectedIndex="{Binding ExpirationDateTypeSelectedIndex}"
StyleClass="box-value"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationTime}" />
<Grid
IsVisible="{Binding ShowExpirationCustomPickers}"
Margin="0,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:ExtendedDatePicker
NullableDate="{Binding ExpirationDate, Mode=TwoWay}"
PlaceHolder="mm/dd/yyyy"
Format="d"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationDate}"
Grid.Column="0" />
<controls:ExtendedTimePicker
NullableTime="{Binding ExpirationTime, Mode=TwoWay}"
PlaceHolder="--:-- --"
Format="t"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationTime}"
Grid.Column="1" />
</Grid>
<StackLayout Orientation="Horizontal" Margin="0,5,0,0">
<Label
Text="{u:I18n ExpirationDateInfo}"
StyleClass="box-footer-label"
HorizontalOptions="StartAndExpand" />
<Button
Text="{u:I18n Clear}"
IsVisible="{Binding EditMode}"
WidthRequest="110"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
StyleClass="box-row-button"
Clicked="ClearExpirationDate_Clicked" />
</StackLayout>
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,5,0,0">
<Label
Text="{u:I18n MaximumAccessCount}"
StyleClass="box-label" />
<StackLayout StyleClass="box-row" Orientation="Horizontal">
<Entry
Text="{Binding MaxAccessCount}"
StyleClass="box-value"
Keyboard="Numeric"
MaxLength="9"
TextChanged="OnMaxAccessCountTextChanged"
HorizontalOptions="FillAndExpand" />
<Stepper
x:Name="_maxAccessCountStepper"
Value="{Binding MaxAccessCount}"
Maximum="999999999"
Margin="10,0,0,0" />
</StackLayout>
<Label
Text="{u:I18n MaximumAccessCountInfo}"
StyleClass="box-footer-label" />
<StackLayout
IsVisible="{Binding EditMode}"
StyleClass="box-row"
Orientation="Horizontal">
<Label
Text="{u:I18n CurrentAccessCount}"
StyleClass="box-footer-label"
VerticalTextAlignment="Center" />
<Label
Text=": "
StyleClass="box-footer-label"
VerticalTextAlignment="Center" />
<Label
Text="{Binding Send.AccessCount, Mode=OneWay}"
StyleClass="box-label"
VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,5,0,0">
<Label
Text="{u:I18n NewPassword}"
StyleClass="box-label" />
<StackLayout Orientation="Horizontal">
<Entry
Text="{Binding NewPassword}"
IsPassword="{Binding ShowPassword, Converter={StaticResource inverseBool}}"
StyleClass="box-value"
IsSpellCheckEnabled="False"
IsTextPredictionEnabled="False"
HorizontalOptions="FillAndExpand" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding ShowPasswordIcon}"
Command="{Binding TogglePasswordCommand}"
Margin="10,0,0,0"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ToggleVisibility}" />
</StackLayout>
<Label
Text="{u:I18n PasswordInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,0" />
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,5,0,0">
<Label
Text="{u:I18n Notes}"
StyleClass="box-label" /> StyleClass="box-label" />
<Editor <Editor
x:Name="_textEditor"
AutoSize="TextChanges" AutoSize="TextChanges"
Text="{Binding Send.Notes}" Text="{Binding Send.Text.Text}"
StyleClass="box-value" StyleClass="box-value"
Margin="{Binding EditorMargins}" /> Margin="{Binding EditorMargins}" />
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowEditorSeparators}" /> <BoxView
StyleClass="box-row-separator"
IsVisible="{Binding ShowEditorSeparators}" />
<Label <Label
Text="{u:I18n NotesInfo}" Text="{u:I18n TypeTextInfo}"
StyleClass="box-footer-label" StyleClass="box-footer-label"
Margin="0,5,0,0" /> Margin="0,5,0,10" />
</StackLayout> <StackLayout
<StackLayout StyleClass="box-row, box-row-switch" Margin="0,5,0,0"> StyleClass="box-row, box-row-switch"
<Label Margin="0,10,0,0">
Text="{u:I18n DisableSend}" <Label
StyleClass="box-label-regular" Text="{u:I18n HideTextByDefault}"
VerticalOptions="Center" StyleClass="box-label-regular"
HorizontalOptions="StartAndExpand" /> VerticalOptions="Center"
<Switch HorizontalOptions="StartAndExpand" />
IsToggled="{Binding Send.Disabled}" <Switch
HorizontalOptions="End" IsToggled="{Binding Send.Text.Hidden}"
Margin="10,0,0,0" /> HorizontalOptions="End"
Margin="10,0,0,0" />
</StackLayout>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box-row, box-row-switch"> <StackLayout StyleClass="box-row, box-row-switch">
<Label <Label
@ -411,6 +244,222 @@
HorizontalOptions="End" HorizontalOptions="End"
Margin="10,0,0,0" /> Margin="10,0,0,0" />
</StackLayout> </StackLayout>
<StackLayout
Orientation="Horizontal"
Spacing="0">
<Button
Text="{u:I18n Options}"
x:Name="_btnOptions"
StyleClass="box-row-button"
Margin="0"
Clicked="ToggleOptions_Clicked" />
<controls:FaButton
x:Name="_btnOptionsUp"
Text="&#xf077;"
StyleClass="box-row-button"
Clicked="ToggleOptions_Clicked"
IsVisible="{Binding ShowOptions}" />
<controls:FaButton
x:Name="_btnOptionsDown"
Text="&#xf078;"
StyleClass="box-row-button"
Clicked="ToggleOptions_Clicked"
IsVisible="{Binding ShowOptions, Converter={StaticResource inverseBool}}" />
</StackLayout>
<StackLayout IsVisible="{Binding ShowOptions}">
<StackLayout
StyleClass="box-row"
Margin="0,10,0,0">
<Label
Text="{u:I18n DeletionDate}"
StyleClass="box-label" />
<Picker
x:Name="_deletionDateTypePicker"
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding DeletionTypeOptions, Mode=OneTime}"
SelectedIndex="{Binding DeletionDateTypeSelectedIndex}"
StyleClass="box-value"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionTime}" />
<Grid
IsVisible="{Binding ShowDeletionCustomPickers}"
Margin="0,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:ExtendedDatePicker
NullableDate="{Binding DeletionDate, Mode=TwoWay}"
Format="d"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionDate}"
Grid.Column="0" />
<controls:ExtendedTimePicker
NullableTime="{Binding DeletionTime, Mode=TwoWay}"
Format="t"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n DeletionTime}"
Grid.Column="1" />
</Grid>
<Label
Text="{u:I18n DeletionDateInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,0" />
</StackLayout>
<StackLayout StyleClass="box-row" Margin="0,5,0,0">
<Label
Text="{u:I18n ExpirationDate}"
StyleClass="box-label" />
<Picker
x:Name="_expirationDateTypePicker"
IsVisible="{Binding EditMode, Converter={StaticResource inverseBool}}"
ItemsSource="{Binding ExpirationTypeOptions, Mode=OneTime}"
SelectedIndex="{Binding ExpirationDateTypeSelectedIndex}"
StyleClass="box-value"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationTime}" />
<Grid
IsVisible="{Binding ShowExpirationCustomPickers}"
Margin="0,5,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:ExtendedDatePicker
NullableDate="{Binding ExpirationDate, Mode=TwoWay}"
PlaceHolder="mm/dd/yyyy"
Format="d"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationDate}"
Grid.Column="0" />
<controls:ExtendedTimePicker
NullableTime="{Binding ExpirationTime, Mode=TwoWay}"
PlaceHolder="--:-- --"
Format="t"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ExpirationTime}"
Grid.Column="1" />
</Grid>
<StackLayout
Orientation="Horizontal"
Margin="0,5,0,0">
<Label
Text="{u:I18n ExpirationDateInfo}"
StyleClass="box-footer-label"
HorizontalOptions="StartAndExpand" />
<Button
Text="{u:I18n Clear}"
IsVisible="{Binding EditMode}"
WidthRequest="110"
HeightRequest="{Binding SegmentedButtonHeight}"
FontSize="{Binding SegmentedButtonFontSize}"
StyleClass="box-row-button"
Clicked="ClearExpirationDate_Clicked" />
</StackLayout>
</StackLayout>
<StackLayout
StyleClass="box-row"
Margin="0,5,0,0">
<Label
Text="{u:I18n MaximumAccessCount}"
StyleClass="box-label" />
<StackLayout
StyleClass="box-row"
Orientation="Horizontal">
<Entry
Text="{Binding MaxAccessCount}"
StyleClass="box-value"
Keyboard="Numeric"
MaxLength="9"
TextChanged="OnMaxAccessCountTextChanged"
HorizontalOptions="FillAndExpand" />
<Stepper
x:Name="_maxAccessCountStepper"
Value="{Binding MaxAccessCount}"
Maximum="999999999"
Margin="10,0,0,0" />
</StackLayout>
<Label
Text="{u:I18n MaximumAccessCountInfo}"
StyleClass="box-footer-label" />
<StackLayout
IsVisible="{Binding EditMode}"
StyleClass="box-row"
Orientation="Horizontal">
<Label
Text="{u:I18n CurrentAccessCount}"
StyleClass="box-footer-label"
VerticalTextAlignment="Center" />
<Label
Text=": "
StyleClass="box-footer-label"
VerticalTextAlignment="Center" />
<Label
Text="{Binding Send.AccessCount, Mode=OneWay}"
StyleClass="box-label"
VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
<StackLayout
StyleClass="box-row"
Margin="0,5,0,0">
<Label
Text="{u:I18n NewPassword}"
StyleClass="box-label" />
<StackLayout Orientation="Horizontal">
<Entry
Text="{Binding NewPassword}"
IsPassword="{Binding ShowPassword, Converter={StaticResource inverseBool}}"
StyleClass="box-value"
IsSpellCheckEnabled="False"
IsTextPredictionEnabled="False"
HorizontalOptions="FillAndExpand" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding ShowPasswordIcon}"
Command="{Binding TogglePasswordCommand}"
Margin="10,0,0,0"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ToggleVisibility}" />
</StackLayout>
<Label
Text="{u:I18n PasswordInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,0" />
</StackLayout>
<StackLayout
StyleClass="box-row"
Margin="0,5,0,0">
<Label
Text="{u:I18n Notes}"
StyleClass="box-label" />
<Editor
AutoSize="TextChanges"
Text="{Binding Send.Notes}"
StyleClass="box-value"
Margin="{Binding EditorMargins}" />
<BoxView
StyleClass="box-row-separator"
IsVisible="{Binding ShowEditorSeparators}" />
<Label
Text="{u:I18n NotesInfo}"
StyleClass="box-footer-label"
Margin="0,5,0,0" />
</StackLayout>
<StackLayout
StyleClass="box-row, box-row-switch"
Margin="0,5,0,0">
<Label
Text="{u:I18n DisableSend}"
StyleClass="box-label-regular"
VerticalOptions="Center"
HorizontalOptions="StartAndExpand" />
<Switch
IsToggled="{Binding Send.Disabled}"
HorizontalOptions="End"
Margin="10,0,0,0" />
</StackLayout>
</StackLayout>
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>

View File

@ -42,6 +42,9 @@ namespace Bit.App.Pages
_vm.SegmentedButtonFontSize = 13; _vm.SegmentedButtonFontSize = 13;
_vm.SegmentedButtonMargins = new Thickness(0, 10, 0, 0); _vm.SegmentedButtonMargins = new Thickness(0, 10, 0, 0);
_vm.EditorMargins = new Thickness(0, 5, 0, 0); _vm.EditorMargins = new Thickness(0, 5, 0, 0);
_btnOptions.WidthRequest = 62;
_btnOptionsDown.WidthRequest = 30;
_btnOptionsUp.WidthRequest = 30;
} }
else if (Device.RuntimePlatform == Device.iOS) else if (Device.RuntimePlatform == Device.iOS)
{ {
@ -153,6 +156,11 @@ namespace Bit.App.Pages
} }
} }
private void ToggleOptions_Clicked(object sender, EventArgs e)
{
_vm.ToggleOptions();
}
private void ClearExpirationDate_Clicked(object sender, EventArgs e) private void ClearExpirationDate_Clicked(object sender, EventArgs e)
{ {
if (DoOnce()) if (DoOnce())

View File

@ -22,6 +22,7 @@ namespace Bit.App.Pages
private bool _canAccessPremium; private bool _canAccessPremium;
private SendView _send; private SendView _send;
private string _fileName; private string _fileName;
private bool _showOptions;
private bool _showPassword; private bool _showPassword;
private int _deletionDateTypeSelectedIndex; private int _deletionDateTypeSelectedIndex;
private int _expirationDateTypeSelectedIndex; private int _expirationDateTypeSelectedIndex;
@ -107,6 +108,11 @@ namespace Bit.App.Pages
get => _deletionTime; get => _deletionTime;
set => SetProperty(ref _deletionTime, value); set => SetProperty(ref _deletionTime, value);
} }
public bool ShowOptions
{
get => _showOptions;
set => SetProperty(ref _showOptions, value);
}
public int ExpirationDateTypeSelectedIndex public int ExpirationDateTypeSelectedIndex
{ {
get => _expirationDateTypeSelectedIndex; get => _expirationDateTypeSelectedIndex;
@ -397,6 +403,11 @@ namespace Bit.App.Pages
} }
} }
public void ToggleOptions()
{
ShowOptions = !ShowOptions;
}
private void DeletionTypeChanged() private void DeletionTypeChanged()
{ {
if (Send != null && DeletionDateTypeSelectedIndex > -1) if (Send != null && DeletionDateTypeSelectedIndex > -1)