Nu fungerar hanteringen kring navigation
This commit is contained in:
@ -5,4 +5,5 @@ namespace GreadyPoang.Services;
|
||||
public class ObjectMessageService : IObjectMessageService
|
||||
{
|
||||
public RoundBuilderGroup CurrentGroup { get; set; }
|
||||
public bool Delivered { get; set; }
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
using GreadyPoang.EntityLayer;
|
||||
|
||||
namespace GreadyPoang.Services;
|
||||
|
||||
public interface IObjectMessageService
|
||||
namespace GreadyPoang.Services
|
||||
{
|
||||
RoundBuilderGroup CurrentGroup { get; set; }
|
||||
|
||||
}
|
||||
public interface IObjectMessageService
|
||||
{
|
||||
RoundBuilderGroup CurrentGroup { get; set; }
|
||||
bool Delivered { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,5 +4,6 @@ public interface INavigationService
|
||||
{
|
||||
Task NavigateToAsync(string route);
|
||||
Task NavigateToPageAsync(Page page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
using Common.Library;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
public class AppShellViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
private bool _roundRounningVisible = true;
|
||||
|
||||
public bool RoundRunningVisible
|
||||
{
|
||||
get { return _roundRounningVisible; }
|
||||
set
|
||||
{
|
||||
_roundRounningVisible = value;
|
||||
RaisePropertyChanged(nameof(RoundRunningVisible));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -24,7 +24,8 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage,
|
||||
ISplashService splashService
|
||||
ISplashService splashService,
|
||||
AppShellViewModel appShell
|
||||
) : base()
|
||||
{
|
||||
_roundsRepo = roundsRepo;
|
||||
@ -33,6 +34,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_splashService = splashService;
|
||||
_appShell = appShell;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
_builderObject = new();
|
||||
_SplashShowing = false;
|
||||
@ -47,6 +49,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private readonly ISplashService _splashService;
|
||||
private readonly AppShellViewModel _appShell;
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
@ -89,6 +92,18 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
private bool _gobackVisible = true;
|
||||
|
||||
public bool GobackVisible
|
||||
{
|
||||
get { return _gobackVisible; }
|
||||
set
|
||||
{
|
||||
_gobackVisible = value;
|
||||
RaisePropertyChanged(nameof(GobackVisible));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> Get()
|
||||
{
|
||||
@ -97,6 +112,8 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
|
||||
if (_objectMessage.CurrentGroup != null)
|
||||
{
|
||||
GobackVisible = _objectMessage.Delivered;
|
||||
_objectMessage.Delivered = false;
|
||||
//CurrentGroup är satt från RoundStarting ViewModel
|
||||
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
|
||||
if (RoundElements.Count > 0)
|
||||
@ -271,6 +288,11 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void GobackAsync()
|
||||
{
|
||||
_appShell.RoundRunningVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,7 +23,9 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
IObjectMessageService objectMessage,
|
||||
INavigationService nav,
|
||||
IPageFactory factory,
|
||||
ISplashService splashService) : base()
|
||||
ISplashService splashService,
|
||||
AppShellViewModel appShellView
|
||||
) : base()
|
||||
{
|
||||
_roundsRepo = roundsRepo;
|
||||
_pointsRepo = pointsRepo;
|
||||
@ -33,6 +35,7 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
_nav = nav;
|
||||
_factory = factory;
|
||||
_splashService = splashService;
|
||||
_appShellView = appShellView;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
}
|
||||
|
||||
@ -49,6 +52,7 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
private readonly INavigationService _nav;
|
||||
private readonly IPageFactory _factory;
|
||||
private readonly ISplashService _splashService;
|
||||
private readonly AppShellViewModel _appShellView;
|
||||
private Participant _selectedItem;
|
||||
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
@ -248,11 +252,14 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
if (rbGroup != null)
|
||||
{
|
||||
_objectMessage.CurrentGroup = rbGroup;
|
||||
await _splashService.ShowSplash("Runda vald, gå till\r 'Påbörja eller fortsätt Runda'", 3000);
|
||||
// await Shell.Current.GoToAsync("RoundRunning");
|
||||
_objectMessage.Delivered = true;
|
||||
//await _splashService.ShowSplash("Runda vald, gå till\r\r 'Påbörja eller fortsätt Runda'", 3000);
|
||||
await Shell.Current.GoToAsync("RoundRunningPage");
|
||||
|
||||
_appShellView.RoundRunningVisible = false;
|
||||
//_roundRunning.GobackVisible = false;
|
||||
//var page = _factory.CreateRoundPage();
|
||||
//await _nav.NavigateToPageAsync(page);
|
||||
//_nav.NavigateToPageAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
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:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
||||
xmlns:views="clr-namespace:GreadyPoang.Views"
|
||||
xmlns:pages="clr-namespace:GreadyPoang.Pages"
|
||||
xmlns:local="clr-namespace:GreadyPoang"
|
||||
Title="GreadyPoang"
|
||||
Shell.TitleColor="LightYellow"
|
||||
x:DataType="vm:AppShellViewModel"
|
||||
Shell.BackgroundColor="CadetBlue">
|
||||
|
||||
<TabBar>
|
||||
@ -17,18 +18,13 @@
|
||||
Route="MainPage" />
|
||||
<ShellContent
|
||||
Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}"
|
||||
Route="Deltagare"/>
|
||||
Route="ParticipantListPage"/>
|
||||
<ShellContent
|
||||
Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}"
|
||||
Route="RoundStart"/>
|
||||
Route="RoundStartingPage"/>
|
||||
<ShellContent
|
||||
Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}"
|
||||
Route="RoundRunning"/>
|
||||
Route="RoundRunningPage" IsVisible="{Binding RoundRunningVisible}"/>
|
||||
</TabBar>
|
||||
<!--<viewsPartial:SplashView
|
||||
x:Name="SplashViewControl"
|
||||
IsVisible="{Binding IsSplashVisible}"
|
||||
Opacity="{Binding SplashOpacity}"
|
||||
TranslationY="{Binding SplashTranslationY}"
|
||||
InputTransparent="False" />-->
|
||||
|
||||
</Shell>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using GreadyPoang.Core;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
|
||||
namespace GreadyPoang
|
||||
{
|
||||
@ -6,14 +7,15 @@ namespace GreadyPoang
|
||||
{
|
||||
private readonly IPageFactory _factory;
|
||||
|
||||
public AppShell(IPageFactory factory)
|
||||
public AppShell(IPageFactory factory, AppShellViewModel appShellView)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Routing.RegisterRoute("RoundStart", typeof(Pages.RoundStartingPage));
|
||||
Routing.RegisterRoute("Deltagare", typeof(Pages.ParticipantListPage));
|
||||
Routing.RegisterRoute("RoundRunning", typeof(Pages.RoundRunningPage));
|
||||
Routing.RegisterRoute("RoundStartingPage", typeof(Pages.RoundStartingPage));
|
||||
Routing.RegisterRoute("ParticipantListPage", typeof(Pages.ParticipantListPage));
|
||||
Routing.RegisterRoute("RoundRunningPage", typeof(Pages.RoundRunningPage));
|
||||
_factory = factory;
|
||||
BindingContext = appShellView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
GreadyPoang/CommandClasses/AppShellViewModelCommands.cs
Normal file
11
GreadyPoang/CommandClasses/AppShellViewModelCommands.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
|
||||
namespace GreadyPoang.CommandClasses;
|
||||
|
||||
public class AppShellViewModelCommands : AppShellViewModel
|
||||
{
|
||||
public AppShellViewModelCommands() : base()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -20,22 +20,20 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage,
|
||||
ISplashService splashService)
|
||||
ISplashService splashService,
|
||||
AppShellViewModel appShell)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
combined,
|
||||
objectMessage,
|
||||
splashService)
|
||||
splashService,
|
||||
appShell)
|
||||
{
|
||||
}
|
||||
|
||||
#region Commands
|
||||
public ICommand SaveCommand { get; private set; }
|
||||
public ICommand EditCommand { get; private set; }
|
||||
public ICommand RensaCommand { get; private set; }
|
||||
public ICommand ElementTappedCommand { get; private set; }
|
||||
public ICommand ParticipantTappedCommand { get; private set; }
|
||||
public ICommand GobackCommand { get; private set; }
|
||||
public ICommand StoreAndHandlePointsCommand { get; private set; }
|
||||
public ICommand OnSplashClickedCommand { get; private set; }
|
||||
|
||||
@ -46,11 +44,13 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
||||
base.Init();
|
||||
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
|
||||
OnSplashClickedCommand = new Command(async () => await ToggleSplash());
|
||||
//EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||
//RensaCommand = new Command(async () => RensaAsync());
|
||||
//ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
|
||||
//ElementTappedCommand = new Command<RoundBuilderElement>((selectedElement) => RoundSelected(selectedElement));
|
||||
GobackCommand = new Command(async () => GobackAsync());
|
||||
}
|
||||
|
||||
private async void GobackAsync()
|
||||
{
|
||||
base.GobackAsync();
|
||||
await Shell.Current.GoToAsync("..");
|
||||
}
|
||||
|
||||
private async Task StoreAndHandleAsync()
|
||||
|
||||
@ -22,7 +22,8 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
IObjectMessageService objectMessage,
|
||||
INavigationService nav,
|
||||
IPageFactory factory,
|
||||
ISplashService splashService)
|
||||
ISplashService splashService,
|
||||
AppShellViewModel appShell)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
@ -30,7 +31,8 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
objectMessage,
|
||||
nav,
|
||||
factory,
|
||||
splashService)
|
||||
splashService,
|
||||
appShell)
|
||||
{
|
||||
}
|
||||
|
||||
@ -108,7 +110,6 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
base.SelectNewlyAddedParticipant(roundBuilder);
|
||||
goneOk = true;
|
||||
return goneOk;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
public class NavigationService : INavigationService
|
||||
{
|
||||
|
||||
public Task NavigateToAsync(string route)
|
||||
=> Shell.Current.GoToAsync(route);
|
||||
|
||||
|
||||
@ -44,7 +44,6 @@ public static class MauiProgram
|
||||
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>();
|
||||
@ -63,8 +62,8 @@ public static class MauiProgram
|
||||
|
||||
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
||||
|
||||
|
||||
//builder.Services.AddSingleton<IOverlayService, OverlayService>();
|
||||
builder.Services.AddSingleton<AppShellViewModel>();
|
||||
builder.Services.AddSingleton<AppShell>();
|
||||
|
||||
builder.Services.AddSingleton<SplashViewModelCommands>();
|
||||
builder.Services.AddSingleton<ISplashService, SplashService>();
|
||||
|
||||
@ -85,9 +85,16 @@
|
||||
<Button Text="Register Points"
|
||||
Style="{StaticResource HoverButtonRedStyle}"
|
||||
Command="{Binding StoreAndHandlePointsCommand}"/>
|
||||
<Button Text="Visa Splash"
|
||||
Style="{StaticResource HoverButtonBlueStyle}"
|
||||
Command="{Binding OnSplashClickedCommand}"/>
|
||||
<VerticalStackLayout>
|
||||
<Button Text="Visa Splash"
|
||||
Style="{StaticResource HoverButtonBlueStyle}"
|
||||
Command="{Binding OnSplashClickedCommand}"/>
|
||||
<Button Text="Återgå"
|
||||
Style="{StaticResource HoverButtonBlueStyle}"
|
||||
Command="{Binding GobackCommand}"
|
||||
IsVisible="{Binding GobackVisible}" />
|
||||
</VerticalStackLayout>
|
||||
|
||||
</HorizontalStackLayout>
|
||||
</Border>
|
||||
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
||||
|
||||
@ -13,17 +13,6 @@ public partial class RoundRunningView : ContentView
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user