Skip to content

Commit

Permalink
同步设置分页
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed Aug 9, 2024
1 parent 9a76284 commit d91ff7d
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 60 deletions.
9 changes: 9 additions & 0 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.

3 changes: 3 additions & 0 deletions src/SyncClipboard.Core/I18n/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,7 @@
<data name="EnableDownload" xml:space="preserve">
<value>Enable Downloading</value>
</data>
<data name="SyncContentControl" xml:space="preserve">
<value>Sync Content Control</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/SyncClipboard.Core/I18n/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,7 @@
<data name="EnableDownload" xml:space="preserve">
<value>开启下载</value>
</data>
<data name="SyncContentControl" xml:space="preserve">
<value>同步內容控制</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/SyncClipboard.Core/ViewModels/PageDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class PageDefinition
public static readonly PageDefinition License = new("License", I18n.Strings.License);
public static readonly PageDefinition NextCloudLogIn = new("NextCloudLogIn", I18n.Strings.UseNextcloud);
public static readonly PageDefinition FileSyncFilterSetting = new("FileSyncFilterSetting", I18n.Strings.FileSyncFilter);
public static readonly PageDefinition SyncContentControl = new("SyncContentControl", I18n.Strings.SyncContentControl);
public static readonly PageDefinition Hotkey = new("Hotkey", I18n.Strings.Hotkeys, "\uE144");

public PageDefinition(string name, string title, string? fontIcon = null)
Expand Down
6 changes: 6 additions & 0 deletions src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ private void SetFileSyncFilter()
_mainVM.NavigateToNextLevel(PageDefinition.FileSyncFilterSetting);
}

[RelayCommand]
private void OpenSyncContentControlPage()
{
_mainVM.NavigateToNextLevel(PageDefinition.SyncContentControl);
}

#endregion

#region for view only
Expand Down
1 change: 1 addition & 0 deletions src/SyncClipboard.Desktop/Views/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ internal void NavigateTo(
string pageName = "SyncClipboard.Desktop.Views." + page.Name + "Page";
Type? pageType = Type.GetType(pageName);
SettingContentFrame.Navigate(pageType, parameter, new SlideNavigationTransitionInfo { Effect = effect });
_ScrollViewer.ScrollToHome();
}

private void BreadcrumbBar_ItemClicked(BreadcrumbBar _, BreadcrumbBarItemClickedEventArgs args)
Expand Down
69 changes: 69 additions & 0 deletions src/SyncClipboard.Desktop/Views/SyncContentControlPage.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<UserControl x:Class="SyncClipboard.Desktop.Views.SyncContentControlPage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:i18n="using:SyncClipboard.Core.I18n"
xmlns:vm="using:SyncClipboard.Core.ViewModels"
xmlns:local="using:SyncClipboard.Desktop.Views"
xmlns:vc="using:SyncClipboard.Desktop.ValueConverters"
x:DataType="vm:SyncSettingViewModel"
d:DesignWidth="800"
d:DesignHeight="450"
mc:Ignorable="d">
<Design.DataContext>
<vm:SyncSettingViewModel />
</Design.DataContext>
<UserControl.Resources>
<ui:SymbolIconSource x:Key="GoIcon" Symbol="ChevronRight" />
</UserControl.Resources>
<StackPanel Spacing="10">
<ui:SettingsExpander Header="{x:Static i18n:Strings.SyncContentControl}" IsExpanded="True">
<ui:SettingsExpander.IconSource>
<ui:FontIconSource Glyph="&#xE8A4;" FontFamily="{StaticResource SymbolThemeFontFamily}" />
</ui:SettingsExpander.IconSource>
<ui:SettingsExpander.Items>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableDownload}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DownloadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUpload}" IsVisible="{Binding IsNormalClientEnable}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding UploadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadText}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding TextEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadMultiFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem IsVisible="{OnPlatform Default=True, macOS=False}" Content="{x:Static i18n:Strings.DoNotUploadWhenCut}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DoNotUploadWhenCut, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.MaxFileSizeToUpload}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding MaxFileSize, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem ActionIconSource="{StaticResource GoIcon}"
IsClickEnabled="True"
Command="{Binding SetFileSyncFilterCommand}"
Content="{x:Static i18n:Strings.FileSyncFilter}" />
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
</StackPanel>
</UserControl>
17 changes: 17 additions & 0 deletions src/SyncClipboard.Desktop/Views/SyncContentControlPage.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Avalonia.Controls;
using Microsoft.Extensions.DependencyInjection;
using SyncClipboard.Core.ViewModels;

