浏览代码

Add date picker demo

/DatePickerDemo
shiyun wen 3 年前
当前提交
c5b6baff
共有 2 个文件被更改,包括 154 次插入7 次删除
  1. 17
      AwesomeUIWidgets/Assets/Scenes/SimpleWorldSpaceUI.unity
  2. 144
      AwesomeUIWidgets/Assets/Scripts/DateAndTimePicker.cs

17
AwesomeUIWidgets/Assets/Scenes/SimpleWorldSpaceUI.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 1803575975}
m_Texture: {fileID: 1431343988}
m_UVRect:
serializedVersion: 2
x: 0

m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!28 &1803575975
--- !u!28 &1431343988
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 2
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0

offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &1882612338
GameObject:
m_ObjectHideFlags: 0

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2074331820}
m_LocalRotation: {x: 0, y: -0.3507795, z: 0, w: 0.9364581}
m_LocalPosition: {x: -174, y: 50.01288, z: 432}
m_LocalRotation: {x: 0, y: -0.078459024, z: 0, w: 0.99691737}
m_LocalPosition: {x: 200, y: 187, z: 780}
m_LocalEulerAnglesHint: {x: 0, y: -41.07, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: -9, z: 0}

144
AwesomeUIWidgets/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)
);
}
}
}
正在加载...
取消
保存