1
1
package com.jyn.composecalculator.ui.view
2
2
3
3
import androidx.compose.foundation.horizontalScroll
4
- import androidx.compose.foundation.indication
5
- import androidx.compose.foundation.interaction.MutableInteractionSource
6
4
import androidx.compose.foundation.layout.*
7
5
import androidx.compose.foundation.rememberScrollState
8
6
import androidx.compose.material3.Text
@@ -15,7 +13,6 @@ import androidx.compose.ui.Modifier
15
13
import androidx.compose.ui.graphics.Color
16
14
import androidx.compose.ui.layout.onSizeChanged
17
15
import androidx.compose.ui.text.style.TextAlign
18
- import androidx.compose.ui.tooling.preview.Preview
19
16
import androidx.compose.ui.unit.dp
20
17
import androidx.compose.ui.unit.sp
21
18
import androidx.lifecycle.viewmodel.compose.viewModel
@@ -26,7 +23,6 @@ import com.jyn.composecalculator.DateViewModel
26
23
fun InputText (input : String ) {
27
24
val viewModel = viewModel<DateViewModel >()
28
25
29
- val mutableInteractionSource = remember { MutableInteractionSource () }
30
26
val inputScrollState = rememberScrollState()
31
27
val resultScrollState = rememberScrollState()
32
28
val inputTextWidth = remember { mutableStateOf(0 ) }
@@ -48,10 +44,6 @@ fun InputText(input: String) {
48
44
modifier = Modifier
49
45
.weight(1f )
50
46
.horizontalScroll(inputScrollState)
51
- .indication( // 水波纹效果怎么去除无效呢,bug?
52
- indication = null ,
53
- interactionSource = mutableInteractionSource
54
- )
55
47
.onSizeChanged { inputTextWidth.value = it.width },
56
48
text = input,
57
49
maxLines = 1 ,
@@ -66,7 +58,7 @@ fun InputText(input: String) {
66
58
modifier = Modifier
67
59
.fillMaxWidth()
68
60
.padding(end = 5 .dp)
69
- .horizontalScroll(inputScrollState )
61
+ .horizontalScroll(resultScrollState )
70
62
.onSizeChanged { resultTextWidth.value = it.width },
71
63
maxLines = 1 ,
72
64
fontSize = 30 .sp,
@@ -81,10 +73,4 @@ fun ItemText(input: String, result: String) {
81
73
Column (verticalArrangement = Arrangement .Bottom ) {
82
74
Text (modifier = Modifier .fillMaxWidth(), text = input, textAlign = TextAlign .End )
83
75
}
84
- }
85
-
86
- @Preview
87
- @Composable
88
- fun InputTextPreview () {
89
- InputText (" 12345678" )
90
76
}
0 commit comments