Skip to content

Commit

Permalink
feat: 刷新插件首页时默认焦点为第一行第一个媒体卡片
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Dec 17, 2024
1 parent f1bc747 commit 73fe3dc
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.tv.material3.OutlinedIconButton
import com.muedsa.compose.tv.model.ContentModel
import com.muedsa.compose.tv.theme.CommonRowCardPadding
import com.muedsa.compose.tv.theme.ScreenPaddingLeft
import com.muedsa.compose.tv.useLocalFocusTransferredOnLaunch
import com.muedsa.compose.tv.useLocalLastFocusedItemPerDestination
import com.muedsa.compose.tv.useLocalNavHostController
import com.muedsa.compose.tv.widget.ContentBlock
Expand All @@ -35,6 +36,7 @@ import com.muedsa.tvbox.api.data.MediaCardRow
import com.muedsa.tvbox.plugin.PluginInfo
import com.muedsa.tvbox.screens.NavigationItems
import com.muedsa.tvbox.screens.SPECIAL_DESTINATION_MEDIA_DETAIL
import com.muedsa.tvbox.screens.SPECIAL_DESTINATION_PLUGIN_HOME
import com.muedsa.tvbox.screens.detail.INIT_FOCUSED_ITEM_KEY_MEDIA_DETAIL
import com.muedsa.tvbox.screens.nav
import com.muedsa.tvbox.screens.plugin.useLocalHomeScreenBackgroundState
Expand All @@ -52,6 +54,7 @@ fun MediaCardRows(
val backgroundState = useLocalHomeScreenBackgroundState()
val navController = useLocalNavHostController()
val lastFocusedItemPerDestination = useLocalLastFocusedItemPerDestination()
val focusTransferredState = useLocalFocusTransferredOnLaunch()
val titleHeight= (MaterialTheme.typography.titleLarge.fontSize.value * configuration.fontScale + 0.5f).dp
val labelHeight= (MaterialTheme.typography.labelLarge.fontSize.value * configuration.fontScale + 0.5f).dp
var firstRow = remember { rows.first() }
Expand Down Expand Up @@ -145,7 +148,12 @@ fun MediaCardRows(
bottom = CommonRowCardPadding
)
) {
OutlinedIconButton(onClick = { onRefresh() }) {
OutlinedIconButton(onClick = {
focusTransferredState.value = false
lastFocusedItemPerDestination[SPECIAL_DESTINATION_PLUGIN_HOME] =
"$HOME_FIRST_ROW_FOCUS_ON_MOUNT_KEY, col 0"
onRefresh()
}) {
Icon(imageVector = Icons.Outlined.Refresh, contentDescription = "Refresh")
}
}
Expand Down

0 comments on commit 73fe3dc

Please sign in to comment.