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
fd68741f
Commit
fd68741f
authored
Aug 06, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add operator+ and operator- to EdgeDims
... and use them to improve the horizontal_scrolling example.
parent
870376da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
horizontal_scrolling.dart
packages/flutter/example/widgets/horizontal_scrolling.dart
+7
-11
box.dart
packages/flutter/lib/rendering/box.dart
+16
-0
No files found.
packages/flutter/example/widgets/horizontal_scrolling.dart
View file @
fd68741f
...
@@ -6,10 +6,14 @@ import 'package:sky/painting/box_painter.dart';
...
@@ -6,10 +6,14 @@ import 'package:sky/painting/box_painter.dart';
import
'package:sky/widgets.dart'
;
import
'package:sky/widgets.dart'
;
class
Circle
extends
Component
{
class
Circle
extends
Component
{
Circle
({
this
.
margin
:
EdgeDims
.
zero
});
final
EdgeDims
margin
;
Widget
build
()
{
Widget
build
()
{
return
new
Container
(
return
new
Container
(
width:
50.0
,
width:
50.0
,
margin:
new
EdgeDims
.
symmetric
(
horizontal:
2.0
),
margin:
margin
+
new
EdgeDims
.
symmetric
(
horizontal:
2.0
),
decoration:
new
BoxDecoration
(
decoration:
new
BoxDecoration
(
shape:
Shape
.
circle
,
shape:
Shape
.
circle
,
backgroundColor:
const
Color
(
0xFF00FF00
)
backgroundColor:
const
Color
(
0xFF00FF00
)
...
@@ -18,18 +22,10 @@ class Circle extends Component {
...
@@ -18,18 +22,10 @@ class Circle extends Component {
}
}
}
}
class
Pad
extends
Component
{
Widget
build
()
{
return
new
SizedBox
(
width:
10.0
);
}
}
class
HorizontalScrollingApp
extends
App
{
class
HorizontalScrollingApp
extends
App
{
Widget
build
()
{
Widget
build
()
{
List
<
Widget
>
circles
=
[
List
<
Widget
>
circles
=
[
new
Pad
(),
new
Circle
(
margin:
new
EdgeDims
.
only
(
left:
10.0
)),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
...
@@ -40,7 +36,7 @@ class HorizontalScrollingApp extends App {
...
@@ -40,7 +36,7 @@ class HorizontalScrollingApp extends App {
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Circle
(),
new
Pad
(
),
new
Circle
(
margin:
new
EdgeDims
.
only
(
right:
10.0
)
),
];
];
return
new
Center
(
return
new
Center
(
...
...
packages/flutter/lib/rendering/box.dart
View file @
fd68741f
...
@@ -52,6 +52,22 @@ class EdgeDims {
...
@@ -52,6 +52,22 @@ class EdgeDims {
&&
left
==
other
.
left
;
&&
left
==
other
.
left
;
}
}
EdgeDims
operator
+(
EdgeDims
other
)
{
return
new
EdgeDims
(
top
+
other
.
top
,
right
+
other
.
right
,
bottom
+
other
.
bottom
,
left
+
other
.
left
);
}
EdgeDims
operator
-(
EdgeDims
other
)
{
return
new
EdgeDims
(
top
-
other
.
top
,
right
-
other
.
right
,
bottom
-
other
.
bottom
,
left
-
other
.
left
);
}
static
const
EdgeDims
zero
=
const
EdgeDims
(
0.0
,
0.0
,
0.0
,
0.0
);
int
get
hashCode
{
int
get
hashCode
{
int
value
=
373
;
int
value
=
373
;
value
=
37
*
value
+
top
.
hashCode
;
value
=
37
*
value
+
top
.
hashCode
;
...
...
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