All Projects → YvesCheung → PageStatusTransformer

YvesCheung / PageStatusTransformer

Licence: Apache-2.0 license
A low invasive state management on Android

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to PageStatusTransformer

Statefulviewcontroller
Placeholder views based on content, loading, error or empty states
Stars: ✭ 2,139 (+17725%)
Mutual labels:  state-management, state, loading, error, empty
Hgplaceholders
Nice library to show placeholders and Empty States for any UITableView/UICollectionView in your project
Stars: ✭ 2,048 (+16966.67%)
Mutual labels:  state-management, loading, empty
Loadinglayout
简单实用的页面多状态布局(content,loading,empty,error)
Stars: ✭ 712 (+5833.33%)
Mutual labels:  status, loading, error
Pagestatemanager
manage the loading,emtpy,error state of page, use in xml or just in code
Stars: ✭ 173 (+1341.67%)
Mutual labels:  status, state, loading
tstate-machine
TypeScript implementation of State Manager(like StateMachine)
Stars: ✭ 20 (+66.67%)
Mutual labels:  state-management, state
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+177283.33%)
Mutual labels:  state-management, state
reactive state
An easy to understand reactive state management solution for Flutter.
Stars: ✭ 19 (+58.33%)
Mutual labels:  state-management, state
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+1950%)
Mutual labels:  state-management, state
ReduxSimple
Simple Stupid Redux Store using Reactive Extensions
Stars: ✭ 119 (+891.67%)
Mutual labels:  state-management, state
agile
🌌 Global State and Logic Library for JavaScript/Typescript applications
Stars: ✭ 90 (+650%)
Mutual labels:  state-management, state
particule
Fine-grained atomic React state management library
Stars: ✭ 31 (+158.33%)
Mutual labels:  state-management, state
okito
Your best flutter coding friend. All in one; state management, navigation management(with dynamic routing), local storage, localization, dependency injection, cool extensions with best usages and with the support of best utilities!
Stars: ✭ 37 (+208.33%)
Mutual labels:  state-management, state
react-apollo-mutation-state
A React HOC wrapper for Apollo GraphQL mutation, provides loading and error in props
Stars: ✭ 16 (+33.33%)
Mutual labels:  state, loading
useSharedState
useSharedState is a simple hook that can be used to share state between multiple React components.
Stars: ✭ 0 (-100%)
Mutual labels:  state-management, state
vue-reactive-store
A VueX alternative : declarative + reactive + centralized way to structure your data store. Inspired by VueX and Vue.js . Compatible with vue-devtools.
Stars: ✭ 27 (+125%)
Mutual labels:  state-management, state
mutable
State containers with dirty checking and more
Stars: ✭ 32 (+166.67%)
Mutual labels:  state-management, state
teaful
🍵 Tiny, easy and powerful React state management
Stars: ✭ 638 (+5216.67%)
Mutual labels:  state-management, state
concave
🧐 Lens-like state management (for React).
Stars: ✭ 13 (+8.33%)
Mutual labels:  state-management, state
jedisdb
redis like key-value state management solution for React
Stars: ✭ 13 (+8.33%)
Mutual labels:  state-management, state
riduce
Get rid of your reducer boilerplate! Zero hassle state management that's typed, flexible and scalable.
Stars: ✭ 14 (+16.67%)
Mutual labels:  state-management, state

PageStatusTransformer

jitpack

A low invasive state management on Android

Preview

中文版

Feature

  • Declare your own state
val transformer =
    PageStatusTransformer.newInstance {

        "Normal" { 
            SimpleState(contentView)
        }

        "Loading" {
            MyLoadingPageState()
        }

        "Empty" {
            MyEmptyPageState()
        }

        //Can be any string or enum
        "Error" {
            MyErrorPageState()
        }
    }
    
//transform to your state by its name
transformer.transform("Empty")
//or by enum
transformer.transform(YourCustomEnum.State1)
  • Replace the origin View
PageStatusTransformer.newInstance(
    replaceTo = contentView /*contentView would be replaced by the new ui which has the same size and parent */
) { 
    State1 {...}
    State2 {...}
}

The view of the original page can be specified by the optional parameter replaceTo. When a transform occurs, the view in the new state will dynamically replace the view in the old state.

Therefore, there is no need to put a so-called <StatusLayout /> in XML, and it is not necessary to plug the business into BaseActivity or BaseFragment.

  • Different ways to toggle the visibility of View
PageStatusTransformer.newInstance(...) { 
    State1 {
        SimpleStatus(view) 
    }
    State2 {
        ViewStubStatus(viewStub)
    }
    State3 {
        ReplacementViewStatus(view)
    }
}

SimpleStatus supports only changing the visibility of the state UI, which is applicable to the state that exists in the layout for a long time, such as the normal state.

ViewStubStatus which supports rendering only when used, is suitable for states in lazy loading layouts.

ReplacementViewStatus supports dynamic adding and removing state UI, which is suitable for temporary state existing in layout.

  • Custom State
PageStatusTransformer.newInstance(replaceTo = ...) { 
    "State 1" {
        object: PageDisplayStatus {
            override fun showView(){
                //how to show state 1
            }
            
            override fun hideView(){
                //how to hide state 1
            }
        }
    }
    "State 2" {
        object: ReplacementViewStatus() {
            override fun inflateView(inflater: LayoutInflater, parent: ViewGroup): View {
                return inflater.inflate(...., parent, false)
            }
        
            override fun onViewShow(){...}

            override fun onViewHide(){...}
        }
    }
    ...
}

Java support

Adapting Java language to Kotlin DSL:

PageStatusTransformer transformer = PageStatusTransformer.newInstance(mRecyclerView, 
    new JavaViewStatusBuilder()
        .putStatus("Normal", new SimpleStatus(mRecyclerView))
        .putStatus("Empty", new YouCustomStatus("No Data"))
        .putStatus("Error", new YouCustomStatus("Sorry! An error happen"))
        .putStatus("Loading"new YouCustomStatus("Loading"))
        .build()
);


transformer.transform("Empty");

Install

repositories {
    ...
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.YvesCheung:PageStatusTransformer:x.y.z'
}

version replace with jitpack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].