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