-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBasePage.cs
More file actions
45 lines (36 loc) · 1.15 KB
/
Copy pathBasePage.cs
File metadata and controls
45 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Diagnostics;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
namespace HotChocolateGraphQL.Mobile;
abstract partial class BasePage<TViewModel> : BasePage where TViewModel : BaseViewModel
{
protected BasePage(in TViewModel viewModel, in string? title = null, in bool shouldUseSafeArea = true) : base(viewModel, title)
{
SafeAreaEdges = shouldUseSafeArea ? Microsoft.Maui.SafeAreaEdges.All : Microsoft.Maui.SafeAreaEdges.None;
On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
}
public new TViewModel BindingContext => (TViewModel)base.BindingContext;
}
abstract partial class BasePage : ContentPage
{
protected BasePage(in object? viewModel = null, in string? title = null)
{
BindingContext = viewModel;
Title = title;
Padding = 12;
if (string.IsNullOrWhiteSpace(Title))
{
Title = GetType().Name;
}
}
protected override void OnAppearing()
{
base.OnAppearing();
Debug.WriteLine($"OnAppearing: {Title}");
}
protected override void OnDisappearing()
{
base.OnDisappearing();
Debug.WriteLine($"OnDisappearing: {Title}");
}
}