From 287a5e593f5f640baa209d46681b3f12ec01ccdc Mon Sep 17 00:00:00 2001 From: Mahmudul Hasan Shohag Date: Mon, 30 Dec 2024 11:44:58 +0600 Subject: [PATCH] refactor: apply ktlint --- .../whynotcompose/ui/screens/NavGraphMain.kt | 18 +- .../composition/button/ButtonScreen.kt | 180 +++++++++--------- .../composition/checkbox/CheckBoxScreen.kt | 8 +- .../composition/switch/SwitchScreen.kt | 4 +- .../DataFetchAndPagingScreen.kt | 22 +-- .../elements/GithubRepoItem.kt | 18 +- .../whynotcompose/utils/CropImage.kt | 7 +- .../cms/ui/compositions/ErrorItem.kt | 11 +- .../cms/ui/compositions/GeneralSheetAppBar.kt | 7 +- .../button/GeneralFilledButton.kt | 12 +- .../button/GeneralOutlinedIconButton.kt | 9 +- .../compositions/button/GeneralTextButton.kt | 12 +- .../ui/screens/comment/add/CommentAddSheet.kt | 4 +- .../screens/comment/edit/CommentEditSheet.kt | 4 +- .../cms/ui/screens/post/add/PostAddSheet.kt | 4 +- .../screens/post/details/PostDetailsScreen.kt | 9 +- .../cms/ui/screens/post/edit/PostEditSheet.kt | 4 +- .../cms/ui/screens/todo/add/TodoAddSheet.kt | 13 +- .../cms/ui/screens/todo/edit/TodoEditSheet.kt | 13 +- .../cms/ui/screens/user/add/UserAddSheet.kt | 4 +- .../screens/user/details/UserDetailsScreen.kt | 18 +- .../cms/ui/screens/user/edit/UserEditSheet.kt | 4 +- 22 files changed, 196 insertions(+), 189 deletions(-) diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/NavGraphMain.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/NavGraphMain.kt index 3811bfa3..6c5aae43 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/NavGraphMain.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/NavGraphMain.kt @@ -218,8 +218,7 @@ sealed class UIsScreen(val route: String) { data object UiMapView : UIsScreen("ui/mapview") data object UiMapViewDetails : UIsScreen("ui/mapview/details?item={item}") { const val PARAM_ITEM = "item" - fun createRoute(item: MapPlace) = - route.replace("{$PARAM_ITEM}", item.getJsonFromObj() ?: "") + fun createRoute(item: MapPlace) = route.replace("{$PARAM_ITEM}", item.getJsonFromObj() ?: "") } data object UiOtpCodeVerify : UIsScreen("ui/otpcodeverify") @@ -253,8 +252,7 @@ sealed class TutorialsScreen(val route: String) { data object TutorialNavDataPassScreen1 : TutorialsScreen("tutorial/nav-data-pass/one/{data}") { const val PARAM_DATA = "data" - fun createRoute(item: DemoData) = - route.replace("{$PARAM_DATA}", item.getJsonFromObj() ?: "") + fun createRoute(item: DemoData) = route.replace("{$PARAM_DATA}", item.getJsonFromObj() ?: "") } data object TutorialNavDataPassScreen2 : TutorialsScreen("tutorial/nav-data-pass/two") { @@ -266,10 +264,9 @@ sealed class TutorialsScreen(val route: String) { const val PARAM_ID = "id" const val PARAM_NAME = "name" - fun createRoute(id: Int, name: String) = - route - .replace("{$PARAM_ID}", "$id") - .replace("{$PARAM_NAME}", name) + fun createRoute(id: Int, name: String) = route + .replace("{$PARAM_ID}", "$id") + .replace("{$PARAM_NAME}", name) } data object TutorialNavDataPassScreen4 : @@ -280,9 +277,8 @@ sealed class TutorialsScreen(val route: String) { const val ARG_NAME = "name" const val ARG_RANKS = "ranks" - fun createRoute(id: Int) = - route - .replace("{$PARAM_ID}", "$id") + fun createRoute(id: Int) = route + .replace("{$PARAM_ID}", "$id") } data object TutorialNavDataPassScreen5 : diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/button/ButtonScreen.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/button/ButtonScreen.kt index de937937..ba829eb6 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/button/ButtonScreen.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/button/ButtonScreen.kt @@ -235,8 +235,8 @@ fun ButtonScreenSkeleton( SolidButton( text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -245,8 +245,8 @@ fun ButtonScreenSkeleton( SolidButton( text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -255,9 +255,9 @@ fun ButtonScreenSkeleton( SolidButton( text = "Like", + onClick = {}, startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -279,9 +279,9 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() SolidWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth() ) // ---------------------------------------------------------------- @@ -289,10 +289,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() SolidWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -300,10 +300,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() SolidWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -311,11 +311,11 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() SolidWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", + onClick = {}, + modifier = Modifier.fillMaxWidth(), startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -347,8 +347,8 @@ fun ButtonScreenSkeleton( GradientButton( text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -357,8 +357,8 @@ fun ButtonScreenSkeleton( GradientButton( text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -367,9 +367,9 @@ fun ButtonScreenSkeleton( GradientButton( text = "Like", + onClick = {}, startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -391,9 +391,9 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() GradientWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth() ) // ---------------------------------------------------------------- @@ -401,10 +401,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() GradientWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -412,10 +412,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() GradientWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -423,11 +423,11 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() GradientWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", + onClick = {}, + modifier = Modifier.fillMaxWidth(), startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -459,8 +459,8 @@ fun ButtonScreenSkeleton( BorderedButton( text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -469,8 +469,8 @@ fun ButtonScreenSkeleton( BorderedButton( text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -479,9 +479,9 @@ fun ButtonScreenSkeleton( BorderedButton( text = "Like", + onClick = {}, startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -503,9 +503,9 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderedWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth() ) // ---------------------------------------------------------------- @@ -513,10 +513,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderedWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -524,10 +524,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderedWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -535,11 +535,11 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderedWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", + onClick = {}, + modifier = Modifier.fillMaxWidth(), startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -571,8 +571,8 @@ fun ButtonScreenSkeleton( BorderlessButton( text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -581,8 +581,8 @@ fun ButtonScreenSkeleton( BorderlessButton( text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -591,9 +591,9 @@ fun ButtonScreenSkeleton( BorderlessButton( text = "Like", + onClick = {}, startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -615,9 +615,9 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderlessWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth() ) // ---------------------------------------------------------------- @@ -625,10 +625,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderlessWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - startIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + startIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -636,10 +636,10 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderlessWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", - endIcon = R.drawable.ic_danger_circle, - onClick = {} + onClick = {}, + modifier = Modifier.fillMaxWidth(), + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -647,11 +647,11 @@ fun ButtonScreenSkeleton( AppComponent.MediumSpacer() BorderlessWideButton( - modifier = Modifier.fillMaxWidth(), text = "Like", + onClick = {}, + modifier = Modifier.fillMaxWidth(), startIcon = R.drawable.ic_danger_circle, - endIcon = R.drawable.ic_danger_circle, - onClick = {} + endIcon = R.drawable.ic_danger_circle ) // ---------------------------------------------------------------- @@ -713,14 +713,14 @@ fun ButtonScreenSkeleton( @Composable fun SolidButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, height: Dp = ButtonDefaults.MinHeight, fontSize: TextUnit = 16.sp, backgroundColor: Color = MaterialTheme.colorScheme.primary, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -767,6 +767,7 @@ fun SolidButton( @Composable fun SolidWideButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, @@ -774,8 +775,7 @@ fun SolidWideButton( fontSize: TextUnit = 16.sp, horizontalPadding: Dp = ButtonDefaults.IconSpacing, backgroundColor: Color = MaterialTheme.colorScheme.primary, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -833,14 +833,14 @@ fun SolidWideButton( @Composable fun GradientButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, height: Dp = ButtonDefaults.MinHeight, fontSize: TextUnit = 16.sp, backgroundGradient: Brush = defaultButtonBackgroundBrush(), - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -893,6 +893,7 @@ fun GradientButton( @Composable fun GradientWideButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, @@ -900,8 +901,7 @@ fun GradientWideButton( fontSize: TextUnit = 16.sp, horizontalPadding: Dp = ButtonDefaults.IconSpacing, backgroundGradient: Brush = defaultButtonBackgroundBrush(), - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -968,14 +968,14 @@ fun GradientWideButton( @Composable fun BorderedButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, height: Dp = ButtonDefaults.MinHeight, fontSize: TextUnit = 16.sp, borderGradient: Brush = defaultButtonBackgroundBrush(.3f), - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1026,6 +1026,7 @@ fun BorderedButton( @Composable fun BorderedWideButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, @@ -1033,8 +1034,7 @@ fun BorderedWideButton( fontSize: TextUnit = 16.sp, horizontalPadding: Dp = ButtonDefaults.IconSpacing, borderGradient: Brush = defaultButtonBackgroundBrush(.3f), - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1097,13 +1097,13 @@ fun BorderedWideButton( @Composable fun BorderlessButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, height: Dp = ButtonDefaults.MinHeight, fontSize: TextUnit = 16.sp, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1149,14 +1149,14 @@ fun BorderlessButton( @Composable fun BorderlessWideButton( text: String, + onClick: () -> Unit, modifier: Modifier = Modifier, @DrawableRes startIcon: Int? = null, @DrawableRes endIcon: Int? = null, height: Dp = ButtonDefaults.MinHeight, fontSize: TextUnit = 16.sp, horizontalPadding: Dp = ButtonDefaults.IconSpacing, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1215,11 +1215,11 @@ fun BorderlessWideButton( fun SolidIconButton( @DrawableRes icon: Int, contentDescription: String?, + onClick: () -> Unit, modifier: Modifier = Modifier, backgroundColor: Color = MaterialTheme.colorScheme.primary, size: Dp = ButtonDefaults.MinHeight, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1253,11 +1253,11 @@ fun SolidIconButton( fun GradientIconButton( @DrawableRes icon: Int, contentDescription: String?, + onClick: () -> Unit, modifier: Modifier = Modifier, backgroundGradient: Brush = defaultButtonBackgroundBrush(), size: Dp = ButtonDefaults.MinHeight, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current @@ -1294,10 +1294,10 @@ fun GradientIconButton( fun BorderlessIconButton( @DrawableRes icon: Int, contentDescription: String?, + onClick: () -> Unit, modifier: Modifier = Modifier, size: Dp = ButtonDefaults.MinHeight, - shape: Shape = MaterialTheme.shapes.medium, - onClick: () -> Unit + shape: Shape = MaterialTheme.shapes.medium ) { val currentFocus = LocalFocusManager.current diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/checkbox/CheckBoxScreen.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/checkbox/CheckBoxScreen.kt index 3a4a6ea9..3dcac5b7 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/checkbox/CheckBoxScreen.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/checkbox/CheckBoxScreen.kt @@ -183,8 +183,8 @@ private fun TriStateCheckboxSample() { fun GeneralTriStateCheckBox( text: String, state: ToggleableState, - modifier: Modifier = Modifier, - onClick: () -> Unit + onClick: () -> Unit, + modifier: Modifier = Modifier ) { Row( modifier @@ -211,8 +211,8 @@ fun GeneralTriStateCheckBox( fun GeneralCheckBox( text: String, state: Boolean, - modifier: Modifier = Modifier, - onStateChange: (Boolean) -> Unit + onStateChange: (Boolean) -> Unit, + modifier: Modifier = Modifier ) { Row( modifier diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/switch/SwitchScreen.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/switch/SwitchScreen.kt index 1bc3f62e..e241fbca 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/switch/SwitchScreen.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/composition/switch/SwitchScreen.kt @@ -152,8 +152,8 @@ fun SwitchScreenSkeleton( fun GeneralStartSwitch( text: String, state: Boolean, - modifier: Modifier = Modifier, - onStateChange: (Boolean) -> Unit + onStateChange: (Boolean) -> Unit, + modifier: Modifier = Modifier ) { Row( modifier diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/DataFetchAndPagingScreen.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/DataFetchAndPagingScreen.kt index 76b0a713..637aef7a 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/DataFetchAndPagingScreen.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/DataFetchAndPagingScreen.kt @@ -268,16 +268,16 @@ fun DataFetchAndPagingScreenSkeleton( Text("Loading...") } else { GithubRepoItem( + item = repo, + onClick = { + // do something... + }, modifier = Modifier.padding( start = 12.dp, top = 4.dp, end = 12.dp, bottom = 4.dp - ), - item = repo, - onClick = { - // do something... - } + ) ) } } @@ -287,7 +287,7 @@ fun DataFetchAndPagingScreenSkeleton( loadState.refresh is LoadState.Loading -> { item { Column { - for (i in 1..6) { + repeat(6) { LoadingGithubRepoItem( Modifier .padding( @@ -450,17 +450,17 @@ fun DataFetchAndPagingScreenSkeleton( private fun ErrorItemPreview() { AppTheme { ErrorItem( - "Something went wrong!" - ) { - } + message = "Something went wrong!", + onRetryClick = {} + ) } } @Composable fun ErrorItem( message: String, - modifier: Modifier = Modifier, - onRetryClick: () -> Unit + onRetryClick: () -> Unit, + modifier: Modifier = Modifier ) { Card( modifier = modifier diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/elements/GithubRepoItem.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/elements/GithubRepoItem.kt index 118521a5..3c96e8ec 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/elements/GithubRepoItem.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/ui/screens/tutorial/datafetchandpaging/elements/GithubRepoItem.kt @@ -66,8 +66,8 @@ import org.imaginativeworld.whynotcompose.repositories.MockData @Composable fun GithubRepoItem( item: GithubRepo, - modifier: Modifier = Modifier, - onClick: () -> Unit + onClick: () -> Unit, + modifier: Modifier = Modifier ) { Card( modifier = modifier @@ -159,12 +159,6 @@ private fun GithubRepoItemPreview() { Column(Modifier.padding(innerPadding)) { repeat(10) { GithubRepoItem( - modifier = Modifier.padding( - start = 12.dp, - top = 4.dp, - end = 12.dp, - bottom = 4.dp - ), item = if (it % 2 == 0) { MockData.dummyGithubRepo } else { @@ -172,7 +166,13 @@ private fun GithubRepoItemPreview() { description = null ) }, - onClick = {} + onClick = {}, + modifier = Modifier.padding( + start = 12.dp, + top = 4.dp, + end = 12.dp, + bottom = 4.dp + ) ) } } diff --git a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/utils/CropImage.kt b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/utils/CropImage.kt index a41bcf84..d9adf387 100644 --- a/app/src/main/kotlin/org/imaginativeworld/whynotcompose/utils/CropImage.kt +++ b/app/src/main/kotlin/org/imaginativeworld/whynotcompose/utils/CropImage.kt @@ -59,10 +59,9 @@ class CropImage( private val aspectRatioX: Float = 1f, private val aspectRatioY: Float = 1f ) : ActivityResultContract, Uri?>() { - override fun createIntent(context: Context, input: Pair): Intent = - UCrop.of(input.first, input.second) - .withAspectRatio(aspectRatioX, aspectRatioY) - .getIntent(context) + override fun createIntent(context: Context, input: Pair): Intent = UCrop.of(input.first, input.second) + .withAspectRatio(aspectRatioX, aspectRatioY) + .getIntent(context) override fun parseResult(resultCode: Int, intent: Intent?): Uri? { if (resultCode != Activity.RESULT_OK || intent == null) { diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/ErrorItem.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/ErrorItem.kt index eb6e6011..60a3fe2f 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/ErrorItem.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/ErrorItem.kt @@ -60,9 +60,10 @@ private fun ErrorItemPreview() { contentAlignment = Alignment.Center ) { ErrorItem( - "Something went wrong!" - ) { - } + "Something went wrong!", + { + } + ) } } } @@ -71,8 +72,8 @@ private fun ErrorItemPreview() { @Composable fun ErrorItem( message: String, - modifier: Modifier = Modifier, - onRetryClick: () -> Unit + onRetryClick: () -> Unit, + modifier: Modifier = Modifier ) { Card( modifier = modifier diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/GeneralSheetAppBar.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/GeneralSheetAppBar.kt index 99585e2b..2ef5b306 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/GeneralSheetAppBar.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/GeneralSheetAppBar.kt @@ -70,10 +70,11 @@ fun GeneralSheetAppBar( actions = { GeneralOutlinedIconButton( icon = Icons.Rounded.Close, + { + onCancelClick() + }, contentDescription = "Cancel" - ) { - onCancelClick() - } + ) Spacer(Modifier.size(ButtonDefaults.IconSpacing)) }, diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralFilledButton.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralFilledButton.kt index 6d21960f..7f6d56e0 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralFilledButton.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralFilledButton.kt @@ -48,9 +48,9 @@ import org.imaginativeworld.whynotcompose.common.compose.theme.AppTheme @Composable fun GeneralFilledButton( caption: String, + onClick: () -> Unit, modifier: Modifier = Modifier, - icon: ImageVector? = null, - onClick: () -> Unit + icon: ImageVector? = null ) { Button( modifier = modifier, @@ -85,13 +85,15 @@ private fun GeneralFilledButtonPreview() { horizontalAlignment = Alignment.CenterHorizontally ) { GeneralFilledButton( - caption = "Click Me" - ) {} + caption = "Click Me", + onClick = {} + ) GeneralFilledButton( caption = "Click Me", + onClick = {}, icon = Icons.Outlined.Star - ) {} + ) } } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralOutlinedIconButton.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralOutlinedIconButton.kt index 6d5a1355..3cc4347b 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralOutlinedIconButton.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralOutlinedIconButton.kt @@ -44,9 +44,9 @@ import org.imaginativeworld.whynotcompose.common.compose.theme.AppTheme @Composable fun GeneralOutlinedIconButton( icon: ImageVector, + onClick: () -> Unit, modifier: Modifier = Modifier, - contentDescription: String? = null, - onClick: () -> Unit + contentDescription: String? = null ) { OutlinedIconButton( modifier = modifier, @@ -71,8 +71,9 @@ private fun GeneralOutlinedButtonPreview() { horizontalAlignment = Alignment.CenterHorizontally ) { GeneralOutlinedIconButton( - icon = Icons.Outlined.Star - ) {} + icon = Icons.Outlined.Star, + onClick = {} + ) } } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralTextButton.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralTextButton.kt index b9de1a49..7f30eb7f 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralTextButton.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/compositions/button/GeneralTextButton.kt @@ -48,9 +48,9 @@ import org.imaginativeworld.whynotcompose.common.compose.theme.AppTheme @Composable fun GeneralTextButton( caption: String, + onClick: () -> Unit, modifier: Modifier = Modifier, - icon: ImageVector? = null, - onClick: () -> Unit + icon: ImageVector? = null ) { TextButton( modifier = modifier, @@ -85,13 +85,15 @@ private fun GeneralTextButtonPreview() { horizontalAlignment = Alignment.CenterHorizontally ) { GeneralTextButton( - caption = "Click Me" - ) {} + caption = "Click Me", + {} + ) GeneralTextButton( caption = "Click Me", + {}, icon = Icons.Outlined.Star - ) {} + ) } } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/add/CommentAddSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/add/CommentAddSheet.kt index fa69a950..cd37d69d 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/add/CommentAddSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/add/CommentAddSheet.kt @@ -232,14 +232,14 @@ fun CommentAddSheetSkeleton( GeneralFilledButton( caption = "Add Comment", - icon = Icons.Rounded.Add, onClick = { addComment( name, email, body ) - } + }, + icon = Icons.Rounded.Add ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/edit/CommentEditSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/edit/CommentEditSheet.kt index 6d9531ca..90285898 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/edit/CommentEditSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/comment/edit/CommentEditSheet.kt @@ -252,14 +252,14 @@ fun CommentEditSheetSkeleton( GeneralFilledButton( caption = "Update Comment", - icon = Icons.Rounded.Check, onClick = { updateComment( name, email, body ) - } + }, + icon = Icons.Rounded.Check ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/add/PostAddSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/add/PostAddSheet.kt index 0711efc0..7310650a 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/add/PostAddSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/add/PostAddSheet.kt @@ -216,13 +216,13 @@ fun PostAddSheetSkeleton( GeneralFilledButton( caption = "Add Post", - icon = Icons.Rounded.Add, onClick = { addPost( title, body ) - } + }, + icon = Icons.Rounded.Add ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/details/PostDetailsScreen.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/details/PostDetailsScreen.kt index 362452f1..fa188272 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/details/PostDetailsScreen.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/details/PostDetailsScreen.kt @@ -289,12 +289,13 @@ fun PostDetailsScreenSkeleton( Spacer(Modifier.weight(1f)) GeneralFilledButton( - modifier = Modifier.weight(2f), caption = "Comments", + { + onCommentsClick() + }, + modifier = Modifier.weight(2f), icon = Icons.Rounded.Chat - ) { - onCommentsClick() - } + ) Spacer(Modifier.weight(1f)) } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/edit/PostEditSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/edit/PostEditSheet.kt index 93210de9..5b85ec66 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/edit/PostEditSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/post/edit/PostEditSheet.kt @@ -236,13 +236,13 @@ fun PostEditSheetSkeleton( GeneralFilledButton( caption = "Update Post", - icon = Icons.Rounded.Check, onClick = { updatePost( title, body ) - } + }, + icon = Icons.Rounded.Check ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/add/TodoAddSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/add/TodoAddSheet.kt index e332295d..e7e4be48 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/add/TodoAddSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/add/TodoAddSheet.kt @@ -235,12 +235,13 @@ fun TodoAddSheetSkeleton( ) GeneralTextButton( - modifier = Modifier.padding(top = 8.dp), caption = "Select", + { + openDatePickerDialog = true + }, + modifier = Modifier.padding(top = 8.dp), icon = Icons.Rounded.CalendarMonth - ) { - openDatePickerDialog = true - } + ) } ExposedDropdownMenuBox( @@ -299,14 +300,14 @@ fun TodoAddSheetSkeleton( GeneralFilledButton( caption = "Add Todo", - icon = Icons.Rounded.Add, onClick = { addTodo( title, dueDate, selectedStatusOption ) - } + }, + icon = Icons.Rounded.Add ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/edit/TodoEditSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/edit/TodoEditSheet.kt index 5d413f0a..d9336075 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/edit/TodoEditSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/todo/edit/TodoEditSheet.kt @@ -259,12 +259,13 @@ fun TodoEditSheetSkeleton( ) GeneralTextButton( - modifier = Modifier.padding(top = 8.dp), caption = "Select", + { + openDatePickerDialog = true + }, + modifier = Modifier.padding(top = 8.dp), icon = Icons.Rounded.CalendarMonth - ) { - openDatePickerDialog = true - } + ) } ExposedDropdownMenuBox( @@ -323,14 +324,14 @@ fun TodoEditSheetSkeleton( GeneralFilledButton( caption = "Update Todo", - icon = Icons.Rounded.Check, onClick = { updateTodo( title, dueDate, selectedStatusOption ) - } + }, + icon = Icons.Rounded.Check ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/add/UserAddSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/add/UserAddSheet.kt index 776c68e7..dfd5e6e2 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/add/UserAddSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/add/UserAddSheet.kt @@ -321,7 +321,6 @@ fun UserAddSheetSkeleton( GeneralFilledButton( caption = "Add User", - icon = Icons.Rounded.Add, onClick = { addUser( name, @@ -329,7 +328,8 @@ fun UserAddSheetSkeleton( selectedGenderOption, selectedStatusOption ) - } + }, + icon = Icons.Rounded.Add ) } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/details/UserDetailsScreen.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/details/UserDetailsScreen.kt index 8047906a..a209be52 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/details/UserDetailsScreen.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/details/UserDetailsScreen.kt @@ -290,22 +290,24 @@ fun UserDetailsScreenSkeleton( Row { GeneralFilledButton( - modifier = Modifier.weight(1f), caption = "Todos", + { + onTodosClick() + }, + modifier = Modifier.weight(1f), icon = Icons.Rounded.Ballot - ) { - onTodosClick() - } + ) Spacer(Modifier.width(16.dp)) GeneralFilledButton( - modifier = Modifier.weight(1f), caption = "Posts", + { + onPostsClick() + }, + modifier = Modifier.weight(1f), icon = Icons.Rounded.TextSnippet - ) { - onPostsClick() - } + ) } } } diff --git a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/edit/UserEditSheet.kt b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/edit/UserEditSheet.kt index e336a58f..9db29080 100644 --- a/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/edit/UserEditSheet.kt +++ b/cms/src/main/kotlin/org/imaginativeworld/whynotcompose/cms/ui/screens/user/edit/UserEditSheet.kt @@ -345,7 +345,6 @@ fun UserEditSheetSkeleton( GeneralFilledButton( caption = "Update User", - icon = Icons.Rounded.Check, onClick = { updateUser( name, @@ -353,7 +352,8 @@ fun UserEditSheetSkeleton( selectedGenderOption, selectedStatusOption ) - } + }, + icon = Icons.Rounded.Check ) } }