Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename IState
  • Loading branch information
adamped committed Sep 14, 2018
1 parent b35d75a commit 47606b9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/definitions.dart
@@ -1,4 +1,4 @@
class StateTransition {
class IState {
Branch branch;
bool reverse = false;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/graph/renderGraph.dart
Expand Up @@ -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) {
Expand All @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions lib/graph/stateGraph.dart
Expand Up @@ -4,12 +4,12 @@ import '../repository/api.dart';
class StateGraph {
static StateSet _triggerBuild;

static List<StateTransition> _state = new List<StateTransition>();
static List<IState> _state = new List<IState>();
static initialize(StateSet setState) {
_triggerBuild = setState;
}

static setInitialState(StateTransition state) {
static setInitialState(IState state) {
_state.add(state);
}

Expand All @@ -19,15 +19,15 @@ class StateGraph {
_triggerBuild();
}

static apply(StateTransition state) {
static apply(IState state) {
_state.add(state);
_triggerBuild();
}

// Get token from state graph
static ApiState apiState() => ApiState(send, "token");

static StateTransition current() {
static IState current() {
return _state[_state.length - 1];
}
}
10 changes: 5 additions & 5 deletions lib/node/login.dart
Expand Up @@ -3,23 +3,23 @@ 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;
}

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),
Expand Down Expand Up @@ -56,7 +56,7 @@ class LoginNode {
])));
}

static StateTransition login(
static IState login(
LoginRequest loginRequest, String username, String password) {
final result = loginRequest(username, password);

Expand Down

0 comments on commit 47606b9

Please sign in to comment.