Commit c8f8d001 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Disable DatePicker vibrate on date change on iOS (#8335)

In the Android native material DatePicker, haptic feedback is expected
on date change. This is not expected behaviour for iOS date/time
pickers.
parent 72fa281f
......@@ -591,6 +591,8 @@ class _DatePickerDialog extends StatefulWidget {
}
class _DatePickerDialogState extends State<_DatePickerDialog> {
bool _vibrate = false;
@override
void initState() {
super.initState();
......@@ -602,6 +604,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
GlobalKey _pickerKey = new GlobalKey();
void _handleModeChanged(_DatePickerMode mode) {
if (_vibrate)
HapticFeedback.vibrate();
setState(() {
_mode = mode;
......@@ -609,6 +612,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
}
void _handleYearChanged(DateTime value) {
if (_vibrate)
HapticFeedback.vibrate();
setState(() {
_mode = _DatePickerMode.day;
......@@ -617,6 +621,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
}
void _handleDayChanged(DateTime value) {
if (_vibrate)
HapticFeedback.vibrate();
setState(() {
_selectedDate = value;
......@@ -657,6 +662,15 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
@override
Widget build(BuildContext context) {
switch (Theme.of(context).platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
_vibrate = true;
break;
case TargetPlatform.iOS:
_vibrate = false;
break;
}
Widget picker = new Flexible(
child: new SizedBox(
height: _kMaxDayPickerHeight,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment