Misslyckat läge , men sparas

This commit is contained in:
2025-10-12 08:31:04 +02:00
parent 18f0dc566b
commit cc5ba52745
17 changed files with 96 additions and 176 deletions

View File

@ -1,5 +1,4 @@
using Common.Library; using Common.Library;
using Gready_Poang.Core;
using Gready_Poang.DataLayer; using Gready_Poang.DataLayer;
using Gready_Poang.EntityLayer; using Gready_Poang.EntityLayer;
using Gready_Poang.Services; using Gready_Poang.Services;
@ -21,9 +20,9 @@ public class RoundStartingViewModel : ViewModelBase
IMethodSharingService<Participant> sharingService, IMethodSharingService<Participant> sharingService,
ICombinedRepository combined, ICombinedRepository combined,
IObjectMessageService objectMessage, IObjectMessageService objectMessage,
INavigationService nav, //INavigationService nav,
IPageFactory factory, //IPageFactory factory,
ISplashService splashService, //ISplashService splashService,
AppShellViewModel appShellView AppShellViewModel appShellView
) : base() ) : base()
{ {
@ -32,9 +31,9 @@ public class RoundStartingViewModel : ViewModelBase
_sharingService = sharingService; _sharingService = sharingService;
_combined = combined; _combined = combined;
_objectMessage = objectMessage; _objectMessage = objectMessage;
_nav = nav; //_nav = nav;
_factory = factory; //_factory = factory;
_splashService = splashService; //_splashService = splashService;
_appShellView = appShellView; _appShellView = appShellView;
_roundElements = new ObservableCollection<RoundBuilderElement>(); _roundElements = new ObservableCollection<RoundBuilderElement>();
} }
@ -49,9 +48,9 @@ public class RoundStartingViewModel : ViewModelBase
private readonly IMethodSharingService<Participant> _sharingService; private readonly IMethodSharingService<Participant> _sharingService;
private readonly ICombinedRepository _combined; private readonly ICombinedRepository _combined;
private readonly IObjectMessageService _objectMessage; private readonly IObjectMessageService _objectMessage;
private readonly INavigationService _nav; //private readonly INavigationService _nav;
private readonly IPageFactory _factory; //private readonly IPageFactory _factory;
private readonly ISplashService _splashService; //private readonly ISplashService _splashService;
private readonly AppShellViewModel _appShellView; private readonly AppShellViewModel _appShellView;
private Participant _selectedItem; private Participant _selectedItem;
@ -253,13 +252,10 @@ public class RoundStartingViewModel : ViewModelBase
{ {
_objectMessage.CurrentGroup = rbGroup; _objectMessage.CurrentGroup = rbGroup;
_objectMessage.Delivered = true; _objectMessage.Delivered = true;
//await _splashService.ShowSplash("Runda vald, gå till\r\r 'Påbörja eller fortsätt Runda'", 3000); await Shell.Current.GoToAsync("RoundRunningView");
await Shell.Current.GoToAsync("RoundRunningPage");
_appShellView.RoundRunningVisible = false; _appShellView.RoundRunningVisible = false;
//_roundRunning.GobackVisible = false;
//var page = _factory.CreateRoundPage();
//_nav.NavigateToPageAsync(page);
} }
} }

View File

@ -1,17 +1,21 @@
using Gready_Poang.DataLayer.Database; using Gready_Poang.DataLayer.Database;
using Gready_Poang.ViewModelLayer;
using System.Diagnostics; using System.Diagnostics;
namespace Gready_Poang; namespace Gready_Poang;
public partial class App : Application 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(); InitializeComponent();
dataContext.Database.EnsureCreated(); dataContext.Database.EnsureCreated();
_services = services; //_services = services;
AppDomain.CurrentDomain.UnhandledException += (sender, e) => AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{ {
@ -24,15 +28,13 @@ public partial class App : Application
if (Debugger.IsAttached) if (Debugger.IsAttached)
Debugger.Break(); Debugger.Break();
}; };
_shellViewModel = shellViewModel;
} }
protected override Window CreateWindow(IActivationState? activationState) protected override Window CreateWindow(IActivationState? activationState)
{ {
//var shell = _services.GetRequiredService<AppShell>();
//var splashVm = ServiceLocator.Services.GetRequiredService<SplashViewModelCommands>(); //return new Window(shell);
//var shell = new AppShell(splashVm); return new Window(new AppShell(_shellViewModel));
var shell = _services.GetRequiredService<AppShell>();
return new Window(shell);
} }
} }

