Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Install App Prompt to dismiss bottomsheet when not now button is tapped #1971

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Surface
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.res.painterResource
import com.google.android.horologist.datalayer.phone.ui.play.launchPlay
import kotlinx.coroutines.launch

internal const val INSTALL_APP_KEY_APP_NAME = "HOROLOGIST_INSTALL_APP_KEY_APP_NAME"
internal const val INSTALL_APP_KEY_APP_PACKAGE_NAME = "HOROLOGIST_INSTALL_APP_KEY_APP_PACKAGE_NAME"
Expand All @@ -53,6 +55,7 @@ internal class InstallAppBottomSheetActivity : ComponentActivity() {
setContent {
Surface {
val installAppBottomSheetState = rememberModalBottomSheetState()
val coroutineScope = rememberCoroutineScope()

val icon: (@Composable () -> Unit)? = imageResId.takeIf { it != NO_IMAGE }?.let {
{
Expand All @@ -70,7 +73,13 @@ internal class InstallAppBottomSheetActivity : ComponentActivity() {
icon = icon,
onDismissRequest = {
setResult(RESULT_CANCELED)
finish()
coroutineScope.launch {
try {
installAppBottomSheetState.hide()
} finally {
finish()
}
}
},
onConfirmation = {
this.launchPlay(appPackageName)
Expand Down