Skip to content

Commit

Permalink
完成基础关于界面
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Dec 19, 2023
1 parent 9089d79 commit c7dd16c
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 26 deletions.
10 changes: 6 additions & 4 deletions src/UnoFileDownloader/UnoFileDownloader/UnoFileDownloader/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
//.AddJsonTypeInfo(WeatherForecastContext.Default.IImmutableListWeatherForecast)
)
.UseHttp((context, services) => services
// Register HttpClient
// Register HttpClient
#if DEBUG
// DelegatingHandler will be automatically injected into Refit Client
.AddTransient<DelegatingHandler, DebugHttpHandler>()
Expand All @@ -74,17 +74,18 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
MainWindow = builder.Window;

#if DEBUG
MainWindow.EnableHotReload();
MainWindow.EnableHotReload();
#endif

Host = await builder.NavigateAsync<MainPage>();
Host = await builder.NavigateAsync<AboutPage>();
}

private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
views.Register(
new ViewMap(ViewModel: typeof(ShellModel)),
new ViewMap(ViewModel: typeof(ShellModel), View: typeof(Shell)),
new ViewMap<MainPage, MainModel>(),
new ViewMap<AboutPage, AboutModel>(),
new DataViewMap<SecondPage, SecondModel, Entity>()
);

Expand All @@ -94,6 +95,7 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
new RouteMap("Main", View: views.FindByViewModel<MainModel>()),
new RouteMap("Second", View: views.FindByViewModel<SecondModel>()),
new RouteMap("About", View: views.FindByViewModel<AboutModel>()),
}
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

namespace UnoFileDownloader.Presentation
{
public partial record AboutModel
public partial record AboutModel(INavigator Navigator)
{
public void CloseAbout()
{
_ = Navigator.NavigateBackAsync(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,46 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" d:DataContext="{d:DesignInstance local:BindableAboutModel}">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Padding="24,0">
<TextBlock
x:Uid="/AboutPage/GridTitleTextBlock"
Margin="0,0,0,12"
FontSize="24"
FontWeight="SemiBold"
Text="[About NanaGet]" />
<TextBlock>
<Run x:Name="Version" />
<LineBreak />
<Run Text="© M2-Team and Contributors. All rights reserved." />
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" Padding="24">
<!--<Grid.Background>
<SolidColorBrush Opacity="0.2" Color="{ThemeResource SystemChromeHighColor}" />
</Grid.Background>-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="GitHubButton"
Grid.Column="0"
HorizontalAlignment="Stretch"
Click="GitHubButton_Click"
Content="GitHub" />
<Button x:Name="CloseButton"
x:Uid="/AboutPage/CloseButton"
Grid.Column="2"
HorizontalAlignment="Stretch"
Command="{Binding CloseAbout}"
Content="[Close]" />
</Grid>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ public sealed partial class AboutPage : Page
public AboutPage()
{
this.InitializeComponent();

Loaded += AboutPage_Loaded;
}

private void AboutPage_Loaded(object sender, RoutedEventArgs e)
{
}

private void GitHubButton_Click(object sender, RoutedEventArgs e)
{

}

private void CloseButton_Click(object sender, RoutedEventArgs e)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public ShellModel(
INavigator navigator)
{
_navigator = navigator;
//_ = Start(); // 将会导致莫名跳转到 MainPage 界面
_ = Start();
}

public async Task Start()
{
await _navigator.NavigateViewModelAsync<MainModel>(this);
await _navigator.NavigateViewModelAsync<AboutModel>(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,7 @@
<UpToDateCheckInput Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>

<ItemGroup>
<None Remove="Presentation\AboutPage.xaml" />
<None Remove="Presentation\NewTaskPage.xaml" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="Presentation\AboutPage.xaml" />
<UpToDateCheckInput Remove="Presentation\NewTaskPage.xaml" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Remove="Presentation\AboutPage.xaml" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Remove="Presentation\NewTaskPage.xaml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\dotnetCampus.FileDownloader\dotnetCampus.FileDownloader.csproj" />
Expand Down

0 comments on commit c7dd16c

Please sign in to comment.