├── icon.png ├── Sample ├── Resources │ ├── Images │ │ └── dotnet_bot.png │ ├── Fonts │ │ ├── OpenSans-Regular.ttf │ │ └── OpenSans-Semibold.ttf │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Styles │ │ ├── Colors.xaml │ │ └── Styles.xaml ├── PopupTestPage.xaml.cs ├── Properties │ └── launchSettings.json ├── App.xaml.cs ├── AppShell.xaml.cs ├── Platforms │ ├── Android │ │ ├── Resources │ │ │ └── values │ │ │ │ └── colors.xml │ │ ├── AndroidManifest.xml │ │ ├── MainApplication.cs │ │ └── MainActivity.cs │ ├── iOS │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ └── Info.plist │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Program.cs │ │ ├── Entitlements.plist │ │ └── Info.plist │ └── Windows │ │ ├── App.xaml │ │ ├── app.manifest │ │ ├── App.xaml.cs │ │ └── Package.appxmanifest ├── AppShell.xaml ├── MauiProgram.cs ├── App.xaml ├── MainPage.xaml.cs ├── PopupTestPage.xaml ├── MainPage.xaml └── Sample.csproj ├── MPowerKit.Popups ├── Animations │ ├── MoveAnimationOptions.cs │ ├── FadeAnimation.cs │ ├── Base │ │ └── BaseAnimation.cs │ ├── FadeBackgroundAnimation.cs │ ├── MoveAnimation.cs │ └── ScaleAnimation.cs ├── DisposableAction.cs ├── PopupService.net.cs ├── Interfaces │ ├── IPopupAnimation.cs │ └── IPopupService.cs ├── Platforms │ ├── Android │ │ ├── AndroidExtensions.cs │ │ ├── KeyboardListener.cs │ │ ├── FragmentLifecycleCallback.cs │ │ ├── ParentLayout.cs │ │ └── PopupService.cs │ └── Windows │ │ └── PopupService.cs ├── DisposableActionAttached.cs ├── BuilderExtensions.cs ├── MPowerKit.Popups.csproj ├── PopupService.cs ├── MaciOS │ └── PopupService.cs └── PopupPage.cs ├── LICENSE ├── MPowerKit.Popups.sln ├── readme.md └── .gitignore /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/Popups/HEAD/icon.png -------------------------------------------------------------------------------- /Sample/Resources/Images/dotnet_bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/Popups/HEAD/Sample/Resources/Images/dotnet_bot.png -------------------------------------------------------------------------------- /Sample/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/Popups/HEAD/Sample/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /Sample/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/Popups/HEAD/Sample/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /Sample/PopupTestPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sample; 2 | 3 | public partial class PopupTestPage 4 | { 5 | public PopupTestPage() 6 | { 7 | InitializeComponent(); 8 | } 9 | } -------------------------------------------------------------------------------- /Sample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sample; 2 | 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | 9 | MainPage = new MainPage(); 10 | } 11 | } -------------------------------------------------------------------------------- /Sample/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sample 2 | { 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /MPowerKit.Popups/Animations/MoveAnimationOptions.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups.Animations; 2 | 3 | [Flags] 4 | public enum MoveAnimationOptions 5 | { 6 | Center = 1, 7 | Left = 2, 8 | Right = 4, 9 | Top = 8, 10 | Bottom = 16 11 | } -------------------------------------------------------------------------------- /Sample/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /Sample/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace Sample 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace Sample 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sample/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPowerKit.Popups/DisposableAction.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups; 2 | 3 | public class DisposableAction : IDisposable 4 | { 5 | private readonly Action _action; 6 | 7 | public DisposableAction(Action action) 8 | { 9 | _action = action ?? throw new ArgumentNullException(nameof(action)); 10 | } 11 | 12 | public void Dispose() 13 | { 14 | _action(); 15 | } 16 | } -------------------------------------------------------------------------------- /MPowerKit.Popups/PopupService.net.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups; 2 | 3 | public partial class PopupService 4 | { 5 | protected virtual partial void AttachToWindow(PopupPage page, IViewHandler pageHandler, Window parentWindow) 6 | { 7 | 8 | } 9 | 10 | protected virtual partial void DetachFromWindow(PopupPage page, IViewHandler pageHandler, Window parentWindow) 11 | { 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /MPowerKit.Popups/Interfaces/IPopupAnimation.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups.Interfaces; 2 | 3 | public interface IPopupAnimation 4 | { 5 | public TimeSpan DurationIn { get; set; } 6 | public TimeSpan DurationOut { get; set; } 7 | void Preparing(View? content, PopupPage page); 8 | void Disposing(View? content, PopupPage page); 9 | Task Appearing(View? content, PopupPage page); 10 | Task Disappearing(View? content, PopupPage page); 11 | } -------------------------------------------------------------------------------- /Sample/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace Sample 5 | { 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /MPowerKit.Popups/Interfaces/IPopupService.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups.Interfaces; 2 | 3 | public interface IPopupService 4 | { 5 | IReadOnlyList PopupStack { get; } 6 | 7 | ValueTask ShowPopupAsync(PopupPage page, bool animated = true); 8 | ValueTask ShowPopupAsync(PopupPage page, Window? attachToWindow, bool animated = true); 9 | ValueTask HidePopupAsync(bool animated = true); 10 | ValueTask HidePopupAsync(PopupPage page, bool animated = true); 11 | } -------------------------------------------------------------------------------- /Sample/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace Sample 6 | { 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sample/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | 3 | using UIKit; 4 | 5 | namespace Sample 6 | { 7 | public class Program 8 | { 9 | // This is the main entry point of the application. 10 | static void Main(string[] args) 11 | { 12 | // if you want to use a different Application Delegate class from "AppDelegate" 13 | // you can specify it here. 14 | UIApplication.Main(args, null, typeof(AppDelegate)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sample/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | 3 | using UIKit; 4 | 5 | namespace Sample 6 | { 7 | public class Program 8 | { 9 | // This is the main entry point of the application. 10 | static void Main(string[] args) 11 | { 12 | // if you want to use a different Application Delegate class from "AppDelegate" 13 | // you can specify it here. 14 | UIApplication.Main(args, null, typeof(AppDelegate)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MPowerKit.Popups/Platforms/Android/AndroidExtensions.cs: -------------------------------------------------------------------------------- 1 | using AndroidX.Fragment.App; 2 | 3 | using Microsoft.Maui.Platform; 4 | 5 | namespace MPowerKit.Popups; 6 | 7 | public static class AndroidExtensions 8 | { 9 | public static FragmentManager GetFragmentManager(IMauiContext mauiContext) 10 | { 11 | var fragmentManager = mauiContext.Services.GetService(); 12 | 13 | return fragmentManager 14 | ?? mauiContext.Context?.GetFragmentManager() 15 | ?? throw new InvalidOperationException("FragmentManager Not Found"); 16 | } 17 | } -------------------------------------------------------------------------------- /Sample/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using MPowerKit.Popups; 2 | 3 | namespace Sample 4 | { 5 | public static class MauiProgram 6 | { 7 | public static MauiApp CreateMauiApp() 8 | { 9 | var builder = MauiApp.CreateBuilder(); 10 | builder 11 | .UseMauiApp() 12 | .UseMPowerKitPopups() 13 | .ConfigureFonts(fonts => 14 | { 15 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 16 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 17 | }); 18 | 19 | return builder.Build(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Sample/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sample/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using MPowerKit.Popups.Interfaces; 2 | 3 | namespace Sample; 4 | 5 | public partial class MainPage 6 | { 7 | int count; 8 | 9 | public IPopupService PopupService { get; } 10 | 11 | public MainPage() 12 | { 13 | InitializeComponent(); 14 | 15 | PopupService = MPowerKit.Popups.PopupService.Current; 16 | } 17 | 18 | private void OnCounterClicked(object sender, EventArgs e) 19 | { 20 | count++; 21 | 22 | if (count == 1) 23 | CounterBtn.Text = $"Clicked {count} time"; 24 | else 25 | CounterBtn.Text = $"Clicked {count} times"; 26 | 27 | PopupService.ShowPopupAsync(new PopupTestPage()); 28 | } 29 | } -------------------------------------------------------------------------------- /Sample/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /MPowerKit.Popups/DisposableActionAttached.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.Popups; 2 | 3 | public class DisposableActionAttached 4 | { 5 | #region DisposableAction 6 | public static readonly BindableProperty DisposableActionProperty = 7 | BindableProperty.CreateAttached( 8 | "DisposableAction", 9 | typeof(DisposableAction), 10 | typeof(DisposableActionAttached), 11 | null); 12 | 13 | public static DisposableAction GetDisposableAction(BindableObject view) => (DisposableAction)view.GetValue(DisposableActionProperty); 14 | 15 | public static void SetDisposableAction(BindableObject view, DisposableAction value) => view.SetValue(DisposableActionProperty, value); 16 | #endregion 17 | } 18 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.apple.security.app-sandbox 8 | 9 | 10 | com.apple.security.network.client 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sample/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Sample/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace Sample.WinUI 7 | { 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Sample/PopupTestPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 MPowerKit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Sample/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /MPowerKit.Popups/Platforms/Android/KeyboardListener.cs: -------------------------------------------------------------------------------- 1 | using Android.Views; 2 | 3 | namespace MPowerKit.Popups; 4 | 5 | public class KeyboardListener : Java.Lang.Object, ViewTreeObserver.IOnGlobalLayoutListener 6 | { 7 | private readonly ViewGroup _decorView; 8 | 9 | public bool KeyboardVisible { get; private set; } 10 | 11 | public KeyboardListener(ViewGroup decorView) 12 | { 13 | _decorView = decorView; 14 | } 15 | 16 | public void OnGlobalLayout() 17 | { 18 | var view = _decorView.FindViewById(Android.Resource.Id.Content); 19 | if (view is null) return; 20 | 21 | var r = new Android.Graphics.Rect(); 22 | view!.GetWindowVisibleDisplayFrame(r); 23 | int screenHeight = view.RootView!.Height; 24 | 25 | // r.bottom is the position above soft keypad or device button. 26 | // if keypad is shown, the r.bottom is smaller than that before. 27 | int keypadHeight = screenHeight - r.Bottom; 28 | 29 | if (keypadHeight > screenHeight * 0.15) 30 | { 31 | if (!KeyboardVisible) 32 | { 33 | KeyboardVisible = true; 34 | } 35 | } 36 | else if (KeyboardVisible) 37 | { 38 | KeyboardVisible = false; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Sample/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 10 | 14 | 15 |