View File

@ -5,7 +5,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vm ="clr-namespace:Gready_Poang.ViewModelLayer;assembly=Gready_Poang.ViewModelLayer" xmlns:vm ="clr-namespace:Gready_Poang.ViewModelLayer;assembly=Gready_Poang.ViewModelLayer"
xmlns:views="clr-namespace:Gready_Poang.Views" xmlns:views="clr-namespace:Gready_Poang.Views"
xmlns:pages="clr-namespace:Gready_Poang.Pages"
xmlns:local="clr-namespace:Gready_Poang" xmlns:local="clr-namespace:Gready_Poang"
Title="Gready_Poang" Title="Gready_Poang"
Shell.TitleColor="LightYellow" Shell.TitleColor="LightYellow"
@ -17,13 +16,13 @@
Title="Home" ContentTemplate="{DataTemplate local:MainPage}" Title="Home" ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" /> Route="MainPage" />
<ShellContent <ShellContent
Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}" Title="Deltagare" ContentTemplate="{DataTemplate views:ParticipantListView}"
Route="ParticipantListPage"/> Route="ParticipantListPage"/>
<ShellContent <ShellContent
Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}" Title="Ny Runda" ContentTemplate="{DataTemplate views:RoundStartingView}"
Route="RoundStartingPage"/> Route="RoundStartingPage"/>
<ShellContent <ShellContent
Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}" Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate views:RoundRunningView}"
Route="RoundRunningPage" IsVisible="{Binding RoundRunningVisible}"/> Route="RoundRunningPage" IsVisible="{Binding RoundRunningVisible}"/>
</TabBar> </TabBar>

View File

@ -1,20 +1,19 @@
using Gready_Poang.Core; using Gready_Poang.ViewModelLayer;
using Gready_Poang.ViewModelLayer;
namespace Gready_Poang namespace Gready_Poang
{ {
public partial class AppShell : Shell 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(); InitializeComponent();
Routing.RegisterRoute("ParticipantListView", typeof(Views.ParticipantListView));
Routing.RegisterRoute("RoundStartingPage", typeof(Pages.RoundStartingPage)); Routing.RegisterRoute("RoundStartingView", typeof(Views.RoundStartingView));
Routing.RegisterRoute("ParticipantListPage", typeof(Pages.ParticipantListPage)); Routing.RegisterRoute("RoundRunningView", typeof(Views.RoundRunningView));
Routing.RegisterRoute("RoundRunningPage", typeof(Pages.RoundRunningPage)); //_factory = factory;
_factory = factory;
BindingContext = appShellView; BindingContext = appShellView;
} }
} }

View File

@ -1,5 +1,4 @@
using Common.Library; using Common.Library;
using Gready_Poang.Core;
using Gready_Poang.DataLayer; using Gready_Poang.DataLayer;
using Gready_Poang.EntityLayer; using Gready_Poang.EntityLayer;
using Gready_Poang.Services; using Gready_Poang.Services;
@ -20,18 +19,18 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
IMethodSharingService<Participant> sharingService, IMethodSharingService<Participant> sharingService,
ICombinedRepository combined, ICombinedRepository combined,
IObjectMessageService objectMessage, IObjectMessageService objectMessage,
INavigationService nav, //INavigationService nav,
IPageFactory factory, //IPageFactory factory,
ISplashService splashService, //ISplashService splashService,
AppShellViewModel appShell) AppShellViewModel appShell)
: base(roundsRepo, : base(roundsRepo,
pointsRepo, pointsRepo,
sharingService, sharingService,
combined, combined,
objectMessage, objectMessage,
nav, //nav,
factory, //factory,
splashService, //splashService,
appShell) appShell)
{ {
} }

