Nu fungerar splash, men måste se vidare på övrig sidhantering
This commit is contained in:
@ -1,10 +1,10 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
|
using GreadyPoang.Core;
|
||||||
using GreadyPoang.DataLayer;
|
using GreadyPoang.DataLayer;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using GreadyPoang.Services;
|
using GreadyPoang.Services;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using GreadyPoang.Core;
|
|
||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
@ -24,7 +24,8 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
ICombinedRepository combined,
|
ICombinedRepository combined,
|
||||||
IObjectMessageService objectMessage,
|
IObjectMessageService objectMessage,
|
||||||
IOverlayService overlay
|
IOverlayService overlay,
|
||||||
|
ISplashService splashService
|
||||||
) : base()
|
) : base()
|
||||||
{
|
{
|
||||||
_roundsRepo = roundsRepo;
|
_roundsRepo = roundsRepo;
|
||||||
@ -33,16 +34,22 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
_combined = combined;
|
_combined = combined;
|
||||||
_objectMessage = objectMessage;
|
_objectMessage = objectMessage;
|
||||||
_overlay = overlay;
|
_overlay = overlay;
|
||||||
|
_splashService = splashService;
|
||||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||||
_builderObject = new();
|
_builderObject = new();
|
||||||
|
_SplashShowing = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _SplashShowing;
|
||||||
|
|
||||||
private readonly IRepository<GameRound>? _roundsRepo;
|
private readonly IRepository<GameRound>? _roundsRepo;
|
||||||
private readonly IRepository<GamePoint> _pointsRepo;
|
private readonly IRepository<GamePoint> _pointsRepo;
|
||||||
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 IOverlayService _overlay;
|
private readonly IOverlayService _overlay;
|
||||||
|
private readonly ISplashService _splashService;
|
||||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||||
private ObservableCollection<Participant> _ParticipantList = new();
|
private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||||
@ -89,7 +96,7 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
public ObservableCollection<RoundBuilderElement> Get()
|
public ObservableCollection<RoundBuilderElement> Get()
|
||||||
{
|
{
|
||||||
|
|
||||||
_overlay.ShowSplash("Laddar...", 3000);
|
//_overlay.ShowSplash("Laddar...", 30);
|
||||||
|
|
||||||
if (_objectMessage.CurrentGroup != null)
|
if (_objectMessage.CurrentGroup != null)
|
||||||
{
|
{
|
||||||
@ -251,6 +258,22 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void ToggleSplash()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!_SplashShowing)
|
||||||
|
{
|
||||||
|
//_overlay.ShowSplash("Clcicked!", 5000);
|
||||||
|
await _splashService.ShowSplash("Clicked", 0);
|
||||||
|
_SplashShowing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _splashService.HideAsync();
|
||||||
|
_SplashShowing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,19 @@ public class SplashViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
// public event PropertyChangedEventHandler PropertyChanged;
|
// public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
private bool _isSplashVisible = true;
|
private Color _splashBackgroundColor = Colors.DarkSlateBlue;
|
||||||
|
public Color SplashBackgroundColor
|
||||||
|
{
|
||||||
|
get => _splashBackgroundColor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashBackgroundColor = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashBackgroundColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool _isSplashVisible = false;
|
||||||
public bool IsSplashVisible
|
public bool IsSplashVisible
|
||||||
{
|
{
|
||||||
get => _isSplashVisible;
|
get => _isSplashVisible;
|
||||||
@ -28,6 +40,19 @@ public class SplashViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color _splashTextColor = Colors.White;
|
||||||
|
|
||||||
|
public Color SplashTextColor
|
||||||
|
{
|
||||||
|
get { return _splashTextColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashTextColor = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashTextColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private double _splashTranslationY = 0;
|
private double _splashTranslationY = 0;
|
||||||
public double SplashTranslationY
|
public double SplashTranslationY
|
||||||
{
|
{
|
||||||
@ -46,19 +71,32 @@ public class SplashViewModel : ViewModelBase
|
|||||||
IsSplashVisible = false;
|
IsSplashVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SplashText { get; set; } = "Välkommen!";
|
private string _splashText = "Välkommen!";
|
||||||
public Color SplashBackgroundColor { get; set; } = Colors.DarkSlateBlue;
|
public string SplashText
|
||||||
public string SplashImage { get; set; } = "splash_icon.png";
|
{
|
||||||
|
get => _splashText;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashText = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public Color SplashBackgroundColor { get; set; } = Colors.DarkSlateBlue;
|
||||||
|
//public string SplashImage { get; set; } = "splash_icon.png";
|
||||||
|
|
||||||
//protected void OnPropertyChanged(string name) =>
|
//protected void OnPropertyChanged(string name) =>
|
||||||
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task AnimateSplashOut()
|
private async Task AnimateSplashOut()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
SplashOpacity -= 0.1;
|
SplashOpacity -= 0.1;
|
||||||
SplashTranslationY += 5;
|
//SplashTranslationY += 5;
|
||||||
await Task.Delay(30);
|
await Task.Delay(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,9 +14,27 @@
|
|||||||
<viewsPartial:SplashView
|
<viewsPartial:SplashView
|
||||||
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
||||||
AbsoluteLayout.LayoutFlags="All"
|
AbsoluteLayout.LayoutFlags="All"
|
||||||
IsVisible="{Binding IsSplashVisible}"
|
x:Name="SplashView"
|
||||||
Opacity="{Binding SplashOpacity}"
|
IsVisible="True"
|
||||||
|
Opacity="1"
|
||||||
|
ZIndex="999"
|
||||||
TranslationY="{Binding SplashTranslationY}"
|
TranslationY="{Binding SplashTranslationY}"
|
||||||
InputTransparent="False" />
|
InputTransparent="True" >
|
||||||
|
</viewsPartial:SplashView>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
WidthRequest="250"
|
||||||
|
HeightRequest="150"
|
||||||
|
IsVisible="{Binding IsSplashVisible}"
|
||||||
|
BackgroundColor="{Binding SplashBackgroundColor}"
|
||||||
|
x:Name="SplashView"
|
||||||
|
BackgroundColor="Black"
|
||||||
|
Opacity="{Binding SplashOpacity}"
|
||||||
|
IsVisible="True"
|
||||||
|
Opacity="0.9"
|
||||||
|
ZIndex="999"
|
||||||
|
BackgroundColor="Black" />-->
|
||||||
|
|
||||||
|
|
||||||
</AbsoluteLayout>
|
</AbsoluteLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
@ -8,6 +8,6 @@ public partial class BasePage : ContentPage
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
MainContent.Content = content;
|
MainContent.Content = content;
|
||||||
BindingContext = splashVm;
|
SplashView.BindingContext = splashVm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,13 +20,15 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
|||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
ICombinedRepository combined,
|
ICombinedRepository combined,
|
||||||
IObjectMessageService objectMessage,
|
IObjectMessageService objectMessage,
|
||||||
IOverlayService overlay)
|
IOverlayService overlay,
|
||||||
|
ISplashService splashService)
|
||||||
: base(roundsRepo,
|
: base(roundsRepo,
|
||||||
pointsRepo,
|
pointsRepo,
|
||||||
sharingService,
|
sharingService,
|
||||||
combined,
|
combined,
|
||||||
objectMessage,
|
objectMessage,
|
||||||
overlay)
|
overlay,
|
||||||
|
splashService)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
|||||||
public ICommand ElementTappedCommand { get; private set; }
|
public ICommand ElementTappedCommand { get; private set; }
|
||||||
public ICommand ParticipantTappedCommand { get; private set; }
|
public ICommand ParticipantTappedCommand { get; private set; }
|
||||||
public ICommand StoreAndHandlePointsCommand { get; private set; }
|
public ICommand StoreAndHandlePointsCommand { get; private set; }
|
||||||
|
public ICommand OnSplashClickedCommand { get; private set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -44,6 +47,7 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
|
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
|
||||||
|
OnSplashClickedCommand = new Command(async () => await ToggleSplash());
|
||||||
//EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
//EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||||
//RensaCommand = new Command(async () => RensaAsync());
|
//RensaCommand = new Command(async () => RensaAsync());
|
||||||
//ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
|
//ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
|
||||||
@ -54,6 +58,12 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
|||||||
private async Task StoreAndHandleAsync()
|
private async Task StoreAndHandleAsync()
|
||||||
{
|
{
|
||||||
base.StoreAndHandlePoints();
|
base.StoreAndHandlePoints();
|
||||||
await Shell.Current.GoToAsync("..");
|
//await Shell.Current.GoToAsync("..");
|
||||||
|
await Shell.Current.GoToAsync("Påbörja eller fortsätt Runda");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ToggleSplash()
|
||||||
|
{
|
||||||
|
base.ToggleSplash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace GreadyPoang.CommandClasses;
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
public class SplashViewModelCommands :SplashViewModel
|
public class SplashViewModelCommands : SplashViewModel
|
||||||
{
|
{
|
||||||
public SplashViewModelCommands() : base()
|
public SplashViewModelCommands() : base()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,13 +15,20 @@ public class SplashService : ISplashService
|
|||||||
public async Task ShowSplash(string text = "Välkommen!", int durationMs = 3000)
|
public async Task ShowSplash(string text = "Välkommen!", int durationMs = 3000)
|
||||||
{
|
{
|
||||||
_viewModel.SplashText = text;
|
_viewModel.SplashText = text;
|
||||||
|
_viewModel.SplashOpacity = 0.8;
|
||||||
|
_viewModel.SplashBackgroundColor = Colors.DodgerBlue;
|
||||||
_viewModel.IsSplashVisible = true;
|
_viewModel.IsSplashVisible = true;
|
||||||
|
//await Task.Yield(); // ger UI-tråden en chans att uppdatera
|
||||||
|
if (durationMs > 0)
|
||||||
|
{
|
||||||
await Task.Delay(durationMs);
|
await Task.Delay(durationMs);
|
||||||
_viewModel.IsSplashVisible = false;
|
_viewModel.IsSplashVisible = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task HideAsync()
|
public async Task HideAsync()
|
||||||
{
|
{
|
||||||
|
//_viewModel.IsSplashVisible = false;
|
||||||
await _viewModel.HideSplashAsync();
|
await _viewModel.HideSplashAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using GreadyPoang.CommandClasses;
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Core;
|
||||||
using GreadyPoang.Views;
|
using GreadyPoang.Views;
|
||||||
|
|
||||||
namespace GreadyPoang.Pages;
|
namespace GreadyPoang.Pages;
|
||||||
@ -6,25 +7,37 @@ namespace GreadyPoang.Pages;
|
|||||||
public class RoundRunningPage : BasePage
|
public class RoundRunningPage : BasePage
|
||||||
{
|
{
|
||||||
private readonly RoundRunningViewModelCommands _vm;
|
private readonly RoundRunningViewModelCommands _vm;
|
||||||
|
private readonly SplashViewModelCommands _splashVm;
|
||||||
|
public ISplashService Splash { get; set; }
|
||||||
|
|
||||||
public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm)
|
public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm)
|
||||||
: base(new RoundRunningView(Vm), splashVm)
|
: base(new RoundRunningView(Vm), splashVm)
|
||||||
{
|
{
|
||||||
Title = "RoundRunningView";
|
Title = "Starta/Fortsätt runda";
|
||||||
_vm = Vm;
|
_vm = Vm;
|
||||||
|
Splash = ServiceLocator.Services?.GetRequiredService<ISplashService>();
|
||||||
|
_splashVm = splashVm;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAppearing()
|
|
||||||
|
public SplashViewModelCommands SplashVm { get; }
|
||||||
|
|
||||||
|
protected override async void OnAppearing()
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
BindingContext = _vm;
|
BindingContext = _vm;
|
||||||
_vm.Get();
|
_vm.Get();
|
||||||
//BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten
|
//BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten
|
||||||
//// _vm.RebuildRequested += ViewModel_RebuildRequested;
|
//// _vm.RebuildRequested += ViewModel_RebuildRequested;
|
||||||
//_splash.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ;
|
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(); ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,9 @@
|
|||||||
<Button Text="Register Points"
|
<Button Text="Register Points"
|
||||||
Style="{StaticResource HoverButtonRedStyle}"
|
Style="{StaticResource HoverButtonRedStyle}"
|
||||||
Command="{Binding StoreAndHandlePointsCommand}"/>
|
Command="{Binding StoreAndHandlePointsCommand}"/>
|
||||||
|
<Button Text="Visa Splash"
|
||||||
|
Style="{StaticResource HoverButtonBlueStyle}"
|
||||||
|
Command="{Binding OnSplashClickedCommand}"/>
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
||||||
|
|||||||
@ -4,23 +4,27 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="GreadyPoang.ViewsPartial.SplashView"
|
x:Class="GreadyPoang.ViewsPartial.SplashView"
|
||||||
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
x:DataType="vm:SplashViewModelCommands"
|
x:DataType="vm:SplashViewModelCommands">
|
||||||
IsVisible="{Binding IsSplashVisible, Mode=OneWay}">
|
<!--IsVisible="{Binding IsSplashVisible}">-->
|
||||||
|
|
||||||
<Border Background="{Binding SplashBackgroundColor}"
|
<Border x:Name="SplashBorder"
|
||||||
WidthRequest="250"
|
Stroke="Black"
|
||||||
HeightRequest="150"
|
BackgroundColor="{Binding SplashBackgroundColor}"
|
||||||
|
WidthRequest="350"
|
||||||
|
HeightRequest="200"
|
||||||
StrokeShape="RoundRectangle 20"
|
StrokeShape="RoundRectangle 20"
|
||||||
Padding="20"
|
Padding="20"
|
||||||
|
IsVisible="{Binding IsSplashVisible}"
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
VerticalOptions="Center">
|
VerticalOptions="Center"
|
||||||
|
Opacity="{Binding SplashOpacity}">
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<Image Source="{Binding SplashImage}" HeightRequest="60" />
|
<!--<Image Source="{Binding SplashImage}" HeightRequest="60" />-->
|
||||||
<Label Text="{Binding SplashText}"
|
<Label Text="{Binding SplashText}"
|
||||||
FontSize="18"
|
FontSize="18"
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
VerticalOptions="Center"
|
VerticalOptions="Center"
|
||||||
TextColor="White"/>
|
TextColor="{Binding SplashTextColor}"/>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
</ContentView>
|
</ContentView>
|
||||||
|
|||||||
@ -9,9 +9,9 @@ public partial class SplashView : ContentView
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SplashViewModelCommands? ViewModel
|
public SplashViewModelCommands ViewModel
|
||||||
{
|
{
|
||||||
get => BindingContext as SplashViewModelCommands;
|
get => (SplashViewModelCommands)BindingContext;
|
||||||
set => BindingContext = value;
|
set => BindingContext = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user