Port big_switch.dart to fn3
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 LeafRenderObjectWidget {
|
||||
class Switch extends StatelessComponent {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user