mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-07-08 09:30:07 +08:00
Improvements based on feedback
This commit is contained in:
@ -19,14 +19,16 @@ import 'package:rive/src/rive_core/state_machine_controller.dart' as core;
|
|||||||
/// enum is exposed for convenience.
|
/// enum is exposed for convenience.
|
||||||
enum SMIType { number, boolean, trigger }
|
enum SMIType { number, boolean, trigger }
|
||||||
|
|
||||||
/// StateMachine Instance Input. This is the abstraction of an instanced input
|
/// SMI = StateMachineInstance
|
||||||
|
///
|
||||||
|
/// This is the abstraction of an instanced input
|
||||||
/// from the [StateMachine]. Whenever a [StateMachineController] is created, the
|
/// from the [StateMachine]. Whenever a [StateMachineController] is created, the
|
||||||
/// list of inputs in the corresponding [StateMachine] is wrapped into a set of
|
/// list of inputs in the corresponding [StateMachine] is wrapped into a set of
|
||||||
/// [SMIInput] objects that ensure inputs are initialized to design-time values.
|
/// [SMIInput] objects that ensure inputs are initialized to design-time values.
|
||||||
/// The implementation can now change these values freely as they are decoupled
|
/// The implementation can now change these values freely as they are decoupled
|
||||||
/// from the backing [StateMachine] and can safely be re-instanced by another
|
/// from the backing [StateMachine] and can safely be re-instanced by another
|
||||||
/// controller later.
|
/// controller later.
|
||||||
class SMIInput<T> {
|
abstract class SMIInput<T> {
|
||||||
final core.StateMachineInput _input;
|
final core.StateMachineInput _input;
|
||||||
final StateMachineController controller;
|
final StateMachineController controller;
|
||||||
final SMIType type;
|
final SMIType type;
|
||||||
@ -43,9 +45,10 @@ class SMIInput<T> {
|
|||||||
/// The name given to this input at design time in Rive.
|
/// The name given to this input at design time in Rive.
|
||||||
String get name => _input.name;
|
String get name => _input.name;
|
||||||
|
|
||||||
/// Convenience method for changing the backing value of the input. Usually
|
/// Convenience method for changing the backing [SMIInput.value] of the input.
|
||||||
/// it's easier to use the various value getter/setters on the derived
|
/// For [SMITrigger] it's usually preferable to use the [SMITrigger.fire]
|
||||||
/// version of [SMIInput] like [SMIBool], [SMINumber], and [SMITrigger].
|
/// method to change the input value, but calling change(true) is totally
|
||||||
|
/// valid.
|
||||||
bool change(T value) {
|
bool change(T value) {
|
||||||
if (controller.inputValues[id] == value) {
|
if (controller.inputValues[id] == value) {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user