From bb626dc62ee31beade2764f7d87ec6234d7e98d9 Mon Sep 17 00:00:00 2001 From: talhafaki Date: Sat, 4 Dec 2021 13:51:53 +0300 Subject: [PATCH] arrange sample app --- .../composablesweettoast/MainScreen.kt | 65 +++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/android/composablesweettoast/MainScreen.kt b/app/src/main/java/com/android/composablesweettoast/MainScreen.kt index 429c484..aef6c9e 100644 --- a/app/src/main/java/com/android/composablesweettoast/MainScreen.kt +++ b/app/src/main/java/com/android/composablesweettoast/MainScreen.kt @@ -1,9 +1,20 @@ package com.android.composablesweettoast +import android.widget.Toast +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.material.Button import androidx.compose.material.Text import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.talhafaki.composablesweettoast.util.SweetToastUtil.SweetError +import com.talhafaki.composablesweettoast.util.SweetToastUtil.SweetInfo import com.talhafaki.composablesweettoast.util.SweetToastUtil.SweetSuccess +import com.talhafaki.composablesweettoast.util.SweetToastUtil.SweetWarning /** * Created by stekinarslan on 02,December,2021 @@ -12,14 +23,58 @@ import com.talhafaki.composablesweettoast.util.SweetToastUtil.SweetSuccess @Composable fun MainScreen() { var openDialogSuccess by remember { mutableStateOf(false) } + var openDialogError by remember { mutableStateOf(false) } + var openDialogWarning by remember { mutableStateOf(false) } + var openDialogInfo by remember { mutableStateOf(false) } - Button(onClick = { - openDialogSuccess = true - }) { - Text("Sweet Toast Success") + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Button(modifier = Modifier.padding(12.dp), onClick = { + openDialogSuccess = true + }) { + Text("Sweet Toast Success") + } + + Button(modifier = Modifier.padding(12.dp), onClick = { + openDialogError = true + }) { + Text("Sweet Toast Error") + } + + Button(modifier = Modifier.padding(12.dp), onClick = { + openDialogWarning = true + }) { + Text("Sweet Toast Warning") + } + + Button(modifier = Modifier.padding(12.dp), onClick = { + openDialogInfo = true + }) { + Text("Sweet Toast Info") + } } if (openDialogSuccess) { - SweetSuccess(message = "Success Text!") + openDialogSuccess = false + SweetSuccess(message = "Success Text!", duration = Toast.LENGTH_SHORT) + } + + if (openDialogError) { + openDialogError = false + SweetError(message = "Error Text!") } + + if (openDialogWarning) { + openDialogWarning = false + SweetWarning(message = "Warning Text!") + } + + if (openDialogInfo) { + openDialogInfo = false + SweetInfo(message = "Info Text!") + } + } \ No newline at end of file