Code Monkey home page Code Monkey logo

spotifycompose's Introduction

Spotify Compose (:construction:work in progres :construction:)

Spotify UI built with Jetpack Compose.

Try now

SpotifyCompose ๐Ÿ‘ˆ click to download ๐Ÿš€๐Ÿš€๐Ÿš€

Preview

SpotifyCompose

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ Useful extensions

/**
 * putting and getting args for navHostController.
 */
 fun <T : Any> NavHostController.putArgs(args: Pair<String, T>) {
        val key = args.first
        val value = args.second
        currentBackStackEntry?.arguments?.apply {
            when (value) {
                is String -> putString(key, value)
                is Int -> putInt(key, value)
                is Short -> putShort(key, value)
                is Long -> putLong(key, value)
                is Byte -> putByte(key, value)
                is ByteArray -> putByteArray(key, value)
                is Char -> putChar(key, value)
                is CharArray -> putCharArray(key, value)
                is CharSequence -> putCharSequence(key, value)
                is Float -> putFloat(key, value)
                is Bundle -> putBundle(key, value)
                // is Serializable -> putSerializable(key, value)
                is Parcelable -> putParcelable(key, value)
                else -> throw IllegalStateException("Type ${value.javaClass.canonicalName} is not supported now")
            }
        }
    }
    
inline fun <reified T : Any> NavHostController.getArgs(tag: String): T? {
    return try {
        previousBackStackEntry?.arguments?.get(tag) as T?
    } catch (ex: Exception) {
        null
    }
}
/**
 * rounding.
 */
fun Modifier.round(
        radius: Dp? = null,
        percent: Int = 0
    ): Modifier {
        return if (radius != null) {
            this.clip(RoundedCornerShape(radius))
        } else {
            this.clip(RoundedCornerShape(percent))
        }
    }
    
fun Modifier.round(
        percent: Int = 0
    ): Modifier {
        return this.clip(RoundedCornerShape(percent = percent))
    }
/**
 * change color.
 */
fun Modifier.color(
        colorHex: Int = 0
    ): Modifier {
        return this.background(Color(colorHex))
    }

fun Modifier.color(
        color: Color = Color.Transparent
    ): Modifier {
        return this.background(color)
    }
/**
 * gradient color.
 */
 enum class GradientType {
        HORIZONTAL, VERTICAL, LINEAR, RADIAL, SWEEP
    }
    
 fun Modifier.gradient(
        colors: List<Color>,
        gradientType: GradientType = GradientType.LINEAR
    ): Modifier {
        return this.background(
            brush = when (gradientType) {
                GradientType.HORIZONTAL -> {
                    Brush.horizontalGradient(colors = colors)
                }
                GradientType.VERTICAL -> {
                    Brush.verticalGradient(colors = colors)
                }
                GradientType.LINEAR -> {
                    Brush.linearGradient(colors = colors)
                }
                GradientType.RADIAL -> {
                    Brush.radialGradient(colors = colors)
                }
                GradientType.SWEEP -> {
                    Brush.sweepGradient(colors = colors)
                }
            }
        )
    }

spotifycompose's People

Contributors

droidbaza 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.