Chaintech-Network / CMPToast

Apache License 2.0
37 stars 2 forks source link

CMPToast - Toasts for Compose Multiplatform

🍞️ CMPToast is a lightweight and easy-to-use library for displaying toast messages in Compose Multiplatform projects.

Hero-image - CMP-Chart 3

✨ Features

πŸ“¦ Installation

To use CMPToast in your Compose Multiplatform project, add the following dependency to your build.gradle.kts:

commonMain.dependencies {
    implementation("network.chaintech:cmptoast:1.0.1")
}


πŸš€ Usage

Basic Toast

To display a simple toast:

showToast(
    message = "This is a Toast"
)


πŸŽ₯ Demo

Watch the demo below to see CMPToast in action:

Toast Demo


🎨 Customisation

⏳ Short Toast

To show a short-duration toast:

showToast(
    message = "This is Short Toast",
    backgroundColor = Color.White,
    textColor = Color.Black,
    duration = ToastDuration.Short
)

⏱️ Long Toast

To show a long-duration toast:

showToast(
    message = "This is Long Toast",
    backgroundColor = Color.White,
    textColor = Color.Black,
    duration = ToastDuration.Long
)

πŸ“ Top Toast

To show toast at top of the screen:

showToast(
    message = "This is Top Toast",
    backgroundColor = Color.White,
    textColor = Color.Black,
    gravity = ToastGravity.Top
)

🎯 Center Toast

To show toast at center of the screen:

showToast(
    message = "This is Center Toast",
    backgroundColor = Color.White,
    textColor = Color.Black,
    gravity = ToastGravity.Center
)

🎨 Colored Toast

To show a colored toast:

showToast(
    message = "This is Colored Toast",
    backgroundColor = Color(0xFF27AD9D)
)


βš™οΈ Properties

Property Type Description
message String The message to be displayed in the toast.
gravity ToastGravity The position of the toast.
backgroundColor Color The background color of the toast.
textColor Color The color of the message text.
duration ToastDuration The duration of the toast.
padding ToastPadding? Internal padding for the toast content.
textSize TextUnit The size of the text.
topPadding Int Padding between toast and top of screen.
bottomPadding Int Padding between toast and bottom of screen.
cornerRadius Int? For rounding the corners of the toast.


πŸ–₯️ Platforms Supported

CMPToast currently supports the following platforms:

πŸ“– Detailed Explanation

For an in-depth guide and detailed explanation, check out our comprehensive Medium Blog Post.

Medium
LinkedIn

Stay connected and keep up with our latest innovations! πŸ’Ό Let's innovate together!

πŸ“„ License

Copyright 2023 Mobile Innovation Network

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.