Skip to content

Commit

Permalink
Merge pull request #57 from swingmx/artist-info
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericgacoki authored Dec 6, 2024
2 parents 57e7475 + 84c4cd5 commit 2ec4d52
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -665,6 +667,7 @@ fun AlbumWithInfoScreen(
val baseUrl by mediaControllerViewModel.baseUrl.collectAsState()

var showOnRefreshIndicator by remember { mutableStateOf(false) }
val refreshState = rememberPullToRefreshState()

LaunchedEffect(
key1 = albumWithInfoState.albumHash,
Expand All @@ -681,13 +684,23 @@ fun AlbumWithInfoScreen(
PullToRefreshBox(
modifier = Modifier.fillMaxSize(),
isRefreshing = showOnRefreshIndicator,
state = refreshState,
onRefresh = {
showOnRefreshIndicator = true

albumWithInfoViewModel.onAlbumWithInfoUiEvent(
event = AlbumWithInfoUiEvent.OnRefreshAlbumInfo
)
},
indicator = {
PullToRefreshDefaults.Indicator(
modifier = Modifier
.padding(top = 76.dp)
.align(Alignment.TopCenter),
isRefreshing = showOnRefreshIndicator,
state = refreshState
)
}
) {
when (albumWithInfoState.infoResource) {
is Resource.Loading -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
Expand Down Expand Up @@ -101,8 +103,7 @@ private fun AllAlbums(
}

var isGridCountMenuExpanded by remember { mutableStateOf(false) }

Scaffold { pv ->
Scaffold { pv ->
Scaffold(
modifier = Modifier.padding(pv),
topBar = {
Expand Down Expand Up @@ -319,6 +320,7 @@ fun AllAlbumScreen(
val baseUrl by allAlbumsViewModel.baseUrl.collectAsState()

var showOnRefreshIndicator by remember { mutableStateOf(false) }
val refreshState = rememberPullToRefreshState()

val errorState = when {
pagingAlbums.loadState.append is LoadState.Error -> pagingAlbums.loadState.append as LoadState.Error
Expand All @@ -338,11 +340,21 @@ fun AllAlbumScreen(
SwingMusicTheme(navBarColor = MaterialTheme.colorScheme.inverseOnSurface) {
PullToRefreshBox(
isRefreshing = showOnRefreshIndicator,
state = refreshState,
onRefresh = {
showOnRefreshIndicator = true

allAlbumsViewModel.onAlbumsUiEvent(AlbumsUiEvent.OnPullToRefresh)
},
indicator = {
PullToRefreshDefaults.Indicator(
modifier = Modifier
.padding(top = 76.dp)
.align(Alignment.TopCenter),
isRefreshing = showOnRefreshIndicator,
state = refreshState
)
}
) {
AllAlbums(
pagingAlbums = pagingAlbums,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -86,7 +88,6 @@ import com.android.swingmusic.uicomponent.presentation.theme.SwingMusicTheme_Pre
import com.android.swingmusic.uicomponent.presentation.util.Screen
import com.android.swingmusic.uicomponent.presentation.util.formattedAlbumDuration
import com.ramcosta.composedestinations.annotation.Destination
import timber.log.Timber

@OptIn(ExperimentalMaterial3Api::class)
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
Expand Down Expand Up @@ -824,6 +825,7 @@ fun ArtistInfoScreen(
artistInfoState.value.similarArtistsResource.data else emptyList()

var showOnRefreshIndicator by remember { mutableStateOf(false) }
val refreshState = rememberPullToRefreshState()

LaunchedEffect(key1 = Unit) {
if (artistInfoState.value.requiresReload || loadNewArtist) {
Expand All @@ -839,6 +841,7 @@ fun ArtistInfoScreen(
PullToRefreshBox(
modifier = Modifier.fillMaxSize(),
isRefreshing = showOnRefreshIndicator,
state = refreshState,
onRefresh = {
showOnRefreshIndicator = true

Expand All @@ -848,10 +851,16 @@ fun ArtistInfoScreen(
?: artistHash
)
)

Timber.e("Artist Hash VM: ${artistInfoState.value.infoResource.data?.artist?.artistHash}")
Timber.e("Artist Hash Nav: $artistHash")
},
indicator = {
PullToRefreshDefaults.Indicator(
modifier = Modifier
.padding(top = 76.dp)
.align(Alignment.TopCenter),
isRefreshing = showOnRefreshIndicator,
state = refreshState
)
}
) {
when (val res = artistInfoState.value.infoResource) {
is Resource.Loading -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -317,7 +319,9 @@ fun ArtistsScreen(
val sortByPairs by remember { derivedStateOf { artistsViewModel.sortArtistsByEntries.toList() } }

val baseUrl by remember { artistsViewModel.baseUrl() }

var showOnRefreshIndicator by remember { mutableStateOf(false) }
val refreshState = rememberPullToRefreshState()

val errorState = when {
pagingArtists.loadState.append is LoadState.Error -> pagingArtists.loadState.append as LoadState.Error
Expand All @@ -337,11 +341,21 @@ fun ArtistsScreen(
SwingMusicTheme(navBarColor = MaterialTheme.colorScheme.inverseOnSurface) {
PullToRefreshBox(
isRefreshing = showOnRefreshIndicator,
state = refreshState,
onRefresh = {
showOnRefreshIndicator = true

artistsViewModel.onArtistUiEvent(ArtistUiEvent.OnPullToRefresh)
},
indicator = {
PullToRefreshDefaults.Indicator(
modifier = Modifier
.padding(top = 76.dp)
.align(Alignment.TopCenter),
isRefreshing = showOnRefreshIndicator,
state = refreshState
)
}
) {
Artists(
pagingArtists = pagingArtists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.PullToRefreshDefaults
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -90,6 +92,7 @@ private fun FoldersAndTracks(
var clickedTrack: Track? by remember { mutableStateOf(null) }

var showOnRefreshIndicator by remember { mutableStateOf(false) }
val refreshState = rememberPullToRefreshState()

val lazyColumnState = rememberLazyListState()
val pathsLazyRowState = rememberLazyListState()
Expand All @@ -99,12 +102,22 @@ private fun FoldersAndTracks(
PullToRefreshBox(
modifier = Modifier.fillMaxSize(),
isRefreshing = showOnRefreshIndicator,
state = refreshState,
onRefresh = {
showOnRefreshIndicator = true

val event = FolderUiEvent.OnClickFolder(currentFolder)
onPullToRefresh(event)
},
indicator = {
PullToRefreshDefaults.Indicator(
modifier = Modifier
.padding(top = 76.dp)
.align(Alignment.TopCenter),
isRefreshing = showOnRefreshIndicator,
state = refreshState
)
}
) {
Scaffold(
modifier = Modifier.padding(it),
Expand Down

0 comments on commit 2ec4d52

Please sign in to comment.