namespace SyncClipboard.Desktop.Views;

public partial class SyncContentControlPage : UserControl
{
private readonly SyncSettingViewModel _viewModel;

public SyncContentControlPage()
{
this.InitializeComponent();
_viewModel = App.Current.Services.GetRequiredService<SyncSettingViewModel>();
this.DataContext = _viewModel;
}
}
41 changes: 3 additions & 38 deletions src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,45 +147,10 @@
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding NotifyOnDownloaded, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableDownload}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DownloadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUpload}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding UploadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadText}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding TextEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadMultiFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem IsVisible="{OnPlatform Default=True, macOS=False}" Content="{x:Static i18n:Strings.DoNotUploadWhenCut}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DoNotUploadWhenCut, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.MaxFileSizeToUpload}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding MaxFileSize, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem ActionIconSource="{StaticResource GoIcon}"
<ui:SettingsExpanderItem ActionIconSource="{StaticResource GoIcon}"
IsClickEnabled="True"
Command="{Binding SetFileSyncFilterCommand}"
Content="{x:Static i18n:Strings.FileSyncFilter}" />
Command="{Binding OpenSyncContentControlPageCommand}"
Content="{x:Static i18n:Strings.SyncContentControl}" />
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
</StackPanel>
Expand Down
1 change: 1 addition & 0 deletions src/SyncClipboard.WinUI3/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal void NavigateTo(PageDefinition page,
string pageName = "SyncClipboard.WinUI3.Views." + page.Name + "Page";
Type? pageType = Type.GetType(pageName);
SettingContentFrame.Navigate(pageType, parameter, new SlideNavigationTransitionInfo { Effect = effect });
_ScrollViewer.ScrollToVerticalOffset(0);

// Memory Leak https://github.com/microsoft/microsoft-ui-xaml/issues/5978
GC.Collect();
Expand Down
45 changes: 45 additions & 0 deletions src/SyncClipboard.WinUI3/Views/SyncContentControlPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page x:Class="SyncClipboard.WinUI3.Views.SyncContentControlPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SyncClipboard.WinUI3.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="using:CommunityToolkit.WinUI.Controls"
xmlns:i18n="using:SyncClipboard.Core.I18n"
xmlns:vm="using:SyncClipboard.Core.ViewModels"
xmlns:vc="using:SyncClipboard.WinUI3.ValueConverters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Spacing="10">
<ui:SettingsExpander Header="{x:Bind i18n:Strings.SyncContentControl}" IsExpanded="True">
<ui:SettingsExpander.HeaderIcon>
<FontIcon Glyph="&#xE8A4;" />
</ui:SettingsExpander.HeaderIcon>
<ui:SettingsExpander.Items>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableDownload}" 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.DownloadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUpload}" 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.UploadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadText}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.TextEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadMultiFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.DoNotUploadWhenCut}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.DoNotUploadWhenCut, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.MaxFileSizeToUpload}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.MaxFileSize, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.FileSyncFilter}" IsClickEnabled="True" Command="{x:Bind _viewModel.SetFileSyncFilterCommand}" />
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
</StackPanel>
</Page>
18 changes: 18 additions & 0 deletions src/SyncClipboard.WinUI3/Views/SyncContentControlPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml.Controls;
using SyncClipboard.Core.ViewModels;

namespace SyncClipboard.WinUI3.Views;

/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SyncContentControlPage : Page
{
private readonly SyncSettingViewModel _viewModel;
public SyncContentControlPage()
{
this.InitializeComponent();
_viewModel = App.Current.Services.GetRequiredService<SyncSettingViewModel>();
}
}
23 changes: 1 addition & 22 deletions src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,28 +129,7 @@
<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>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableDownload}" 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.DownloadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUpload}" 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.UploadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadText}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.TextEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadMultiFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.DoNotUploadWhenCut}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.DoNotUploadWhenCut, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.MaxFileSizeToUpload}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.MaxFileSize, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.FileSyncFilter}" IsClickEnabled="True" Command="{x:Bind _viewModel.SetFileSyncFilterCommand}" />
<ui:SettingsCard Header="{x:Bind i18n:Strings.SyncContentControl}" IsClickEnabled="True" Command="{x:Bind _viewModel.OpenSyncContentControlPageCommand}" />
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<local:ServerSettingDialog x:Name="_ServerSettingDialog" PrimaryButtonClick="ServerSettingDialog_OkClick" TextBoxName="{x:Bind i18n:Strings.Port}" />
Expand Down

0 comments on commit d91ff7d

Please sign in to comment.