Skip to content

Commit

Permalink
feat: now tts dialog won't be dismissed without pressing dismiss butt…
Browse files Browse the repository at this point in the history
…on or touch outside of dialog
  • Loading branch information
plateaukao committed Sep 27, 2024
1 parent 86dfd6c commit 6029194
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -46,11 +45,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogWindowProvider
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import info.plateaukao.einkbro.R
import info.plateaukao.einkbro.preference.ChatGPTActionInfo
import info.plateaukao.einkbro.preference.ConfigManager
Expand All @@ -59,7 +58,7 @@ import info.plateaukao.einkbro.view.compose.MyTheme
import info.plateaukao.einkbro.view.compose.SelectableText
import org.koin.android.ext.android.inject

class GptActionsActivity : ComponentActivity() {
class GptActionsActivity : ComponentActivity() {
private val config: ConfigManager by inject()

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -221,9 +220,9 @@ fun GptActionListContent(
verticalAlignment = Alignment.CenterVertically
) {
// icon: action type
Image(
Icon(
modifier = Modifier.wrapContentWidth(),
painter = rememberDrawablePainter(context.getDrawable(iconRes)),
painter = painterResource(id = iconRes),
contentDescription = "Action Type",
)
Spacer(modifier = Modifier.width(15.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ fun SelectableText(
modifier: Modifier,
selected: Boolean,
text: String,
isEnabled: Boolean = true,
textAlign: TextAlign = TextAlign.Start,
onClick: () -> Unit,
) {
val interactionSource = remember { MutableInteractionSource() }
val borderWidth = if (selected) 1.dp else -1.dp
Text(
text = text,
color = MaterialTheme.colors.onBackground,
color = MaterialTheme.colors.onBackground.copy(alpha = if (isEnabled) 1f else 0.5f),
style = MaterialTheme.typography.button,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
Expand All @@ -37,6 +38,8 @@ fun SelectableText(
.clickable(
indication = null,
interactionSource = interactionSource,
) { onClick() }
) {
if (isEnabled) onClick()
}
)
}
Loading

0 comments on commit 6029194

Please sign in to comment.