Skip to content

Commit

Permalink
feat: small improvements
Browse files Browse the repository at this point in the history
- Updated AGP version
- Added corner radius setting to SearchFab
- Improved AppListScreen layout and tile appearance
- Added corner radius display in EditBottomSheet
  • Loading branch information
Tgo1014 committed Jun 16, 2024
1 parent ce55124 commit 63249bc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/tgo1014/gridlauncher/app/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package tgo1014.gridlauncher.app

object Constants {
const val gridColumns = 6
const val defaultTileRadius = 8
const val defaultRadius = 8
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package tgo1014.gridlauncher.domain.models

import kotlinx.serialization.Serializable
import tgo1014.gridlauncher.app.Constants.defaultTileRadius
import tgo1014.gridlauncher.app.Constants.defaultRadius

@Serializable
data class TileSettings(
val isTileFlipEnabled: Boolean = true,
val cornerRadius: Int = defaultTileRadius,
val cornerRadius: Int = defaultRadius,
val isAppLabelsHidden: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ private fun EditSheetContent(
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Text("Corners:", modifier = Modifier.align(Alignment.CenterVertically).weight(1f))
Text("Corners:", modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f))
Text(text = tileSettings.cornerRadius.toString())
Slider(
value = tileSettings.cornerRadius.toFloat(),
onValueChange = { onSettingsUpdated(tileSettings.copy(cornerRadius = it.toInt())) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ fun GridTile(
val app = item.app
Box(
modifier = Modifier
.combinedClickable(
onClick = { onItemClicked(item) },
onLongClick = { onItemLongClicked(item) }
)
.modifyIf(!isEditMode && tileSettings.isTileFlipEnabled) {
flipRandomly()
}
.tileEditMode(isEditMode)
.background(MaterialTheme.colorScheme.primaryContainer, shape)
.clip(shape)
.combinedClickable(
onClick = { onItemClicked(item) },
onLongClick = { onItemLongClicked(item) }
)
.then(modifier)
) {
AsyncImage(
Expand Down Expand Up @@ -88,7 +88,7 @@ fun GridTile(
AsyncImage(
model = item.app.icon.iconFile,
contentDescription = null,
modifier = iconModifier
modifier = iconModifier,
)
}
if (item.width > 1 && item.height > 1 && !tileSettings.isAppLabelsHidden) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import tgo1014.gridlauncher.R
import tgo1014.gridlauncher.app.Constants.defaultRadius
import tgo1014.gridlauncher.ui.theme.GridLauncherTheme

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -65,14 +66,15 @@ fun SearchFab(
modifier: Modifier = Modifier,
searchText: String,
buttonState: SearchFabState,
cornerRadius: Int = defaultRadius,
onCloseClicked: () -> Unit = {},
onSearchTextChanged: (String) -> Unit = {},
onButtonClicked: () -> Unit = {},
) = BoxWithConstraints(modifier) {
val keyboardController = LocalSoftwareKeyboardController.current
val fabSize = 56.dp
val itemsSize = 32.dp
val shape = RoundedCornerShape(25)
val shape = RoundedCornerShape(cornerRadius)
val interactionSource = remember { MutableInteractionSource() }
val transition = updateTransition(buttonState, label = "Width")
val height by transition.animateDp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -95,17 +96,18 @@ fun AppListScreen(
},
label = "Inclination"
)
val isOnTop = lazyListState.canScrollBackward
val isOnTop by remember { derivedStateOf { lazyListState.firstVisibleItemIndex == 0 } }
val mainColor = MaterialTheme.colorScheme.primary
val focusManager = LocalFocusManager.current
val searchInputTextPadding = 75.dp
val alignment = if (state.filterString.isEmpty()) Alignment.Top else Alignment.Bottom
LazyColumn(
state = lazyListState,
contentPadding = PaddingValues(8.dp)
+ WindowInsets.systemBars.asPaddingValues()
+ WindowInsets.ime.asPaddingValues()
+ PaddingValues(bottom = searchInputTextPadding),
verticalArrangement = Arrangement.spacedBy(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp, alignment),
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
Expand Down Expand Up @@ -200,7 +202,7 @@ fun AppListScreen(
val iconModifier = Modifier
.graphicsLayer { rotationX = angle }
.size(50.dp)
.border(2.dp, mainColor, shape)
.border(1.dp, mainColor, shape)
.clip(shape)
/*val filter = ColorFilter.lighting(
multiply = mainColor,
Expand Down Expand Up @@ -234,6 +236,7 @@ fun AppListScreen(
SearchFab(
buttonState = fabState,
searchText = state.filterString,
cornerRadius = state.tileSettings.cornerRadius,
onSearchTextChanged = {
scope.launch {
lazyListState.animateScrollToItem(0)
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
accompanist-systemuicontroller = "0.35.1-alpha"
activity-compose = "1.9.0"
# @pin so this is not updated to alpha versions
agp = "8.4.2"
agp = "8.5.0"
androidx-test-ext-junit = "1.2.0-rc01"
app-turbine = "1.1.0"
coil-compose = "2.6.0"
Expand All @@ -17,7 +17,7 @@ kotlin = "2.0.0"
kotlinx-coroutines-test = "1.9.0-RC"
kotlinx-serialization-json = "1.7.0"
lazytable = "1.8.0"
lifecycle-runtime-ktx = "2.8.1"
lifecycle-runtime-ktx = "2.8.2"
reorderable = "0.9.6"

[libraries]
Expand Down

0 comments on commit 63249bc

Please sign in to comment.