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
93f1ba5d
Commit
93f1ba5d
authored
Sep 25, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Mimic to fn3
parent
24171915
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
framework.dart
packages/flutter/lib/src/fn3/framework.dart
+2
-0
mimic.dart
packages/flutter/lib/src/fn3/mimic.dart
+87
-0
No files found.
packages/flutter/lib/src/fn3/framework.dart
View file @
93f1ba5d
...
@@ -298,6 +298,8 @@ abstract class State<T extends StatefulComponent> {
...
@@ -298,6 +298,8 @@ abstract class State<T extends StatefulComponent> {
/// The context in which this object will be built
/// The context in which this object will be built
BuildContext
get
context
=>
_element
;
BuildContext
get
context
=>
_element
;
bool
get
mounted
=>
_element
!=
null
;
/// Called when this object is inserted into the tree. Override this function
/// Called when this object is inserted into the tree. Override this function
/// to perform initialization that depends on the location at which this
/// to perform initialization that depends on the location at which this
/// object was inserted into the tree or on the widget configuration object.
/// object was inserted into the tree or on the widget configuration object.
...
...
packages/flutter/lib/src/fn3/mimic.dart
0 → 100644
View file @
93f1ba5d
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:sky/rendering.dart'
;
import
'package:sky/src/fn3/basic.dart'
;
import
'package:sky/src/fn3/framework.dart'
;
class
MimicableKey
{
MimicableKey
.
_
(
this
.
_state
);
final
MimicableState
_state
;
Rect
get
globalBounds
=>
_state
.
_globalBounds
;
void
stopMimic
()
{
_state
.
_stopMimic
();
}
}
class
Mimic
extends
StatelessComponent
{
Mimic
({
Key
key
,
this
.
original
})
:
super
(
key:
key
);
final
MimicableKey
original
;
Widget
build
(
BuildContext
context
)
{
if
(
original
!=
null
&&
original
.
_state
.
_beingMimicked
)
return
original
.
_state
.
config
.
child
;
return
new
Container
();
}
}
class
Mimicable
extends
StatefulComponent
{
Mimicable
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
MimicableState
createState
()
=>
new
MimicableState
();
}
class
MimicableState
extends
State
<
Mimicable
>
{
Size
_size
;
bool
_beingMimicked
=
false
;
MimicableKey
startMimic
()
{
assert
(!
_beingMimicked
);
assert
(
_size
!=
null
);
setState
(()
{
_beingMimicked
=
true
;
});
return
new
MimicableKey
.
_
(
this
);
}
void
_stopMimic
()
{
assert
(!
_beingMimicked
);
if
(!
mounted
)
{
_beingMimicked
=
false
;
return
;
}
setState
(()
{
_beingMimicked
=
false
;
});
}
Rect
get
_globalBounds
{
RenderBox
box
=
context
.
findRenderObject
();
return
box
.
localToGlobal
(
Point
.
origin
)
&
box
.
size
;
}
void
_handleSizeChanged
(
Size
size
)
{
setState
(()
{
_size
=
size
;
});
}
Widget
build
(
BuildContext
context
)
{
if
(
_beingMimicked
)
{
return
new
ConstrainedBox
(
constraints:
new
BoxConstraints
.
tight
(
_size
)
);
}
return
new
SizeObserver
(
callback:
_handleSizeChanged
,
child:
config
.
child
);
}
}
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