-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(host-settings): Add ability to edit host configurations #45
- Loading branch information
1 parent
73141f8
commit 9e37467
Showing
14 changed files
with
612 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Page x:Class="MyFTP.WinUI.Pages.HostSettingsViewPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:MyFTP.WinUI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:MyFTP.WinUI.Pages" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<x:Double x:Key="ContentMaxWidth">820</x:Double> | ||
|
||
<Style x:Key="GridItemContent" TargetType="Grid"> | ||
<Setter Property="Margin" Value="0,2" /> | ||
<Setter Property="Padding" Value="18,12" /> | ||
<Setter Property="Background" Value="{ThemeResource ExpanderBackground}" /> | ||
<Setter Property="BorderBrush" Value="{ThemeResource NavigationViewItemSeparatorForeground}" /> | ||
<Setter Property="BorderThickness" Value="{ThemeResource ExpanderHeaderBorderThickness}" /> | ||
<Setter Property="ColumnSpacing" Value="12" /> | ||
<Setter Property="CornerRadius" Value="4" /> | ||
<Setter Property="Shadow"> | ||
<Setter.Value> | ||
<ThemeShadow /> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
<Style x:Key="OptionToggleSwitch" | ||
BasedOn="{StaticResource DefaultToggleSwitchStyle}" | ||
TargetType="ToggleSwitch"> | ||
<Setter Property="Grid.RowSpan" Value="2" /> | ||
<Setter Property="Grid.Column" Value="1" /> | ||
<Setter Property="MinWidth" Value="0" /> | ||
<Setter Property="HorizontalAlignment" Value="Right" /> | ||
<Setter Property="VerticalAlignment" Value="Center" /> | ||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | ||
<Setter Property="KeyTipPlacementMode" Value="Right" /> | ||
</Style> | ||
|
||
<Style x:Key="OptionHeader" TargetType="TextBlock"> | ||
<Setter Property="VerticalAlignment" Value="Center" /> | ||
<Setter Property="TextWrapping" Value="Wrap" /> | ||
<Setter Property="FontWeight" Value="SemiBold" /> | ||
</Style> | ||
|
||
<Style x:Key="OptionSubtitle" TargetType="TextBlock"> | ||
<Setter Property="Opacity" Value="0.6" /> | ||
<Setter Property="FontSize" Value="12" /> | ||
<Setter Property="TextWrapping" Value="Wrap" /> | ||
</Style> | ||
</Page.Resources> | ||
|
||
<Grid x:DefaultBindMode="OneWay"> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition Height="auto" /> | ||
<RowDefinition Height="auto" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<controls:TitleBarControl Title="{x:Bind ViewModel.DisplayName}" | ||
BorderBrush="{ThemeResource NavigationViewItemSeparatorForeground}" | ||
BorderThickness="0,0,0,1" /> | ||
|
||
<InfoBar Title="Saved successfully" | ||
Grid.Row="1" | ||
Canvas.ZIndex="1" | ||
IsOpen="{x:Bind ViewModel.SaveChangesCommand.ExecutionTask.IsCompletedSuccessfully}" | ||
Message="The changes have been saved successfully" | ||
Severity="Success" /> | ||
|
||
|
||
<Grid Grid.Row="2" Background="{ThemeResource LayerFillColorDefaultBrush}"> | ||
<Grid.Transitions> | ||
<TransitionCollection> | ||
<RepositionThemeTransition /> | ||
</TransitionCollection> | ||
</Grid.Transitions> | ||
<ScrollViewer VerticalScrollBarVisibility="Auto"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="100*" MaxWidth="{StaticResource ContentMaxWidth}" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<StackPanel Grid.Column="1" | ||
Padding="18,8,18,8" | ||
Spacing="4"> | ||
<StackPanel.Shadow> | ||
<ThemeShadow /> | ||
</StackPanel.Shadow> | ||
|
||
<TextBlock FontSize="20" FontWeight="SemiBold"> | ||
<Run Text="Host settings" /> | ||
</TextBlock> | ||
|
||
<RadioButtons Header="Protocol" | ||
ItemsSource="{x:Bind ViewModel.AllProtocols.Type1Values}" | ||
MaxColumns="4" | ||
SelectedItem="{x:Bind ViewModel.Protocol, Mode=TwoWay}" /> | ||
|
||
<Grid ColumnSpacing="8"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="150" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBox Grid.Column="0" | ||
Header="Host" | ||
Text="{x:Bind ViewModel.Host, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<NumberBox Grid.Column="1" | ||
Header="Port" | ||
Minimum="0" | ||
SpinButtonPlacementMode="Compact" | ||
Value="{x:Bind ViewModel.Port, Mode=TwoWay}" /> | ||
|
||
</Grid> | ||
|
||
<TextBox Header="Nickname" Text="{x:Bind ViewModel.DisplayName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<TextBox Header="Username" Text="{x:Bind ViewModel.Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> | ||
|
||
<PasswordBox Header="Password" | ||
Password="{x:Bind ViewModel.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||
Visibility="Collapsed" /> | ||
|
||
<Rectangle Height="1" | ||
Margin="0,12" | ||
Fill="{ThemeResource NavigationViewItemSeparatorForeground}" /> | ||
|
||
<TextBlock Text="Advanced options" /> | ||
|
||
|
||
<Grid Style="{StaticResource GridItemContent}" Translation="0,0,8"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
|
||
<TextBlock Style="{StaticResource OptionHeader}" Text="Accept invalid certificates" /> | ||
|
||
<TextBlock Grid.Row="1" | ||
Style="{StaticResource OptionSubtitle}" | ||
Text="This option allows the FTP client to connect to servers even if their SSL/TLS certificates have issues. Be aware that enabling this bypasses critical security checks, so it should be used with a clear understanding of the potential risks" /> | ||
|
||
<ToggleSwitch IsOn="{x:Bind ViewModel.AcceptInvalidCertificates, Mode=TwoWay}" Style="{StaticResource OptionToggleSwitch}" /> | ||
|
||
</Grid> | ||
|
||
</StackPanel> | ||
</Grid> | ||
</ScrollViewer> | ||
</Grid> | ||
|
||
<Border Grid.Row="3"> | ||
<Grid Padding="12" | ||
BorderBrush="{ThemeResource NavigationViewItemSeparatorForeground}" | ||
BorderThickness="0,1,0,0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="130" /> | ||
<ColumnDefinition Width="auto" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Button MinWidth="120" Click="OnButtonClick"> | ||
<StackPanel Orientation="Horizontal" Spacing="4"> | ||
<FontIcon FontFamily="Segoe Fluent Icons" | ||
FontSize="15" | ||
Glyph="" /> | ||
<TextBlock Text="Delete" /> | ||
</StackPanel> | ||
</Button> | ||
|
||
<ProgressRing Grid.Column="1" | ||
Width="20" | ||
Height="20" | ||
HorizontalAlignment="Right" | ||
IsActive="{x:Bind ViewModel.SaveChangesCommand.IsRunning, Mode=OneWay}" /> | ||
|
||
<StackPanel Grid.Column="2" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Center" | ||
Orientation="Horizontal" | ||
Spacing="4"> | ||
|
||
<Button MinWidth="120" | ||
Click="{x:Bind GoBackOrCloseWindow, Mode=OneTime}" | ||
Content="Back" /> | ||
|
||
<Button MinWidth="120" | ||
Command="{x:Bind ViewModel.SaveChangesCommand}" | ||
Style="{ThemeResource AccentButtonStyle}"> | ||
<StackPanel Orientation="Horizontal" Spacing="4"> | ||
<FontIcon FontFamily="Segoe Fluent Icons" | ||
FontSize="15" | ||
Glyph="" /> | ||
<TextBlock Text="Save" /> | ||
</StackPanel> | ||
</Button> | ||
</StackPanel> | ||
</Grid> | ||
</Border> | ||
|
||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using MyFTP.WinUI.Services.Security; | ||
using MyFTP.WinUI.ViewModels; | ||
using System.ComponentModel; | ||
|
||
namespace MyFTP.WinUI.Pages; | ||
|
||
public sealed partial class HostSettingsViewPage : Page, INotifyPropertyChanged | ||
{ | ||
public HostSettingsViewPage() => InitializeComponent(); | ||
|
||
public HostOptionsViewModel ViewModel { get; set; } | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
{ | ||
ViewModel = (HostOptionsViewModel)e.Parameter; | ||
OnPropertyChanged(nameof(ViewModel)); | ||
} | ||
|
||
private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
|
||
private async void OnButtonClick(object sender, RoutedEventArgs e) | ||
{ | ||
await App.Current.Services | ||
.GetRequiredService<IHostCredentialLocker>() | ||
.RemoveCredentialAsync(ViewModel.Id); | ||
|
||
GoBackOrCloseWindow(); | ||
} | ||
|
||
private void GoBackOrCloseWindow() | ||
{ | ||
if (Frame.CanGoBack) | ||
{ | ||
Frame.GoBack(); | ||
} | ||
else | ||
{ | ||
App.WindowManager.GetWindow(XamlRoot).Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.