AwaitablePopups 0.1.7
See the version list below for details.
dotnet add package AwaitablePopups --version 0.1.7
NuGet\Install-Package AwaitablePopups -Version 0.1.7
<PackageReference Include="AwaitablePopups" Version="0.1.7" />
paket add AwaitablePopups --version 0.1.7
#r "nuget: AwaitablePopups, 0.1.7"
// Install AwaitablePopups as a Cake Addin #addin nuget:?package=AwaitablePopups&version=0.1.7 // Install AwaitablePopups as a Cake Tool #tool nuget:?package=AwaitablePopups&version=0.1.7
Table of Contents
About The Project
Awaitable Popups is a neat blend of the Rg.Plugins.Popup and AsyncAwaitBestPractices plugins to bring you a quick way to add popups into your Xamarin Forms App using familiar concepts
Built With
Getting Started
First, you must follow the initialisation guide set out by Rg.Plugins.Popup, once you have that, have a look at usage down below
Installation
You can install the nuget by looking up 'AwaitablePopups' in your nuget package manager, or by getting it here
Usage
I have included a very base example, but here is the nuts and bolts.
This is a function that is called when a user logs in using the incorrect credentials.
First, there is the loader. This is a new addition to the Plugin, and it allows you to wrap any function in a Progress loader, and it will automatically disappear when that task is complete. It has an extra of allowing you to scroll through messages that will display to the end user, if you so choose.
Second, now that the Login attempt is over, We create the ViewModel, and then assign the ViewModel properties with what we want. The most important is the Single Button Command here, (which can accept the AsyncCommand from AsyncAwaitBestPractices or anything that implements ICommand).
This property allows you to enact any functionality within the popup once a button is pressed, this could be a call to an API, an extended amount of processing, it does however, need to finish with SafeCloseModal, a function which will return whatever value you place inside it (aslong as it matches pushasync, which is below)
Once you have setup the rest of the properties (image is important), you then use PushAsync. PushAsync is the generic glue that holds this all together. With it, you will specify the ViewModel, the Page, and the type you are returning using safeclosemodal.
This is because one ViewModel could be used for several popuppages, and so forth.
A limitation here is that no matter what, you return one type. This is something I will need to workaround in the future.
private async Task<bool> IncorrectLoginAsync()
{
System.Collections.Generic.List<string> Reasons = new System.Collections.Generic.List<string>
{
"Twiddling Thumbs",
"Rolling Eyes",
"Checking Watch",
"General Complaining",
"Calling in late to work",
"Waiting"
};
await PopupService.WrapTaskInLoader(Task.Delay(10000), Xamarin.Forms.Color.Blue, Xamarin.Forms.Color.White, Reasons, Xamarin.Forms.Color.Black);
var incorrectLoginError = new SingleResponseViewModel(PopupService);
incorrectLoginError.SingleButtonCommand = new Xamarin.Forms.Command(() => incorrectLoginError.SafeCloseModal(false));
incorrectLoginError.SingleButtonColour = Xamarin.Forms.Color.Goldenrod;
incorrectLoginError.SingleButtonText = "Okay";
incorrectLoginError.MainPopupInformation = "Your Phone Number or Pin is incorrect, please try again.";
incorrectLoginError.MainPopupColour = Xamarin.Forms.Color.Gray;
incorrectLoginError.SingleDisplayImage = "NoSource.png";
return await PopupService.PushAsync<SingleResponseViewModel, SingleResponsePopupPage, bool>(incorrectLoginError);
}
This function then is called like this:
if (string.IsNullOrEmpty(Mobile) || string.IsNullOrEmpty(Password))
{
loginResult = await IncorrectLoginAsync();
}
And then, if a user puts in an incorrect login, the popup will show, wait for user interaction, and fire off
incorrectLoginError.SafeCloseModal(false))
which in turn, makes loginResult = false
.
here is an example (Looks slow due to giphy)
If you want to make your own Popup Page
This is the real power of this Plugin (Thanks in no small amount to Rotorgames amazing plugin). If you look at the source for DualResponsePopupPage, or the SingleResponse version you'll notice that they are just simple Xaml Pages. Nothing fancy. (except for the rg popup spice).
All you need to do is follow that example. So:
- Create Xaml Page with codebehind
- Create your ViewModel that is associated with the popup, lets call ours
InformationPopupPage
- Ensure your ViewModel inherits from
PopupViewModel<TReturnable>
whereTReturnable
is what you want the popuppage to return to its caller - Ensure that your xaml page codebehind inherits from
PopupPage
(requirement to use rg plugins popup) andIGenericViewModel<TViewModel>
whereTViewModel
is your Viewmodel, in our case it will beIGenericViewModel<InformationPopupPage>
- You're ready to start using it the same as
DualResponsePopupPage
Contributing
Coming soon, but if you have any ideas or anything, please feel free to make an issue or PR.
License
This project uses the MIT license
Contact
My Github, or reach me on the Xamarin Slack, or on my E-mail
Project Link: AwaitablePopups
Acknowledgements
- Brimmick has been a model to follow (might steal his hackernews app for an example)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- AsyncAwaitBestPractices (>= 4.1.0)
- Rg.Plugins.Popup (>= 1.2.0.223)
- Xamarin.Forms (>= 4.5.0.356)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.1.5 | 2,218 | 1/13/2021 | |
1.1.4 | 842 | 8/26/2020 | |
1.1.3 | 458 | 8/24/2020 | |
1.1.2 | 480 | 8/20/2020 | |
1.1.1-rc | 407 | 8/18/2020 | |
1.1.0 | 473 | 8/7/2020 | |
1.0.2 | 541 | 7/21/2020 | |
1.0.1 | 506 | 7/3/2020 | |
1.0.0 | 600 | 7/1/2020 | |
0.3.8 | 620 | 6/8/2020 | |
0.3.5 | 650 | 5/4/2020 | |
0.3.4 | 611 | 4/20/2020 | |
0.3.3 | 789 | 4/20/2020 | |
0.3.1 | 791 | 4/20/2020 | |
0.3.1-Alpha | 652 | 4/17/2020 | |
0.3.0 | 742 | 3/24/2020 | |
0.2.5 | 1,077 | 3/23/2020 | |
0.2.4 | 1,115 | 3/23/2020 | |
0.2.3 | 1,125 | 3/23/2020 | |
0.2.1 | 1,123 | 3/23/2020 | |
0.2.0 | 1,020 | 3/20/2020 | |
0.1.9 | 1,239 | 3/20/2020 | |
0.1.8 | 954 | 3/11/2020 | |
0.1.7 | 949 | 3/9/2020 | |
0.1.6 | 1,068 | 2/24/2020 | |
0.1.5 | 1,083 | 2/10/2020 | |
0.1.3 | 1,661 | 1/31/2020 | |
0.1.2 | 1,416 | 1/31/2020 |
Bug Fixing arround concurrent popups
Added the ability for a loader to have switchable text!