diff --git a/androidApp/src/main/java/dev/xinto/argos/ui/component/HtmlText2.kt b/androidApp/src/main/java/dev/xinto/argos/ui/component/HtmlText2.kt index acf2578..82255c7 100644 --- a/androidApp/src/main/java/dev/xinto/argos/ui/component/HtmlText2.kt +++ b/androidApp/src/main/java/dev/xinto/argos/ui/component/HtmlText2.kt @@ -1,7 +1,6 @@ package dev.xinto.argos.ui.component import android.annotation.SuppressLint -import android.view.MotionEvent import android.webkit.WebView import android.widget.FrameLayout import android.widget.FrameLayout.LayoutParams @@ -31,12 +30,14 @@ import org.intellij.lang.annotations.Language fun MaterialHtmlText2( @Language("HTML") text: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + userScrollEnabled: Boolean = true ) { HtmlText2( modifier = modifier, text = text, - typography = HtmlText2Defaults.material3Typography() + typography = HtmlText2Defaults.material3Typography(), + userScrollEnabled = userScrollEnabled ) } @@ -48,7 +49,8 @@ fun HtmlText2( @Language("HTML") text: String, typography: HtmlText2Typography, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + userScrollEnabled: Boolean = true, ) { val textCss = typography.asCss(LocalDensity.current) AndroidView( @@ -61,10 +63,6 @@ fun HtmlText2( isLongClickable = false setOnLongClickListener { true } isHapticFeedbackEnabled = false - setOnTouchListener { _, event -> - event.action == MotionEvent.ACTION_MOVE - } - setInitialScale(250) layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) } FrameLayout(it).apply { //FrameLayout needed to prevent crashes @@ -89,6 +87,15 @@ fun HtmlText2( """.trimIndent() webView.loadData(htmlText, "text/html; charset=utf-8", "UTF-8") + + if (userScrollEnabled) { + webView.setOnTouchListener { v, event -> + webView.requestDisallowInterceptTouchEvent(true) + false + } + } else { + webView.setOnTouchListener(null) + } }, onReset = { //enable reuse diff --git a/androidApp/src/main/java/dev/xinto/argos/ui/screen/course/page/syllabus/SyllabusPage.kt b/androidApp/src/main/java/dev/xinto/argos/ui/screen/course/page/syllabus/SyllabusPage.kt index 8d0e664..d2d50ff 100644 --- a/androidApp/src/main/java/dev/xinto/argos/ui/screen/course/page/syllabus/SyllabusPage.kt +++ b/androidApp/src/main/java/dev/xinto/argos/ui/screen/course/page/syllabus/SyllabusPage.kt @@ -1,12 +1,9 @@ package dev.xinto.argos.ui.screen.course.page.syllabus import androidx.annotation.StringRes -import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -88,17 +85,12 @@ fun SyllabusPage( append("") } } - Box( + MaterialHtmlText2( + text = text, modifier = Modifier .fillMaxSize() - .verticalScroll(rememberScrollState()) - .horizontalScroll(rememberScrollState()) - ) { - MaterialHtmlText2( - text = text, - modifier = Modifier.padding(16.dp) - ) - } + .padding(16.dp), + ) } is SyllabusState.Error -> { diff --git a/androidApp/src/main/java/dev/xinto/argos/ui/screen/message/MessageScreen.kt b/androidApp/src/main/java/dev/xinto/argos/ui/screen/message/MessageScreen.kt index 71637a6..78b92a3 100644 --- a/androidApp/src/main/java/dev/xinto/argos/ui/screen/message/MessageScreen.kt +++ b/androidApp/src/main/java/dev/xinto/argos/ui/screen/message/MessageScreen.kt @@ -105,7 +105,8 @@ fun MessageScreen( ${state.message.body} """.trimIndent() - } + }, + userScrollEnabled = false ) } }