Skip to content

Commit 80f335a

Browse files
committed
refactor(ui): revert "article item line number adaptive"
1 parent e62c0f6 commit 80f335a

File tree

1 file changed

+6
-51
lines changed

1 file changed

+6
-51
lines changed

app/src/main/java/me/ash/reader/ui/page/home/flow/ArticleItem.kt

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,20 @@ package me.ash.reader.ui.page.home.flow
22

33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.clickable
5-
import androidx.compose.foundation.layout.Arrangement
6-
import androidx.compose.foundation.layout.Box
7-
import androidx.compose.foundation.layout.Column
8-
import androidx.compose.foundation.layout.Row
9-
import androidx.compose.foundation.layout.Spacer
10-
import androidx.compose.foundation.layout.fillMaxSize
11-
import androidx.compose.foundation.layout.fillMaxWidth
12-
import androidx.compose.foundation.layout.padding
13-
import androidx.compose.foundation.layout.size
14-
import androidx.compose.foundation.layout.width
15-
import androidx.compose.material.DismissDirection
16-
import androidx.compose.material.DismissValue
17-
import androidx.compose.material.ExperimentalMaterialApi
18-
import androidx.compose.material.SwipeToDismiss
5+
import androidx.compose.foundation.layout.*
6+
import androidx.compose.material.*
197
import androidx.compose.material.icons.Icons
208
import androidx.compose.material.icons.rounded.CheckCircleOutline
219
import androidx.compose.material.icons.rounded.Star
22-
import androidx.compose.material.rememberDismissState
2310
import androidx.compose.material3.Icon
2411
import androidx.compose.material3.MaterialTheme
2512
import androidx.compose.material3.Text
26-
import androidx.compose.runtime.Composable
27-
import androidx.compose.runtime.LaunchedEffect
28-
import androidx.compose.runtime.getValue
29-
import androidx.compose.runtime.mutableStateOf
30-
import androidx.compose.runtime.remember
31-
import androidx.compose.runtime.setValue
13+
import androidx.compose.runtime.*
3214
import androidx.compose.ui.Alignment
3315
import androidx.compose.ui.Modifier
3416
import androidx.compose.ui.draw.alpha
3517
import androidx.compose.ui.draw.clip
3618
import androidx.compose.ui.layout.ContentScale
37-
import androidx.compose.ui.layout.onGloballyPositioned
38-
import androidx.compose.ui.platform.LocalDensity
3919
import androidx.compose.ui.res.stringResource
4020
import androidx.compose.ui.text.style.TextAlign
4121
import androidx.compose.ui.text.style.TextOverflow
@@ -44,13 +24,7 @@ import coil.size.Precision
4424
import coil.size.Scale
4525
import me.ash.reader.R
4626
import me.ash.reader.domain.model.article.ArticleWithFeed
47-
import me.ash.reader.infrastructure.preference.FlowArticleReadIndicatorPreference
48-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListDesc
49-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListFeedIcon
50-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListFeedName
51-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListImage
52-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListReadIndicator
53-
import me.ash.reader.infrastructure.preference.LocalFlowArticleListTime
27+
import me.ash.reader.infrastructure.preference.*
5428
import me.ash.reader.ui.component.FeedIcon
5529
import me.ash.reader.ui.component.base.RYAsyncImage
5630
import me.ash.reader.ui.component.base.SIZE_1000
@@ -69,18 +43,6 @@ fun ArticleItem(
6943
val articleListDesc = LocalFlowArticleListDesc.current
7044
val articleListDate = LocalFlowArticleListTime.current
7145
val articleListReadIndicator = LocalFlowArticleListReadIndicator.current
72-
var titleHeight by remember { mutableStateOf(0) }
73-
val density = LocalDensity.current
74-
var descriptionLines by remember { mutableStateOf(1) }
75-
LaunchedEffect(titleHeight) {
76-
with(density) {
77-
descriptionLines = if (titleHeight > 0 && titleHeight + 16.dp.roundToPx() / 16 > 32) {
78-
1
79-
} else {
80-
2
81-
}
82-
}
83-
}
8446

8547
Column(
8648
modifier = Modifier
@@ -174,15 +136,8 @@ fun ArticleItem(
174136
text = articleWithFeed.article.title,
175137
color = MaterialTheme.colorScheme.onSurface,
176138
style = MaterialTheme.typography.titleMedium,
177-
// maxLines = if (articleListDesc.value) 2 else 4,
139+
maxLines = if (articleListDesc.value) 2 else 4,
178140
overflow = TextOverflow.Ellipsis,
179-
modifier = Modifier.onGloballyPositioned {coordinates ->
180-
if (titleHeight == 0) {
181-
titleHeight = with(density) {
182-
coordinates.size.height.toDp().value.toInt()
183-
}
184-
}
185-
}
186141
)
187142

188143
// Description
@@ -192,7 +147,7 @@ fun ArticleItem(
192147
text = articleWithFeed.article.shortDescription,
193148
color = MaterialTheme.colorScheme.onSurfaceVariant,
194149
style = MaterialTheme.typography.bodySmall,
195-
maxLines = descriptionLines,
150+
maxLines = 2,
196151
overflow = TextOverflow.Ellipsis,
197152
)
198153
}

0 commit comments

Comments
 (0)