11package com.cornellappdev.transit.ui.components.home
22
3+ import android.content.ActivityNotFoundException
4+ import android.content.Intent
5+ import androidx.compose.foundation.clickable
36import androidx.compose.foundation.layout.Column
47import androidx.compose.foundation.layout.Row
58import androidx.compose.foundation.layout.Spacer
@@ -13,9 +16,11 @@ import androidx.compose.material3.Text
1316import androidx.compose.runtime.Composable
1417import androidx.compose.ui.Alignment
1518import androidx.compose.ui.Modifier
19+ import androidx.compose.ui.platform.LocalContext
1620import androidx.compose.ui.res.painterResource
1721import androidx.compose.ui.res.stringResource
1822import androidx.compose.ui.unit.dp
23+ import androidx.core.net.toUri
1924import com.cornellappdev.transit.R
2025import com.cornellappdev.transit.models.ecosystem.UpliftGym
2126import com.cornellappdev.transit.ui.theme.DividerGray
@@ -97,11 +102,32 @@ fun GymDetailsContent(
97102 val (annotatedString, inlineContent) =
98103 stringResource(R .string.view_gym).createDeepLink(R .drawable.upliftlink)
99104
105+ val context = LocalContext .current
106+
100107 Text (
101108 text = annotatedString,
102109 inlineContent = inlineContent,
103110 style = Style .heading2,
104- color = TransitBlue
111+ color = TransitBlue ,
112+ modifier = Modifier .clickable(
113+ onClick = {
114+ val upliftPackage = " com.cornellappdev.uplift"
115+ val upliftIntent = context.packageManager.getLaunchIntentForPackage(upliftPackage)
116+
117+ if (upliftIntent != null ) {
118+ context.startActivity(upliftIntent)
119+ } else {
120+ try {
121+ val playStoreIntent = Intent (Intent .ACTION_VIEW , " market://details?id=$upliftPackage " .toUri())
122+ playStoreIntent.setPackage(" com.android.vending" )
123+ context.startActivity(playStoreIntent)
124+ } catch (e: ActivityNotFoundException ) {
125+ context.startActivity(Intent (Intent .ACTION_VIEW , " https://play.google.com/store/apps/details?id=$upliftPackage }" .toUri()))
126+
127+ }
128+ }
129+ }
130+ )
105131 )
106132
107133 Spacer (modifier = Modifier .height(24 .dp))
0 commit comments