diff --git a/lib/definitions.dart b/lib/definitions.dart index b66ee98..e7f0ebb 100644 --- a/lib/definitions.dart +++ b/lib/definitions.dart @@ -1,4 +1,4 @@ -class StateTransition { +class IState { Branch branch; bool reverse = false; } diff --git a/lib/graph/renderGraph.dart b/lib/graph/renderGraph.dart index 3f107e1..41bc9e6 100644 --- a/lib/graph/renderGraph.dart +++ b/lib/graph/renderGraph.dart @@ -36,7 +36,7 @@ class RenderGraph { _state = state; } - static Widget build(StateTransition state) { + static Widget build(IState state) { var buildState = _build(state); if (_current == null) { @@ -63,7 +63,7 @@ class RenderGraph { } } - static WidgetState _build(StateTransition state) { + static WidgetState _build(IState state) { // Compiled state management if (state.branch == Branch.login) return WidgetState(LoginNode.render(state), diff --git a/lib/graph/stateGraph.dart b/lib/graph/stateGraph.dart index 34545ab..35b17b4 100644 --- a/lib/graph/stateGraph.dart +++ b/lib/graph/stateGraph.dart @@ -4,12 +4,12 @@ import '../repository/api.dart'; class StateGraph { static StateSet _triggerBuild; - static List _state = new List(); + static List _state = new List(); static initialize(StateSet setState) { _triggerBuild = setState; } - static setInitialState(StateTransition state) { + static setInitialState(IState state) { _state.add(state); } @@ -19,7 +19,7 @@ class StateGraph { _triggerBuild(); } - static apply(StateTransition state) { + static apply(IState state) { _state.add(state); _triggerBuild(); } @@ -27,7 +27,7 @@ class StateGraph { // Get token from state graph static ApiState apiState() => ApiState(send, "token"); - static StateTransition current() { + static IState current() { return _state[_state.length - 1]; } } \ No newline at end of file diff --git a/lib/node/login.dart b/lib/node/login.dart index 4454741..df89379 100644 --- a/lib/node/login.dart +++ b/lib/node/login.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import '../graph/stateGraph.dart'; import '../repository/account.dart'; -class DefaultLoginState extends StateTransition { +class DefaultLoginState extends IState { Branch branch = Branch.login; } @@ -11,15 +11,15 @@ class LoginErrorState extends DefaultLoginState { String loginErrorMessage = "There was an error"; } -typedef StateTransition LoginFunction( +typedef IState LoginFunction( LoginRequest loginRequest, String username, String password); class LoginNode { - static Widget render(StateTransition state) { + static Widget render(IState state) { return _render(state); } - static Widget _render(StateTransition state) { + static Widget _render(IState state) { if (state is LoginErrorState) return Container( padding: EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 0.0), @@ -56,7 +56,7 @@ class LoginNode { ]))); } - static StateTransition login( + static IState login( LoginRequest loginRequest, String username, String password) { final result = loginRequest(username, password);