Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimonovdd/Xamarin.DateTimePopups
Little library of popups for picking dates and times
https://github.com/dimonovdd/Xamarin.DateTimePopups
date datepicker datetimepicker picker popup time timepicker xamarin xamarin-android xamarin-forms xamarin-ios
Last synced: 3 months ago
JSON representation
Little library of popups for picking dates and times
- Host: GitHub
- URL: https://github.com/dimonovdd/Xamarin.DateTimePopups
- Owner: dimonovdd
- License: mit
- Created: 2021-03-07T16:28:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-20T21:50:38.000Z (about 3 years ago)
- Last Synced: 2024-07-29T08:11:41.197Z (3 months ago)
- Topics: date, datepicker, datetimepicker, picker, popup, time, timepicker, xamarin, xamarin-android, xamarin-forms, xamarin-ios
- Language: C#
- Homepage:
- Size: 877 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xamarin-forms - DateTimePopups ★11
README
# Xamarin.DateTimePopups [![NuGet Badge](https://buildstats.info/nuget/Xamarin.DateTimePopups)](https://www.nuget.org/packages/Xamarin.DateTimePopups/)
### Little library of popups for picking dates and times![header](/header.svg)
# Available Platforms
| Platform | Version |
| --- | --- |
| Android | MonoAndroid90+|
| iOS | Xamarin.iOS10 |
| .NET Standard | 2.0 |# Getting started
This library can be used in Xamarin.iOS, Xamarin.Android or Xamarin.Forms projects## Android
In the Android project's MainLauncher or any Activity that is launched, this library must be initialized in the OnCreate method:
```csharp
protected override void OnCreate(Bundle savedInstanceState)
{
//...
base.OnCreate(savedInstanceState);
Xamarin.DateTimePopups.Platform.Init(this, savedInstanceState); // add this line to your code, it may also be called: bundle
//...
}
```## iOS (Optional)
You can set the function to get the current `UIView````csharp
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Xamarin.DateTimePopups.Platform.Init(()=> Xamarin.Essentials.Platform.GetCurrentUIViewController()?.View);
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());return base.FinishedLaunching(app, options);
}
```
## Shared```csharp
using System;
using Xamarin.Forms;
using Xamarin.DateTimePopups;namespace Sample.Views
{
public partial class HomePage : ContentPage
{
public HomePage()
=> InitializeComponent();async void DateButton_Clicked(System.Object sender, System.EventArgs e)
{
DateTime? date = await DateTimePopups.PickDateAsync();
ResultLabel.Text = date.ToString();
}async void TimeButton_Clicked(System.Object sender, System.EventArgs e)
{
TimeSpan? date = await DateTimePopups.PickTimeAsync();
ResultLabel.Text = date.ToString();
}
}
}
```## Screenshots
| iOS (Date) | Android (Date) | iOS (Time) | Android (Time) |
|:--:|:--:|:--:|:--:|
|![iosDate](/Screenshots/iosDate.png)|![androidDate](/Screenshots/androidDate.png)|![iosTime](/Screenshots/iosTime.png)|![androidTime](/Screenshots/androidTime.png)|## Powered by
- [Xamarin.iOS.DatePickerDialog](https://github.com/alexsorokoletov/Xamarin.iOS.DatePickerDialog)