From 30e4aad112fcd12e9e87191caa5ad49b09f65b29 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 24 Jul 2023 21:33:32 +0200 Subject: [PATCH] feat: add custom ripple for back button --- .../compose/screens/SettingsScreen.kt | 22 +++++++++++++------ .../calculator/compose/theme/Colors.kt | 3 +++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/compose/screens/SettingsScreen.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/compose/screens/SettingsScreen.kt index 2c964aad..898f6020 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/compose/screens/SettingsScreen.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/compose/screens/SettingsScreen.kt @@ -1,17 +1,20 @@ package com.simplemobiletools.calculator.compose.screens -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable +import androidx.compose.foundation.* +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.ripple.LocalRippleTheme +import androidx.compose.material.ripple.rememberRipple import androidx.compose.material3.* import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.SideEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.lerp import androidx.compose.ui.input.nestedscroll.nestedScroll @@ -67,7 +70,7 @@ fun SettingsScreen( systemUiController.setStatusBarColor(Color.Transparent, darkIcons = scrolledColor.isNotLitWell()) } val startingPadding = Modifier.padding(horizontal = 4.dp) - + val navigationIconInteractionSource = remember { MutableInteractionSource() } Scaffold( modifier = Modifier .fillMaxSize() @@ -87,8 +90,13 @@ fun SettingsScreen( Icon( imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(id = R.string.back), modifier = Modifier - .clickable { goBack() } - .padding(start = 8.dp), + .padding(start = 8.dp) + .clip(RoundedCornerShape(50)) + .clickable( + navigationIconInteractionSource, rememberRipple( + color = MaterialTheme.colorScheme.onSurface + ) + ) { goBack() }, tint = scrolledColor ) }, diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/compose/theme/Colors.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/compose/theme/Colors.kt index abc66757..8310ed74 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/compose/theme/Colors.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/compose/theme/Colors.kt @@ -441,3 +441,6 @@ val default_app_icon_color = color_primary val default_accent_color = color_primary val default_widget_bg_color = Color(0xAA000000) val default_widget_text_color = color_primary + +val ripple_light = Color(0x1f000000) +val ripple_dark = Color(0x33ffffff)