-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df636b8
commit 004f593
Showing
6 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/kotlin/dev/aaa1115910/bv/mobile/activities/HistoryActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.aaa1115910.bv.mobile.activities | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi | ||
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass | ||
import dev.aaa1115910.bv.mobile.screen.HistoryScreen | ||
import dev.aaa1115910.bv.mobile.theme.BVMobileTheme | ||
|
||
class HistoryActivity : ComponentActivity() { | ||
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class) | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
val windowSize = calculateWindowSizeClass(this) | ||
BVMobileTheme { | ||
HistoryScreen( | ||
windowSize = windowSize | ||
) | ||
} | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
app/src/main/kotlin/dev/aaa1115910/bv/mobile/screen/HistoryScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package dev.aaa1115910.bv.mobile.screen | ||
|
||
import android.app.Activity | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.items | ||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.LargeTopAppBar | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.material3.rememberTopAppBarState | ||
import androidx.compose.material3.windowsizeclass.WindowSizeClass | ||
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import dev.aaa1115910.bv.R | ||
import dev.aaa1115910.bv.mobile.activities.VideoPlayerActivity | ||
import dev.aaa1115910.bv.mobile.component.videocard.SmallVideoCard | ||
import dev.aaa1115910.bv.util.OnBottomReached | ||
import dev.aaa1115910.bv.util.fInfo | ||
import dev.aaa1115910.bv.viewmodel.user.HistoryViewModel | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import org.koin.androidx.compose.koinViewModel | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun HistoryScreen( | ||
modifier: Modifier = Modifier, | ||
windowSize: WindowSizeClass, | ||
historyViewModel: HistoryViewModel = koinViewModel() | ||
) { | ||
val context = LocalContext.current | ||
val logger = KotlinLogging.logger("HistoryScreen") | ||
val listState = rememberLazyGridState() | ||
val scrollBehavior = | ||
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState()) | ||
|
||
listState.OnBottomReached( | ||
loading = historyViewModel.updating | ||
) { | ||
logger.fInfo { "on reached rcmd page bottom" } | ||
historyViewModel.update() | ||
} | ||
|
||
Scaffold( | ||
modifier = modifier | ||
.nestedScroll(scrollBehavior.nestedScrollConnection), | ||
topBar = { | ||
LargeTopAppBar( | ||
title = { Text(text = stringResource(R.string.title_mobile_activity_history)) }, | ||
navigationIcon = { | ||
IconButton( | ||
onClick = { (context as Activity).finish() } | ||
) { | ||
Icon( | ||
imageVector = Icons.AutoMirrored.Default.ArrowBack, | ||
contentDescription = null | ||
) | ||
} | ||
}, | ||
scrollBehavior = scrollBehavior | ||
) | ||
} | ||
) { innerPadding -> | ||
LazyVerticalGrid( | ||
modifier = Modifier.padding(top = innerPadding.calculateTopPadding()), | ||
columns = GridCells.Adaptive(if (windowSize.widthSizeClass == WindowWidthSizeClass.Compact) 180.dp else 220.dp), | ||
state = listState, | ||
horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
verticalArrangement = Arrangement.spacedBy(8.dp), | ||
contentPadding = PaddingValues(8.dp) | ||
) { | ||
items(historyViewModel.histories) { history -> | ||
SmallVideoCard( | ||
data = history, | ||
onClick = { | ||
VideoPlayerActivity.actionStart( | ||
context = context, | ||
aid = history.avid | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters