@@ -1,6 +1,7 @@
|
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace Mopups.Pages;
|
|||||||
|
|
||||||
public partial class PopupPage : ContentPage
|
public partial class PopupPage : ContentPage
|
||||||
{
|
{
|
||||||
|
|
||||||
public event EventHandler? BackgroundClicked;
|
public event EventHandler? BackgroundClicked;
|
||||||
|
|
||||||
public static readonly BindableProperty CloseWhenBackgroundIsClickedProperty = BindableProperty.Create(nameof(CloseWhenBackgroundIsClicked), typeof(bool), typeof(PopupPage), true);
|
public static readonly BindableProperty CloseWhenBackgroundIsClickedProperty = BindableProperty.Create(nameof(CloseWhenBackgroundIsClicked), typeof(bool), typeof(PopupPage), true);
|
||||||
@@ -40,8 +39,6 @@ public partial class PopupPage : ContentPage
|
|||||||
private set { SetValue(KeyboardOffsetProperty, value); }
|
private set { SetValue(KeyboardOffsetProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PopupPage()
|
public PopupPage()
|
||||||
{
|
{
|
||||||
BackgroundColor = Color.FromArgb("#80000000");
|
BackgroundColor = Color.FromArgb("#80000000");
|
||||||
@@ -52,20 +49,17 @@ public partial class PopupPage : ContentPage
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void LayoutChildren(double x, double y, double width, double height)
|
protected override void LayoutChildren(double x, double y, double width, double height)
|
||||||
{
|
{
|
||||||
height -= KeyboardOffset;
|
height -= KeyboardOffset;
|
||||||
base.LayoutChildren(x, y, width, height);
|
base.LayoutChildren(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual bool OnBackgroundClicked()
|
protected virtual bool OnBackgroundClicked()
|
||||||
{
|
{
|
||||||
return CloseWhenBackgroundIsClicked;
|
return CloseWhenBackgroundIsClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void SendBackgroundClick()
|
internal void SendBackgroundClick()
|
||||||
{
|
{
|
||||||
BackgroundClicked?.Invoke(this, EventArgs.Empty);
|
BackgroundClicked?.Invoke(this, EventArgs.Empty);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
private readonly MopupGestureDetectorListener _gestureDetectorListener;
|
private readonly MopupGestureDetectorListener _gestureDetectorListener;
|
||||||
private readonly GestureDetector _gestureDetector;
|
private readonly GestureDetector _gestureDetector;
|
||||||
private DateTime _downTime;
|
private DateTime _downTime;
|
||||||
private Microsoft.Maui.Graphics.Point _downPosition;
|
private Point _downPosition;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public PopupPageHandler()
|
public PopupPageHandler()
|
||||||
@@ -57,7 +57,7 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool OnTouchEvent(object? sender, MotionEvent e)
|
private bool OnTouchEvent(object? sender, MotionEvent? e)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,6 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
|
|
||||||
private void OnBackgroundClick(object? sender, MotionEvent e)
|
private void OnBackgroundClick(object? sender, MotionEvent e)
|
||||||
{
|
{
|
||||||
|
|
||||||
var isInRegion = IsInRegion(e.RawX, e.RawY, (sender as Android.Views.View)!);
|
var isInRegion = IsInRegion(e.RawX, e.RawY, (sender as Android.Views.View)!);
|
||||||
|
|
||||||
if (!isInRegion)
|
if (!isInRegion)
|
||||||
@@ -101,7 +100,6 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
DispatchTouchEvent(e.Event);
|
DispatchTouchEvent(e.Event);
|
||||||
|
|
||||||
void DispatchTouchEvent(MotionEvent e)
|
void DispatchTouchEvent(MotionEvent e)
|
||||||
@@ -142,7 +140,6 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,9 +148,9 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var activity = Microsoft.Maui.Essentials.Platform.CurrentActivity;
|
var activity = Platform.CurrentActivity;
|
||||||
|
|
||||||
Microsoft.Maui.Thickness systemPadding;
|
Thickness systemPadding;
|
||||||
var keyboardOffset = 0d;
|
var keyboardOffset = 0d;
|
||||||
|
|
||||||
var decoreView = activity.Window.DecorView;
|
var decoreView = activity.Window.DecorView;
|
||||||
@@ -189,8 +186,6 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var keyboardHeight = 0d;
|
var keyboardHeight = 0d;
|
||||||
|
|
||||||
if (visibleRect.Bottom < screenSize.Y)
|
if (visibleRect.Bottom < screenSize.Y)
|
||||||
@@ -218,7 +213,6 @@ public class PopupPageHandler : ContentViewHandler
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ public class PopupNavigation : IPopupNavigation
|
|||||||
public IReadOnlyList<PopupPage> PopupStack => _popupStack;
|
public IReadOnlyList<PopupPage> PopupStack => _popupStack;
|
||||||
private readonly List<PopupPage> _popupStack = new();
|
private readonly List<PopupPage> _popupStack = new();
|
||||||
|
|
||||||
public event EventHandler<PopupPage> Pushing;
|
public event EventHandler<PopupPage>? Pushing;
|
||||||
|
|
||||||
public event EventHandler<PopupPage> Pushed;
|
public event EventHandler<PopupPage>? Pushed;
|
||||||
|
|
||||||
public event EventHandler<PopupPage> Popping;
|
public event EventHandler<PopupPage>? Popping;
|
||||||
|
|
||||||
public event EventHandler<PopupPage> Popped;
|
public event EventHandler<PopupPage>? Popped;
|
||||||
|
|
||||||
|
|
||||||
private static readonly Lazy<IPopupPlatform> lazyImplementation = new(() => GeneratePopupPlatform(), System.Threading.LazyThreadSafetyMode.PublicationOnly);
|
private static readonly Lazy<IPopupPlatform> lazyImplementation = new(() => GeneratePopupPlatform(), System.Threading.LazyThreadSafetyMode.PublicationOnly);
|
||||||
@@ -80,7 +80,6 @@ public class PopupNavigation : IPopupNavigation
|
|||||||
|
|
||||||
public Task RemovePageAsync(PopupPage page)
|
public Task RemovePageAsync(PopupPage page)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (page == null)
|
if (page == null)
|
||||||
throw new InvalidOperationException("Page can not be null");
|
throw new InvalidOperationException("Page can not be null");
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Mopups.Pages;
|
using Mopups.Pages;
|
||||||
using Mopups.Services;
|
using Mopups.Services;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using ScrollView = Microsoft.Maui.Controls.ScrollView;
|
using ScrollView = Microsoft.Maui.Controls.ScrollView;
|
||||||
|
|
||||||
namespace SampleMaui.CSharpMarkup;
|
namespace SampleMaui.CSharpMarkup;
|
||||||
@@ -7,12 +8,17 @@ namespace SampleMaui.CSharpMarkup;
|
|||||||
public partial class LoginPage : PopupPage
|
public partial class LoginPage : PopupPage
|
||||||
{
|
{
|
||||||
public Frame FrameContainer { get; set; }
|
public Frame FrameContainer { get; set; }
|
||||||
public Image DotNetBotImage { get; set; }
|
public Image? DotNetBotImage { get; set; }
|
||||||
|
|
||||||
public Entry UsernameEntry { get; set; }
|
public Entry UsernameEntry { get; set; }
|
||||||
public Entry PasswordEntry { get; set; }
|
public Entry PasswordEntry { get; set; }
|
||||||
|
|
||||||
public Button LoginButton { get; set; }
|
public Button LoginButton { get; set; }
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(UsernameEntry))]
|
||||||
|
[MemberNotNull(nameof(PasswordEntry))]
|
||||||
|
[MemberNotNull(nameof(LoginButton))]
|
||||||
|
[MemberNotNull(nameof(FrameContainer))]
|
||||||
protected void BuildContent()
|
protected void BuildContent()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -23,7 +29,6 @@ public partial class LoginPage : PopupPage
|
|||||||
VerticalOptions = LayoutOptions.Center,
|
VerticalOptions = LayoutOptions.Center,
|
||||||
BackgroundColor = Color.FromRgb(200.00, 0.00, 0.00),
|
BackgroundColor = Color.FromRgb(200.00, 0.00, 0.00),
|
||||||
Content = GenerateLoginView()
|
Content = GenerateLoginView()
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -32,13 +37,17 @@ public partial class LoginPage : PopupPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(UsernameEntry))]
|
||||||
|
[MemberNotNull(nameof(PasswordEntry))]
|
||||||
|
[MemberNotNull(nameof(LoginButton))]
|
||||||
|
[MemberNotNull(nameof(FrameContainer))]
|
||||||
private Frame GenerateLoginView()
|
private Frame GenerateLoginView()
|
||||||
{
|
{
|
||||||
FrameContainer = new Frame
|
FrameContainer = new Frame
|
||||||
{
|
{
|
||||||
Margin = new Microsoft.Maui.Thickness(1),
|
Margin = new Thickness(1),
|
||||||
Padding = new Microsoft.Maui.Thickness(0),
|
Padding = new Thickness(0),
|
||||||
BackgroundColor = Microsoft.Maui.Graphics.Colors.Gray,
|
BackgroundColor = Colors.Gray,
|
||||||
HorizontalOptions = LayoutOptions.Center,
|
HorizontalOptions = LayoutOptions.Center,
|
||||||
VerticalOptions = LayoutOptions.Center,
|
VerticalOptions = LayoutOptions.Center,
|
||||||
Content = GenerateFrameContainerContent()
|
Content = GenerateFrameContainerContent()
|
||||||
@@ -46,15 +55,17 @@ public partial class LoginPage : PopupPage
|
|||||||
return FrameContainer;
|
return FrameContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(UsernameEntry))]
|
||||||
|
[MemberNotNull(nameof(PasswordEntry))]
|
||||||
|
[MemberNotNull(nameof(LoginButton))]
|
||||||
private StackLayout GenerateFrameContainerContent()
|
private StackLayout GenerateFrameContainerContent()
|
||||||
{
|
{
|
||||||
var frameContainerContent = new StackLayout
|
var frameContainerContent = new StackLayout
|
||||||
{
|
{
|
||||||
Margin = new Microsoft.Maui.Thickness(1),
|
Margin = new Thickness(1),
|
||||||
Padding = new Microsoft.Maui.Thickness(1, 1),
|
Padding = new Thickness(1, 1),
|
||||||
HorizontalOptions = LayoutOptions.Center,
|
HorizontalOptions = LayoutOptions.Center,
|
||||||
VerticalOptions = LayoutOptions.Center
|
VerticalOptions = LayoutOptions.Center
|
||||||
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
DotNetBotImage = new Image
|
DotNetBotImage = new Image
|
||||||
|
|||||||
Reference in New Issue
Block a user