shiyun wen
3 年前
当前提交
c5b6baff
共有 2 个文件被更改,包括 154 次插入 和 7 次删除
-
17AwesomeUIWidgets/Assets/Scenes/SimpleWorldSpaceUI.unity
-
144AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs
|
|||
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 DatePickerDemo : 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> |
|||
{ |
|||
|
|||
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: 216f, |
|||
width : 500f, |
|||
padding: EdgeInsets.only(top: 6.0f), |
|||
color: Colors.white, |
|||
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: () => { |
|||
CupertinoRouteUtils.showCupertinoModalPopup( |
|||
context: context, |
|||
builder: (BuildContext _context) => { |
|||
return this._buildBottomPicker( |
|||
new CupertinoTheme( |
|||
data: new CupertinoThemeData( |
|||
textTheme: new CupertinoTextThemeData( |
|||
dateTimePickerTextStyle: new TextStyle( |
|||
fontSize: 16, |
|||
color: Colors.white |
|||
) |
|||
) |
|||
), |
|||
child :new CupertinoDatePicker( |
|||
backgroundColor: Colors.black, |
|||
mode: CupertinoDatePickerMode.dateAndTime, |
|||
initialDateTime: this.dateTime, |
|||
onDateTimeChanged: (DateTime newDateTime) => { |
|||
this.setState(() => this.dateTime = newDateTime); |
|||
} |
|||
) |
|||
)); |
|||
} |
|||
); |
|||
}, |
|||
child: new Text( |
|||
this.dateTime.ToString("MMMM dd, yyyy h:mm tt"), |
|||
style: new TextStyle(color: Colors.white) |
|||
|
|||
) |
|||
); |
|||
} |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new Container( |
|||
color : Colors.black, |
|||
child : this._buildDateAndTimePicker(context) |
|||
); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue