Skip to content

Commit

Permalink
Uno samples
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Feb 9, 2025
1 parent f8e2c57 commit 4e2cdda
Show file tree
Hide file tree
Showing 55 changed files with 1,766 additions and 11 deletions.
3 changes: 3 additions & 0 deletions ShinyMediator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shiny.Mediator.DapperReques
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shiny.Mediator.Uno", "src\Shiny.Mediator.Uno\Shiny.Mediator.Uno.csproj", "{24DB79F2-629D-45C2-A63A-1780D6A6C921}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Uno", "samples\Sample.Uno\Sample.Uno.csproj", "{A8B5A8CC-77FA-49C4-9251-3F65959FC591}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -132,5 +134,6 @@ Global
{D5E10100-9EE4-4ED7-B1F4-2B22E37225C6} = {967E9F7E-D082-4E7F-934B-D3BD05D1C22F}
{A94FECD0-EB11-4D77-83F5-E3D25820C79B} = {967E9F7E-D082-4E7F-934B-D3BD05D1C22F}
{AFEE02F0-ED0D-4257-BA65-DDBFBB31CB5B} = {967E9F7E-D082-4E7F-934B-D3BD05D1C22F}
{A8B5A8CC-77FA-49C4-9251-3F65959FC591} = {967E9F7E-D082-4E7F-934B-D3BD05D1C22F}
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions samples/Sample.Uno/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Application x:Class="Sample.Uno.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>

<!-- Add resources here -->

</ResourceDictionary>
</Application.Resources>

</Application>
105 changes: 105 additions & 0 deletions samples/Sample.Uno/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Microsoft.UI.Xaml;
using Shiny.Mediator;
using Uno.Extensions;
using Uno.Extensions.Configuration;
using Uno.Extensions.Hosting;
using Uno.Extensions.Navigation;
using Uno.Resizetizer;
using Uno.UI;
using Window = ABI.Microsoft.UI.Xaml.Window;

namespace Sample.Uno;

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)
// Add navigation support for toolkit controls such as TabBar and NavigationView
.UseToolkitNavigation()
.Configure(host => host
#if DEBUG
// Switch to Development environment when running in DEBUG
.UseEnvironment(Environments.Development)
#endif
.UseLogging(configure: (context, logBuilder) =>
{
// Configure log levels for different categories of logging
logBuilder
.SetMinimumLevel(
context.HostingEnvironment.IsDevelopment() ? LogLevel.Information : LogLevel.Warning)

// Default filters for core Uno Platform namespaces
.CoreLogLevel(LogLevel.Warning);

// Uno Platform namespace filter groups
// Uncomment individual methods to see more detailed logging
//// Generic Xaml events
//logBuilder.XamlLogLevel(LogLevel.Debug);
//// Layout specific messages
//logBuilder.XamlLayoutLogLevel(LogLevel.Debug);
//// Storage messages
//logBuilder.StorageLogLevel(LogLevel.Debug);
//// Binding related messages
//logBuilder.XamlBindingLogLevel(LogLevel.Debug);
//// Binder memory references tracking
//logBuilder.BinderMemoryReferenceLogLevel(LogLevel.Debug);
//// DevServer and HotReload related
//logBuilder.HotReloadCoreLogLevel(LogLevel.Information);
//// Debug JS interop
//logBuilder.WebAssemblyLogLevel(LogLevel.Debug);
}, enableUnoLogging: true)
.UseConfiguration(configure: configBuilder =>
configBuilder
.EmbeddedSource<App>()
.Section<AppConfig>()
)
.ConfigureServices((context, services) =>
{
// TODO: Register your services
//services.AddSingleton<IMyService, MyService>();
})
.UseNavigation(RegisterRoutes)
.AddShinyMediator()
);
MainWindow = builder.Window;

#if DEBUG
MainWindow.UseStudio();
#endif
MainWindow.SetWindowIcon();

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

private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
views.Register(
new ViewMap(ViewModel: typeof(ShellViewModel)),
new ViewMap<MainPage, MainViewModel>(),
new DataViewMap<SecondPage, SecondViewModel, Entity>()
);

routes.Register(
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
Nested:
[
new("Main", View: views.FindByViewModel<MainViewModel>(), IsDefault: true),
new("Second", View: views.FindByViewModel<SecondViewModel>()),
]
)
);
}
}
42 changes: 42 additions & 0 deletions samples/Sample.Uno/Assets/Icons/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions samples/Sample.Uno/Assets/Icons/icon_foreground.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions samples/Sample.Uno/Assets/Images/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions samples/Sample.Uno/Assets/SharedAssets.md
Original file line number Diff line number Diff line change
@@ -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/MacCatalyst | 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 |
Loading

0 comments on commit 4e2cdda

Please sign in to comment.