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
6f17228e
Commit
6f17228e
authored
Nov 30, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #634 from abarth/popup_menu_align
PopupMenu shouldn't use CustomPaint
parents
114135aa
c810b050
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
62 deletions
+43
-62
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+21
-54
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+22
-8
No files found.
packages/flutter/lib/src/material/popup_menu.dart
View file @
6f17228e
...
...
@@ -5,13 +5,11 @@
import
'dart:async'
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/widgets.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'popup_menu_item.dart'
;
import
'shadows.dart'
;
import
'theme.dart'
;
const
Duration
_kMenuDuration
=
const
Duration
(
milliseconds:
300
);
const
double
_kMenuCloseIntervalEnd
=
2.0
/
3.0
;
...
...
@@ -21,38 +19,6 @@ const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep;
const
double
_kMenuHorizontalPadding
=
16.0
;
const
double
_kMenuVerticalPadding
=
8.0
;
class
_PopupMenuPainter
extends
CustomPainter
{
const
_PopupMenuPainter
({
this
.
color
,
this
.
elevation
,
this
.
width
,
this
.
height
});
final
Color
color
;
final
int
elevation
;
final
double
width
;
final
double
height
;
void
paint
(
Canvas
canvas
,
Size
size
)
{
double
widthValue
=
width
*
size
.
width
;
double
heightValue
=
height
*
size
.
height
;
final
BoxPainter
painter
=
new
BoxPainter
(
new
BoxDecoration
(
backgroundColor:
color
,
borderRadius:
2.0
,
boxShadow:
elevationToShadow
[
elevation
]
));
painter
.
paint
(
canvas
,
new
Rect
.
fromLTWH
(
size
.
width
-
widthValue
,
0.0
,
widthValue
,
heightValue
));
}
bool
shouldRepaint
(
_PopupMenuPainter
oldPainter
)
{
return
oldPainter
.
color
!=
color
||
oldPainter
.
elevation
!=
elevation
||
oldPainter
.
width
!=
width
||
oldPainter
.
height
!=
height
;
}
}
class
_PopupMenu
<
T
>
extends
StatelessComponent
{
_PopupMenu
({
Key
key
,
...
...
@@ -88,25 +54,26 @@ class _PopupMenu<T> extends StatelessComponent {
builder:
(
BuildContext
context
)
{
return
new
Opacity
(
opacity:
opacity
.
value
,
child:
new
CustomPaint
(
painter:
new
_PopupMenuPainter
(
color:
Theme
.
of
(
context
).
canvasColor
,
elevation:
route
.
elevation
,
width:
width
.
value
,
height:
height
.
value
),
child:
new
ConstrainedBox
(
constraints:
new
BoxConstraints
(
minWidth:
_kMenuMinWidth
,
maxWidth:
_kMenuMaxWidth
),
child:
new
IntrinsicWidth
(
stepWidth:
_kMenuWidthStep
,
child:
new
Block
(
children
,
padding:
const
EdgeDims
.
symmetric
(
horizontal:
_kMenuHorizontalPadding
,
vertical:
_kMenuVerticalPadding
child:
new
Material
(
type:
MaterialType
.
card
,
elevation:
route
.
elevation
,
child:
new
Align
(
alignment:
const
FractionalOffset
(
1.0
,
0.0
),
widthFactor:
width
.
value
,
heightFactor:
height
.
value
,
child:
new
ConstrainedBox
(
constraints:
new
BoxConstraints
(
minWidth:
_kMenuMinWidth
,
maxWidth:
_kMenuMaxWidth
),
child:
new
IntrinsicWidth
(
stepWidth:
_kMenuWidthStep
,
child:
new
Block
(
children
,
padding:
const
EdgeDims
.
symmetric
(
horizontal:
_kMenuHorizontalPadding
,
vertical:
_kMenuVerticalPadding
)
)
)
)
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
6f17228e
...
...
@@ -162,8 +162,8 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
widthFactor
,
double
heightFactor
})
:
_widthFactor
=
widthFactor
,
_heightFactor
=
heightFactor
,
super
(
child
)
{
assert
(
_widthFactor
==
null
||
_widthFactor
>
0.0
);
assert
(
_heightFactor
==
null
||
_heightFactor
>
0.0
);
assert
(
_widthFactor
==
null
||
_widthFactor
>
=
0.0
);
assert
(
_heightFactor
==
null
||
_heightFactor
>
=
0.0
);
}
/// The multiple to apply to the incoming maximum width constraint to use as
...
...
@@ -172,7 +172,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
get
widthFactor
=>
_widthFactor
;
double
_widthFactor
;
void
set
widthFactor
(
double
value
)
{
assert
(
value
==
null
||
value
>
0.0
);
assert
(
value
==
null
||
value
>
=
0.0
);
if
(
_widthFactor
==
value
)
return
;
_widthFactor
=
value
;
...
...
@@ -185,7 +185,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
get
heightFactor
=>
_heightFactor
;
double
_heightFactor
;
void
set
heightFactor
(
double
value
)
{
assert
(
value
==
null
||
value
>
0.0
);
assert
(
value
==
null
||
value
>
=
0.0
);
if
(
_heightFactor
==
value
)
return
;
_heightFactor
=
value
;
...
...
@@ -193,11 +193,25 @@ class RenderFractionallySizedBox extends RenderProxyBox {
}
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
double
minWidth
=
constraints
.
minWidth
;
double
maxWidth
=
constraints
.
maxWidth
;
if
(
_widthFactor
!=
null
)
{
double
width
=
maxWidth
*
_widthFactor
;
minWidth
=
width
;
maxWidth
=
width
;
}
double
minHeight
=
constraints
.
minHeight
;
double
maxHeight
=
constraints
.
maxHeight
;
if
(
_heightFactor
!=
null
)
{
double
height
=
maxHeight
*
_heightFactor
;
minHeight
=
height
;
maxHeight
=
height
;
}
return
new
BoxConstraints
(
minWidth:
_widthFactor
==
null
?
constraints
.
minWidth
:
constraints
.
maxWidth
*
_widthFactor
,
maxWidth:
_widthFactor
==
null
?
constraints
.
maxWidth
:
constraints
.
maxWidth
*
_widthFactor
,
minHeight:
_heightFactor
==
null
?
constraints
.
minHeight
:
constraints
.
maxHeight
*
_heightFactor
,
maxHeight:
_heightFactor
==
null
?
constraints
.
maxHeight
:
constraints
.
maxHeight
*
_heightFactor
minWidth:
minWidth
,
maxWidth:
maxWidth
,
minHeight:
minHeight
,
maxHeight:
maxHeight
);
}
...
...
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