Skip to content

Commit

Permalink
perf: app list page title scroll to top
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 16, 2024
1 parent 56f69a7 commit 63930d5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/src/main/kotlin/li/songe/gkd/ui/home/AppListPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.compose.viewModel
import com.blankj.utilcode.util.KeyboardUtils
import com.google.accompanist.drawablepainter.rememberDrawablePainter
Expand All @@ -69,6 +70,7 @@ import li.songe.gkd.ui.style.appItemPadding
import li.songe.gkd.ui.style.menuPadding
import li.songe.gkd.util.LocalNavController
import li.songe.gkd.util.SortTypeOption
import li.songe.gkd.util.launchTry
import li.songe.gkd.util.mapHashCode
import li.songe.gkd.util.ruleSummaryFlow
import li.songe.gkd.util.storeFlow
Expand Down Expand Up @@ -152,6 +154,14 @@ fun useAppListPage(): ScaffoldExt {
)
} else {
Text(
modifier = Modifier.clickable(
enabled = orderedAppInfos.isNotEmpty(),
onClick = throttle {
if (orderedAppInfos.isNotEmpty()) {
vm.viewModelScope.launchTry { listState.scrollToItem(0) }
}
}
),
text = appListNav.label,
)
}
Expand Down

0 comments on commit 63930d5

Please sign in to comment.