Skip to content

Commit

Permalink
feat(顶部): 分割线
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaoyaning committed Aug 10, 2022
1 parent 8edec0b commit da81738
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 11 additions & 9 deletions app/src/main/java/com/jyn/composecalculator/ui/TopResultView.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.jyn.composecalculator.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.FractionalThreshold
import androidx.compose.material.SwipeableDefaults.resistanceConfig
import androidx.compose.material.TabRowDefaults.Divider
import androidx.compose.material.rememberSwipeableState
import androidx.compose.material.swipeable
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -88,14 +87,17 @@ fun TextBox(process: Float) {
) {
LazyColumn(
modifier = Modifier
.weight(1f)
.background(Color.Gray),
.weight(1f),
reverseLayout = true,
userScrollEnabled = false
userScrollEnabled = false,
) {
items(viewModel.results) {
Spacer(modifier = Modifier.height(5.dp))
ItemText(input = it.input, result = it.result)
itemsIndexed(viewModel.results) { index, item ->
ItemText(input = item.input, result = item.result)
if (index < viewModel.results.size - 1) {
Spacer(modifier = Modifier.height(5.dp))
Divider()
Spacer(modifier = Modifier.height(5.dp))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ fun ItemText(input: String, result: String) {
Text(
modifier = Modifier.fillMaxWidth(),
text = input,
fontSize = 20.sp,
fontSize = 23.sp,
maxLines = 1,
textAlign = TextAlign.End,
style = TextStyle(
platformStyle = PlatformTextStyle(
Expand All @@ -93,7 +94,8 @@ fun ItemText(input: String, result: String) {
Text(
modifier = Modifier.fillMaxWidth(),
text = result,
fontSize = 28.sp,
fontSize = 33.sp,
maxLines = 1,
textAlign = TextAlign.End,
style = TextStyle(
platformStyle = PlatformTextStyle(
Expand Down

0 comments on commit da81738

Please sign in to comment.