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
c810b050
Commit
c810b050
authored
Nov 30, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PopupMenu shouldn't use CustomPaint
Align is now powerful enough to do all the work we need to do here.
parent
4472d06e
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 @
c810b050
...
@@ -5,13 +5,11 @@
...
@@ -5,13 +5,11 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/painting.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'ink_well.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'popup_menu_item.dart'
;
import
'popup_menu_item.dart'
;
import
'shadows.dart'
;
import
'theme.dart'
;
const
Duration
_kMenuDuration
=
const
Duration
(
milliseconds:
300
);
const
Duration
_kMenuDuration
=
const
Duration
(
milliseconds:
300
);
const
double
_kMenuCloseIntervalEnd
=
2.0
/
3.0
;
const
double
_kMenuCloseIntervalEnd
=
2.0
/
3.0
;
...
@@ -21,38 +19,6 @@ const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep;
...
@@ -21,38 +19,6 @@ const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep;
const
double
_kMenuHorizontalPadding
=
16.0
;
const
double
_kMenuHorizontalPadding
=
16.0
;
const
double
_kMenuVerticalPadding
=
8.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
{
class
_PopupMenu
<
T
>
extends
StatelessComponent
{
_PopupMenu
({
_PopupMenu
({
Key
key
,
Key
key
,
...
@@ -88,25 +54,26 @@ class _PopupMenu<T> extends StatelessComponent {
...
@@ -88,25 +54,26 @@ class _PopupMenu<T> extends StatelessComponent {
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
new
Opacity
(
return
new
Opacity
(
opacity:
opacity
.
value
,
opacity:
opacity
.
value
,
child:
new
CustomPaint
(
child:
new
Material
(
painter:
new
_PopupMenuPainter
(
type:
MaterialType
.
card
,
color:
Theme
.
of
(
context
).
canvasColor
,
elevation:
route
.
elevation
,
elevation:
route
.
elevation
,
child:
new
Align
(
width:
width
.
value
,
alignment:
const
FractionalOffset
(
1.0
,
0.0
),
height:
height
.
value
widthFactor:
width
.
value
,
),
heightFactor:
height
.
value
,
child:
new
ConstrainedBox
(
child:
new
ConstrainedBox
(
constraints:
new
BoxConstraints
(
constraints:
new
BoxConstraints
(
minWidth:
_kMenuMinWidth
,
minWidth:
_kMenuMinWidth
,
maxWidth:
_kMenuMaxWidth
maxWidth:
_kMenuMaxWidth
),
),
child:
new
IntrinsicWidth
(
child:
new
IntrinsicWidth
(
stepWidth:
_kMenuWidthStep
,
stepWidth:
_kMenuWidthStep
,
child:
new
Block
(
child:
new
Block
(
children
,
children
,
padding:
const
EdgeDims
.
symmetric
(
padding:
const
EdgeDims
.
symmetric
(
horizontal:
_kMenuHorizontalPadding
,
horizontal:
_kMenuHorizontalPadding
,
vertical:
_kMenuVerticalPadding
vertical:
_kMenuVerticalPadding
)
)
)
)
)
)
)
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
c810b050
...
@@ -162,8 +162,8 @@ class RenderFractionallySizedBox extends RenderProxyBox {
...
@@ -162,8 +162,8 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
widthFactor
,
double
widthFactor
,
double
heightFactor
double
heightFactor
})
:
_widthFactor
=
widthFactor
,
_heightFactor
=
heightFactor
,
super
(
child
)
{
})
:
_widthFactor
=
widthFactor
,
_heightFactor
=
heightFactor
,
super
(
child
)
{
assert
(
_widthFactor
==
null
||
_widthFactor
>
0.0
);
assert
(
_widthFactor
==
null
||
_widthFactor
>
=
0.0
);
assert
(
_heightFactor
==
null
||
_heightFactor
>
0.0
);
assert
(
_heightFactor
==
null
||
_heightFactor
>
=
0.0
);
}
}
/// The multiple to apply to the incoming maximum width constraint to use as
/// The multiple to apply to the incoming maximum width constraint to use as
...
@@ -172,7 +172,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
...
@@ -172,7 +172,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
get
widthFactor
=>
_widthFactor
;
double
get
widthFactor
=>
_widthFactor
;
double
_widthFactor
;
double
_widthFactor
;
void
set
widthFactor
(
double
value
)
{
void
set
widthFactor
(
double
value
)
{
assert
(
value
==
null
||
value
>
0.0
);
assert
(
value
==
null
||
value
>
=
0.0
);
if
(
_widthFactor
==
value
)
if
(
_widthFactor
==
value
)
return
;
return
;
_widthFactor
=
value
;
_widthFactor
=
value
;
...
@@ -185,7 +185,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
...
@@ -185,7 +185,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
double
get
heightFactor
=>
_heightFactor
;
double
get
heightFactor
=>
_heightFactor
;
double
_heightFactor
;
double
_heightFactor
;
void
set
heightFactor
(
double
value
)
{
void
set
heightFactor
(
double
value
)
{
assert
(
value
==
null
||
value
>
0.0
);
assert
(
value
==
null
||
value
>
=
0.0
);
if
(
_heightFactor
==
value
)
if
(
_heightFactor
==
value
)
return
;
return
;
_heightFactor
=
value
;
_heightFactor
=
value
;
...
@@ -193,11 +193,25 @@ class RenderFractionallySizedBox extends RenderProxyBox {
...
@@ -193,11 +193,25 @@ class RenderFractionallySizedBox extends RenderProxyBox {
}
}
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
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
(
return
new
BoxConstraints
(
minWidth:
_widthFactor
==
null
?
constraints
.
minWidth
:
constraints
.
maxWidth
*
_widthFactor
,
minWidth:
minWidth
,
maxWidth:
_widthFactor
==
null
?
constraints
.
maxWidth
:
constraints
.
maxWidth
*
_widthFactor
,
maxWidth:
maxWidth
,
minHeight:
_heightFactor
==
null
?
constraints
.
minHeight
:
constraints
.
maxHeight
*
_heightFactor
,
minHeight:
minHeight
,
maxHeight:
_heightFactor
==
null
?
constraints
.
maxHeight
:
constraints
.
maxHeight
*
_heightFactor
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