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
bd9036cd
Commit
bd9036cd
authored
Oct 21, 2015
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port spinning_mixed demo to fn3
parent
33c7820d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
59 deletions
+76
-59
align_items.dart
examples/rendering/align_items.dart
+1
-1
flex.dart
examples/rendering/flex.dart
+1
-1
interactive_flex.dart
examples/rendering/interactive_flex.dart
+1
-1
justify_content.dart
examples/rendering/justify_content.dart
+1
-1
solid_color_box.dart
examples/rendering/lib/solid_color_box.dart
+0
-0
render_grid.dart
examples/rendering/render_grid.dart
+1
-1
render_paragraph.dart
examples/rendering/render_paragraph.dart
+1
-1
spinning_flex.dart
examples/rendering/spinning_flex.dart
+1
-1
spinning_mixed.dart
examples/widgets/spinning_mixed.dart
+45
-33
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+24
-19
No files found.
examples/rendering/align_items.dart
View file @
bd9036cd
...
...
@@ -4,7 +4,7 @@
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
void
main
(
)
{
var
table
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
...
...
examples/rendering/flex.dart
View file @
bd9036cd
...
...
@@ -5,7 +5,7 @@
import
'dart:ui'
as
ui
;
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
RenderBox
buildFlexExample
(
)
{
RenderFlex
flexRoot
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
...
...
examples/rendering/interactive_flex.dart
View file @
bd9036cd
...
...
@@ -8,7 +8,7 @@ import 'dart:math' as math;
import
'package:flutter/services.dart'
;
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
class
Touch
{
final
double
x
;
...
...
examples/rendering/justify_content.dart
View file @
bd9036cd
...
...
@@ -4,7 +4,7 @@
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
const
TextStyle
style
=
const
TextStyle
(
color:
const
Color
(
0xFF000000
));
...
...
examples/rendering/solid_color_box.dart
→
examples/rendering/
lib/
solid_color_box.dart
View file @
bd9036cd
File moved
examples/rendering/render_grid.dart
View file @
bd9036cd
...
...
@@ -7,7 +7,7 @@ import 'dart:math' as math;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
Color
randomColor
(
)
{
final
List
<
Color
>
allColors
=
[
...
...
examples/rendering/render_paragraph.dart
View file @
bd9036cd
...
...
@@ -4,7 +4,7 @@
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
void
main
(
)
{
RenderFlex
flexRoot
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
...
...
examples/rendering/spinning_flex.dart
View file @
bd9036cd
...
...
@@ -7,7 +7,7 @@ import 'dart:ui' as ui;
import
'package:flutter/animation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'solid_color_box.dart'
;
import
'
lib/
solid_color_box.dart'
;
Duration
timeBase
;
RenderTransform
transformBox
;
...
...
examples/widgets/spinning_mixed.dart
.old
→
examples/widgets/spinning_mixed.dart
View file @
bd9036cd
...
...
@@ -8,20 +8,21 @@ import 'package:flutter/animation.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import '
../rendering
/solid_color_box.dart';
import
'
package:flutter_rendering_examples
/solid_color_box.dart'
;
// Solid colour, RenderObject version
void
addFlexChildSolidColor
(
RenderFlex
parent
,
ui
.
Color
backgroundColor
,
{
int
flex:
0
})
{
RenderSolidColorBox
child
=
new
RenderSolidColorBox
(
backgroundColor
);
parent
.
add
(
child
);
child.parentData.flex = flex;
FlexParentData
childParentData
=
child
.
parentData
;
childParentData
.
flex
=
flex
;
}
// Solid colour, Widget version
class Rectangle extends Component {
class
Rectangle
extends
Stateless
Component
{
Rectangle
(
this
.
color
,
{
Key
key
})
:
super
(
key:
key
);
final
Color
color
;
Widget build() {
Widget
build
(
BuildContext
context
)
{
return
new
Flexible
(
child:
new
Container
(
decoration:
new
BoxDecoration
(
backgroundColor:
color
)
...
...
@@ -30,28 +31,42 @@ class Rectangle extends Component {
}
}
Widget builder() {
return new Container(
height: 300.0,
child: new Column([
new Rectangle(const Color(0xFF00FFFF)),
new Container(
padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
child: new RaisedButton(
child: new Row([
new NetworkImage(src: "https://www.dartlang.org/logos/dart-logo.png"),
new Text('PRESS ME'),
]),
onPressed: () => print("Hello World")
)
),
new Rectangle(const Color(0xFFFFFF00)),
],
justifyContent: FlexJustifyContent.spaceBetween
double
value
;
RenderObjectToWidgetElement
<
RenderBox
>
element
;
void
attachWidgetTreeToRenderTree
(
RenderProxyBox
container
)
{
element
=
new
RenderObjectToWidgetAdapter
<
RenderBox
>(
container:
container
,
child:
new
Container
(
height:
300.0
,
child:
new
Column
(<
Widget
>[
new
Rectangle
(
const
Color
(
0xFF00FFFF
)),
new
Container
(
padding:
new
EdgeDims
.
all
(
10.0
),
margin:
new
EdgeDims
.
all
(
10.0
),
decoration:
new
BoxDecoration
(
backgroundColor:
const
Color
(
0xFFCCCCCC
)),
child:
new
Row
(<
Widget
>[
new
RaisedButton
(
child:
new
Row
(<
Widget
>[
new
NetworkImage
(
src:
"http://flutter.io/favicon.ico"
),
new
Text
(
'PRESS ME'
),
]
),
onPressed:
()
{
value
=
value
==
null
?
0.1
:
(
value
+
0.1
)
%
1.0
;
attachWidgetTreeToRenderTree
(
container
);
}
),
new
CircularProgressIndicator
(
value:
value
),
],
justifyContent:
FlexJustifyContent
.
spaceAround
)
),
new
Rectangle
(
const
Color
(
0xFFFFFF00
)),
],
justifyContent:
FlexJustifyContent
.
spaceBetween
)
)
);
)
.
attachToRenderTree
(
element
)
;
}
Duration
timeBase
;
...
...
@@ -69,16 +84,13 @@ void rotate(Duration timeStamp) {
}
void
main
(
)
{
// Because we're going to use Widgets, we want to initialise its
// FlutterBinding, not use the default one. We don't really need to do
// this, because RenderBoxToWidgetAdapter does it for us, but
// it's good practice in case we happen to not have a
// RenderBoxToWidgetAdapter in our tree at startup, or in case we
// want a renderViewOverride.
WidgetFlutterBinding.initWidgetFlutterBinding();
// Because we're going to use Widgets, we want to ensure we're using a
// WidgetFlutterBinding rather than some other kind of binding (e.g. a
// straight rendering library FlutterBinding).
WidgetFlutterBinding
.
ensureInitialized
();
RenderProxyBox
proxy
=
new
RenderProxyBox
();
new RenderBoxToWidgetAdapter(proxy, builder); // adds itself to proxy
attachWidgetTreeToRenderTree
(
proxy
);
RenderFlex
flexRoot
=
new
RenderFlex
(
direction:
FlexDirection
.
vertical
);
addFlexChildSolidColor
(
flexRoot
,
const
ui
.
Color
(
0xFFFF00FF
),
flex:
1
);
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
bd9036cd
...
...
@@ -11,8 +11,6 @@ class WidgetFlutterBinding extends FlutterBinding {
WidgetFlutterBinding
()
{
BuildableElement
.
scheduleBuildFor
=
scheduleBuildFor
;
_renderViewElement
=
new
RenderObjectToWidgetElement
<
RenderBox
>(
describeApp
(
null
));
_renderViewElement
.
mount
(
null
,
null
);
}
/// Ensures that there is a FlutterBinding object instantiated.
...
...
@@ -24,18 +22,6 @@ class WidgetFlutterBinding extends FlutterBinding {
static
WidgetFlutterBinding
get
instance
=>
FlutterBinding
.
instance
;
/// The [Element] that is at the root of the hierarchy (and which wraps the
/// [RenderView] object at the root of the rendering hierarchy).
Element
get
renderViewElement
=>
_renderViewElement
;
Element
_renderViewElement
;
RenderObjectToWidgetAdapter
<
RenderBox
>
describeApp
(
Widget
app
)
{
return
new
RenderObjectToWidgetAdapter
<
RenderBox
>(
container:
instance
.
renderView
,
child:
app
);
}
void
beginFrame
(
Duration
timeStamp
)
{
buildDirtyElements
();
super
.
beginFrame
(
timeStamp
);
...
...
@@ -78,15 +64,22 @@ class WidgetFlutterBinding extends FlutterBinding {
},
building:
true
);
assert
(
_dirtyElements
.
isEmpty
);
}
/// The [Element] that is at the root of the hierarchy (and which wraps the
/// [RenderView] object at the root of the rendering hierarchy).
Element
get
renderViewElement
=>
_renderViewElement
;
Element
_renderViewElement
;
void
_runApp
(
Widget
app
)
{
_renderViewElement
=
new
RenderObjectToWidgetAdapter
<
RenderBox
>(
container:
renderView
,
child:
app
).
attachToRenderTree
(
_renderViewElement
);
}
}
void
runApp
(
Widget
app
)
{
WidgetFlutterBinding
.
ensureInitialized
();
BuildableElement
.
lockState
(()
{
WidgetFlutterBinding
.
instance
.
renderViewElement
.
update
(
WidgetFlutterBinding
.
instance
.
describeApp
(
app
)
);
},
building:
true
);
WidgetFlutterBinding
.
instance
.
_runApp
(
app
);
}
void
debugDumpApp
(
)
{
...
...
@@ -115,6 +108,18 @@ class RenderObjectToWidgetAdapter<T extends RenderObject> extends RenderObjectWi
RenderObjectWithChildMixin
<
T
>
createRenderObject
()
=>
container
;
void
updateRenderObject
(
RenderObject
renderObject
,
RenderObjectWidget
oldWidget
)
{
}
RenderObjectToWidgetElement
<
T
>
attachToRenderTree
([
RenderObjectToWidgetElement
<
T
>
element
])
{
BuildableElement
.
lockState
(()
{
if
(
element
==
null
)
{
element
=
createElement
();
element
.
mount
(
null
,
null
);
}
else
{
element
.
update
(
this
);
}
},
building:
true
);
return
element
;
}
}
/// This element class is the instantiation of a [RenderObjectToWidgetAdapter].
...
...
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