package net.schueller.peertube.feature_video.presentation.video import android.util.Log import android.widget.Toast import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import androidx.paging.LoadState import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemsIndexed import coil.annotation.ExperimentalCoilApi import com.google.accompanist.swiperefresh.SwipeRefresh import com.google.accompanist.swiperefresh.rememberSwipeRefreshState import kotlinx.coroutines.flow.collectLatest import net.schueller.peertube.feature_video.domain.model.Overview import net.schueller.peertube.feature_video.domain.model.Video import net.schueller.peertube.feature_video.presentation.video.components.* import net.schueller.peertube.feature_video.presentation.video.components.appBarBottom.BottomBarComponent import net.schueller.peertube.feature_video.presentation.video.components.appBarTop.TopAppBarComponent import net.schueller.peertube.feature_video.presentation.video.components.videoPlay.VideoPlayScreen import net.schueller.peertube.feature_video.presentation.video.events.VideoPlayEvent import net.schueller.peertube.feature_video.presentation.video.player.ExoPlayerHolder import net.schueller.peertube.presentation.ui.theme.PeertubeTheme import kotlin.math.roundToInt @OptIn(ExperimentalMaterialApi::class) @ExperimentalCoilApi @Composable fun VideoListScreen( navController: NavController, exoPlayerHolder: ExoPlayerHolder, viewModel: VideoListViewModel = hiltViewModel(), videoPlayViewModel: VideoPlayViewModel = hiltViewModel(), viewExploreModel: VideoExploreViewModel = hiltViewModel() ) { val state = viewModel.state.value val lazyVideoExploreItems: LazyPagingItems = viewExploreModel.videos.collectAsLazyPagingItems() val lazyVideoItems: LazyPagingItems