Giter Club home page Giter Club logo

statelayout's Introduction

StateLayout

HitCount

StateLayout is a Layout enable you to change and navigate between customizable layout states easily just by a line of code.

alt text

Installation

  • Add it in your root build.gradle at the end of repositories:
    allprojects {
      repositories {
       ...
       maven { url 'https://jitpack.io' }
      }
     }
    
  • Add the dependency
    dependencies {
             implementation 'com.github.ahmed7official:StateLayout:0.1.0'
     }
    

Usage

<com.github.ahmed7official.statelayout.StateLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!--StateLayout should have only one child-->

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <!--Your Content-->
    
</androidx.constraintlayout.widget.ConstraintLayout>


</com.github.ahmed7official.statelayout.StateLayout>

Available States

State Loading

stateLayout.stateLoading()

or

stateLayout.stateLoading(
        message = "String",
        messageColor = R.color.colorPrimary,
        backgroundColor = R.color.colorAccent
    )

State Error

stateLayout.stateError()

or

stateLayout.stateError(
        title = "Internal Server Error",
        titleTextColor = R.color.colorAccent,
        backgroundColor = R.color.colorAccent,
        icon = R.drawable.ic_error
    )

State Error With Retry Button

stateLayout.stateRetry(){}

or

stateLayout.stateRetry(
        title = "",
        titleTextColor = R.color.colorAccent,
        msg = "",
        msgTextColor = R.color.colorAccent,
        icon = R.drawable.ic_error,
        backgroundColor = R.color.colorAccent
    ){

        Toast.makeText(this, "Retry", Toast.LENGTH_SHORT).show()
    }

show content

to show your layout content call stateLayout.showContent()

customization

you can easily change and customize default style for any state screen by overriding style attributes

<string name="loading_message">loading</string>
<string name="error_title">Something went wrong</string>
<string name="retry_title">Something went wrong</string>



<color name="loadingMessageColor">#7C7C7C</color>
<color name="loadingBackgroundColor">#FFFFFF</color>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<color name="errorTitleColor">#616161</color>
<color name="errorBackgroundColor">#FFFFFF</color>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<color name="retryTitleColor">#616161</color>
<color name="retryMessageColor">#7C7C7C</color>
<color name="retryBackgroundColor">#FFFFFF</color>
<color name="retryButtonBackgroundColor">#979797</color>
<color name="retryButtonTextColor">#FFFFFF</color>

statelayout's People

Contributors

ahmed7official avatar mahmoudmabrok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mahmoudmabrok

statelayout's Issues

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.