diff --git a/Bookmarkly.Uno/App.xaml b/Bookmarkly.Uno/App.xaml new file mode 100644 index 0000000..3bef818 --- /dev/null +++ b/Bookmarkly.Uno/App.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/Bookmarkly.Uno/App.xaml.cs b/Bookmarkly.Uno/App.xaml.cs new file mode 100644 index 0000000..d9d2083 --- /dev/null +++ b/Bookmarkly.Uno/App.xaml.cs @@ -0,0 +1,134 @@ +#nullable enable +using System; +using Microsoft.Extensions.Logging; +using Uno.Resizetizer; + +namespace Bookmarkly.Uno; + +public partial class App : Application +{ + /// + /// 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(). + /// + public App() + { + this.InitializeComponent(); + } + + protected Window? MainWindow { get; private set; } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + MainWindow = new Window(); +#if DEBUG + MainWindow.UseStudio(); +#endif + + + // 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(MainPage), args.Arguments); + } + + MainWindow.SetWindowIcon(); + // Ensure the current window is active + MainWindow.Activate(); + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}"); + } + + /// + /// Configures global Uno Platform logging + /// + 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__ + builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider()); + + // Log to the Visual Studio Debug console + builder.AddConsole(); +#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 + } +} diff --git a/Bookmarkly.Uno/Assets/Icons/icon.svg b/Bookmarkly.Uno/Assets/Icons/icon.svg new file mode 100644 index 0000000..a15af53 --- /dev/null +++ b/Bookmarkly.Uno/Assets/Icons/icon.svg @@ -0,0 +1,42 @@ + + + + + + diff --git a/Bookmarkly.Uno/Assets/Icons/icon_foreground.svg b/Bookmarkly.Uno/Assets/Icons/icon_foreground.svg new file mode 100644 index 0000000..8ffc41a --- /dev/null +++ b/Bookmarkly.Uno/Assets/Icons/icon_foreground.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bookmarkly.Uno/Assets/SharedAssets.md b/Bookmarkly.Uno/Assets/SharedAssets.md new file mode 100644 index 0000000..b1cc4e7 --- /dev/null +++ b/Bookmarkly.Uno/Assets/SharedAssets.md @@ -0,0 +1,32 @@ +# Shared Assets + +See documentation about assets here: https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-assets.md + +## Here is a cheat sheet + +1. Add the image file to the `Assets` directory of a shared project. +2. Set the build action to `Content`. +3. (Recommended) Provide an asset for various scales/dpi + +### Examples + +```text +\Assets\Images\logo.scale-100.png +\Assets\Images\logo.scale-200.png +\Assets\Images\logo.scale-400.png + +\Assets\Images\scale-100\logo.png +\Assets\Images\scale-200\logo.png +\Assets\Images\scale-400\logo.png +``` + +### Table of scales + +| Scale | WinUI | iOS | Android | +|-------|:-----------:|:---------------:|:-------:| +| `100` | scale-100 | @1x | mdpi | +| `125` | scale-125 | N/A | N/A | +| `150` | scale-150 | N/A | hdpi | +| `200` | scale-200 | @2x | xhdpi | +| `300` | scale-300 | @3x | xxhdpi | +| `400` | scale-400 | N/A | xxxhdpi | diff --git a/Bookmarkly.Uno/Assets/Splash/splash_screen.svg b/Bookmarkly.Uno/Assets/Splash/splash_screen.svg new file mode 100644 index 0000000..8ffc41a --- /dev/null +++ b/Bookmarkly.Uno/Assets/Splash/splash_screen.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bookmarkly.Uno/Bookmarkly.Uno.csproj b/Bookmarkly.Uno/Bookmarkly.Uno.csproj new file mode 100644 index 0000000..249612c --- /dev/null +++ b/Bookmarkly.Uno/Bookmarkly.Uno.csproj @@ -0,0 +1,41 @@ + + + net10.0-desktop + + Exe + true + Bookmarkly.Uno + + + Bookmarkly + + com.bookmarkly.app + + 1.0 + 1 + + Bookmarkly + + Bookmarkly cross-platform app powered by Uno Platform. + + + + SkiaRenderer; + + + + + + diff --git a/Bookmarkly.Uno/GlobalUsings.cs b/Bookmarkly.Uno/GlobalUsings.cs new file mode 100644 index 0000000..aa20bfb --- /dev/null +++ b/Bookmarkly.Uno/GlobalUsings.cs @@ -0,0 +1,9 @@ +global using System; +global using System.Collections.Immutable; +global using System.Collections.ObjectModel; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Logging; +global using Microsoft.UI.Xaml; +global using Microsoft.UI.Xaml.Controls; +global using Microsoft.UI.Xaml.Navigation; +global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState; diff --git a/Bookmarkly.Uno/MainPage.xaml b/Bookmarkly.Uno/MainPage.xaml new file mode 100644 index 0000000..6418e7d --- /dev/null +++ b/Bookmarkly.Uno/MainPage.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Bookmarkly.Uno/MainPage.xaml.cs b/Bookmarkly.Uno/MainPage.xaml.cs new file mode 100644 index 0000000..955be53 --- /dev/null +++ b/Bookmarkly.Uno/MainPage.xaml.cs @@ -0,0 +1,22 @@ +using System.Collections.ObjectModel; + +namespace Bookmarkly.Uno; + +public sealed partial class MainPage : Page +{ + private readonly ObservableCollection datas = new(); + + public MainPage() + { + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + datas.Add(1); + this.InitializeComponent(); + } +} diff --git a/Bookmarkly.Uno/Package.appxmanifest b/Bookmarkly.Uno/Package.appxmanifest new file mode 100644 index 0000000..9ef3814 --- /dev/null +++ b/Bookmarkly.Uno/Package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bookmarkly.Uno/Platforms/Desktop/Program.cs b/Bookmarkly.Uno/Platforms/Desktop/Program.cs new file mode 100644 index 0000000..9fa3c28 --- /dev/null +++ b/Bookmarkly.Uno/Platforms/Desktop/Program.cs @@ -0,0 +1,22 @@ +using Uno.UI.Hosting; + +namespace Bookmarkly.Uno; + +internal class Program +{ + [STAThread] + public static void Main(string[] args) + { + App.InitializeLogging(); + + var host = UnoPlatformHostBuilder.Create() + .App(() => new App()) + .UseX11() + .UseLinuxFrameBuffer() + .UseMacOS() + .UseWin32() + .Build(); + + host.Run(); + } +} diff --git a/Bookmarkly.Uno/Properties/launchSettings.json b/Bookmarkly.Uno/Properties/launchSettings.json new file mode 100644 index 0000000..475eaa0 --- /dev/null +++ b/Bookmarkly.Uno/Properties/launchSettings.json @@ -0,0 +1,22 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8080", + "sslPort": 0 + } + }, + "profiles": { + "Bookmarkly.Uno (Desktop)": { + "commandName": "Project", + "compatibleTargetFramework": "desktop" + }, + "Bookmarkly.Uno (Desktop WSL2)": { + "commandName": "WSL2", + "commandLineArgs": "{ProjectDir}/bin/Debug/net10.0-desktop/Bookmarkly.Uno.dll", + "distributionName": "", + "compatibleTargetFramework": "desktop" + } + } +} diff --git a/Bookmarkly.Uno/Strings/en/Resources.resw b/Bookmarkly.Uno/Strings/en/Resources.resw new file mode 100644 index 0000000..56fe376 --- /dev/null +++ b/Bookmarkly.Uno/Strings/en/Resources.resw @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Bookmarkly.Uno-en + + diff --git a/Bookmarkly.Uno/app.manifest b/Bookmarkly.Uno/app.manifest new file mode 100644 index 0000000..9505c84 --- /dev/null +++ b/Bookmarkly.Uno/app.manifest @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/Bookmarkly.slnx b/Bookmarkly.slnx index 0db10e7..7f33ae3 100644 --- a/Bookmarkly.slnx +++ b/Bookmarkly.slnx @@ -16,10 +16,16 @@ + + + + + + diff --git a/global.json b/global.json new file mode 100644 index 0000000..b3ee12f --- /dev/null +++ b/global.json @@ -0,0 +1,9 @@ +{ + // To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information. + "msbuild-sdks": { + "Uno.Sdk": "6.4.42" + }, + "sdk": { + "allowPrerelease": false + } +}