Skip to content

Commit

Permalink
Merge pull request #61 from dotnet-campus/t/lindexi/Uno
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi authored May 19, 2024
2 parents 1da8977 + 34b9244 commit 7a5b887
Show file tree
Hide file tree
Showing 105 changed files with 468 additions and 1,955 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,5 @@ FodyWeavers.xsd

# Single Target Config
solution-config.props
# Windows Publish Profiles
!**/*.Windows/Properties/PublishProfiles/*.pubxml
# Publish Profiles
!**/Properties/PublishProfiles/*.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
"Microsoft.Component.NetFX.Native",
"Microsoft.VisualStudio.Component.Graphics",
"Microsoft.VisualStudio.Component.Merq",
"Component.Xamarin.RemotedSimulator",
"Microsoft.VisualStudio.Component.MonoDebugger",
"Component.Xamarin",
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
"Component.Android.SDK34",
"Component.Android.SDK33",
"Component.OpenJDK",
"Microsoft.VisualStudio.Workload.NetCrossPlat",
"Microsoft.VisualStudio.Workload.NetCoreTools"
]
Expand Down
23 changes: 23 additions & 0 deletions src/UnoFileDownloader/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project>
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>

<!--
Adding NoWarn to remove build warnings
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
NETSDK1201: Warning that specifying RID won't create self containing app
PRI257: Ignore default language (en) not being one of the included resources (eg en-us, en-uk)
-->
<NoWarn>$(NoWarn);NU1507;NETSDK1201;PRI257</NoWarn>
</PropertyGroup>

<!-- See https://aka.platform.uno/using-uno-sdk#implicit-packages for more information regarding the Implicit Packages version properties. -->
<PropertyGroup>
<UnoExtensionsVersion>4.1.23</UnoExtensionsVersion>
<UnoToolkitVersion>6.0.18</UnoToolkitVersion>
<UnoThemesVersion>5.0.13</UnoThemesVersion>
<UnoCSharpMarkupVersion>5.2.14</UnoCSharpMarkupVersion>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions src/UnoFileDownloader/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Project>
</Project>
9 changes: 9 additions & 0 deletions src/UnoFileDownloader/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project ToolsVersion="15.0">
<!--
To update the version of Uno, you should instead update the Sdk version in the global.json file.
See https://aka.platform.uno/using-uno-sdk for more information.
-->
<ItemGroup>
</ItemGroup>
</Project>
232 changes: 20 additions & 212 deletions src/UnoFileDownloader/UnoFileDownloader.sln

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/UnoFileDownloader/UnoFileDownloader/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Application x:Class="UnoFileDownloader.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:utum="using:Uno.Toolkit.UI.Material">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- Load WinUI resources -->
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<utum:MaterialToolkitTheme
ColorOverrideSource="ms-appx:///Styles/ColorPaletteOverride.xaml">
<!-- NOTE: You can override the default Roboto font by providing your font assets here. -->
<!-- <utum:MaterialToolkitTheme.FontOverrideDictionary>
<ResourceDictionary>
<FontFamily x:Key="MaterialLightFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf#Roboto</FontFamily>
<FontFamily x:Key="MaterialMediumFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf#Roboto</FontFamily>
<FontFamily x:Key="MaterialRegularFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
</ResourceDictionary>
</utum:MaterialToolkitTheme.FontOverrideDictionary> -->
</utum:MaterialToolkitTheme>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

<!-- Add resources here -->

</Application>
193 changes: 193 additions & 0 deletions src/UnoFileDownloader/UnoFileDownloader/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
using System;

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;

using Uno.Resizetizer;
using UnoFileDownloader.Business;
using UnoFileDownloader.Business.Models;
using UnoFileDownloader.Presentation;
using UnoFileDownloader.Utils;

namespace UnoFileDownloader;
public partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}

protected Window? MainWindow { get; private set; }
protected IHost? Host { get; private set; }

protected async override void OnLaunched(LaunchActivatedEventArgs args)
{


var builder = this.CreateBuilder(args)
.UseToolkitNavigation()
.Configure(host =>
{
host.UseConfiguration(configure: configBuilder =>
configBuilder
.EmbeddedSource<App>()
.Section<AppConfig>())
.UseLocalization()
.ConfigureServices((context, services) =>
{
services.AddSingleton<IDispatcherQueueProvider>(c =>
{
return new DispatcherQueueProvider(MainWindow!.DispatcherQueue);
});

// 下载文件管理器
services.AddSingleton<DownloadFileListManager>();
})
.UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes)
;
});
MainWindow = builder.Window;
//MainWindow = new Window();
#if DEBUG
MainWindow.EnableHotReload();
#endif
Host = await builder.NavigateAsync<Shell>();
var localizer = (Uno.Extensions.Localization.ResourceLoaderStringLocalizer) Host.Services.GetRequiredService<IStringLocalizer>();
string title = localizer["ApplicationName"];

MainWindow.Title = title;

//// Do not repeat app initialization when the Window already has content,
//// just ensure that the window is active
//if (MainWindow.Content is not Frame rootFrame)
//{
// // Create a Frame to act as the navigation context and navigate to the first page
// rootFrame = new Frame();

// // Place the frame in the current Window
// MainWindow.Content = rootFrame;

// rootFrame.NavigationFailed += OnNavigationFailed;
//}

//if (rootFrame.Content == null)
//{
// // When the navigation stack isn't restored navigate to the first page,
// // configuring the new page by passing required information as a navigation
// // parameter
// rootFrame.Navigate(typeof(Shell), args.Arguments);
//}

MainWindow.SetWindowIcon();
// Ensure the current window is active
MainWindow.Activate();
}

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

// 必须写注册哦,否则无法跳转
routes.Register
(
new RouteMap("", View: views.FindByViewModel<ShellModel>(),
Nested: new RouteMap[]
{
new RouteMap("Main", View: views.FindByViewModel<MainModel>()),
new RouteMap("Second", View: views.FindByViewModel<SecondModel>()),
new RouteMap("About", View: views.FindByViewModel<AboutModel>()),
new RouteMap("NewTask",View: views.FindByViewModel<NewTaskModel>()),
}
)
);
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
}

/// <summary>
/// Configures global Uno Platform logging
/// </summary>
public static void InitializeLogging()
{
#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// is a concern for your application, keep this disabled. If you're running on the web or
// desktop targets, you can use URL or command line parameters to enable it.
//
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html

var factory = LoggerFactory.Create(builder =>
{
#if __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__ || __MACCATALYST__
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
#else
builder.AddConsole();
#endif

// Exclude logs below this level
builder.SetMinimumLevel(LogLevel.Information);

// Default filters for Uno Platform namespaces
builder.AddFilter("Uno", LogLevel.Warning);
builder.AddFilter("Windows", LogLevel.Warning);
builder.AddFilter("Microsoft", LogLevel.Warning);

// Generic Xaml events
// builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );

// Layouter specific messages
// builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );

// builder.AddFilter("Windows.Storage", LogLevel.Debug );

// Binding related messages
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );

// Binder memory references tracking
// builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );

// DevServer and HotReload related
// builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information);

// Debug JS interop
// builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug );
});

global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;

#if HAS_UNO
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
#endif
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

using UnoFileDownloader.Business.Models;
using UnoFileDownloader.Utils;

namespace UnoFileDownloader.Business
Expand Down
77 changes: 0 additions & 77 deletions src/UnoFileDownloader/UnoFileDownloader/Directory.Build.props

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7a5b887

Please sign in to comment.