项目作者: dimonovdd

项目描述 :
Little library of popups for picking dates and times
高级语言: C#
项目地址: git://github.com/dimonovdd/Xamarin.DateTimePopups.git
创建时间: 2021-03-07T16:28:03Z
项目社区:https://github.com/dimonovdd/Xamarin.DateTimePopups

开源协议:MIT License

下载


Xamarin.DateTimePopups NuGet Badge

Little library of popups for picking dates and times

header

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:

  1. protected override void OnCreate(Bundle savedInstanceState)
  2. {
  3. //...
  4. base.OnCreate(savedInstanceState);
  5. Xamarin.DateTimePopups.Platform.Init(this, savedInstanceState); // add this line to your code, it may also be called: bundle
  6. //...
  7. }

iOS (Optional)

You can set the function to get the current UIView

  1. public override bool FinishedLaunching(UIApplication app, NSDictionary options)
  2. {
  3. Xamarin.DateTimePopups.Platform.Init(()=> Xamarin.Essentials.Platform.GetCurrentUIViewController()?.View);
  4. global::Xamarin.Forms.Forms.Init();
  5. LoadApplication(new App());
  6. return base.FinishedLaunching(app, options);
  7. }

Shared

  1. using System;
  2. using Xamarin.Forms;
  3. using Xamarin.DateTimePopups;
  4. namespace Sample.Views
  5. {
  6. public partial class HomePage : ContentPage
  7. {
  8. public HomePage()
  9. => InitializeComponent();
  10. async void DateButton_Clicked(System.Object sender, System.EventArgs e)
  11. {
  12. DateTime? date = await DateTimePopups.PickDateAsync();
  13. ResultLabel.Text = date.ToString();
  14. }
  15. async void TimeButton_Clicked(System.Object sender, System.EventArgs e)
  16. {
  17. TimeSpan? date = await DateTimePopups.PickTimeAsync();
  18. ResultLabel.Text = date.ToString();
  19. }
  20. }
  21. }

Screenshots

iOS (Date) Android (Date) iOS (Time) Android (Time)
iosDate androidDate iosTime androidTime

Powered by