您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
165 行
5.8 KiB
165 行
5.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using uiwidgets;
|
|
using Unity.UIWidgets.cupertino;
|
|
using Unity.UIWidgets.engine;
|
|
using Unity.UIWidgets.painting;
|
|
using Unity.UIWidgets.rendering;
|
|
using Unity.UIWidgets.ui;
|
|
using Unity.UIWidgets.widgets;
|
|
using UnityEngine;
|
|
using Color = Unity.UIWidgets.ui.Color;
|
|
using Text = Unity.UIWidgets.widgets.Text;
|
|
using ui_ = Unity.UIWidgets.widgets.ui_;
|
|
using TextStyle = Unity.UIWidgets.painting.TextStyle;
|
|
|
|
namespace UIWidgetsSample
|
|
{
|
|
|
|
|
|
public class DateAndTimePicker : UIWidgetsPanel
|
|
{
|
|
protected void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
}
|
|
|
|
protected override void main()
|
|
{
|
|
ui_.runApp(new MyApp());
|
|
}
|
|
|
|
class MyApp : StatelessWidget
|
|
{
|
|
public override Widget build(BuildContext context)
|
|
{
|
|
return new CupertinoApp(
|
|
home: new DateAndTimePickerWidget()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class DateAndTimePickerWidget : StatefulWidget {
|
|
|
|
public override State createState() {
|
|
return new DateAndTimePickerWidgetState();
|
|
}
|
|
}
|
|
|
|
|
|
public class DateAndTimePickerWidgetState : State<DateAndTimePickerWidget>
|
|
{
|
|
public bool isLottieVisable = true;
|
|
private Widget picker = null;
|
|
Widget _buildMenu(List<Widget> children) {
|
|
return new Container(
|
|
decoration: new BoxDecoration(
|
|
color: CupertinoTheme.of(this.context).scaffoldBackgroundColor,
|
|
border: new Border(
|
|
top: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f),
|
|
bottom: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f)
|
|
)
|
|
),
|
|
height: 44.0f,
|
|
child: new Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0f),
|
|
child: new SafeArea(
|
|
top: false,
|
|
bottom: false,
|
|
child: new Row(
|
|
//mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: children
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
DateTime dateTime = DateTime.Now;
|
|
|
|
Widget _buildBottomPicker(Widget picker) {
|
|
return new Container(
|
|
height: 280f,
|
|
width : 500f,
|
|
padding: EdgeInsets.only(top: 6.0f),
|
|
color: Color.fromARGB(100,0,0,0),
|
|
child: new DefaultTextStyle(
|
|
style: new TextStyle(
|
|
color: Colors.red,
|
|
fontSize: 12.0f
|
|
),
|
|
child: new GestureDetector(
|
|
// Blocks taps from propagating to the modal sheet and popping.
|
|
onTap: () => { },
|
|
child: new SafeArea(
|
|
top: false,
|
|
child: picker
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
Widget _buildDateAndTimePicker(BuildContext context) {
|
|
return new GestureDetector(
|
|
onTap: () => {
|
|
setState(() =>
|
|
{
|
|
isLottieVisable = false;
|
|
});
|
|
ModalPage.popup(
|
|
context,
|
|
_buildBottomPicker(
|
|
new CupertinoTheme(
|
|
data: new CupertinoThemeData(
|
|
textTheme: new CupertinoTextThemeData(
|
|
dateTimePickerTextStyle: new TextStyle(
|
|
fontSize: 16,
|
|
color: Color.fromARGB(255, 226, 255, 255)
|
|
)
|
|
)
|
|
),
|
|
child: new CupertinoDatePicker(
|
|
backgroundColor: Colors.transparent,
|
|
mode: CupertinoDatePickerMode.dateAndTime,
|
|
initialDateTime: this.dateTime,
|
|
onDateTimeChanged: (DateTime newDateTime) =>
|
|
{
|
|
this.setState(() =>
|
|
{
|
|
LightManager.time = newDateTime;
|
|
this.dateTime = newDateTime;
|
|
});
|
|
}
|
|
)
|
|
)
|
|
),
|
|
onPop: () =>
|
|
{
|
|
setState(() =>
|
|
{
|
|
isLottieVisable = true;
|
|
});
|
|
Debug.Log("onPop");
|
|
});
|
|
},
|
|
child: new Text(
|
|
this.dateTime.ToString("MMMM dd, yyyy h:mm tt"),
|
|
style: new TextStyle(color: Colors.white, fontSize:23)
|
|
)
|
|
);
|
|
}
|
|
public override Widget build(BuildContext context)
|
|
{
|
|
return new Container(
|
|
child : new Stack(
|
|
children:new List<Widget>()
|
|
{
|
|
new Visibility(
|
|
child: new LottieApp(),
|
|
visible: isLottieVisable),
|
|
this._buildDateAndTimePicker(context),
|
|
})
|
|
);
|
|
}
|
|
}
|
|
}
|