Skip to content

Commit

Permalink
优化UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed Aug 8, 2024
1 parent 8c3bdff commit b45f846
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/SyncClipboard.Core/I18n/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/SyncClipboard.Core/I18n/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
<data name="FileFilterDescription" xml:space="preserve">
<value>Each file extension per line</value>
</data>
<data name="Save" xml:space="preserve">
<value>Save</value>
<data name="SaveList" xml:space="preserve">
<value>Save List</value>
</data>
</root>
4 changes: 2 additions & 2 deletions src/SyncClipboard.Core/I18n/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
<data name="FileFilterDescription" xml:space="preserve">
<value>每行一个文件扩展名</value>
</data>
<data name="Save" xml:space="preserve">
<value>保存</value>
<data name="SaveList" xml:space="preserve">
<value>保存名单</value>
</data>
</root>
19 changes: 18 additions & 1 deletion src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ public partial class SyncSettingViewModel : ObservableObject
#region server
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsNormalClientEnable))]
[NotifyPropertyChangedFor(nameof(UseManulServer))]
[NotifyPropertyChangedFor(nameof(ClientEnabled))]
private bool serverEnable;
partial void OnServerEnableChanged(bool value) => ServerConfig = ServerConfig with { SwitchOn = value };

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsNormalClientEnable))]
[NotifyPropertyChangedFor(nameof(UseManulServer))]
[NotifyPropertyChangedFor(nameof(ClientEnabled))]
private bool clientMixedMode;
partial void OnClientMixedModeChanged(bool value) => ServerConfig = ServerConfig with { ClientMixedMode = value };

Expand All @@ -32,6 +36,7 @@ partial void OnServerConfigChanged(ServerConfig value)

#region client
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ClientEnabled))]
private bool syncEnable;
partial void OnSyncEnableChanged(bool value) => ClientConfig = ClientConfig with { SyncSwitchOn = value };

Expand Down Expand Up @@ -113,7 +118,19 @@ private void SetFileSyncFilter()

public bool IsNormalClientEnable => !ServerEnable || !ClientMixedMode;

public bool UseManulServer => !UseLocalServer;
public bool UseManulServer => !UseLocalServer && IsNormalClientEnable;

