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
e7675995
Commit
e7675995
authored
Mar 30, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3002 from flutter/date_picker
DatePicker et al updates
parents
4fae8dfb
c2366f33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
14 deletions
+28
-14
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+22
-13
date_picker_dialog.dart
packages/flutter/lib/src/material/date_picker_dialog.dart
+5
-0
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+1
-1
No files found.
packages/flutter/lib/src/material/date_picker.dart
View file @
e7675995
...
...
@@ -229,24 +229,26 @@ class DayPicker extends StatelessWidget {
if
(
day
<
1
||
day
>
daysInMonth
)
{
item
=
new
Text
(
""
);
}
else
{
// Put a light circle around the selected day
BoxDecoration
decoration
;
if
(
selectedDate
.
year
==
year
&&
selectedDate
.
month
==
month
&&
selectedDate
.
day
==
day
)
TextStyle
itemStyle
=
dayStyle
;
if
(
selectedDate
.
year
==
year
&&
selectedDate
.
month
==
month
&&
selectedDate
.
day
==
day
)
{
// The selected day gets a circle background highlight, and a contrasting text color.
final
ThemeData
theme
=
Theme
.
of
(
context
);
itemStyle
=
itemStyle
.
copyWith
(
color:
(
theme
.
brightness
==
ThemeBrightness
.
light
)
?
Colors
.
white
:
Colors
.
black87
);
decoration
=
new
BoxDecoration
(
backgroundColor:
themeData
.
background
Color
,
backgroundColor:
themeData
.
accent
Color
,
shape:
BoxShape
.
circle
);
// Use a different font color for the current day
TextStyle
itemStyle
=
dayStyle
;
if
(
currentDate
.
year
==
year
&&
currentDate
.
month
==
month
&&
currentDate
.
day
==
day
)
itemStyle
=
itemStyle
.
copyWith
(
color:
themeData
.
primaryColor
);
}
else
if
(
currentDate
.
year
==
year
&&
currentDate
.
month
==
month
&&
currentDate
.
day
==
day
)
{
// The current day gets a different text color.
itemStyle
=
itemStyle
.
copyWith
(
color:
themeData
.
accentColor
);
}
item
=
new
GestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
onTap:
()
{
DateTime
result
=
new
DateTime
(
year
,
month
,
day
);
onChanged
(
result
);
...
...
@@ -285,6 +287,7 @@ class MonthPicker extends StatefulWidget {
assert
(
selectedDate
!=
null
);
assert
(
onChanged
!=
null
);
assert
(
lastDate
.
isAfter
(
firstDate
));
assert
(
selectedDate
.
isAfter
(
firstDate
)
||
selectedDate
.
isAtSameMomentAs
(
firstDate
));
}
final
DateTime
selectedDate
;
...
...
@@ -321,6 +324,10 @@ class _MonthPickerState extends State<MonthPicker> {
});
}
int
_monthDelta
(
DateTime
startDate
,
DateTime
endDate
)
{
return
(
endDate
.
year
-
startDate
.
year
)
*
12
+
endDate
.
month
-
startDate
.
month
;
}
List
<
Widget
>
buildItems
(
BuildContext
context
,
int
start
,
int
count
)
{
List
<
Widget
>
result
=
new
List
<
Widget
>();
DateTime
startDate
=
new
DateTime
(
config
.
firstDate
.
year
+
start
~/
12
,
config
.
firstDate
.
month
+
start
%
12
);
...
...
@@ -344,8 +351,10 @@ class _MonthPickerState extends State<MonthPicker> {
@override
Widget
build
(
BuildContext
context
)
{
return
new
ScrollableLazyList
(
key:
new
ValueKey
<
DateTime
>(
config
.
selectedDate
),
initialScrollOffset:
config
.
itemExtent
*
_monthDelta
(
config
.
firstDate
,
config
.
selectedDate
),
itemExtent:
config
.
itemExtent
,
itemCount:
(
config
.
lastDate
.
year
-
config
.
firstDate
.
year
)
*
12
+
config
.
lastDate
.
month
-
config
.
firstDate
.
month
+
1
,
itemCount:
_monthDelta
(
config
.
firstDate
,
config
.
lastDate
)
+
1
,
itemBuilder:
buildItems
);
}
...
...
packages/flutter/lib/src/material/date_picker_dialog.dart
View file @
e7675995
...
...
@@ -9,6 +9,8 @@ import 'package:flutter/widgets.dart';
import
'dialog.dart'
;
import
'date_picker.dart'
;
import
'flat_button.dart'
;
import
'theme.dart'
;
import
'theme_data.dart'
;
class
_DatePickerDialog
extends
StatefulWidget
{
_DatePickerDialog
({
...
...
@@ -51,6 +53,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
@override
Widget
build
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
return
new
Dialog
(
content:
new
DatePicker
(
selectedDate:
_selectedDate
,
...
...
@@ -61,10 +64,12 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
contentPadding:
EdgeInsets
.
zero
,
actions:
<
Widget
>[
new
FlatButton
(
textColor:
theme
.
accentColor
,
child:
new
Text
(
'CANCEL'
),
onPressed:
_handleCancel
),
new
FlatButton
(
textColor:
theme
.
accentColor
,
child:
new
Text
(
'OK'
),
onPressed:
_handleOk
),
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
e7675995
...
...
@@ -61,7 +61,7 @@ class ThemeData {
primarySwatch
??=
Colors
.
blue
;
primaryColor
??=
isDark
?
Colors
.
grey
[
900
]
:
primarySwatch
[
500
];
primaryColorBrightness
??=
ThemeBrightness
.
dark
;
accentColor
??=
primarySwatch
[
500
];
accentColor
??=
isDark
?
Colors
.
tealAccent
[
200
]
:
primarySwatch
[
500
];
accentColorBrightness
??=
ThemeBrightness
.
dark
;
canvasColor
??=
isDark
?
Colors
.
grey
[
850
]
:
Colors
.
grey
[
50
];
cardColor
??=
isDark
?
Colors
.
grey
[
800
]
:
Colors
.
white
;
...
...
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