diff --git a/GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj b/GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj new file mode 100644 index 0000000..b5d6b07 --- /dev/null +++ b/GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj @@ -0,0 +1,15 @@ + + + + net9.0 + enable + enable + + + + + + + + + diff --git a/GreadyPoang.ViewModelLayer/Interfaces/INavigationService.cs b/GreadyPoang.ViewModelLayer/Interfaces/INavigationService.cs new file mode 100644 index 0000000..d3658ae --- /dev/null +++ b/GreadyPoang.ViewModelLayer/Interfaces/INavigationService.cs @@ -0,0 +1,8 @@ +namespace GreadyPoang.Core; + +public interface INavigationService +{ + Task NavigateToAsync(string route); + Task NavigateToPageAsync(Page page); +} + diff --git a/GreadyPoang.ViewModelLayer/Interfaces/IOverlayService.cs b/GreadyPoang.ViewModelLayer/Interfaces/IOverlayService.cs new file mode 100644 index 0000000..66034e1 --- /dev/null +++ b/GreadyPoang.ViewModelLayer/Interfaces/IOverlayService.cs @@ -0,0 +1,7 @@ +namespace GreadyPoang.Core; + +public interface IOverlayService +{ + void ShowSplash(string text, int duration); + void HideSplash(); +} diff --git a/GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs b/GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs new file mode 100644 index 0000000..b45d9df --- /dev/null +++ b/GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs @@ -0,0 +1,6 @@ +namespace GreadyPoang.Core; + +public interface IPageFactory +{ + Page CreateRoundPage(); +} \ No newline at end of file diff --git a/GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs b/GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs new file mode 100644 index 0000000..31d5247 --- /dev/null +++ b/GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs @@ -0,0 +1,9 @@ + +namespace GreadyPoang.Core; + +public interface ISplashService +{ + Task ShowSplash(string text = "Välkommen!", int durationMs = 3000); + Task HideAsync(); + +} \ No newline at end of file diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs index d846c6f..8443623 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs @@ -4,6 +4,7 @@ using GreadyPoang.EntityLayer; using GreadyPoang.Services; using System.Collections.ObjectModel; using System.Diagnostics; +using GreadyPoang.Core; namespace GreadyPoang.ViewModelLayer; @@ -22,7 +23,8 @@ public class RoundRunningViewModel : ViewModelBase IRepository pointsRepo, IMethodSharingService sharingService, ICombinedRepository combined, - IObjectMessageService objectMessage + IObjectMessageService objectMessage, + IOverlayService overlay ) : base() { _roundsRepo = roundsRepo; @@ -30,6 +32,7 @@ public class RoundRunningViewModel : ViewModelBase _sharingService = sharingService; _combined = combined; _objectMessage = objectMessage; + _overlay = overlay; _roundElements = new ObservableCollection(); _builderObject = new(); } @@ -39,7 +42,7 @@ public class RoundRunningViewModel : ViewModelBase private readonly IMethodSharingService _sharingService; private readonly ICombinedRepository _combined; private readonly IObjectMessageService _objectMessage; - + private readonly IOverlayService _overlay; private ObservableCollection _GameRoundList = new(); private ObservableCollection _ParticipantList = new(); private ObservableCollection _roundElements; @@ -86,6 +89,7 @@ public class RoundRunningViewModel : ViewModelBase public ObservableCollection Get() { + _overlay.ShowSplash("Laddar...", 3000); if (_objectMessage.CurrentGroup != null) { diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs index aafa65c..a657911 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs @@ -1,4 +1,5 @@ using Common.Library; +using GreadyPoang.Core; using GreadyPoang.DataLayer; using GreadyPoang.EntityLayer; using GreadyPoang.Services; @@ -12,7 +13,6 @@ public class RoundStartingViewModel : ViewModelBase #region Constructors public RoundStartingViewModel() : base() { - } public RoundStartingViewModel( @@ -20,13 +20,17 @@ public class RoundStartingViewModel : ViewModelBase IRepository pointsRepo, IMethodSharingService sharingService, ICombinedRepository combined, - IObjectMessageService objectMessage) : base() + IObjectMessageService objectMessage, + INavigationService nav, + IPageFactory factory) : base() { _roundsRepo = roundsRepo; _pointsRepo = pointsRepo; _sharingService = sharingService; _combined = combined; _objectMessage = objectMessage; + _nav = nav; + _factory = factory; _roundElements = new ObservableCollection(); } @@ -40,6 +44,8 @@ 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 Participant _selectedItem; private ObservableCollection _roundElements; @@ -239,10 +245,13 @@ public class RoundStartingViewModel : ViewModelBase if (rbGroup != null) { _objectMessage.CurrentGroup = rbGroup; - Shell.Current.GoToAsync("//RoundRunningView"); + //Shell.Current.GoToAsync("//RoundRunningPage"); + var page = _factory.CreateRoundPage(); + _nav.NavigateToPageAsync(page); } } + public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder) { Debug.WriteLine($"Du valde raden med Runda {roundBuilder.GameRoundId} och spelare: {roundBuilder.ParticipantName}"); diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs new file mode 100644 index 0000000..7c571b6 --- /dev/null +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs @@ -0,0 +1,65 @@ +using Common.Library; + +namespace GreadyPoang.ViewModelLayer; + +public class SplashViewModel : ViewModelBase +{ + // public event PropertyChangedEventHandler PropertyChanged; + + private bool _isSplashVisible = true; + public bool IsSplashVisible + { + get => _isSplashVisible; + set + { + _isSplashVisible = value; + RaisePropertyChanged(nameof(IsSplashVisible)); + } + } + + private double _splashOpacity = 1.0; + public double SplashOpacity + { + get => _splashOpacity; + set + { + _splashOpacity = value; + RaisePropertyChanged(nameof(SplashOpacity)); + } + } + + private double _splashTranslationY = 0; + public double SplashTranslationY + { + get => _splashTranslationY; + set + { + _splashTranslationY = value; + RaisePropertyChanged(nameof(SplashTranslationY)); + } + } + + public async Task HideSplashAsync() + { + await Task.Delay(1000); // Simulera laddning + await AnimateSplashOut(); + IsSplashVisible = false; + } + + public string SplashText { get; set; } = "Välkommen!"; + public Color SplashBackgroundColor { get; set; } = Colors.DarkSlateBlue; + public string SplashImage { get; set; } = "splash_icon.png"; + + //protected void OnPropertyChanged(string name) => + // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); + + private async Task AnimateSplashOut() + { + for (int i = 0; i < 10; i++) + { + SplashOpacity -= 0.1; + SplashTranslationY += 5; + await Task.Delay(30); + } + } +} diff --git a/GreadyPoang.sln b/GreadyPoang.sln index fa48196..cb7d75e 100644 --- a/GreadyPoang.sln +++ b/GreadyPoang.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36408.4 +VisualStudioVersion = 17.14.36518.9 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang", "GreadyPoang\GreadyPoang.csproj", "{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}" EndProject diff --git a/GreadyPoang/App.xaml.cs b/GreadyPoang/App.xaml.cs index bd8dfde..31c9041 100644 --- a/GreadyPoang/App.xaml.cs +++ b/GreadyPoang/App.xaml.cs @@ -1,18 +1,25 @@ using GreadyPoang.DataLayer.Database; -namespace GreadyPoang -{ - public partial class App : Application - { - public App(DataContext dataContext) - { - InitializeComponent(); - dataContext.Database.EnsureCreated(); - } +namespace GreadyPoang; - protected override Window CreateWindow(IActivationState? activationState) - { - return new Window(new AppShell()); - } +public partial class App : Application +{ + private readonly IServiceProvider _services; + + public App(IServiceProvider services, DataContext dataContext) + { + InitializeComponent(); + dataContext.Database.EnsureCreated(); + _services = services; + } + + protected override Window CreateWindow(IActivationState? activationState) + { + + //var splashVm = ServiceLocator.Services.GetRequiredService(); + //var shell = new AppShell(splashVm); + + var shell = _services.GetRequiredService(); + return new Window(shell); } } \ No newline at end of file diff --git a/GreadyPoang/AppShell.xaml b/GreadyPoang/AppShell.xaml index 1197f0e..9e3d921 100644 --- a/GreadyPoang/AppShell.xaml +++ b/GreadyPoang/AppShell.xaml @@ -3,28 +3,29 @@ x:Class="GreadyPoang.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses" xmlns:views="clr-namespace:GreadyPoang.Views" + xmlns:pages="clr-namespace:GreadyPoang.Pages" xmlns:local="clr-namespace:GreadyPoang" Title="GreadyPoang" Shell.TitleColor="LightYellow" Shell.BackgroundColor="CadetBlue"> + + Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}"/> + Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}"/> + Title="PÃ¥börja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}"/> - + diff --git a/GreadyPoang/AppShell.xaml.cs b/GreadyPoang/AppShell.xaml.cs index d90304a..9600656 100644 --- a/GreadyPoang/AppShell.xaml.cs +++ b/GreadyPoang/AppShell.xaml.cs @@ -1,10 +1,21 @@ -namespace GreadyPoang +using GreadyPoang.CommandClasses; +using GreadyPoang.Core; +using System.Text; + +namespace GreadyPoang { public partial class AppShell : Shell { - public AppShell() + private readonly IPageFactory _factory; + + public AppShell(IPageFactory factory) { InitializeComponent(); + + Routing.RegisterRoute("Ny Runda", typeof(Pages.RoundStartingPage)); + Routing.RegisterRoute("Deltagare", typeof(Pages.ParticipantListPage)); + Routing.RegisterRoute("PÃ¥börja eller fortsätt Runda", typeof(Pages.RoundRunningPage)); + _factory = factory; } } } diff --git a/GreadyPoang/BasePage.xaml b/GreadyPoang/BasePage.xaml new file mode 100644 index 0000000..dbd4ac4 --- /dev/null +++ b/GreadyPoang/BasePage.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/GreadyPoang/BasePage.xaml.cs b/GreadyPoang/BasePage.xaml.cs new file mode 100644 index 0000000..063c4e3 --- /dev/null +++ b/GreadyPoang/BasePage.xaml.cs @@ -0,0 +1,13 @@ +using GreadyPoang.CommandClasses; + +namespace GreadyPoang; + +public partial class BasePage : ContentPage +{ + public BasePage(View content, SplashViewModelCommands splashVm) + { + InitializeComponent(); + MainContent.Content = content; + BindingContext = splashVm; + } +} \ No newline at end of file diff --git a/GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs b/GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs index 57d1806..9000827 100644 --- a/GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs +++ b/GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs @@ -3,6 +3,7 @@ using GreadyPoang.EntityLayer; using GreadyPoang.ViewModelLayer; using System.Windows.Input; + namespace GreadyPoang.CommandClasses; public class ParticipantViewModelCommands : ParticipantViewModel diff --git a/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs index c4407c8..d1a9806 100644 --- a/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs +++ b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs @@ -1,4 +1,5 @@ using Common.Library; +using GreadyPoang.Core; using GreadyPoang.DataLayer; using GreadyPoang.EntityLayer; using GreadyPoang.Services; @@ -18,12 +19,14 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel IRepository pointsRepo, IMethodSharingService sharingService, ICombinedRepository combined, - IObjectMessageService objectMessage) + IObjectMessageService objectMessage, + IOverlayService overlay) : base(roundsRepo, pointsRepo, sharingService, combined, - objectMessage) + objectMessage, + overlay) { } diff --git a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs index d4a845b..3c57067 100644 --- a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs +++ b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs @@ -1,4 +1,5 @@ using Common.Library; +using GreadyPoang.Core; using GreadyPoang.DataLayer; using GreadyPoang.EntityLayer; using GreadyPoang.Services; @@ -18,12 +19,16 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel IRepository pointsRepo, IMethodSharingService sharingService, ICombinedRepository combined, - IObjectMessageService objectMessage) + IObjectMessageService objectMessage, + INavigationService nav, + IPageFactory factory) : base(roundsRepo, pointsRepo, sharingService, combined, - objectMessage) + objectMessage, + nav, + factory) { } diff --git a/GreadyPoang/CommandClasses/SplashViewModelCommands.cs b/GreadyPoang/CommandClasses/SplashViewModelCommands.cs new file mode 100644 index 0000000..8a6ca30 --- /dev/null +++ b/GreadyPoang/CommandClasses/SplashViewModelCommands.cs @@ -0,0 +1,10 @@ +using GreadyPoang.ViewModelLayer; + +namespace GreadyPoang.CommandClasses; + +public class SplashViewModelCommands :SplashViewModel +{ + public SplashViewModelCommands() : base() + { + } +} diff --git a/GreadyPoang/Core/NavigationService.cs b/GreadyPoang/Core/NavigationService.cs new file mode 100644 index 0000000..dd7ede7 --- /dev/null +++ b/GreadyPoang/Core/NavigationService.cs @@ -0,0 +1,10 @@ +namespace GreadyPoang.Core; + +public class NavigationService : INavigationService +{ + public Task NavigateToAsync(string route) + => Shell.Current.GoToAsync(route); + + public Task NavigateToPageAsync(Page page) + => Shell.Current.Navigation.PushAsync(page); +} diff --git a/GreadyPoang/Core/PageFactory.cs b/GreadyPoang/Core/PageFactory.cs new file mode 100644 index 0000000..f8982db --- /dev/null +++ b/GreadyPoang/Core/PageFactory.cs @@ -0,0 +1,30 @@ +using GreadyPoang.CommandClasses; +using GreadyPoang.Core; +using GreadyPoang.Pages; + +namespace GreadyPoang; + +public class PageFactory : IPageFactory +{ + private readonly IServiceProvider _services; + + public PageFactory(IServiceProvider services) + { + _services = services; + } + + public Page CreateRoundPage() + { + var vm = _services.GetRequiredService(); + var splashVm = _services.GetRequiredService(); + return new RoundRunningPage(vm, splashVm); + } + + //public Page CreateStatsPage() + //{ + // //var vm = _services.GetRequiredService(); + // //var splashVm = _services.GetRequiredService(); + // //var view = new StatsView { BindingContext = vm }; + // //return new StatsPage(view, splashVm); + //} +} diff --git a/GreadyPoang/Core/ServiceLocator.cs b/GreadyPoang/Core/ServiceLocator.cs new file mode 100644 index 0000000..898a6f4 --- /dev/null +++ b/GreadyPoang/Core/ServiceLocator.cs @@ -0,0 +1,10 @@ +using GreadyPoang.InterFaces; + +namespace GreadyPoang; + +public class ServiceLocator : IServiceLocator +{ + public static IServiceProvider? Services { get; set; } = default; + public T Get() => (T)Services!.GetService(typeof(T))!; + +} diff --git a/GreadyPoang/GreadyPoang.csproj b/GreadyPoang/GreadyPoang.csproj index a7fa4ac..c59de35 100644 --- a/GreadyPoang/GreadyPoang.csproj +++ b/GreadyPoang/GreadyPoang.csproj @@ -70,7 +70,7 @@ - + @@ -81,6 +81,9 @@ + + MSBuild:Compile + MSBuild:Compile @@ -96,6 +99,9 @@ MSBuild:Compile + + MSBuild:Compile + diff --git a/GreadyPoang/InterFaces/IServiceLocator.cs b/GreadyPoang/InterFaces/IServiceLocator.cs new file mode 100644 index 0000000..d6ae444 --- /dev/null +++ b/GreadyPoang/InterFaces/IServiceLocator.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GreadyPoang.InterFaces; + +public interface IServiceLocator +{ + T Get(); +} diff --git a/GreadyPoang/LocalServices/Implements/OverlayService.cs b/GreadyPoang/LocalServices/Implements/OverlayService.cs new file mode 100644 index 0000000..78866f3 --- /dev/null +++ b/GreadyPoang/LocalServices/Implements/OverlayService.cs @@ -0,0 +1,17 @@ +using GreadyPoang.Core; + +namespace GreadyPoang.LocalServices; + +public class OverlayService : IOverlayService +{ + private readonly ISplashService _splashService; + + public OverlayService(ISplashService splashService) + { + _splashService = splashService; + } + + public void ShowSplash(string text, int duration = 3000) => _splashService.ShowSplash(text, duration).GetAwaiter().GetResult(); + public void HideSplash() => _splashService.HideAsync().GetAwaiter().GetResult(); + +} diff --git a/GreadyPoang/LocalServices/Implements/SplashService.cs b/GreadyPoang/LocalServices/Implements/SplashService.cs new file mode 100644 index 0000000..39df135 --- /dev/null +++ b/GreadyPoang/LocalServices/Implements/SplashService.cs @@ -0,0 +1,27 @@ +using GreadyPoang.CommandClasses; +using GreadyPoang.Core; + +namespace GreadyPoang.LocalServices; + +public class SplashService : ISplashService +{ + private readonly SplashViewModelCommands _viewModel; + + public SplashService(SplashViewModelCommands viewModel) + { + _viewModel = viewModel; + } + + public async Task ShowSplash(string text = "Välkommen!", int durationMs = 3000) + { + _viewModel.SplashText = text; + _viewModel.IsSplashVisible = true; + await Task.Delay(durationMs); + _viewModel.IsSplashVisible = false; + } + + public async Task HideAsync() + { + await _viewModel.HideSplashAsync(); + } +} diff --git a/GreadyPoang/MauiProgram.cs b/GreadyPoang/MauiProgram.cs index 9034e53..b89e3c0 100644 --- a/GreadyPoang/MauiProgram.cs +++ b/GreadyPoang/MauiProgram.cs @@ -1,8 +1,11 @@ using Common.Library; using GreadyPoang.CommandClasses; +using GreadyPoang.Core; using GreadyPoang.DataLayer; using GreadyPoang.DataLayer.Database; using GreadyPoang.EntityLayer; +using GreadyPoang.InterFaces; +using GreadyPoang.LocalServices; using GreadyPoang.Services; using GreadyPoang.ViewModelLayer; using GreadyPoang.Views; @@ -30,7 +33,7 @@ public static class MauiProgram builder.Services.AddDbContext(options => { var MauiDataPath = FileSystem.Current.AppDataDirectory; - if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ; + if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))); { File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath); } @@ -38,6 +41,11 @@ public static class MauiProgram options.UseSqlite($"Data Source={dbPath}"); }); + builder.Services.AddScoped(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + builder.Services.AddScoped, ParticipantRepository>(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -46,22 +54,28 @@ public static class MauiProgram builder.Services.AddScoped(); builder.Services.AddScoped(); - builder.Services.AddSingleton(); - + builder.Services.AddScoped, GamePointRepository>(); builder.Services.AddScoped(); builder.Services.AddScoped(); - builder.Services.AddScoped, GamePointRepository>(); - - builder.Services.AddScoped, MethodSharingService>(); - builder.Services.AddScoped(); + builder.Services.AddSingleton(); + + + builder.Services.AddSingleton(); + + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + + + #if DEBUG builder.Logging.AddDebug(); #endif - - return builder.Build(); + var app = builder.Build(); + ServiceLocator.Services = app.Services; + return app; } } diff --git a/GreadyPoang/Pages/ParticipantListPage.cs b/GreadyPoang/Pages/ParticipantListPage.cs new file mode 100644 index 0000000..53cda00 --- /dev/null +++ b/GreadyPoang/Pages/ParticipantListPage.cs @@ -0,0 +1,24 @@ +using GreadyPoang.CommandClasses; +using GreadyPoang.Views; + +namespace GreadyPoang.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/GreadyPoang/Pages/RoundRunningPage.cs b/GreadyPoang/Pages/RoundRunningPage.cs new file mode 100644 index 0000000..cfd1138 --- /dev/null +++ b/GreadyPoang/Pages/RoundRunningPage.cs @@ -0,0 +1,30 @@ +using GreadyPoang.CommandClasses; +using GreadyPoang.Views; + +namespace GreadyPoang.Pages; + +public class RoundRunningPage : BasePage +{ + private readonly RoundRunningViewModelCommands _vm; + + public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm) + : base(new RoundRunningView(Vm), splashVm) + { + Title = "RoundRunningView"; + _vm = Vm; + } + + protected override void OnAppearing() + { + base.OnAppearing(); + BindingContext = _vm; + _vm.Get(); + //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten + //// _vm.RebuildRequested += ViewModel_RebuildRequested; + //_splash.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ; + + + } + + +} diff --git a/GreadyPoang/Pages/RoundStartingPage.cs b/GreadyPoang/Pages/RoundStartingPage.cs new file mode 100644 index 0000000..1c59651 --- /dev/null +++ b/GreadyPoang/Pages/RoundStartingPage.cs @@ -0,0 +1,25 @@ +using GreadyPoang.CommandClasses; +using GreadyPoang.Views; + +namespace GreadyPoang.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/GreadyPoang/Views/ParticipantListView.xaml b/GreadyPoang/Views/ParticipantListView.xaml index 121ef2e..3228a54 100644 --- a/GreadyPoang/Views/ParticipantListView.xaml +++ b/GreadyPoang/Views/ParticipantListView.xaml @@ -1,13 +1,13 @@ - + x:Name="ParticipantListPage"> + @@ -86,4 +86,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/GreadyPoang/Views/ParticipantListView.xaml.cs b/GreadyPoang/Views/ParticipantListView.xaml.cs index e655933..38c12a1 100644 --- a/GreadyPoang/Views/ParticipantListView.xaml.cs +++ b/GreadyPoang/Views/ParticipantListView.xaml.cs @@ -2,7 +2,7 @@ using GreadyPoang.CommandClasses; namespace GreadyPoang.Views; -public partial class ParticipantListView : ContentPage +public partial class ParticipantListView : ContentView { public ParticipantListView(ParticipantViewModelCommands viewModel) { @@ -13,15 +13,12 @@ public partial class ParticipantListView : ContentPage 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/GreadyPoang/Views/RoundRunningView.xaml b/GreadyPoang/Views/RoundRunningView.xaml index b13bda5..a15ed2d 100644 --- a/GreadyPoang/Views/RoundRunningView.xaml +++ b/GreadyPoang/Views/RoundRunningView.xaml @@ -1,5 +1,5 @@ - + x:DataType="vm:RoundRunningViewModelCommands"> + @@ -98,4 +98,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/GreadyPoang/Views/RoundRunningView.xaml.cs b/GreadyPoang/Views/RoundRunningView.xaml.cs index 092d5aa..8bda243 100644 --- a/GreadyPoang/Views/RoundRunningView.xaml.cs +++ b/GreadyPoang/Views/RoundRunningView.xaml.cs @@ -3,25 +3,28 @@ using GreadyPoang.EntityLayer; namespace GreadyPoang.Views; -public partial class RoundRunningView : ContentPage +public partial class RoundRunningView : ContentView { + public RoundRunningView(RoundRunningViewModelCommands viewModel) { InitializeComponent(); ViewModel = viewModel; - } - - protected override void OnAppearing() - { - base.OnAppearing(); - BindingContext = ViewModel; - ViewModel.Get(); - //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten ViewModel.RebuildRequested += ViewModel_RebuildRequested; - - } + //protected override void OnAppearing() + //{ + // base.OnAppearing(); + // BindingContext = ViewModel; + // ViewModel.Get(); + // //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten + // ViewModel.RebuildRequested += ViewModel_RebuildRequested; + // //_splash.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/GreadyPoang/Views/RoundStartingView.xaml b/GreadyPoang/Views/RoundStartingView.xaml index 88b9b2e..0b2713d 100644 --- a/GreadyPoang/Views/RoundStartingView.xaml +++ b/GreadyPoang/Views/RoundStartingView.xaml @@ -1,5 +1,5 @@ - + x:Name="GameRoundStartingPage"> + @@ -151,4 +151,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/GreadyPoang/Views/RoundStartingView.xaml.cs b/GreadyPoang/Views/RoundStartingView.xaml.cs index 7e13819..e41fcd2 100644 --- a/GreadyPoang/Views/RoundStartingView.xaml.cs +++ b/GreadyPoang/Views/RoundStartingView.xaml.cs @@ -2,7 +2,7 @@ using GreadyPoang.CommandClasses; namespace GreadyPoang.Views; -public partial class RoundStartingView : ContentPage +public partial class RoundStartingView : ContentView { @@ -15,28 +15,24 @@ public partial class RoundStartingView : ContentPage 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) { base.OnSizeAllocated(width, height); - if (width < 500) - { - VisualStateManager.GoToState(ResponsiveStack, "Narrow"); - System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack=Narrow "); - } - else - { - VisualStateManager.GoToState(ResponsiveStack, "Wide"); - System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack=Wide "); - } + if (ResponsiveStack == null || width <= 0) + return; + + var state = width < 500 ? "Narrow" : "Wide"; + VisualStateManager.GoToState(ResponsiveStack, state); + System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack={state} "); } diff --git a/GreadyPoang/ViewsPartial/SplashView.xaml b/GreadyPoang/ViewsPartial/SplashView.xaml new file mode 100644 index 0000000..6e4540e --- /dev/null +++ b/GreadyPoang/ViewsPartial/SplashView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/GreadyPoang/ViewsPartial/SplashView.xaml.cs b/GreadyPoang/ViewsPartial/SplashView.xaml.cs new file mode 100644 index 0000000..c6dbdb0 --- /dev/null +++ b/GreadyPoang/ViewsPartial/SplashView.xaml.cs @@ -0,0 +1,18 @@ +using GreadyPoang.CommandClasses; + +namespace GreadyPoang.ViewsPartial; + +public partial class SplashView : ContentView +{ + public SplashView() + { + InitializeComponent(); + } + + public SplashViewModelCommands? ViewModel + { + get => BindingContext as SplashViewModelCommands; + set => BindingContext = value; + } + +} \ No newline at end of file diff --git a/TempProj/GreadyPoang.CommandClasses.old.csproj b/TempProj/GreadyPoang.CommandClasses.old.csproj new file mode 100644 index 0000000..125f4c9 --- /dev/null +++ b/TempProj/GreadyPoang.CommandClasses.old.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + +