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
d8eaac42
Commit
d8eaac42
authored
Mar 02, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added menu dividers
parent
52a24840
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
31 deletions
+80
-31
menu_demo.dart
examples/material_gallery/lib/demo/menu_demo.dart
+2
-2
drawer.dart
examples/material_gallery/lib/gallery/drawer.dart
+1
-1
stock_home.dart
examples/stocks/lib/stock_home.dart
+2
-2
card_collection.dart
examples/widgets/card_collection.dart
+4
-4
material.dart
packages/flutter/lib/material.dart
+1
-1
divider.dart
packages/flutter/lib/src/material/divider.dart
+34
-0
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+36
-21
No files found.
examples/material_gallery/lib/demo/menu_demo.dart
View file @
d8eaac42
...
...
@@ -111,7 +111,7 @@ class MenuDemoState extends State<MenuDemo> {
primary:
new
Text
(
'An item with a sectioned menu'
),
right:
new
PopupMenuButton
<
String
>(
onSelected:
showMenuSelection
,
items:
<
PopupMenu
Item
>[
items:
<
PopupMenu
Entry
<
String
>
>[
new
PopupMenuItem
(
value:
'Preview'
,
child:
new
ListItem
(
...
...
@@ -128,12 +128,12 @@ class MenuDemoState extends State<MenuDemo> {
),
new
PopupMenuItem
(
value:
'Get Link'
,
hasDivider:
true
,
child:
new
ListItem
(
left:
new
Icon
(
icon:
'content/link'
),
primary:
new
Text
(
'Get Link'
)
)
),
new
PopupMenuDivider
(),
new
PopupMenuItem
(
value:
'Remove'
,
child:
new
ListItem
(
...
...
examples/material_gallery/lib/gallery/drawer.dart
View file @
d8eaac42
...
...
@@ -56,7 +56,7 @@ class GalleryDrawer extends StatelessComponent {
]
)
),
new
D
rawerD
ivider
(),
new
Divider
(),
new
DrawerItem
(
icon:
'action/hourglass_empty'
,
selected:
timeDilation
!=
1.0
,
...
...
examples/stocks/lib/stock_home.dart
View file @
d8eaac42
...
...
@@ -169,7 +169,7 @@ class StockHomeState extends State<StockHome> {
},
child:
new
Text
(
'Dump App to Console'
)
),
new
D
rawerD
ivider
(),
new
Divider
(),
new
DrawerItem
(
icon:
'action/thumb_up'
,
onPressed:
()
=>
_handleStockModeChange
(
StockMode
.
optimistic
),
...
...
@@ -190,7 +190,7 @@ class StockHomeState extends State<StockHome> {
]
)
),
new
D
rawerD
ivider
(),
new
Divider
(),
new
DrawerItem
(
icon:
'action/settings'
,
onPressed:
_handleShowSettings
,
...
...
examples/widgets/card_collection.dart
View file @
d8eaac42
...
...
@@ -128,20 +128,20 @@ class CardCollectionState extends State<CardCollection> {
buildDrawerCheckbox
(
"Fixed size cards"
,
_fixedSizeCards
,
_toggleFixedSizeCards
),
buildDrawerCheckbox
(
"Let the sun shine"
,
_sunshine
,
_toggleSunshine
),
buildDrawerCheckbox
(
"Vary font sizes"
,
_varyFontSizes
,
_toggleVaryFontSizes
,
enabled:
!
_editable
),
new
D
rawerD
ivider
(),
new
Divider
(),
buildDrawerColorRadioItem
(
"Deep Purple"
,
Colors
.
deepPurple
,
_primaryColor
,
_selectColor
),
buildDrawerColorRadioItem
(
"Green"
,
Colors
.
green
,
_primaryColor
,
_selectColor
),
buildDrawerColorRadioItem
(
"Amber"
,
Colors
.
amber
,
_primaryColor
,
_selectColor
),
buildDrawerColorRadioItem
(
"Teal"
,
Colors
.
teal
,
_primaryColor
,
_selectColor
),
new
D
rawerD
ivider
(),
new
Divider
(),
buildDrawerDirectionRadioItem
(
"Dismiss horizontally"
,
DismissDirection
.
horizontal
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'action/code'
),
buildDrawerDirectionRadioItem
(
"Dismiss left"
,
DismissDirection
.
left
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_back'
),
buildDrawerDirectionRadioItem
(
"Dismiss right"
,
DismissDirection
.
right
,
_dismissDirection
,
_changeDismissDirection
,
icon:
'navigation/arrow_forward'
),
new
D
rawerD
ivider
(),
new
Divider
(),
buildFontRadioItem
(
"Left-align text"
,
new
TextStyle
(
textAlign:
TextAlign
.
left
),
_textStyle
,
_changeTextStyle
,
icon:
'editor/format_align_left'
,
enabled:
!
_editable
),
buildFontRadioItem
(
"Center-align text"
,
new
TextStyle
(
textAlign:
TextAlign
.
center
),
_textStyle
,
_changeTextStyle
,
icon:
'editor/format_align_center'
,
enabled:
!
_editable
),
buildFontRadioItem
(
"Right-align text"
,
new
TextStyle
(
textAlign:
TextAlign
.
right
),
_textStyle
,
_changeTextStyle
,
icon:
'editor/format_align_right'
,
enabled:
!
_editable
),
new
D
rawerD
ivider
(),
new
Divider
(),
new
DrawerItem
(
icon:
'device/dvr'
,
onPressed:
()
{
debugDumpApp
();
debugDumpRenderTree
();
},
...
...
packages/flutter/lib/material.dart
View file @
d8eaac42
...
...
@@ -20,9 +20,9 @@ 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'
;
export
'src/material/drawer_header.dart'
;
export
'src/material/drawer_item.dart'
;
export
'src/material/divider.dart'
;
export
'src/material/dropdown.dart'
;
export
'src/material/flat_button.dart'
;
export
'src/material/flexible_space_bar.dart'
;
...
...
packages/flutter/lib/src/material/d
rawer_d
ivider.dart
→
packages/flutter/lib/src/material/divider.dart
View file @
d8eaac42
...
...
@@ -6,20 +6,29 @@ import 'package:flutter/widgets.dart';
import
'theme.dart'
;
class
DrawerDivider
extends
StatelessComponent
{
const
DrawerDivider
({
Key
key
})
:
super
(
key:
key
);
class
Divider
extends
StatelessComponent
{
Divider
({
Key
key
,
this
.
height
:
16.0
,
this
.
indent
:
0.0
,
this
.
color
})
:
super
(
key:
key
)
{
assert
(
height
>=
1.0
);
}
final
double
height
;
final
double
indent
;
final
Color
color
;
Widget
build
(
BuildContext
context
)
{
final
double
bottom
=
(
height
~/
2.0
).
toDouble
();
return
new
Container
(
height:
0.0
,
margin:
new
EdgeDims
.
only
(
top:
height
-
bottom
-
1.0
,
left:
indent
,
bottom:
bottom
),
decoration:
new
BoxDecoration
(
border:
new
Border
(
bottom:
new
BorderSide
(
color:
Theme
.
of
(
context
).
dividerColor
)
bottom:
new
BorderSide
(
color:
color
??
Theme
.
of
(
context
).
dividerColor
)
)
),
margin:
const
EdgeDims
.
symmetric
(
vertical:
8.0
)
)
);
}
}
packages/flutter/lib/src/material/popup_menu.dart
View file @
d8eaac42
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'package:flutter/widgets.dart'
;
import
'divider.dart'
;
import
'icon.dart'
;
import
'icon_button.dart'
;
import
'icon_theme.dart'
;
...
...
@@ -26,20 +27,36 @@ const double _kMenuVerticalPadding = 8.0;
const
double
_kMenuWidthStep
=
56.0
;
const
double
_kMenuScreenPadding
=
8.0
;
class
PopupMenuItem
<
T
>
extends
StatelessComponent
{
abstract
class
PopupMenuEntry
<
T
>
extends
StatelessComponent
{
PopupMenuEntry
({
Key
key
})
:
super
(
key:
key
);
double
get
height
;
T
get
value
=>
null
;
bool
get
enabled
=>
true
;
}
class
PopupMenuDivider
extends
PopupMenuEntry
<
dynamic
>
{
PopupMenuDivider
({
Key
key
,
this
.
height
:
16.0
})
:
super
(
key:
key
);
final
double
height
;
Widget
build
(
BuildContext
context
)
=>
new
Divider
(
height:
height
);
}
class
PopupMenuItem
<
T
>
extends
PopupMenuEntry
<
T
>
{
PopupMenuItem
({
Key
key
,
this
.
value
,
this
.
enabled
:
true
,
this
.
hasDivider
:
false
,
this
.
child
})
:
super
(
key:
key
);
final
T
value
;
final
bool
enabled
;
final
bool
hasDivider
;
final
Widget
child
;
double
get
height
=>
_kMenuItemHeight
;
Widget
build
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
TextStyle
style
=
theme
.
text
.
subhead
;
...
...
@@ -49,7 +66,7 @@ class PopupMenuItem<T> extends StatelessComponent {
Widget
item
=
new
DefaultTextStyle
(
style:
style
,
child:
new
Baseline
(
baseline:
_kMenuItemH
eight
-
_kBaselineOffsetFromBottom
,
baseline:
h
eight
-
_kBaselineOffsetFromBottom
,
child:
child
)
);
...
...
@@ -63,11 +80,8 @@ class PopupMenuItem<T> extends StatelessComponent {
return
new
MergeSemantics
(
child:
new
Container
(
height:
_kMenuItemH
eight
,
height:
h
eight
,
padding:
const
EdgeDims
.
symmetric
(
horizontal:
_kMenuHorizontalPadding
),
decoration:
!
hasDivider
?
null
:
new
BoxDecoration
(
border:
new
Border
(
bottom:
new
BorderSide
(
color:
theme
.
dividerColor
))
),
child:
item
)
);
...
...
@@ -172,10 +186,10 @@ class _PopupMenu<T> extends StatelessComponent {
}
class
_PopupMenuRouteLayout
extends
OneChildLayoutDelegate
{
_PopupMenuRouteLayout
(
this
.
position
,
this
.
selectedI
ndex
);
_PopupMenuRouteLayout
(
this
.
position
,
this
.
selectedI
temOffset
);
final
ModalPosition
position
;
final
int
selectedIndex
;
final
double
selectedItemOffset
;
BoxConstraints
getConstraintsForChild
(
BoxConstraints
constraints
)
{
return
new
BoxConstraints
(
...
...
@@ -195,8 +209,8 @@ class _PopupMenuRouteLayout extends OneChildLayoutDelegate {
double
y
=
position
?.
top
??
(
position
?.
bottom
!=
null
?
size
.
height
-
(
position
.
bottom
-
childSize
.
height
)
:
_kMenuScreenPadding
);
if
(
selectedI
ndex
!=
-
1
)
y
-=
(
_kMenuItemHeight
*
selectedIndex
)
+
_kMenuVerticalPadding
+
_kMenuItemHeight
/
2.0
;
if
(
selectedI
temOffset
!=
null
)
y
-=
selectedItemOffset
+
_kMenuVerticalPadding
+
_kMenuItemHeight
/
2.0
;
if
(
x
<
_kMenuScreenPadding
)
x
=
_kMenuScreenPadding
;
...
...
@@ -224,7 +238,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
})
:
super
(
completer:
completer
);
final
ModalPosition
position
;
final
List
<
PopupMenu
Item
<
T
>>
items
;
final
List
<
PopupMenu
Entry
<
T
>>
items
;
final
dynamic
initialValue
;
final
int
elevation
;
...
...
@@ -242,19 +256,20 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
Color
get
barrierColor
=>
null
;
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
forwardAnimation
)
{
int
selectedIndex
=
-
1
;
double
selectedItemOffset
=
null
;
if
(
initialValue
!=
null
)
{
for
(
int
i
=
0
;
i
<
items
.
length
;
i
++)
if
(
initialValue
==
items
[
i
].
value
)
{
selectedIndex
=
i
;
selectedItemOffset
=
0.0
;
for
(
int
i
=
0
;
i
<
items
.
length
;
i
++
)
{
if
(
initialValue
==
items
[
i
].
value
)
break
;
}
selectedItemOffset
+=
items
[
i
].
height
;
}
}
final
Size
screenSize
=
MediaQuery
.
of
(
context
).
size
;
return
new
ConstrainedBox
(
constraints:
new
BoxConstraints
(
maxWidth:
screenSize
.
width
,
maxHeight:
screenSize
.
height
),
child:
new
CustomOneChildLayout
(
delegate:
new
_PopupMenuRouteLayout
(
position
,
selectedI
ndex
),
delegate:
new
_PopupMenuRouteLayout
(
position
,
selectedI
temOffset
),
child:
new
_PopupMenu
(
route:
this
)
)
);
...
...
@@ -269,7 +284,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
Future
/*<T>*/
showMenu
/*<T>*/
({
BuildContext
context
,
ModalPosition
position
,
List
<
PopupMenu
Item
/*<T>*/
>
items
,
List
<
PopupMenu
Entry
/*<T>*/
>
items
,
dynamic
/*=T*/
initialValue
,
int
elevation:
8
})
{
...
...
@@ -305,7 +320,7 @@ class PopupMenuButton<T> extends StatefulComponent {
this
.
child
})
:
super
(
key:
key
);
final
List
<
PopupMenu
Item
<
T
>>
items
;
final
List
<
PopupMenu
Entry
<
T
>>
items
;
final
T
initialValue
;
final
PopupMenuItemSelected
<
T
>
onSelected
;
final
String
tooltip
;
...
...
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