View File

@ -1,6 +1,4 @@
using Gready_Poang.CommandClasses; using Gready_Poang.Core;
using Gready_Poang.Core;
using Gready_Poang.Pages;
namespace Gready_Poang; namespace Gready_Poang;
@ -15,9 +13,9 @@ public class PageFactory : IPageFactory
public Page CreateRoundPage() public Page CreateRoundPage()
{ {
var vm = _services.GetRequiredService<RoundRunningViewModelCommands>(); //var vm = _services.GetRequiredService<RoundRunningViewModelCommands>();
var splashVm = _services.GetRequiredService<SplashViewModelCommands>(); //return new RoundRunningView(vm);
return new RoundRunningPage(vm, splashVm); return null;
} }
//public Page CreateStatsPage() //public Page CreateStatsPage()

View File

@ -59,6 +59,14 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Remove="BasePage.xaml.cs" />
</ItemGroup>
<ItemGroup>
<MauiXaml Remove="BasePage.xaml" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" /> <PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
@ -81,9 +89,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MauiXaml Update="BasePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Styles\AppStyles.xaml"> <MauiXaml Update="Resources\Styles\AppStyles.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>

View File

@ -41,7 +41,7 @@ public static class MauiProgram
options.UseSqlite($"Data Source={dbPath}"); options.UseSqlite($"Data Source={dbPath}");
}); });
builder.Services.AddScoped<IPageFactory, PageFactory>(); // builder.Services.AddScoped<IPageFactory, PageFactory>();
builder.Services.AddSingleton<INavigationService, NavigationService>(); builder.Services.AddSingleton<INavigationService, NavigationService>();
builder.Services.AddSingleton<IServiceLocator, ServiceLocator>(); builder.Services.AddSingleton<IServiceLocator, ServiceLocator>();
@ -74,8 +74,9 @@ public static class MauiProgram
#if DEBUG #if DEBUG
builder.Logging.AddDebug(); builder.Logging.AddDebug();
#endif #endif
var app = builder.Build(); //var app = builder.Build();
ServiceLocator.Services = app.Services; //ServiceLocator.Services = app.Services;
return app; //return app;
return builder.Build();
} }
} }

View File

@ -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();
}
}

View File

@ -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<ISplashService>();
_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(); ;
}
}

View File

@ -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();
}
}

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial" xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial"
xmlns:vm="clr-namespace:Gready_Poang.CommandClasses" xmlns:vm="clr-namespace:Gready_Poang.CommandClasses"
xmlns:model="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer" xmlns:model="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer"
x:Class="Gready_Poang.Views.ParticipantListView" x:Class="Gready_Poang.Views.ParticipantListView"
x:DataType="vm:ParticipantViewModelCommands" x:DataType="vm:ParticipantViewModelCommands"
x:Name="ParticipantListPage"> x:Name="ParticipantListPage"
<!--Title="Deltagar Lista"--> Title="Deltagar Lista">
<Border Style="{StaticResource Border.Page}" StrokeThickness="4"> <Border Style="{StaticResource Border.Page}" StrokeThickness="4">
<Grid Style="{StaticResource Grid.Page}"> <Grid Style="{StaticResource Grid.Page}">
@ -86,4 +86,4 @@
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
</ContentView> </ContentPage>

View File

