From cc5ba5274522d4d96d1d4e648d0e18bcdf447550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sun, 12 Oct 2025 08:31:04 +0200 Subject: [PATCH] =?UTF-8?q?Misslyckat=20l=C3=A4ge=20,=20men=20sparas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoundStartingViewModel.cs | 26 +++++------ Gready_Poang/App.xaml.cs | 20 +++++---- Gready_Poang/AppShell.xaml | 7 ++- Gready_Poang/AppShell.xaml.cs | 17 ++++---- .../RoundStartingViewModelCommands.cs | 13 +++--- Gready_Poang/Core/PageFactory.cs | 10 ++--- Gready_Poang/Gready_Poang.csproj | 11 +++-- Gready_Poang/MauiProgram.cs | 9 ++-- Gready_Poang/Pages/ParticipantListPage.cs | 24 ----------- Gready_Poang/Pages/RoundRunningPage.cs | 43 ------------------- Gready_Poang/Pages/RoundStartingPage.cs | 25 ----------- Gready_Poang/Views/ParticipantListView.xaml | 8 ++-- .../Views/ParticipantListView.xaml.cs | 19 +++++--- Gready_Poang/Views/RoundRunningView.xaml | 9 ++-- Gready_Poang/Views/RoundRunningView.xaml.cs | 11 ++++- Gready_Poang/Views/RoundStartingView.xaml | 4 +- Gready_Poang/Views/RoundStartingView.xaml.cs | 16 +++---- 17 files changed, 96 insertions(+), 176 deletions(-) delete mode 100644 Gready_Poang/Pages/ParticipantListPage.cs delete mode 100644 Gready_Poang/Pages/RoundRunningPage.cs delete mode 100644 Gready_Poang/Pages/RoundStartingPage.cs diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs index 3f8a042..feaef7a 100644 --- a/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs @@ -1,5 +1,4 @@ using Common.Library; -using Gready_Poang.Core; using Gready_Poang.DataLayer; using Gready_Poang.EntityLayer; using Gready_Poang.Services; @@ -21,9 +20,9 @@ public class RoundStartingViewModel : ViewModelBase IMethodSharingService sharingService, ICombinedRepository combined, IObjectMessageService objectMessage, - INavigationService nav, - IPageFactory factory, - ISplashService splashService, + //INavigationService nav, + //IPageFactory factory, + //ISplashService splashService, AppShellViewModel appShellView ) : base() { @@ -32,9 +31,9 @@ public class RoundStartingViewModel : ViewModelBase _sharingService = sharingService; _combined = combined; _objectMessage = objectMessage; - _nav = nav; - _factory = factory; - _splashService = splashService; + //_nav = nav; + //_factory = factory; + //_splashService = splashService; _appShellView = appShellView; _roundElements = new ObservableCollection(); } @@ -49,9 +48,9 @@ public class RoundStartingViewModel : ViewModelBase private readonly IMethodSharingService _sharingService; private readonly ICombinedRepository _combined; private readonly IObjectMessageService _objectMessage; - private readonly INavigationService _nav; - private readonly IPageFactory _factory; - private readonly ISplashService _splashService; + //private readonly INavigationService _nav; + //private readonly IPageFactory _factory; + //private readonly ISplashService _splashService; private readonly AppShellViewModel _appShellView; private Participant _selectedItem; @@ -253,13 +252,10 @@ public class RoundStartingViewModel : ViewModelBase { _objectMessage.CurrentGroup = rbGroup; _objectMessage.Delivered = true; - //await _splashService.ShowSplash("Runda vald, gÃ¥ till\r\r 'PÃ¥börja eller fortsätt Runda'", 3000); - await Shell.Current.GoToAsync("RoundRunningPage"); + await Shell.Current.GoToAsync("RoundRunningView"); _appShellView.RoundRunningVisible = false; - //_roundRunning.GobackVisible = false; - //var page = _factory.CreateRoundPage(); - //_nav.NavigateToPageAsync(page); + } } diff --git a/Gready_Poang/App.xaml.cs b/Gready_Poang/App.xaml.cs index 9af81ab..a605473 100644 --- a/Gready_Poang/App.xaml.cs +++ b/Gready_Poang/App.xaml.cs @@ -1,17 +1,21 @@ using Gready_Poang.DataLayer.Database; +using Gready_Poang.ViewModelLayer; using System.Diagnostics; namespace Gready_Poang; public partial class App : Application { - private readonly IServiceProvider _services; + private readonly AppShellViewModel _shellViewModel; - public App(IServiceProvider services, DataContext dataContext) + //private readonly IServiceProvider _services; + + //public App(IServiceProvider services, DataContext dataContext) + public App(DataContext dataContext, AppShellViewModel shellViewModel) { InitializeComponent(); dataContext.Database.EnsureCreated(); - _services = services; + //_services = services; AppDomain.CurrentDomain.UnhandledException += (sender, e) => { @@ -24,15 +28,13 @@ public partial class App : Application if (Debugger.IsAttached) Debugger.Break(); }; + _shellViewModel = shellViewModel; } protected override Window CreateWindow(IActivationState? activationState) { - - //var splashVm = ServiceLocator.Services.GetRequiredService(); - //var shell = new AppShell(splashVm); - - var shell = _services.GetRequiredService(); - return new Window(shell); + //var shell = _services.GetRequiredService(); + //return new Window(shell); + return new Window(new AppShell(_shellViewModel)); } } \ No newline at end of file diff --git a/Gready_Poang/AppShell.xaml b/Gready_Poang/AppShell.xaml index d8e5967..d53c6b6 100644 --- a/Gready_Poang/AppShell.xaml +++ b/Gready_Poang/AppShell.xaml @@ -5,7 +5,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:vm ="clr-namespace:Gready_Poang.ViewModelLayer;assembly=Gready_Poang.ViewModelLayer" xmlns:views="clr-namespace:Gready_Poang.Views" - xmlns:pages="clr-namespace:Gready_Poang.Pages" xmlns:local="clr-namespace:Gready_Poang" Title="Gready_Poang" Shell.TitleColor="LightYellow" @@ -17,13 +16,13 @@ Title="Home" ContentTemplate="{DataTemplate local:MainPage}" Route="MainPage" /> diff --git a/Gready_Poang/AppShell.xaml.cs b/Gready_Poang/AppShell.xaml.cs index f97eeb6..a2293ce 100644 --- a/Gready_Poang/AppShell.xaml.cs +++ b/Gready_Poang/AppShell.xaml.cs @@ -1,20 +1,19 @@ -using Gready_Poang.Core; -using Gready_Poang.ViewModelLayer; +using Gready_Poang.ViewModelLayer; namespace Gready_Poang { public partial class AppShell : Shell { - private readonly IPageFactory _factory; + //private readonly IPageFactory _factory; - public AppShell(IPageFactory factory, AppShellViewModel appShellView) + //public AppShell(IPageFactory factory, AppShellViewModel appShellView) + public AppShell(AppShellViewModel appShellView) { InitializeComponent(); - - Routing.RegisterRoute("RoundStartingPage", typeof(Pages.RoundStartingPage)); - Routing.RegisterRoute("ParticipantListPage", typeof(Pages.ParticipantListPage)); - Routing.RegisterRoute("RoundRunningPage", typeof(Pages.RoundRunningPage)); - _factory = factory; + Routing.RegisterRoute("ParticipantListView", typeof(Views.ParticipantListView)); + Routing.RegisterRoute("RoundStartingView", typeof(Views.RoundStartingView)); + Routing.RegisterRoute("RoundRunningView", typeof(Views.RoundRunningView)); + //_factory = factory; BindingContext = appShellView; } } diff --git a/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs b/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs index c64ada0..4d28db2 100644 --- a/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs +++ b/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs @@ -1,5 +1,4 @@ using Common.Library; -using Gready_Poang.Core; using Gready_Poang.DataLayer; using Gready_Poang.EntityLayer; using Gready_Poang.Services; @@ -20,18 +19,18 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel IMethodSharingService sharingService, ICombinedRepository combined, IObjectMessageService objectMessage, - INavigationService nav, - IPageFactory factory, - ISplashService splashService, + //INavigationService nav, + //IPageFactory factory, + //ISplashService splashService, AppShellViewModel appShell) : base(roundsRepo, pointsRepo, sharingService, combined, objectMessage, - nav, - factory, - splashService, + //nav, + //factory, + //splashService, appShell) { } diff --git a/Gready_Poang/Core/PageFactory.cs b/Gready_Poang/Core/PageFactory.cs index 718b9ad..509f2c6 100644 --- a/Gready_Poang/Core/PageFactory.cs +++ b/Gready_Poang/Core/PageFactory.cs @@ -1,6 +1,4 @@ -using Gready_Poang.CommandClasses; -using Gready_Poang.Core; -using Gready_Poang.Pages; +using Gready_Poang.Core; namespace Gready_Poang; @@ -15,9 +13,9 @@ public class PageFactory : IPageFactory public Page CreateRoundPage() { - var vm = _services.GetRequiredService(); - var splashVm = _services.GetRequiredService(); - return new RoundRunningPage(vm, splashVm); + //var vm = _services.GetRequiredService(); + //return new RoundRunningView(vm); + return null; } //public Page CreateStatsPage() diff --git a/Gready_Poang/Gready_Poang.csproj b/Gready_Poang/Gready_Poang.csproj index 5f24b19..5ddff03 100644 --- a/Gready_Poang/Gready_Poang.csproj +++ b/Gready_Poang/Gready_Poang.csproj @@ -59,6 +59,14 @@ + + + + + + + + @@ -81,9 +89,6 @@ - - MSBuild:Compile - MSBuild:Compile diff --git a/Gready_Poang/MauiProgram.cs b/Gready_Poang/MauiProgram.cs index ca7cd6f..c11d263 100644 --- a/Gready_Poang/MauiProgram.cs +++ b/Gready_Poang/MauiProgram.cs @@ -41,7 +41,7 @@ public static class MauiProgram options.UseSqlite($"Data Source={dbPath}"); }); - builder.Services.AddScoped(); + // builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -74,8 +74,9 @@ public static class MauiProgram #if DEBUG builder.Logging.AddDebug(); #endif - var app = builder.Build(); - ServiceLocator.Services = app.Services; - return app; + //var app = builder.Build(); + //ServiceLocator.Services = app.Services; + //return app; + return builder.Build(); } } diff --git a/Gready_Poang/Pages/ParticipantListPage.cs b/Gready_Poang/Pages/ParticipantListPage.cs deleted file mode 100644 index 6f1cc90..0000000 --- a/Gready_Poang/Pages/ParticipantListPage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Gready_Poang.CommandClasses; -using Gready_Poang.Views; - -namespace Gready_Poang.Pages; - -public class ParticipantListPage : BasePage -{ - private readonly ParticipantViewModelCommands _vm; - - public ParticipantListPage(ParticipantViewModelCommands vm, SplashViewModelCommands splashVm) - : base(new ParticipantListView(vm), splashVm) - { - Title = "Deltagar Lista"; - _vm = vm; - } - - protected override void OnAppearing() - { - base.OnAppearing(); - BindingContext = _vm; - _vm.Get(); - } - -} diff --git a/Gready_Poang/Pages/RoundRunningPage.cs b/Gready_Poang/Pages/RoundRunningPage.cs deleted file mode 100644 index 81afb70..0000000 --- a/Gready_Poang/Pages/RoundRunningPage.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Gready_Poang.CommandClasses; -using Gready_Poang.Core; -using Gready_Poang.Views; - -namespace Gready_Poang.Pages; - -public class RoundRunningPage : BasePage -{ - private readonly RoundRunningViewModelCommands _vm; - private readonly SplashViewModelCommands _splashVm; - public ISplashService Splash { get; set; } - - public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm) - : base(new RoundRunningView(Vm), splashVm) - { - Title = "Starta/Fortsätt runda"; - _vm = Vm; - Splash = ServiceLocator.Services?.GetRequiredService(); - _splashVm = splashVm; - } - - - public SplashViewModelCommands SplashVm { get; } - - protected override async void OnAppearing() - { - base.OnAppearing(); - BindingContext = _vm; - _vm.Get(); - //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten - //// _vm.RebuildRequested += ViewModel_RebuildRequested; - if (_splashVm != null) - { - await Splash.ShowSplash("Nu kan du spela vidare", 3000); - //await Splash.ShowSplash("Nu kan du spela vidare", 3000).GetAwaiter().GetResult(); - } - //_splashVm.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ; - - } - - - -} diff --git a/Gready_Poang/Pages/RoundStartingPage.cs b/Gready_Poang/Pages/RoundStartingPage.cs deleted file mode 100644 index 4e74b61..0000000 --- a/Gready_Poang/Pages/RoundStartingPage.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Gready_Poang.CommandClasses; -using Gready_Poang.Views; - -namespace Gready_Poang.Pages; - -public class RoundStartingPage : BasePage -{ - private readonly RoundStartingViewModelCommands _vm; - - public RoundStartingPage(RoundStartingViewModelCommands vm, SplashViewModelCommands splashVm) - : base(new RoundStartingView(vm), splashVm) - { - Title = "Starta ny Runda"; - _vm = vm; - } - - protected override void OnAppearing() - { - base.OnAppearing(); - BindingContext = _vm; - _vm.Get(); - _vm.GetParticipants(); - } - -} diff --git a/Gready_Poang/Views/ParticipantListView.xaml b/Gready_Poang/Views/ParticipantListView.xaml index 044f995..6a6b54a 100644 --- a/Gready_Poang/Views/ParticipantListView.xaml +++ b/Gready_Poang/Views/ParticipantListView.xaml @@ -1,13 +1,13 @@ - - + x:Name="ParticipantListPage" + Title="Deltagar Lista"> @@ -86,4 +86,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Gready_Poang/Views/ParticipantListView.xaml.cs b/Gready_Poang/Views/ParticipantListView.xaml.cs index cea01c5..6348b9c 100644 --- a/Gready_Poang/Views/ParticipantListView.xaml.cs +++ b/Gready_Poang/Views/ParticipantListView.xaml.cs @@ -2,23 +2,28 @@ using Gready_Poang.CommandClasses; namespace Gready_Poang.Views; -public partial class ParticipantListView : ContentView +public partial class ParticipantListView : ContentPage { + + private readonly ParticipantViewModelCommands _vm; + public ParticipantListView(ParticipantViewModelCommands viewModel) { InitializeComponent(); ViewModel = viewModel; + _vm = viewModel; + } public ParticipantViewModelCommands ViewModel { get; set; } public int ParticipantId { get; set; } - //protected override void OnAppearing() - //{ - // base.OnAppearing(); - // BindingContext = ViewModel; - // ViewModel.Get(); - //} + protected override void OnAppearing() + { + base.OnAppearing(); + BindingContext = ViewModel; + ViewModel.Get(); + } } diff --git a/Gready_Poang/Views/RoundRunningView.xaml b/Gready_Poang/Views/RoundRunningView.xaml index 7537406..c113f08 100644 --- a/Gready_Poang/Views/RoundRunningView.xaml +++ b/Gready_Poang/Views/RoundRunningView.xaml @@ -1,14 +1,13 @@ - - + Title = "Starta/Fortsätt runda"> @@ -112,4 +111,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Gready_Poang/Views/RoundRunningView.xaml.cs b/Gready_Poang/Views/RoundRunningView.xaml.cs index 06494d0..36cd00b 100644 --- a/Gready_Poang/Views/RoundRunningView.xaml.cs +++ b/Gready_Poang/Views/RoundRunningView.xaml.cs @@ -3,7 +3,7 @@ using Gready_Poang.EntityLayer; namespace Gready_Poang.Views; -public partial class RoundRunningView : ContentView +public partial class RoundRunningView : ContentPage { public RoundRunningView(RoundRunningViewModelCommands viewModel) @@ -13,7 +13,16 @@ public partial class RoundRunningView : ContentView ViewModel.RebuildRequested += ViewModel_RebuildRequested; } + protected override async void OnAppearing() + { + base.OnAppearing(); + BindingContext = ViewModel; + ViewModel.Get(); + //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten + //// _vm.RebuildRequested += ViewModel_RebuildRequested; + //_splashVm.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ; + } private void ViewModel_RebuildRequested(object? sender, EventArgs e) { BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten diff --git a/Gready_Poang/Views/RoundStartingView.xaml b/Gready_Poang/Views/RoundStartingView.xaml index b7c3901..8ed322d 100644 --- a/Gready_Poang/Views/RoundStartingView.xaml +++ b/Gready_Poang/Views/RoundStartingView.xaml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/Gready_Poang/Views/RoundStartingView.xaml.cs b/Gready_Poang/Views/RoundStartingView.xaml.cs index a3f88e1..308b084 100644 --- a/Gready_Poang/Views/RoundStartingView.xaml.cs +++ b/Gready_Poang/Views/RoundStartingView.xaml.cs @@ -2,7 +2,7 @@ using Gready_Poang.CommandClasses; namespace Gready_Poang.Views; -public partial class RoundStartingView : ContentView +public partial class RoundStartingView : ContentPage { @@ -15,13 +15,13 @@ public partial class RoundStartingView : ContentView public int GameRoundId { get; set; } - //protected override void OnAppearing() - //{ - // base.OnAppearing(); - // BindingContext = ViewModel; - // ViewModel.Get(); - // ViewModel.GetParticipants(); - //} + protected override void OnAppearing() + { + base.OnAppearing(); + BindingContext = ViewModel; + ViewModel.Get(); + ViewModel.GetParticipants(); + } protected override void OnSizeAllocated(double width, double height) {