Skip to content
Merged
Show file tree
Hide file tree
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 @@ -23,6 +23,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -40,7 +41,6 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.IntOffset
Expand Down Expand Up @@ -346,7 +346,7 @@ private fun OCRTextArea(
.verticalScroll(rememberScrollState()),
text = ocrText,
locale = Locale.US,
textStyle = TextStyle(
textStyle = LocalTextStyle.current.copy(
color = MaterialTheme.colorScheme.onSurface,
fontSize = fontSize.sp,
),
Expand Down Expand Up @@ -409,7 +409,6 @@ private fun TranslationTextArea(
translatedText: String,
fontSize: Float,
) {

if (showProcessing) {
ProgressIndicator()
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tw.firemaples.onscreenocr.floatings.compose.wigets

import androidx.compose.foundation.text.ClickableText
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -23,7 +24,7 @@ fun WordSelectionText(
modifier: Modifier = Modifier,
text: String,
locale: Locale,
textStyle: TextStyle = TextStyle.Default,
textStyle: TextStyle = LocalTextStyle.current,
selectedSpanStyle: SpanStyle = SpanStyle(),
onTextSelected: (String) -> Unit
) {
Expand Down
31 changes: 20 additions & 11 deletions main/src/main/java/tw/firemaples/onscreenocr/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package tw.firemaples.onscreenocr.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextDirection


private val LightColors = lightColorScheme(
Expand Down Expand Up @@ -74,17 +77,23 @@ private val DarkColors = darkColorScheme(

@Composable
fun AppTheme(
useDarkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit
useDarkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colors = if (!useDarkTheme) {
LightColors
} else {
DarkColors
}
val colors = if (!useDarkTheme) {
LightColors
} else {
DarkColors
}

MaterialTheme(
colorScheme = colors,
content = content
)
MaterialTheme(
colorScheme = colors,
) {
val textStyle = TextStyle(
textDirection = TextDirection.Content,
)
ProvideTextStyle(value = textStyle) {
content()
}
}
}