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
b17fe3af
Commit
b17fe3af
authored
Nov 23, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate Date Picker into material_gallery
parent
1a351a65
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
192 additions
and
124 deletions
+192
-124
measurement.dart
examples/fitness/lib/measurement.dart
+5
-52
flutter.yaml
examples/material_gallery/flutter.yaml
+1
-0
chip_demo.dart
examples/material_gallery/lib/chip_demo.dart
+1
-1
date_picker_demo.dart
examples/material_gallery/lib/date_picker_demo.dart
+48
-0
gallery_page.dart
examples/material_gallery/lib/gallery_page.dart
+38
-4
main.dart
examples/material_gallery/lib/main.dart
+6
-2
widget_demo.dart
examples/material_gallery/lib/widget_demo.dart
+2
-2
pubspec.yaml
examples/material_gallery/pubspec.yaml
+2
-0
date_picker.dart
examples/widgets/date_picker.dart
+0
-63
material.dart
packages/flutter/lib/material.dart
+1
-0
date_picker_dialog.dart
packages/flutter/lib/src/material/date_picker_dialog.dart
+88
-0
No files found.
examples/fitness/lib/measurement.dart
View file @
b17fe3af
...
...
@@ -54,55 +54,6 @@ class MeasurementRow extends FitnessItemRow {
}
}
class
MeasurementDateDialog
extends
StatefulComponent
{
MeasurementDateDialog
({
this
.
previousDate
});
final
DateTime
previousDate
;
MeasurementDateDialogState
createState
()
=>
new
MeasurementDateDialogState
();
}
class
MeasurementDateDialogState
extends
State
<
MeasurementDateDialog
>
{
@override
void
initState
()
{
_selectedDate
=
config
.
previousDate
;
}
DateTime
_selectedDate
;
void
_handleDateChanged
(
DateTime
value
)
{
setState
(()
{
_selectedDate
=
value
;
});
}
Widget
build
(
BuildContext
context
)
{
return
new
Dialog
(
content:
new
DatePicker
(
selectedDate:
_selectedDate
,
firstDate:
new
DateTime
(
2015
,
8
),
lastDate:
new
DateTime
(
2101
),
onChanged:
_handleDateChanged
),
contentPadding:
EdgeDims
.
zero
,
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'CANCEL'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
}
),
new
FlatButton
(
child:
new
Text
(
'OK'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
_selectedDate
);
}
),
]
);
}
}
class
MeasurementFragment
extends
StatefulComponent
{
MeasurementFragment
({
this
.
onCreated
});
...
...
@@ -154,11 +105,13 @@ class MeasurementFragmentState extends State<MeasurementFragment> {
static
final
GlobalKey
weightKey
=
new
GlobalKey
();
Future
_handleDatePressed
()
async
{
DateTime
value
=
await
showD
ialog
(
DateTime
value
=
await
showD
atePicker
(
context:
context
,
child:
new
MeasurementDateDialog
(
previousDate:
_when
)
initialDate:
_when
,
firstDate:
new
DateTime
(
2015
,
8
),
lastDate:
new
DateTime
(
2101
)
);
if
(
value
!=
null
)
{
if
(
value
!=
_when
)
{
setState
(()
{
_when
=
value
;
});
...
...
examples/material_gallery/flutter.yaml
View file @
b17fe3af
name
:
material_gallery
material-design-icons
:
-
name
:
navigation/cancel
-
name
:
navigation/menu
examples/material_gallery/lib/chip_demo.dart
View file @
b17fe3af
...
...
@@ -50,6 +50,6 @@ class _ChipDemoState extends State<ChipDemo> {
final
WidgetDemo
kChipDemo
=
new
WidgetDemo
(
title:
'Chips'
,
route
:
'/
'
,
route
Name:
'/chips
'
,
builder:
(
_
)
=>
new
ChipDemo
()
);
examples/material_gallery/lib/date_picker_demo.dart
0 → 100644
View file @
b17fe3af
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:intl/intl.dart'
;
import
'widget_demo.dart'
;
class
DatePickerDemo
extends
StatefulComponent
{
_DatePickerDemoState
createState
()
=>
new
_DatePickerDemoState
();
}
class
_DatePickerDemoState
extends
State
<
DatePickerDemo
>
{
DateTime
_selectedDate
=
new
DateTime
.
now
();
Future
_handleSelectDate
()
async
{
DateTime
picked
=
await
showDatePicker
(
context:
context
,
initialDate:
_selectedDate
,
firstDate:
new
DateTime
(
2015
,
8
),
lastDate:
new
DateTime
(
2101
)
);
if
(
picked
!=
_selectedDate
)
{
setState
(()
{
_selectedDate
=
picked
;
});
}
}
Widget
build
(
BuildContext
context
)
{
return
new
Column
([
new
Text
(
new
DateFormat
.
yMMMd
().
format
(
_selectedDate
)),
new
RaisedButton
(
onPressed:
_handleSelectDate
,
child:
new
Text
(
'SELECT DATE'
)
),
],
justifyContent:
FlexJustifyContent
.
center
);
}
}
final
WidgetDemo
kDatePickerDemo
=
new
WidgetDemo
(
title:
'Date Picker'
,
routeName:
'/date-picker'
,
builder:
(
_
)
=>
new
DatePickerDemo
()
);
examples/material_gallery/lib/gallery_page.dart
View file @
b17fe3af
...
...
@@ -7,14 +7,48 @@ import 'package:flutter/material.dart';
import
'widget_demo.dart'
;
class
GalleryPage
extends
StatelessComponent
{
GalleryPage
({
this
.
demo
});
GalleryPage
({
this
.
demo
s
,
this
.
active
});
final
WidgetDemo
demo
;
final
List
<
WidgetDemo
>
demos
;
final
WidgetDemo
active
;
void
_showDrawer
(
BuildContext
context
)
{
List
<
Widget
>
items
=
<
Widget
>[
new
DrawerHeader
(
child:
new
Text
(
'Material demos'
)),
];
for
(
WidgetDemo
demo
in
demos
)
{
items
.
add
(
new
DrawerItem
(
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
demo
.
routeName
);
},
child:
new
Text
(
demo
.
title
)
));
}
showDrawer
(
context:
context
,
child:
new
Block
(
items
));
}
Widget
_body
(
BuildContext
context
)
{
if
(
active
!=
null
)
return
active
.
builder
(
context
);
return
new
Material
(
child:
new
Center
(
child:
new
Text
(
'Select a demo from the drawer'
)
)
);
}
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
demo
.
title
)),
body:
demo
.
builder
(
context
)
toolBar:
new
ToolBar
(
left:
new
IconButton
(
icon:
'navigation/menu'
,
onPressed:
()
{
_showDrawer
(
context
);
}
),
center:
new
Text
(
active
?.
title
??
'Material gallery'
)
),
body:
_body
(
context
)
);
}
}
examples/material_gallery/lib/main.dart
View file @
b17fe3af
...
...
@@ -6,16 +6,20 @@ import 'package:flutter/material.dart';
import
'chip_demo.dart'
;
import
'gallery_page.dart'
;
import
'date_picker_demo.dart'
;
import
'widget_demo.dart'
;
final
List
<
WidgetDemo
>
_kDemos
=
<
WidgetDemo
>[
kChipDemo
kChipDemo
,
kDatePickerDemo
,
];
void
main
(
)
{
Map
<
String
,
RouteBuilder
>
routes
=
new
Map
<
String
,
RouteBuilder
>();
routes
[
'/'
]
=
(
_
)
=>
new
GalleryPage
(
demos:
_kDemos
);
for
(
WidgetDemo
demo
in
_kDemos
)
routes
[
demo
.
route
]
=
(
_
)
=>
new
GalleryPage
(
demo
:
demo
);
routes
[
demo
.
route
Name
]
=
(
_
)
=>
new
GalleryPage
(
demos:
_kDemos
,
active
:
demo
);
runApp
(
new
MaterialApp
(
title:
'Material Gallery'
,
...
...
examples/material_gallery/lib/widget_demo.dart
View file @
b17fe3af
...
...
@@ -5,9 +5,9 @@
import
'package:flutter/material.dart'
;
class
WidgetDemo
{
WidgetDemo
({
this
.
title
,
this
.
route
,
this
.
builder
});
WidgetDemo
({
this
.
title
,
this
.
route
Name
,
this
.
builder
});
final
String
title
;
final
String
route
;
final
String
route
Name
;
final
WidgetBuilder
builder
;
}
examples/material_gallery/pubspec.yaml
View file @
b17fe3af
name
:
material_gallery
dependencies
:
intl
:
'
>=0.12.4+2
<0.13.0'
flutter
:
path
:
../../packages/flutter
examples/widgets/date_picker.dart
deleted
100644 → 0
View file @
1a351a65
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
new
DatePickerDemo
());
class
DatePickerDemo
extends
StatefulComponent
{
DatePickerDemoState
createState
()
=>
new
DatePickerDemoState
();
}
class
DatePickerDemoState
extends
State
<
DatePickerDemo
>
{
void
initState
()
{
super
.
initState
();
DateTime
now
=
new
DateTime
.
now
();
_dateTime
=
new
DateTime
(
now
.
year
,
now
.
month
,
now
.
day
);
}
DateTime
_dateTime
;
void
_handleDateChanged
(
DateTime
dateTime
)
{
setState
(()
{
_dateTime
=
dateTime
;
});
}
Widget
build
(
BuildContext
context
)
{
return
new
Theme
(
data:
new
ThemeData
(
brightness:
ThemeBrightness
.
light
,
primarySwatch:
Colors
.
teal
),
child:
new
Stack
(<
Widget
>[
new
Scaffold
(
toolBar:
new
ToolBar
(
center:
new
Text
(
"Date Picker"
)),
body:
new
Row
(
<
Widget
>[
new
Text
(
_dateTime
.
toString
())],
alignItems:
FlexAlignItems
.
end
,
justifyContent:
FlexJustifyContent
.
center
)
),
new
Dialog
(
content:
new
DatePicker
(
selectedDate:
_dateTime
,
firstDate:
new
DateTime
(
2015
,
8
),
lastDate:
new
DateTime
(
2101
),
onChanged:
_handleDateChanged
),
contentPadding:
EdgeDims
.
zero
,
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'CANCEL'
)
),
new
FlatButton
(
child:
new
Text
(
'OK'
)
),
]
)
])
);
}
}
packages/flutter/lib/material.dart
View file @
b17fe3af
...
...
@@ -15,6 +15,7 @@ export 'src/material/circle_avatar.dart';
export
'src/material/colors.dart'
;
export
'src/material/constants.dart'
;
export
'src/material/date_picker.dart'
;
export
'src/material/date_picker_dialog.dart'
;
export
'src/material/dialog.dart'
;
export
'src/material/drawer.dart'
;
export
'src/material/drawer_divider.dart'
;
...
...
packages/flutter/lib/src/material/date_picker_dialog.dart
0 → 100644
View file @
b17fe3af
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/widgets.dart'
;
import
'dialog.dart'
;
import
'date_picker.dart'
;
import
'flat_button.dart'
;
class
_DatePickerDialog
extends
StatefulComponent
{
_DatePickerDialog
({
Key
key
,
this
.
initialDate
,
this
.
firstDate
,
this
.
lastDate
})
:
super
(
key:
key
);
final
DateTime
initialDate
;
final
DateTime
firstDate
;
final
DateTime
lastDate
;
_DatePickerDialogState
createState
()
=>
new
_DatePickerDialogState
();
}
class
_DatePickerDialogState
extends
State
<
_DatePickerDialog
>
{
void
initState
()
{
super
.
initState
();
_selectedDate
=
config
.
initialDate
;
}
DateTime
_selectedDate
;
void
_handleDateChanged
(
DateTime
value
)
{
setState
(()
{
_selectedDate
=
value
;
});
}
void
_handleCancel
()
{
Navigator
.
of
(
context
).
pop
();
}
void
_handleOk
()
{
Navigator
.
of
(
context
).
pop
(
_selectedDate
);
}
Widget
build
(
BuildContext
context
)
{
return
new
Dialog
(
content:
new
DatePicker
(
selectedDate:
_selectedDate
,
firstDate:
config
.
firstDate
,
lastDate:
config
.
lastDate
,
onChanged:
_handleDateChanged
),
contentPadding:
EdgeDims
.
zero
,
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
'CANCEL'
),
onPressed:
_handleCancel
),
new
FlatButton
(
child:
new
Text
(
'OK'
),
onPressed:
_handleOk
),
]
);
}
}
Future
<
DateTime
>
showDatePicker
({
BuildContext
context
,
DateTime
initialDate
,
DateTime
firstDate
,
DateTime
lastDate
})
async
{
DateTime
picked
=
await
showDialog
(
context:
context
,
child:
new
_DatePickerDialog
(
initialDate:
initialDate
,
firstDate:
firstDate
,
lastDate:
lastDate
)
);
return
picked
??
initialDate
;
}
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