mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This also removes one bit of magic to make it more obvious what on is going on during a sync, which should hopefully help. Components have to decide if they support being stateful or not. If they do, then they must implement syncFields() and have mutable fields; if they don't, then they must have final fields. This isn't particularly enforced, though. This also renames _willSync() to _retainStatefulNodeIfPossible(), for clarity, and fixes some minor style issues and one typo that was breaking the drawer. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1174023003
45 lines
900 B
Dart
45 lines
900 B
Dart
// 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 '../fn2.dart';
|
|
|
|
abstract class ButtonBase extends Component {
|
|
|
|
ButtonBase({ Object key, this.highlight: false }) : super(key: key);
|
|
|
|
bool highlight;
|
|
|
|
void syncFields(ButtonBase source) {
|
|
highlight = source.highlight;
|
|
}
|
|
|
|
void _handlePointerDown(_) {
|
|
setState(() {
|
|
highlight = true;
|
|
});
|
|
}
|
|
void _handlePointerUp(_) {
|
|
setState(() {
|
|
highlight = false;
|
|
});
|
|
}
|
|
void _handlePointerCancel(_) {
|
|
setState(() {
|
|
highlight = false;
|
|
});
|
|
}
|
|
|
|
UINode build() {
|
|
return new EventListenerNode(
|
|
buildContent(),
|
|
onPointerDown: _handlePointerDown,
|
|
onPointerUp: _handlePointerUp,
|
|
onPointerCancel: _handlePointerCancel
|
|
);
|
|
}
|
|
|
|
UINode buildContent();
|
|
|
|
}
|