|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using uiwidgets; |
|
|
|
using Unity.UIWidgets.cupertino; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.painting; |
|
|
|
|
|
|
|
|
|
|
return new GestureDetector( |
|
|
|
onTap: () => { |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoPicker( |
|
|
|
scrollController: scrollController, |
|
|
|
itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight, |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
onSelectedItemChanged: (int index)=> { |
|
|
|
setState(() => _selectedColorIndex = index); |
|
|
|
}, |
|
|
|
children: widgets |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoPicker( |
|
|
|
scrollController: scrollController, |
|
|
|
itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight, |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
onSelectedItemChanged: (int index)=> { |
|
|
|
setState(() => _selectedColorIndex = index); |
|
|
|
}, |
|
|
|
children: widgets |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
); |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Favorite Color"), |
|
|
|
new Text( |
|
|
|
CupertinoPickerDemoUtils.coolColorNames[_selectedColorIndex], |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
Widget _buildCountdownTimerPicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () =>{ |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoTimerPicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
initialTimerDuration: timer, |
|
|
|
onTimerDurationChanged: (newTimer) =>{ |
|
|
|
setState(() => timer = newTimer); |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Favorite Color"), |
|
|
|
new Text( |
|
|
|
CupertinoPickerDemoUtils.coolColorNames[_selectedColorIndex], |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Countdown Timer"), |
|
|
|
new Text( |
|
|
|
$"{timer.Hours}:" + |
|
|
|
$"{(timer.Minutes % 60).ToString("00")}:" + |
|
|
|
$"{(timer.Seconds % 60).ToString("00")}", |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildCountdownTimerPicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () =>{ |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoTimerPicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
initialTimerDuration: timer, |
|
|
|
onTimerDurationChanged: (newTimer) =>{ |
|
|
|
setState(() => timer = newTimer); |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Countdown Timer"), |
|
|
|
new Text( |
|
|
|
$"{timer.Hours}:" + |
|
|
|
$"{(timer.Minutes % 60).ToString("00")}:" + |
|
|
|
$"{(timer.Seconds % 60).ToString("00")}", |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
Widget _buildDatePicker(BuildContext context) |
|
|
|
{ |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () => |
|
|
|
Widget _buildDatePicker(BuildContext context) |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) => |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () => |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.date, |
|
|
|
initialDateTime: date, |
|
|
|
onDateTimeChanged: (DateTime newDateTime) =>{ |
|
|
|
setState(() => date = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) => |
|
|
|
{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.date, |
|
|
|
initialDateTime: date, |
|
|
|
onDateTimeChanged: (DateTime newDateTime) =>{ |
|
|
|
setState(() => date = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Date"), |
|
|
|
new Text( |
|
|
|
date.ToString("MMMM dd, yyyy"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Date"), |
|
|
|
new Text( |
|
|
|
date.ToString("MMMM dd, yyyy"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
Widget _buildTimePicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () =>{ |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.time, |
|
|
|
initialDateTime: time, |
|
|
|
onDateTimeChanged: (newDateTime) => { |
|
|
|
setState(() => time = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
Widget _buildTimePicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: () =>{ |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.time, |
|
|
|
initialDateTime: time, |
|
|
|
onDateTimeChanged: (newDateTime) => { |
|
|
|
setState(() => time = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
child:new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Time"), |
|
|
|
new Text( |
|
|
|
time.ToString("h:mm tt"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
}, |
|
|
|
child:new _Menu( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Text("Time"), |
|
|
|
new Text( |
|
|
|
time.ToString("h:mm tt"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
Widget _buildDateAndTimePicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: ()=> { |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.dateAndTime, |
|
|
|
initialDateTime: dateTime, |
|
|
|
onDateTimeChanged: (newDateTime) => { |
|
|
|
setState(() => dateTime = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
Widget _buildDateAndTimePicker(BuildContext context) { |
|
|
|
return new GestureDetector( |
|
|
|
onTap: ()=> { |
|
|
|
CupertinoRouteUtils.showCupertinoModalPopup( |
|
|
|
context: context, |
|
|
|
semanticsDismissible: true, |
|
|
|
builder: (BuildContext context1) =>{ |
|
|
|
return new _BottomPicker( |
|
|
|
child: new CupertinoDatePicker( |
|
|
|
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1), |
|
|
|
mode: CupertinoDatePickerMode.dateAndTime, |
|
|
|
initialDateTime: dateTime, |
|
|
|
onDateTimeChanged: (newDateTime) => { |
|
|
|
setState(() => dateTime = newDateTime); |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children:new List<Widget>{ |
|
|
|
new Text("Date and Time"), |
|
|
|
new Text( |
|
|
|
dateTime.ToString("MMMM dd, yyyy") + " " + dateTime.ToString("HH:mm tt"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
}, |
|
|
|
child: new _Menu( |
|
|
|
children:new List<Widget>{ |
|
|
|
new Text("Date and Time"), |
|
|
|
new Text( |
|
|
|
dateTime.ToString("MMMM dd, yyyy") + " " + dateTime.ToString("HH:mm tt"), |
|
|
|
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context)) |
|
|
|
), |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
return new CupertinoPageScaffold( |
|
|
|
navigationBar: new CupertinoNavigationBar( |
|
|
|
middle: new Text("Picker"), |
|
|
|
// We're specifying a back label here because the previous page is a
|
|
|
|
// Material page. CupertinoPageRoutes could auto-populate these back
|
|
|
|
// labels.
|
|
|
|
previousPageTitle: "Cupertino" |
|
|
|
//trailing: CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
|
|
|
|
), |
|
|
|
child: new DefaultTextStyle( |
|
|
|
style: CupertinoTheme.of(context).textTheme.textStyle, |
|
|
|
child: new ListView( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Padding(padding: EdgeInsets.only(top: 32.0f)), |
|
|
|
_buildColorPicker(context), |
|
|
|
_buildCountdownTimerPicker(context), |
|
|
|
_buildDatePicker(context), |
|
|
|
_buildTimePicker(context), |
|
|
|
_buildDateAndTimePicker(context), |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
return new CupertinoPageScaffold( |
|
|
|
navigationBar: new CupertinoNavigationBar( |
|
|
|
middle: new Text("Picker"), |
|
|
|
// We're specifying a back label here because the previous page is a
|
|
|
|
// Material page. CupertinoPageRoutes could auto-populate these back
|
|
|
|
// labels.
|
|
|
|
previousPageTitle: "Cupertino" |
|
|
|
//trailing: CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
|
|
|
|
), |
|
|
|
child: new DefaultTextStyle( |
|
|
|
style: CupertinoTheme.of(context).textTheme.textStyle, |
|
|
|
child: new ListView( |
|
|
|
children: new List<Widget>{ |
|
|
|
new Padding(padding: EdgeInsets.only(top: 32.0f)), |
|
|
|
_buildColorPicker(context), |
|
|
|
_buildCountdownTimerPicker(context), |
|
|
|
_buildDatePicker(context), |
|
|
|
_buildTimePicker(context), |
|
|
|
_buildDateAndTimePicker(context), |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|