Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PopupOptions.cs
1using Microsoft.Maui;
2using Microsoft.Maui.Graphics;
4
6{
10 public class PopupOptions
11 {
12 private double overlayOpacity = 0.7;
13
17 public PopupTransition ShowTransition { get; set; } = PopupTransition.Scale;
18
22 public PopupTransition HideTransition { get; set; } = PopupTransition.Fade;
23
28 public bool CloseOnBackgroundTap { get; set; } = true;
29
34 public bool CloseOnBackButton { get; set; } = true;
35
40 public double OverlayOpacity
41 {
42 get => this.overlayOpacity;
43 set
44 {
45 double clamped = value;
46 if (clamped < 0)
47 clamped = 0;
48 else if (clamped > 1)
49 clamped = 1;
50 this.overlayOpacity = clamped;
51 }
52 }
53
57 public bool IsBlocking { get; set; } = false;
58
62 public bool DisableBackgroundTap { get; set; } = false;
63
67 public PopupPlacement Placement { get; set; } = PopupPlacement.Center;
68
72 public Point? AnchorPoint { get; set; }
73
77 public Thickness Margin { get; set; } = new Thickness(0);
78
82 public Thickness Padding { get; set; } = new Thickness(0);
83
87 public void Normalize()
88 {
89 if (this.IsBlocking)
90 {
91 // Blocking popups should not close on background tap unless developer explicitly allows it.
93 this.CloseOnBackgroundTap = false;
94 // Ensure overlay is at least semi-opaque for modals.
95 if (this.OverlayOpacity < 0.3)
96 this.OverlayOpacity = 0.7;
97 }
98 if (this.DisableBackgroundTap)
99 this.CloseOnBackgroundTap = false;
100 }
101
108 public static PopupOptions CreateModal(double overlayOpacity = 0.7, bool closeOnBackButton = true)
109 {
110 PopupOptions options = new()
111 {
112 IsBlocking = true,
114 OverlayOpacity = overlayOpacity,
115 CloseOnBackButton = closeOnBackButton,
116 ShowTransition = PopupTransition.Scale,
117 HideTransition = PopupTransition.Fade
118 };
119 options.Normalize();
120 return options;
121 }
122 }
123}
Options controlling popup presentation and behavior.
Definition: PopupOptions.cs:11
Thickness Margin
Margin applied around the popup container.
Definition: PopupOptions.cs:77
PopupTransition ShowTransition
Gets or sets the transition used when the popup is shown.
Definition: PopupOptions.cs:17
double OverlayOpacity
Gets or sets the opacity applied to the backdrop overlay when the popup is visible....
Definition: PopupOptions.cs:41
PopupPlacement Placement
Defines how the popup content should be positioned on screen.
Definition: PopupOptions.cs:67
bool CloseOnBackButton
Gets or sets if the hardware back button should close the popup. For blocking popups this is typicall...
Definition: PopupOptions.cs:34
Thickness Padding
Padding applied inside the popup container before measuring child content.
Definition: PopupOptions.cs:82
Point? AnchorPoint
Optional anchor coordinate in device-independent units used with PopupPlacement.Anchor.
Definition: PopupOptions.cs:72
static PopupOptions CreateModal(double overlayOpacity=0.7, bool closeOnBackButton=true)
Creates standard blocking modal popup options.
bool CloseOnBackgroundTap
Gets or sets if tapping the dimmed background should close the popup. Ignored if IsBlocking or Disabl...
Definition: PopupOptions.cs:28
bool DisableBackgroundTap
Explicit flag to disable background tap regardless of CloseOnBackgroundTap.
Definition: PopupOptions.cs:62
PopupTransition HideTransition
Gets or sets the transition used when the popup is dismissed.
Definition: PopupOptions.cs:22
bool IsBlocking
If true, popup behaves as a blocking modal (single logical layer). Background taps are disabled unles...
Definition: PopupOptions.cs:57
void Normalize()
Normalizes option combinations enforcing blocking semantics.
Definition: PopupOptions.cs:87