Skip to content

Commit

Permalink
ui: Made app description below the "Metadator" text less transparent …
Browse files Browse the repository at this point in the history
…and auto-resizable

Signed-off-by: Gabriel Fontán <[email protected]>
  • Loading branch information
BobbyESP committed Apr 6, 2024
1 parent c2a04c7 commit 34e34ea
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 34e34ea

Please sign in to comment.