diff --git a/app/src/main/java/com/bobbyesp/metadator/presentation/pages/home/HomePage.kt b/app/src/main/java/com/bobbyesp/metadator/presentation/pages/home/HomePage.kt index c5cdb05..21f658f 100644 --- a/app/src/main/java/com/bobbyesp/metadator/presentation/pages/home/HomePage.kt +++ b/app/src/main/java/com/bobbyesp/metadator/presentation/pages/home/HomePage.kt @@ -62,6 +62,7 @@ import com.bobbyesp.metadator.presentation.pages.MediaStorePageViewModel import com.bobbyesp.ui.components.dropdown.AnimatedDropdownMenu import com.bobbyesp.ui.components.dropdown.DropdownItemContainer import com.bobbyesp.ui.components.pulltorefresh.rememberPullState +import com.bobbyesp.ui.components.text.AutoResizableText import com.bobbyesp.utilities.preferences.Preferences import com.bobbyesp.utilities.preferences.PreferencesKeys.DESIRED_OVERLAY import com.bobbyesp.utilities.ui.permission.PermissionNotGrantedDialog @@ -113,114 +114,116 @@ fun HomePage( val gridIsFirstItemVisible by remember { derivedStateOf { mediaStoreLazyGridState.firstVisibleItemIndex == 0 } } val listIsFirstItemVisible by remember { derivedStateOf { mediaStoreLazyColumnState.firstVisibleItemIndex == 0 } } - Scaffold(modifier = modifier.fillMaxSize(), topBar = { - CenterAlignedTopAppBar(navigationIcon = { - IconButton(onClick = { - scope.launch { - drawerState.open() + Scaffold( + modifier = modifier.fillMaxSize(), topBar = { + CenterAlignedTopAppBar(navigationIcon = { + IconButton(onClick = { + scope.launch { + drawerState.open() + } + }) { + Icon( + imageVector = Icons.Rounded.Menu, + contentDescription = stringResource(id = R.string.open_navigation) + ) } - }) { - Icon( - imageVector = Icons.Rounded.Menu, - contentDescription = stringResource(id = R.string.open_navigation) - ) - } - }, title = { - Column( - horizontalAlignment = androidx.compose.ui.Alignment.CenterHorizontally, - ) { - Text( - text = stringResource(id = R.string.app_name).uppercase(), - fontWeight = FontWeight.SemiBold, - fontFamily = FontFamily.Monospace, - style = MaterialTheme.typography.titleLarge.copy( - letterSpacing = 4.sp, - ), - ) - Text( - text = stringResource(id = R.string.app_desc).uppercase(), - fontWeight = FontWeight.Normal, - fontFamily = FontFamily.Monospace, - style = MaterialTheme.typography.bodySmall.copy( - letterSpacing = 2.sp, - ), - color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f) - ) - } - }, actions = { - IconButton(onClick = { - moreOptionsVisible = !moreOptionsVisible - }) { - Icon( - imageVector = Icons.Rounded.MoreVert, contentDescription = stringResource( - id = R.string.open_more_options + }, title = { + Column( + horizontalAlignment = androidx.compose.ui.Alignment.CenterHorizontally, + ) { + Text( + text = stringResource(id = R.string.app_name).uppercase(), + fontWeight = FontWeight.SemiBold, + fontFamily = FontFamily.Monospace, + style = MaterialTheme.typography.titleLarge.copy( + letterSpacing = 4.sp, + ), ) - ) - } - if (moreOptionsVisible) { - AnimatedDropdownMenu(expanded = moreOptionsVisible, onDismissRequest = { - moreOptionsVisible = false + AutoResizableText( + text = stringResource(id = R.string.app_desc).uppercase(), + fontWeight = FontWeight.Normal, + fontFamily = FontFamily.Monospace, + style = MaterialTheme.typography.bodySmall.copy( + letterSpacing = 2.sp, + ), + color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.7f) + ) + } + }, actions = { + IconButton(onClick = { + moreOptionsVisible = !moreOptionsVisible }) { - DropdownMenuContent(reloadMediastore = { - scope.launch { - viewModel.silentMediaStoreTracksLoad(context) { - pullState.finishRefresh(skipReloadFinished = false) - } - } - }, onLayoutChanged = { - desiredLayout = it - }) + Icon( + imageVector = Icons.Rounded.MoreVert, + contentDescription = stringResource( + id = R.string.open_more_options + ) + ) } - } - }, scrollBehavior = scrollBehavior - ) - }, floatingActionButton = { - when (desiredLayout) { - LayoutType.Grid -> { - AnimatedVisibility( - visible = !gridIsFirstItemVisible, - enter = fadeIn() + scaleIn(), - exit = fadeOut() + scaleOut() - ) { - FloatingActionButton(onClick = { - scope.launch { - mediaStoreLazyGridState.animateScrollToItem(0) - } + if (moreOptionsVisible) { + AnimatedDropdownMenu(expanded = moreOptionsVisible, onDismissRequest = { + moreOptionsVisible = false }) { - Icon( - imageVector = Icons.Rounded.KeyboardDoubleArrowUp, - contentDescription = stringResource( - id = R.string.scroll_to_top + DropdownMenuContent(reloadMediastore = { + scope.launch { + viewModel.silentMediaStoreTracksLoad(context) { + pullState.finishRefresh(skipReloadFinished = false) + } + } + }, onLayoutChanged = { + desiredLayout = it + }) + } + } + }, scrollBehavior = scrollBehavior + ) + }, floatingActionButton = { + when (desiredLayout) { + LayoutType.Grid -> { + AnimatedVisibility( + visible = !gridIsFirstItemVisible, + enter = fadeIn() + scaleIn(), + exit = fadeOut() + scaleOut() + ) { + FloatingActionButton(onClick = { + scope.launch { + mediaStoreLazyGridState.animateScrollToItem(0) + } + }) { + Icon( + imageVector = Icons.Rounded.KeyboardDoubleArrowUp, + contentDescription = stringResource( + id = R.string.scroll_to_top + ) ) - ) + } } } - } - LayoutType.List -> { - AnimatedVisibility( - visible = !listIsFirstItemVisible, - enter = fadeIn() + scaleIn(), - exit = fadeOut() + scaleOut() - ) { - FloatingActionButton(onClick = { - scope.launch { - mediaStoreLazyColumnState.animateScrollToItem(0) - } - }) { - Icon( - imageVector = Icons.Rounded.KeyboardDoubleArrowUp, - contentDescription = stringResource( - id = R.string.scroll_to_top + LayoutType.List -> { + AnimatedVisibility( + visible = !listIsFirstItemVisible, + enter = fadeIn() + scaleIn(), + exit = fadeOut() + scaleOut() + ) { + FloatingActionButton(onClick = { + scope.launch { + mediaStoreLazyColumnState.animateScrollToItem(0) + } + }) { + Icon( + imageVector = Icons.Rounded.KeyboardDoubleArrowUp, + contentDescription = stringResource( + id = R.string.scroll_to_top + ) ) - ) + } } } } - } - //for scrolling up to the top + //for scrolling up to the top - }) { paddingValues -> + }) { paddingValues -> PermissionRequestHandler(permissionState = storagePermissionState, deniedContent = { shouldShowRationale -> PermissionNotGrantedDialog( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d7a8c09..18638af 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -248,7 +248,6 @@ kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -kotlin-gradlePlugin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } androidLibrary = { id = "com.android.library", version.ref = "agp" }