public bool ClientEnabled
{
get => !IsNormalClientEnable || SyncEnable;
set
{
if (IsNormalClientEnable)
{
SyncEnable = value;
}
}
}

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ServerConfigDescription))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
Margin="16,0,0,0"
Orientation="Vertical"
Spacing="10">
<Button HorizontalAlignment="Stretch" Content="{x:Static i18n:Strings.Save}" Command="{Binding ApplyCommand}" />
<Button HorizontalAlignment="Stretch" Content="{x:Static i18n:Strings.SaveList}" Command="{Binding ApplyCommand}" />
</StackPanel>
</Grid>
</Grid>
Expand Down
26 changes: 11 additions & 15 deletions src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@
</ui:SettingsExpanderItem>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander Header="{x:Static i18n:Strings.ClipboardSyncing}" IsExpanded="{Binding IsNormalClientEnable, Mode=OneWay}" IsEnabled="{Binding IsNormalClientEnable, Mode=OneWay}">
<ui:SettingsExpander Header="{x:Static i18n:Strings.ClipboardSyncing}" IsExpanded="True">
<ui:SettingsExpander.IconSource>
<ui:FontIconSource Glyph="&#xE117;" FontFamily="{StaticResource SymbolThemeFontFamily}" />
</ui:SettingsExpander.IconSource>
<ui:SettingsExpander.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding SyncEnable, Mode=TwoWay}" />
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}"
OffContent="{x:Static i18n:Strings.Off}"
IsChecked="{Binding ClientEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsNormalClientEnable, Mode=OneWay}" />
</ui:SettingsExpander.Footer>
<ui:SettingsExpander.Items>
<ui:SettingsExpanderItem Description="{x:Static i18n:Strings.UseBuiltInServerDescription}" Content="{x:Static i18n:Strings.UseSelfHostServer}">
<ui:SettingsExpanderItem Description="{x:Static i18n:Strings.UseBuiltInServerDescription}" Content="{x:Static i18n:Strings.UseSelfHostServer}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding UseLocalServer, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
Expand Down Expand Up @@ -114,38 +117,31 @@
FontSize="12"
FontWeight="SemiBold" />
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.QueryInterval}">
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.QueryInterval}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding IntervalTime, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.RetryTimes}">
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.RetryTimes}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding RetryTimes, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.TimeoutPeriod}">
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.TimeoutPeriod}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding TimeOut, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.DeleteServerTemporaryFileAutoly}">
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.DeleteServerTemporaryFileAutoly}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding AutoDeleleServerFile, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.SendNotificationAfterManuallyUpload}">
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.SendNotificationAfterManuallyUpload}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding NotifyOnManualUpload, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander Header="{x:Static i18n:Strings.ClientGeneral}" IsExpanded="True">
<ui:SettingsExpander.IconSource>
<ui:FontIconSource Glyph="&#xE90F;" FontFamily="{StaticResource SymbolThemeFontFamily}" />
</ui:SettingsExpander.IconSource>
<ui:SettingsExpander.Items>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.SendNotificationAfterUpdateLocalClipboard}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding NotifyOnDownloaded, Mode=TwoWay}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
Margin="16,0,0,0"
Orientation="Vertical"
Spacing="10">
<Button HorizontalAlignment="Stretch" Content="{x:Bind i18n:Strings.Save}" Command="{x:Bind _viewModel.ApplyCommand}" />
<Button HorizontalAlignment="Stretch" Content="{x:Bind i18n:Strings.SaveList}" Command="{x:Bind _viewModel.ApplyCommand}" />
</StackPanel>
</Grid>
</Grid>
Expand Down
25 changes: 9 additions & 16 deletions src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@
</ui:SettingsCard>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander Header="{x:Bind i18n:Strings.ClipboardSyncing}" IsExpanded="{Binding IsNormalClientEnable, Mode=OneWay}" IsEnabled="{x:Bind _viewModel.IsNormalClientEnable, Mode=OneWay}">
<ui:SettingsExpander Header="{x:Bind i18n:Strings.ClipboardSyncing}" IsExpanded="True">
<ui:SettingsExpander.HeaderIcon>
<FontIcon Glyph="&#xE117;" />
</ui:SettingsExpander.HeaderIcon>
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.SyncEnable, Mode=TwoWay}" />
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.ClientEnabled, Mode=TwoWay}" IsEnabled="{x:Bind _viewModel.IsNormalClientEnable, Mode=OneWay}"/>
<ui:SettingsExpander.Items>
<ui:SettingsCard Description="{x:Bind i18n:Strings.UseBuiltInServerDescription}" Header="{x:Bind i18n:Strings.UseSelfHostServer}">
<ui:SettingsCard Description="{x:Bind i18n:Strings.UseBuiltInServerDescription}" Header="{x:Bind i18n:Strings.UseSelfHostServer}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.UseLocalServer, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.UseManulServer), Mode=OneWay}" Description="{x:Bind _viewModel.ClientConfigDescription, Mode=OneWay}">
<ui:SettingsCard Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.UseManulServer)}" Description="{x:Bind _viewModel.ClientConfigDescription, Mode=OneWay}">
<StackPanel Orientation="Horizontal" Spacing="5">
<ToggleButton IsChecked="{x:Bind _viewModel.ShowClientPassword, Mode=TwoWay}">
<FontIcon Glyph="{x:Bind _viewModel.ShowClientPassword, Mode=OneWay, Converter={StaticResource BoolToPasswordIconConverter}}" />
Expand Down Expand Up @@ -108,28 +108,21 @@
<HyperlinkButton Content="{x:Bind i18n:Strings.UseNextcloud}" Command="{x:Bind _viewModel.LoginWithNextcloudCommand}" />
</ui:SettingsCard.Description>
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.QueryInterval}">
<ui:SettingsCard Header="{x:Bind i18n:Strings.QueryInterval}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.IntervalTime, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.RetryTimes}">
<ui:SettingsCard Header="{x:Bind i18n:Strings.RetryTimes}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.RetryTimes, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.TimeoutPeriod}">
<ui:SettingsCard Header="{x:Bind i18n:Strings.TimeoutPeriod}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.TimeOut, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.DeleteServerTemporaryFileAutoly}">
<ui:SettingsCard Header="{x:Bind i18n:Strings.DeleteServerTemporaryFileAutoly}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.AutoDeleleServerFile, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.SendNotificationAfterManuallyUpload}">
<ui:SettingsCard Header="{x:Bind i18n:Strings.SendNotificationAfterManuallyUpload}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.NotifyOnManualUpload, Mode=TwoWay}" />
</ui:SettingsCard>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsExpander Header="{x:Bind i18n:Strings.ClientGeneral}" IsExpanded="True">
<ui:SettingsExpander.HeaderIcon>
<FontIcon Glyph="&#xE90F;" />
</ui:SettingsExpander.HeaderIcon>
<ui:SettingsExpander.Items>
<ui:SettingsCard Header="{x:Bind i18n:Strings.SendNotificationAfterUpdateLocalClipboard}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.NotifyOnDownloaded, Mode=TwoWay}" />
</ui:SettingsCard>
Expand Down

0 comments on commit b45f846

Please sign in to comment.