@ -2,23 +2,28 @@ using Gready_Poang.CommandClasses;
namespace Gready_Poang.Views; namespace Gready_Poang.Views;
public partial class ParticipantListView : ContentView public partial class ParticipantListView : ContentPage
{ {
private readonly ParticipantViewModelCommands _vm;
public ParticipantListView(ParticipantViewModelCommands viewModel) public ParticipantListView(ParticipantViewModelCommands viewModel)
{ {
InitializeComponent(); InitializeComponent();
ViewModel = viewModel; ViewModel = viewModel;
_vm = viewModel;
} }
public ParticipantViewModelCommands ViewModel { get; set; } public ParticipantViewModelCommands ViewModel { get; set; }
public int ParticipantId { get; set; } public int ParticipantId { get; set; }
//protected override void OnAppearing() protected override void OnAppearing()
//{ {
// base.OnAppearing(); base.OnAppearing();
// BindingContext = ViewModel; BindingContext = ViewModel;
// ViewModel.Get(); ViewModel.Get();
//} }
} }

View File

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial" xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial"
x:Class="Gready_Poang.Views.RoundRunningView" x:Class="Gready_Poang.Views.RoundRunningView"
xmlns:vm ="clr-namespace:Gready_Poang.CommandClasses" xmlns:vm="clr-namespace:Gready_Poang.CommandClasses"
xmlns:behaviors="clr-namespace:Gready_Poang.Common;assembly=Gready_Poang.Common" xmlns:behaviors="clr-namespace:Gready_Poang.Common;assembly=Gready_Poang.Common"
xmlns:local="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer" xmlns:local="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer"
xmlns:model="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer" xmlns:model="clr-namespace:Gready_Poang.EntityLayer;assembly=Gready_Poang.EntityLayer"
x:DataType="vm:RoundRunningViewModelCommands"> Title = "Starta/Fortsätt runda">
<!--Title="RoundRunningView"-->
<Border Style="{StaticResource Border.Page}" StrokeThickness="4"> <Border Style="{StaticResource Border.Page}" StrokeThickness="4">
<Grid Style="{StaticResource Grid.Page}"> <Grid Style="{StaticResource Grid.Page}">
@ -112,4 +111,4 @@
</ScrollView> </ScrollView>
</Grid> </Grid>
</Border> </Border>
</ContentView> </ContentPage>

View File

@ -3,7 +3,7 @@ using Gready_Poang.EntityLayer;
namespace Gready_Poang.Views; namespace Gready_Poang.Views;
public partial class RoundRunningView : ContentView public partial class RoundRunningView : ContentPage
{ {
public RoundRunningView(RoundRunningViewModelCommands viewModel) public RoundRunningView(RoundRunningViewModelCommands viewModel)
@ -13,7 +13,16 @@ public partial class RoundRunningView : ContentView
ViewModel.RebuildRequested += ViewModel_RebuildRequested; 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) private void ViewModel_RebuildRequested(object? sender, EventArgs e)
{ {
BuildScoreGrid(ViewModel.PlayerColumns); // <-- h<>r bygger du layouten BuildScoreGrid(ViewModel.PlayerColumns); // <-- h<>r bygger du layouten

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial" xmlns:partial="clr-namespace:Gready_Poang.ViewsPartial"
x:Class="Gready_Poang.Views.RoundStartingView" x:Class="Gready_Poang.Views.RoundStartingView"
@ -151,4 +151,4 @@
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
</ContentView> </ContentPage>

View File

@ -2,7 +2,7 @@ using Gready_Poang.CommandClasses;
namespace Gready_Poang.Views; 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; } public int GameRoundId { get; set; }
//protected override void OnAppearing() protected override void OnAppearing()
//{ {
// base.OnAppearing(); base.OnAppearing();
// BindingContext = ViewModel; BindingContext = ViewModel;
// ViewModel.Get(); ViewModel.Get();
// ViewModel.GetParticipants(); ViewModel.GetParticipants();
//} }
protected override void OnSizeAllocated(double width, double height) protected override void OnSizeAllocated(double width, double height)
{ {