Skip to content

Commit 27b8985

Browse files
committed
TodoApp.Uno now working without syncing.
1 parent 906aa11 commit 27b8985

File tree

115 files changed

+4015
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4015
-115
lines changed

samples/todoapp/TodoApp.Uno/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<ImplicitUsings>enable</ImplicitUsings>
4-
<Nullable>enable</Nullable>
4+
<!--<Nullable>enable</Nullable>-->
55
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
66

77
<!--

samples/todoapp/TodoApp.Uno/TodoApp.Uno.sln

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.10.35201.131
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoApp.Uno", "TodoApp.Uno\TodoApp.Uno.csproj", "{5FD4876C-302E-42DF-B28B-55035009E545}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApp.Uno", "TodoApp.Uno\TodoApp.Uno.csproj", "{5FD4876C-302E-42DF-B28B-55035009E545}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F20ED0E3-BD89-4202-A1C8-E809AA315AFB}"
99
ProjectSection(SolutionItems) = preProject
@@ -14,6 +14,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
global.json = global.json
1515
EndProjectSection
1616
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "library", "library", "{0AAB65A5-8A90-47AF-AAED-AF27E82D50A4}"
18+
EndProject
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Client", "..\..\..\src\CommunityToolkit.Datasync.Client\CommunityToolkit.Datasync.Client.csproj", "{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963}"
20+
EndProject
1721
Global
1822
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1923
Debug|Any CPU = Debug|Any CPU
@@ -26,10 +30,17 @@ Global
2630
{5FD4876C-302E-42DF-B28B-55035009E545}.Release|Any CPU.ActiveCfg = Release|Any CPU
2731
{5FD4876C-302E-42DF-B28B-55035009E545}.Release|Any CPU.Build.0 = Release|Any CPU
2832
{5FD4876C-302E-42DF-B28B-55035009E545}.Release|Any CPU.Deploy.0 = Release|Any CPU
33+
{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963}.Release|Any CPU.Build.0 = Release|Any CPU
2937
EndGlobalSection
3038
GlobalSection(SolutionProperties) = preSolution
3139
HideSolutionNode = FALSE
3240
EndGlobalSection
41+
GlobalSection(NestedProjects) = preSolution
42+
{2D6F113F-D3A1-43A5-BF57-E72E5D5F5963} = {0AAB65A5-8A90-47AF-AAED-AF27E82D50A4}
43+
EndGlobalSection
3344
GlobalSection(ExtensibilityGlobals) = postSolution
3445
SolutionGuid = {EA315B6A-4F6C-4482-A88B-61900C1B6934}
3546
EndGlobalSection

samples/todoapp/TodoApp.Uno/TodoApp.Uno/App.xaml.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
using System;
2+
using Microsoft.Data.Sqlite;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.UI.Xaml;
6+
using Microsoft.UI.Xaml.Controls;
7+
using TodoApp.Uno.Database;
8+
using TodoApp.Uno.ViewModels;
9+
using TodoApp.Uno.Views;
110
using Uno.Resizetizer;
211

312
namespace TodoApp.Uno;
@@ -10,13 +19,20 @@ public partial class App : Application
1019
public App()
1120
{
1221
this.InitializeComponent();
22+
23+
1324
}
1425

1526
protected Window? MainWindow { get; private set; }
16-
protected IHost? Host { get; private set; }
27+
public IHost? Host { get; private set; }
28+
29+
private SqliteConnection dbConnection;
1730

1831
protected async override void OnLaunched(LaunchActivatedEventArgs args)
1932
{
33+
this.dbConnection = new SqliteConnection("Data Source=:memory:");
34+
this.dbConnection.Open();
35+
2036
var builder = this.CreateBuilder(args)
2137
// Add navigation support for toolkit controls such as TabBar and NavigationView
2238
.UseToolkitNavigation()
@@ -78,6 +94,9 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
7894
{
7995
// TODO: Register your services
8096
//services.AddSingleton<IMyService, MyService>();
97+
services.AddTransient<TodoListViewModel>();
98+
services.AddScoped<IDbInitializer, DbContextInitializer>();
99+
services.AddDbContext<AppDbContext>(options => options.UseSqlite(this.dbConnection));
81100
})
82101
.UseNavigation(RegisterRoutes)
83102
);
@@ -88,23 +107,35 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
88107
#endif
89108
MainWindow.SetWindowIcon();
90109

110+
//Host = builder.Build();
111+
91112
Host = await builder.NavigateAsync<Shell>();
113+
114+
InitializeDatabase();
115+
}
116+
117+
private void InitializeDatabase()
118+
{
119+
IDbInitializer? initializer = Host?.Services?.GetRequiredService<IDbInitializer>();
120+
initializer?.Initialize();
92121
}
93122

94123
private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
95124
{
96125
views.Register(
97126
new ViewMap(ViewModel: typeof(ShellViewModel)),
98127
new ViewMap<MainPage, MainViewModel>(),
99-
new DataViewMap<SecondPage, SecondViewModel, Entity>()
128+
new DataViewMap<SecondPage, SecondViewModel, Entity>(),
129+
new ViewMap<TodoListPage, TodoListViewModel>()
100130
);
101131

102132
routes.Register(
103133
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
104134
Nested:
105135
[
106-
new ("Main", View: views.FindByViewModel<MainViewModel>(), IsDefault:true),
136+
new ("Main", View: views.FindByViewModel<MainViewModel>(), IsDefault: false),
107137
new ("Second", View: views.FindByViewModel<SecondViewModel>()),
138+
new ("TodoList", View: views.FindByViewModel<TodoListViewModel>(), IsDefault: true)
108139
]
109140
)
110141
);
373 Bytes
Loading
432 Bytes
Loading
866 Bytes
Loading
5.25 KB
Loading
1.71 KB
Loading
637 Bytes
Loading
283 Bytes
Loading

0 commit comments

Comments
 (0)