Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
79e92a53
Commit
79e92a53
authored
Aug 26, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add haptic feedback to date picker
parent
4cd223a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
date_picker.dart
packages/flutter/lib/widgets/date_picker.dart
+15
-5
No files found.
packages/flutter/lib/widgets/date_picker.dart
View file @
79e92a53
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'package:sky/mojo/activity.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/theme/typography.dart'
as
typography
;
import
'package:sky/widgets.dart'
;
...
...
@@ -43,12 +44,14 @@ class DatePicker extends StatefulComponent {
DatePickerMode
_mode
=
DatePickerMode
.
day
;
void
_handleModeChanged
(
DatePickerMode
mode
)
{
userFeedback
.
performHapticFeedback
(
HapticFeedbackType_VIRTUAL_KEY
);
setState
(()
{
_mode
=
mode
;
});
}
void
_handleYearChanged
(
DateTime
dateTime
)
{
userFeedback
.
performHapticFeedback
(
HapticFeedbackType_VIRTUAL_KEY
);
setState
(()
{
_mode
=
DatePickerMode
.
day
;
});
...
...
@@ -56,6 +59,12 @@ class DatePicker extends StatefulComponent {
onChanged
(
dateTime
);
}
void
_handleDayChanged
(
DateTime
dateTime
)
{
userFeedback
.
performHapticFeedback
(
HapticFeedbackType_VIRTUAL_KEY
);
if
(
onChanged
!=
null
)
onChanged
(
dateTime
);
}
static
const
double
_calendarHeight
=
210.0
;
Widget
build
()
{
...
...
@@ -69,7 +78,7 @@ class DatePicker extends StatefulComponent {
case
DatePickerMode
.
day
:
picker
=
new
MonthPicker
(
selectedDate:
selectedDate
,
onChanged:
on
Changed
,
onChanged:
_handleDay
Changed
,
firstDate:
firstDate
,
lastDate:
lastDate
,
itemExtent:
_calendarHeight
...
...
@@ -167,6 +176,7 @@ class DayPicker extends Component {
})
{
assert
(
selectedDate
!=
null
);
assert
(
currentDate
!=
null
);
assert
(
onChanged
!=
null
);
assert
(
displayedMonth
!=
null
);
}
...
...
@@ -239,8 +249,7 @@ class DayPicker extends Component {
item
=
new
Listener
(
onGestureTap:
(
_
)
{
DateTime
result
=
new
DateTime
(
year
,
month
,
day
);
if
(
onChanged
!=
null
)
onChanged
(
result
);
onChanged
(
result
);
},
child:
new
Container
(
height:
30.0
,
...
...
@@ -277,6 +286,7 @@ class MonthPicker extends ScrollableWidgetList {
double
itemExtent
})
:
super
(
itemExtent:
itemExtent
)
{
assert
(
selectedDate
!=
null
);
assert
(
onChanged
!=
null
);
assert
(
lastDate
.
isAfter
(
firstDate
));
}
...
...
@@ -354,6 +364,7 @@ class YearPicker extends ScrollableWidgetList {
this
.
lastDate
})
:
super
(
itemExtent:
50.0
)
{
assert
(
selectedDate
!=
null
);
assert
(
onChanged
!=
null
);
assert
(
lastDate
.
isAfter
(
firstDate
));
}
DateTime
selectedDate
;
...
...
@@ -381,8 +392,7 @@ class YearPicker extends ScrollableWidgetList {
key:
new
Key
(
label
),
onGestureTap:
(
_
)
{
DateTime
result
=
new
DateTime
(
year
,
selectedDate
.
month
,
selectedDate
.
day
);
if
(
onChanged
!=
null
)
onChanged
(
result
);
onChanged
(
result
);
},
child:
new
InkWell
(
child:
new
Container
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment