Code Monkey home page Code Monkey logo

flutter_todos_redux's Introduction

flutter_todos_redux

A Flutter hobby project using redux for state management. The UI has been inspired from a dribbble by DhipuMathew.

Screenshots

GIF

home page add todo

I have been playing with flutter for about 3 weeks(sep 2018). This is my very first flutter app I built to check out the framework. The codebase is not well structured and also can be coded better. It is me just playing with the framework and quickly prototyping a working app.

Architecture of the app

The App's state consists of:

  1. list of todos
  2. current tab the user is on i.e ''today'' or ''week'' or ''month''
  3. boolean editing
  4. list of categories

The app consists of two pages:

  1. home page: it displays the user info, the tab view showing the upcoming todos and the todo categoris grid view.
  2. todos list page: displays all the todos belonging to a particular category.
The Home Page

The home page is essentially a Stack widget consisting of two layers:

  1. Main Layer: This layer displays the appbar, user info, the upcoming todos(in a tabbed view) and all the todo categories.
  2. AddTodo Layer: This consists of the 'ADD TODO' button and the form that appears when the button is clicked.

Explanation of the add todo animation:

The AddTodo layer is a Stack itself. This stack consist of two children:

  1. AddTodoForm
  2. AddTodoButton

These both are PositionedTransition widgets which is the animated version of Positioned widgets.

The initial position of the form is completely pushed of the screen downwards which is derived from the RelativeRectTween as below:

    _rectAnimation = RelativeRectTween(
      begin: RelativeRect.fromLTRB(0.0, size.height, 0.0, -size.height),
      end: RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0),
    ).animate(_animCntroller);

	...
    ...
    ...

  @override
  Widget build(BuildContext context) {
    return PositionedTransition(
      rect: _rectAnimation,
      child: Column(
        ...
      ),
    );
  }

Similarly the button also has its own animations which control its position and the button text. These animations are deferred using an Interval. The button moves down and expands for the 70% of the animation and the the text animates for the remaining 30%

//animation that animates the position: 0.0 -> 0.7
_buttonAnimation = RelativeRectTween(
    begin: RelativeRect.fromLTRB(
        initialLeftRight, top - 25.0, initialLeftRight, 25.0),
    end: RelativeRect.fromLTRB(0.0, top, 0.0, 0.0),
  ).animate(CurvedAnimation(curve: Interval(0.0, 0.7), parent: _controller));


//animation that animates the text: 0.7 -> 1.0
_buttonTextAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
    CurvedAnimation(curve: Interval(0.7, 1.0), parent: _controller));

When the button is pressed initially it triggers a redux action mutating the editing state of the store to true. This causes the re-render of the widgets. Both these widgets has a didUpdateWidget lifecycle hook. This lifecycle hook gets called when the widget's parent rebuilds and passes new properties to the widgets. In this lifecycle hook we perform the animation depending on the editing property.

flutter_todos_redux's People

Contributors

rvamsikrishna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.