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
878775bb
Commit
878775bb
authored
Sep 24, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port big_switch.dart to fn3
parent
0206f1a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
18 deletions
+84
-18
big_switch.dart
examples/widgets/big_switch.dart
+24
-12
fn3.dart
packages/flutter/lib/src/fn3.dart
+39
-1
switch.dart
packages/flutter/lib/src/fn3/switch.dart
+21
-5
No files found.
examples/widgets/big_switch.dart
View file @
878775bb
...
...
@@ -3,9 +3,19 @@
// found in the LICENSE file.
import
'package:sky/material.dart'
;
import
'package:sky/widgets.dart'
;
import
'package:sky/src/fn3.dart'
;
class
BigSwitch
extends
StatefulComponent
{
BigSwitch
({
this
.
scale
});
final
double
scale
;
BigSwitchState
createState
()
=>
new
BigSwitchState
(
this
);
}
class
BigSwitchState
extends
ComponentState
<
BigSwitch
>
{
BigSwitchState
(
BigSwitch
config
)
:
super
(
config
);
class
BigSwitchApp
extends
App
{
bool
_value
=
false
;
void
_handleOnChanged
(
bool
value
)
{
...
...
@@ -14,20 +24,22 @@ class BigSwitchApp extends App {
});
}
Widget
build
()
{
Widget
build
(
BuildContext
context
)
{
Matrix4
scale
=
new
Matrix4
.
identity
();
scale
.
scale
(
5.0
,
5.0
);
return
new
Container
(
child:
new
Switch
(
value:
_value
,
onChanged:
_handleOnChanged
),
padding:
new
EdgeDims
.
all
(
20.0
),
transform:
scale
,
decoration:
new
BoxDecoration
(
backgroundColor:
Colors
.
teal
[
600
]
)
scale
.
scale
(
config
.
scale
,
config
.
scale
);
return
new
Transform
(
transform:
scale
,
child:
new
Switch
(
value:
_value
,
onChanged:
_handleOnChanged
)
);
}
}
void
main
(
)
{
runApp
(
new
BigSwitchApp
());
runApp
(
new
Container
(
child:
new
BigSwitch
(
scale:
5.0
),
padding:
new
EdgeDims
.
all
(
20.0
),
decoration:
new
BoxDecoration
(
backgroundColor:
Colors
.
teal
[
600
]
)
));
}
packages/flutter/lib/src/fn3.dart
View file @
878775bb
...
...
@@ -4,7 +4,45 @@
library
fn3
;
export
'fn3/animated_component.dart'
;
export
'fn3/basic.dart'
;
export
'fn3/framework.dart'
;
export
'fn3/binding.dart'
;
export
'fn3/button_state.dart'
;
export
'fn3/card.dart'
;
export
'fn3/checkbox.dart'
;
export
'fn3/date_picker.dart'
;
export
'fn3/dialog.dart'
;
export
'fn3/dismissable.dart'
;
export
'fn3/drag_target.dart'
;
export
'fn3/drawer.dart'
;
export
'fn3/drawer_divider.dart'
;
export
'fn3/drawer_header.dart'
;
export
'fn3/drawer_item.dart'
;
export
'fn3/flat_button.dart'
;
export
'fn3/floating_action_button.dart'
;
export
'fn3/focus.dart'
;
export
'fn3/framework.dart'
;
export
'fn3/gesture_detector.dart'
;
export
'fn3/homogeneous_viewport.dart'
;
export
'fn3/icon_button.dart'
;
export
'fn3/icon.dart'
;
export
'fn3/ink_well.dart'
;
export
'fn3/material_button.dart'
;
export
'fn3/material.dart'
;
export
'fn3/navigator.dart'
;
export
'fn3/popup_menu.dart'
;
export
'fn3/popup_menu_item.dart'
;
export
'fn3/progress_indicator.dart'
;
export
'fn3/radio.dart'
;
export
'fn3/raised_button.dart'
;
export
'fn3/scaffold.dart'
;
export
'fn3/scrollable.dart'
;
export
'fn3/snack_bar.dart'
;
export
'fn3/switch.dart'
;
export
'fn3/tabs.dart'
;
export
'fn3/theme.dart'
;
export
'fn3/title.dart'
;
export
'fn3/tool_bar.dart'
;
export
'fn3/transitions.dart'
;
export
'package:vector_math/vector_math.dart'
show
Matrix4
;
packages/flutter/lib/src/fn3/switch.dart
View file @
878775bb
...
...
@@ -27,24 +27,40 @@ const Duration _kCheckDuration = const Duration(milliseconds: 200);
const
Size
_kSwitchSize
=
const
Size
(
_kSwitchWidth
+
2.0
,
_kSwitchHeight
+
2.0
);
const
double
_kReactionRadius
=
_kSwitchWidth
/
2.0
;
class
Switch
extends
LeafRenderObjectWidge
t
{
class
Switch
extends
StatelessComponen
t
{
Switch
({
Key
key
,
this
.
value
,
this
.
onChanged
})
:
super
(
key:
key
);
final
bool
value
;
final
ValueChanged
onChanged
;
Widget
build
(
BuildContext
context
)
{
return
new
_SwitchWrapper
(
value:
value
,
thumbColor:
Theme
.
of
(
context
).
accentColor
,
onChanged:
onChanged
);
}
}
class
_SwitchWrapper
extends
LeafRenderObjectWidget
{
_SwitchWrapper
({
Key
key
,
this
.
value
,
this
.
thumbColor
,
this
.
onChanged
})
:
super
(
key:
key
);
final
bool
value
;
final
Color
thumbColor
;
final
ValueChanged
onChanged
;
_RenderSwitch
createRenderObject
()
=>
new
_RenderSwitch
(
value:
value
,
thumbColor:
null
,
thumbColor:
thumbColor
,
onChanged:
onChanged
);
void
updateRenderObject
(
_RenderSwitch
renderObject
,
Switch
oldWidget
)
{
void
updateRenderObject
(
_RenderSwitch
renderObject
,
_SwitchWrapper
oldWidget
)
{
renderObject
.
value
=
value
;
renderObject
.
thumbColor
=
thumbColor
;
renderObject
.
onChanged
=
onChanged
;
// TODO(abarth): How do we get the current theme here?
// renderObject.thumbColor = Theme.of(this).accentColor;
}
}
...
...
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