Stor ombearbetning som skall ge splash möjligheter
This commit is contained in:
15
GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj
Normal file
15
GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,8 @@
|
||||
namespace GreadyPoang.Core;
|
||||
|
||||
public interface INavigationService
|
||||
{
|
||||
Task NavigateToAsync(string route);
|
||||
Task NavigateToPageAsync(Page page);
|
||||
}
|
||||
|
||||
7
GreadyPoang.ViewModelLayer/Interfaces/IOverlayService.cs
Normal file
7
GreadyPoang.ViewModelLayer/Interfaces/IOverlayService.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace GreadyPoang.Core;
|
||||
|
||||
public interface IOverlayService
|
||||
{
|
||||
void ShowSplash(string text, int duration);
|
||||
void HideSplash();
|
||||
}
|
||||
6
GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs
Normal file
6
GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace GreadyPoang.Core;
|
||||
|
||||
public interface IPageFactory
|
||||
{
|
||||
Page CreateRoundPage();
|
||||
}
|
||||
9
GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs
Normal file
9
GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
namespace GreadyPoang.Core;
|
||||
|
||||
public interface ISplashService
|
||||
{
|
||||
Task ShowSplash(string text = "Välkommen!", int durationMs = 3000);
|
||||
Task HideAsync();
|
||||
|
||||
}
|
||||
@ -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<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> 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<RoundBuilderElement>();
|
||||
_builderObject = new();
|
||||
}
|
||||
@ -39,7 +42,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
|
||||
private readonly IOverlayService _overlay;
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
@ -86,6 +89,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
public ObservableCollection<RoundBuilderElement> Get()
|
||||
{
|
||||
|
||||
_overlay.ShowSplash("Laddar...", 3000);
|
||||
|
||||
if (_objectMessage.CurrentGroup != null)
|
||||
{
|
||||
|
||||
@ -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<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> 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<RoundBuilderElement>();
|
||||
}
|
||||
|
||||
@ -40,6 +44,8 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private readonly INavigationService _nav;
|
||||
private readonly IPageFactory _factory;
|
||||
private Participant _selectedItem;
|
||||
|
||||
private ObservableCollection<RoundBuilderElement> _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}");
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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<SplashViewModelCommands>();
|
||||
//var shell = new AppShell(splashVm);
|
||||
|
||||
var shell = _services.GetRequiredService<AppShell>();
|
||||
return new Window(shell);
|
||||
}
|
||||
}
|
||||
@ -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">
|
||||
|
||||
<TabBar>
|
||||
<ShellContent
|
||||
Title="Home"
|
||||
ContentTemplate="{DataTemplate local:MainPage}"
|
||||
Title="Home" ContentTemplate="{DataTemplate local:MainPage}"
|
||||
Route="MainPage" />
|
||||
<ShellContent
|
||||
Title="Deltagare"
|
||||
ContentTemplate="{DataTemplate views:ParticipantListView}"
|
||||
Route="ParticipantListView" />
|
||||
Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}"/>
|
||||
<ShellContent
|
||||
Title="Starta Ny Runda"
|
||||
ContentTemplate="{DataTemplate views:RoundStartingView}"
|
||||
Route="RoundStartingView" />
|
||||
Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}"/>
|
||||
<ShellContent
|
||||
Title="Påbörja eller fortsätt Runda"
|
||||
ContentTemplate="{DataTemplate views:RoundRunningView}"
|
||||
Route="RoundRunningView" />
|
||||
Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}"/>
|
||||
</TabBar>
|
||||
|
||||
<!--<viewsPartial:SplashView
|
||||
x:Name="SplashViewControl"
|
||||
IsVisible="{Binding IsSplashVisible}"
|
||||
Opacity="{Binding SplashOpacity}"
|
||||
TranslationY="{Binding SplashTranslationY}"
|
||||
InputTransparent="False" />-->
|
||||
</Shell>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
GreadyPoang/BasePage.xaml
Normal file
22
GreadyPoang/BasePage.xaml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="GreadyPoang.BasePage"
|
||||
xmlns:viewsPartial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||
x:Name="Root">
|
||||
<AbsoluteLayout>
|
||||
<!-- Huvudinnehåll -->
|
||||
<ContentView x:Name="MainContent"
|
||||
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
||||
AbsoluteLayout.LayoutFlags="All" />
|
||||
|
||||
<!-- Overlay: Splash -->
|
||||
<viewsPartial:SplashView
|
||||
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
||||
AbsoluteLayout.LayoutFlags="All"
|
||||
IsVisible="{Binding IsSplashVisible}"
|
||||
Opacity="{Binding SplashOpacity}"
|
||||
TranslationY="{Binding SplashTranslationY}"
|
||||
InputTransparent="False" />
|
||||
</AbsoluteLayout>
|
||||
</ContentPage>
|
||||
13
GreadyPoang/BasePage.xaml.cs
Normal file
13
GreadyPoang/BasePage.xaml.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
||||
namespace GreadyPoang.CommandClasses;
|
||||
|
||||
public class ParticipantViewModelCommands : ParticipantViewModel
|
||||
|
||||
@ -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<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage)
|
||||
IObjectMessageService objectMessage,
|
||||
IOverlayService overlay)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
combined,
|
||||
objectMessage)
|
||||
objectMessage,
|
||||
overlay)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -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<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage)
|
||||
IObjectMessageService objectMessage,
|
||||
INavigationService nav,
|
||||
IPageFactory factory)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
combined,
|
||||
objectMessage)
|
||||
objectMessage,
|
||||
nav,
|
||||
factory)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
10
GreadyPoang/CommandClasses/SplashViewModelCommands.cs
Normal file
10
GreadyPoang/CommandClasses/SplashViewModelCommands.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
|
||||
namespace GreadyPoang.CommandClasses;
|
||||
|
||||
public class SplashViewModelCommands :SplashViewModel
|
||||
{
|
||||
public SplashViewModelCommands() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
10
GreadyPoang/Core/NavigationService.cs
Normal file
10
GreadyPoang/Core/NavigationService.cs
Normal file
@ -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);
|
||||
}
|
||||
30
GreadyPoang/Core/PageFactory.cs
Normal file
30
GreadyPoang/Core/PageFactory.cs
Normal file
@ -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<RoundRunningViewModelCommands>();
|
||||
var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
|
||||
return new RoundRunningPage(vm, splashVm);
|
||||
}
|
||||
|
||||
//public Page CreateStatsPage()
|
||||
//{
|
||||
// //var vm = _services.GetRequiredService<StatsViewModel>();
|
||||
// //var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
|
||||
// //var view = new StatsView { BindingContext = vm };
|
||||
// //return new StatsPage(view, splashVm);
|
||||
//}
|
||||
}
|
||||
10
GreadyPoang/Core/ServiceLocator.cs
Normal file
10
GreadyPoang/Core/ServiceLocator.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using GreadyPoang.InterFaces;
|
||||
|
||||
namespace GreadyPoang;
|
||||
|
||||
public class ServiceLocator : IServiceLocator
|
||||
{
|
||||
public static IServiceProvider? Services { get; set; } = default;
|
||||
public T Get<T>() => (T)Services!.GetService(typeof(T))!;
|
||||
|
||||
}
|
||||
@ -70,7 +70,7 @@
|
||||
<ProjectReference Include="..\GreadyPoang.Common\GreadyPoang.Common.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />
|
||||
<!--<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />-->
|
||||
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -81,6 +81,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MauiXaml Update="BasePage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Resources\Styles\AppStyles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
@ -96,6 +99,9 @@
|
||||
<MauiXaml Update="Views\RoundStartingView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="ViewsPartial\SplashView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
12
GreadyPoang/InterFaces/IServiceLocator.cs
Normal file
12
GreadyPoang/InterFaces/IServiceLocator.cs
Normal file
@ -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<T>();
|
||||
}
|
||||
17
GreadyPoang/LocalServices/Implements/OverlayService.cs
Normal file
17
GreadyPoang/LocalServices/Implements/OverlayService.cs
Normal file
@ -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();
|
||||
|
||||
}
|
||||
27
GreadyPoang/LocalServices/Implements/SplashService.cs
Normal file
27
GreadyPoang/LocalServices/Implements/SplashService.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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<DataContext>(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<IPageFactory, PageFactory>();
|
||||
builder.Services.AddSingleton<INavigationService, NavigationService>();
|
||||
builder.Services.AddSingleton<IServiceLocator,ServiceLocator>();
|
||||
builder.Services.AddSingleton<AppShell>();
|
||||
|
||||
builder.Services.AddScoped<IRepository<Participant>, ParticipantRepository>();
|
||||
builder.Services.AddScoped<ParticipantViewModelCommands>();
|
||||
builder.Services.AddScoped<ParticipantListView>();
|
||||
@ -46,22 +54,28 @@ public static class MauiProgram
|
||||
builder.Services.AddScoped<RoundStartingViewModelCommands>();
|
||||
builder.Services.AddScoped<RoundStartingView>();
|
||||
|
||||
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
||||
|
||||
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
|
||||
builder.Services.AddScoped<RoundRunningViewModelCommands>();
|
||||
builder.Services.AddScoped<RoundRunningView>();
|
||||
|
||||
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
|
||||
|
||||
|
||||
builder.Services.AddScoped<IMethodSharingService<Participant>, MethodSharingService>();
|
||||
|
||||
builder.Services.AddScoped<ICombinedRepository, CombinedRepository>();
|
||||
|
||||
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
||||
|
||||
|
||||
builder.Services.AddSingleton<IOverlayService, OverlayService>();
|
||||
|
||||
builder.Services.AddSingleton<SplashViewModelCommands>();
|
||||
builder.Services.AddSingleton<ISplashService, SplashService>();
|
||||
|
||||
|
||||
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
|
||||
return builder.Build();
|
||||
var app = builder.Build();
|
||||
ServiceLocator.Services = app.Services;
|
||||
return app;
|
||||
}
|
||||
}
|
||||
|
||||
24
GreadyPoang/Pages/ParticipantListPage.cs
Normal file
24
GreadyPoang/Pages/ParticipantListPage.cs
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
30
GreadyPoang/Pages/RoundRunningPage.cs
Normal file
30
GreadyPoang/Pages/RoundRunningPage.cs
Normal file
@ -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(); ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
25
GreadyPoang/Pages/RoundStartingPage.cs
Normal file
25
GreadyPoang/Pages/RoundStartingPage.cs
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
x:Class="GreadyPoang.Views.ParticipantListView"
|
||||
x:DataType="vm:ParticipantViewModelCommands"
|
||||
x:Name="ParticipantListPage"
|
||||
Title="Deltagar Lista">
|
||||
x:Name="ParticipantListPage">
|
||||
<!--Title="Deltagar Lista"-->
|
||||
|
||||
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||
<Grid Style="{StaticResource Grid.Page}">
|
||||
@ -86,4 +86,4 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ContentPage>
|
||||
</ContentView>
|
||||
@ -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();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||
x:Class="GreadyPoang.Views.RoundRunningView"
|
||||
@ -7,8 +7,8 @@
|
||||
xmlns:behaviors="clr-namespace:GreadyPoang.Common;assembly=GreadyPoang.Common"
|
||||
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
x:DataType="vm:RoundRunningViewModelCommands"
|
||||
Title="RoundRunningView">
|
||||
x:DataType="vm:RoundRunningViewModelCommands">
|
||||
<!--Title="RoundRunningView"-->
|
||||
|
||||
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||
<Grid Style="{StaticResource Grid.Page}">
|
||||
@ -98,4 +98,4 @@
|
||||
</ScrollView>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ContentPage>
|
||||
</ContentView>
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||
x:Class="GreadyPoang.Views.RoundStartingView"
|
||||
@ -7,8 +7,8 @@
|
||||
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
x:DataType="vm:RoundStartingViewModelCommands"
|
||||
x:Name="GameRoundStartingPage"
|
||||
Title="Starta ny Runda">
|
||||
x:Name="GameRoundStartingPage">
|
||||
<!--Title="Starta ny Runda"-->
|
||||
|
||||
|
||||
|
||||
@ -151,4 +151,4 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ContentPage>
|
||||
</ContentView>
|
||||
@ -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} ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
GreadyPoang/ViewsPartial/SplashView.xaml
Normal file
26
GreadyPoang/ViewsPartial/SplashView.xaml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Views/SplashView.xaml -->
|
||||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="GreadyPoang.ViewsPartial.SplashView"
|
||||
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||
x:DataType="vm:SplashViewModelCommands"
|
||||
IsVisible="{Binding IsSplashVisible, Mode=OneWay}">
|
||||
|
||||
<Border Background="{Binding SplashBackgroundColor}"
|
||||
WidthRequest="250"
|
||||
HeightRequest="150"
|
||||
StrokeShape="RoundRectangle 20"
|
||||
Padding="20"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center">
|
||||
<StackLayout>
|
||||
<Image Source="{Binding SplashImage}" HeightRequest="60" />
|
||||
<Label Text="{Binding SplashText}"
|
||||
FontSize="18"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center"
|
||||
TextColor="White"/>
|
||||
</StackLayout>
|
||||
</Border>
|
||||
</ContentView>
|
||||
18
GreadyPoang/ViewsPartial/SplashView.xaml.cs
Normal file
18
GreadyPoang/ViewsPartial/SplashView.xaml.cs
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
9
TempProj/GreadyPoang.CommandClasses.old.csproj
Normal file
9
TempProj/GreadyPoang.CommandClasses.old.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user