Manager commun à toutes les pages
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
parent bdc78ba250
commit 63eae4f24b

@ -4,12 +4,9 @@ namespace Stim;
public partial class AddGamePage : ContentPage
{
public Manager Manager { get; set; }
public AddGamePage(Manager Mgr)
public AddGamePage()
{
InitializeComponent();
Manager = Mgr;
}
private void AddGame(object sender, EventArgs e)
@ -17,7 +14,7 @@ public partial class AddGamePage : ContentPage
int year;
if (string.IsNullOrEmpty(NameEntry.Text) || string.IsNullOrEmpty(DescriptionEntry.Text) || string.IsNullOrEmpty(YearEntry.Text) || !int.TryParse(YearEntry.Text, out year) || string.IsNullOrWhiteSpace(LinkEntry.Text)) return;
Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, "nyancat.png", LinkEntry.Text));
((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, "nyancat.png", LinkEntry.Text));
Navigation.RemovePage(this);
}
}

@ -6,28 +6,11 @@ namespace Stim;
public partial class App : Application
{
Manager Mgr
{
get; set;
}
public Manager Manager { get; set; }
public App()
{
InitializeComponent();
string mainDir = FileSystem.Current.AppDataDirectory;
if (File.Exists(Path.Combine(mainDir,"games.xml"))) Mgr = new Manager(new Persistance(mainDir));
else Mgr = new Manager(new Stub());
MainPage = new AppShell();
}
protected override Window CreateWindow(IActivationState activationState)
{
Window window = base.CreateWindow(activationState);
window.Stopped += (s, e) =>
{
Mgr._persistance = new Persistance(FileSystem.Current.AppDataDirectory);
Mgr.SaveGames();
};
return window;
Manager = new(new Stub());
}
}

@ -3,18 +3,14 @@ using Model;
using StimPersistance;
using StimStub;
using Microsoft.Maui.Storage;
using Windows.System;
public partial class MainPage : ContentPage
{
public IPersistance persistance = new Persistance(FileSystem.Current.AppDataDirectory);
public Manager Manager { get; set; }
public MainPage()
{
InitializeComponent();
Manager = new(persistance);
BindingContext = Manager;
BindingContext = ((App)App.Current).Manager;
}
private async void OnClickGameList(object sender, EventArgs e)
@ -24,6 +20,6 @@ public partial class MainPage : ContentPage
private async void GoToAddGamePage(object sender, EventArgs e)
{
await Navigation.PushAsync(new AddGamePage(Manager));
await Navigation.PushAsync(new AddGamePage());
}
}

Loading…
Cancel
Save