mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-12-01 15:40:32 +01:00
The browser shows what you type in its search bar and in fullscreen, every row of the car's Settings lines up, and the live weather wallpaper waits for debug builds until it's finished
This commit is contained in:
1 parent
00e92274b0
commit
920ad3a720
4 files changed
+27
-14
No files matched your search
@@ -66,7 +66,7 @@ private val REMOVE_ROOM = 10.dp
|
|||||||
* else, or Done, puts them away. Adding happens from the browser's star, or on the phone.
|
* else, or Done, puts them away. Adding happens from the browser's star, or on the phone.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
internal fun BrowserStartPage(onOpen: (String) -> Unit, onSearch: () -> Unit, onAdd: () -> Unit) {
|
internal fun BrowserStartPage(onOpen: (String) -> Unit, onSearch: () -> Unit, onAdd: () -> Unit, typing: String? = null) {
|
||||||
val bookmarks by BrowserSettings.bookmarks.collectAsState()
|
val bookmarks by BrowserSettings.bookmarks.collectAsState()
|
||||||
var editing by remember { mutableStateOf(false) }
|
var editing by remember { mutableStateOf(false) }
|
||||||
if (bookmarks.isEmpty()) editing = false
|
if (bookmarks.isEmpty()) editing = false
|
||||||
@@ -78,7 +78,7 @@ internal fun BrowserStartPage(onOpen: (String) -> Unit, onSearch: () -> Unit, on
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(20.dp),
|
verticalArrangement = Arrangement.spacedBy(20.dp),
|
||||||
) {
|
) {
|
||||||
SearchBar(onSearch)
|
SearchBar(onSearch, typing)
|
||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
columns = GridCells.Adaptive(TILE_WIDTH),
|
columns = GridCells.Adaptive(TILE_WIDTH),
|
||||||
contentPadding = PaddingValues(bottom = 16.dp),
|
contentPadding = PaddingValues(bottom = 16.dp),
|
||||||
@@ -112,15 +112,22 @@ internal fun BrowserStartPage(onOpen: (String) -> Unit, onSearch: () -> Unit, on
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Looks like a text field, but opens the car keyboard: the same as the header's Search. */
|
/**
|
||||||
|
* Looks like a text field, but opens the car keyboard: the same as the header's Search. While the
|
||||||
|
* keyboard is up, [typing] is what's been typed so far, shown here with a cursor.
|
||||||
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun SearchBar(onSearch: () -> Unit) {
|
private fun SearchBar(onSearch: () -> Unit, typing: String? = null) {
|
||||||
val colors = gsColors(GsTone.Neutral)
|
val colors = gsColors(GsTone.Neutral)
|
||||||
GsIconBox(onSearch, Modifier.widthIn(max = SEARCH_MAX_WIDTH).fillMaxWidth().height(56.dp), colors, shape = CircleShape) {
|
GsIconBox(onSearch, Modifier.widthIn(max = SEARCH_MAX_WIDTH).fillMaxWidth().height(56.dp), colors, shape = CircleShape) {
|
||||||
Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
Icon(Icons.Filled.Search, null, Modifier.size(24.dp))
|
Icon(Icons.Filled.Search, null, Modifier.size(24.dp))
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.web_search),
|
when {
|
||||||
|
typing.isNullOrEmpty() -> stringResource(R.string.web_search)
|
||||||
|
typing.length > 60 -> "…" + typing.takeLast(59) + "|"
|
||||||
|
else -> "$typing|"
|
||||||
|
},
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
|||||||
@@ -310,8 +310,10 @@ private fun Note(text: String) {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun <T> ChoiceRow(title: String, options: List<Pair<T, String>>, selected: T, onSelect: (T) -> Unit) {
|
private fun <T> ChoiceRow(title: String, options: List<Pair<T, String>>, selected: T, onSelect: (T) -> Unit) {
|
||||||
// On a wide screen the name sits beside its choices, which halves how far there is to scroll.
|
// On a wide screen the name sits beside its choices, which halves how far there is to scroll.
|
||||||
|
// Every row the same way, five choices too: Size alone dropped below its name, out of line
|
||||||
|
// with the rows around it.
|
||||||
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxWidth()) {
|
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxWidth()) {
|
||||||
if (maxWidth >= 720.dp && options.size <= 4) {
|
if (maxWidth >= 720.dp) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
Text(title, style = MaterialTheme.typography.titleMedium, modifier = Modifier.weight(0.3f))
|
Text(title, style = MaterialTheme.typography.titleMedium, modifier = Modifier.weight(0.3f))
|
||||||
Box(Modifier.weight(0.7f)) { ChoiceButtons(options, selected, onSelect) }
|
Box(Modifier.weight(0.7f)) { ChoiceButtons(options, selected, onSelect) }
|
||||||
|
|||||||
@@ -146,11 +146,11 @@ fun WebApp(content: String) {
|
|||||||
|
|
||||||
Column(Modifier.fillMaxSize()) {
|
Column(Modifier.fillMaxSize()) {
|
||||||
// Back steps through the page's history first (the interceptor above), then leaves.
|
// Back steps through the page's history first (the interceptor above), then leaves.
|
||||||
if (!fullscreen) {
|
// While the car keyboard is up for an address or a search, the header is where the
|
||||||
// While the car keyboard is up for an address or a search, the header is where the
|
// typing shows, fullscreen or not: the keyboard draws no field of its own, so the words
|
||||||
// typing shows: the keyboard draws no field of its own, so the words were invisible
|
// were invisible until Enter loaded the search.
|
||||||
// until Enter loaded the search.
|
val typing = address ?: newBookmark
|
||||||
val typing = address ?: newBookmark
|
if (!fullscreen || typing != null) {
|
||||||
val heading = when {
|
val heading = when {
|
||||||
// The end of what's typed, where the next letter goes, not the start.
|
// The end of what's typed, where the next letter goes, not the start.
|
||||||
typing != null -> typing.ifEmpty { stringResource(R.string.web_search) }
|
typing != null -> typing.ifEmpty { stringResource(R.string.web_search) }
|
||||||
@@ -261,6 +261,7 @@ fun WebApp(content: String) {
|
|||||||
address = ""
|
address = ""
|
||||||
},
|
},
|
||||||
onAdd = { newBookmark = "https://" },
|
onAdd = { newBookmark = "https://" },
|
||||||
|
typing = address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -814,10 +814,13 @@ private fun WallpaperRows() {
|
|||||||
listOf(
|
listOf(
|
||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.OFF to stringResource(R.string.choice_wallpaper_off),
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.OFF to stringResource(R.string.choice_wallpaper_off),
|
||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.PHOTO to stringResource(R.string.choice_wallpaper_photo),
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.PHOTO to stringResource(R.string.choice_wallpaper_photo),
|
||||||
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.WEATHER to stringResource(R.string.choice_wallpaper_weather),
|
|
||||||
) + if (app.seb3thehacker.gearslip.BuildConfig.DEBUG) {
|
) + if (app.seb3thehacker.gearslip.BuildConfig.DEBUG) {
|
||||||
// Not translated: debug builds only, for checking every scene.
|
// The live weather isn't finished, so only debug builds offer it for now. The demo
|
||||||
listOf(app.seb3thehacker.gearslip.car.CarWallpaper.Mode.DEMO to "Weather demo")
|
// isn't translated: it's for checking every scene.
|
||||||
|
listOf(
|
||||||
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.WEATHER to stringResource(R.string.choice_wallpaper_weather),
|
||||||
|
app.seb3thehacker.gearslip.car.CarWallpaper.Mode.DEMO to "Weather demo",
|
||||||
|
)
|
||||||
} else emptyList(),
|
} else emptyList(),
|
||||||
mode,
|
mode,
|
||||||
{ app.seb3thehacker.gearslip.car.CarWallpaper.setMode(context, it) },
|
{ app.seb3thehacker.gearslip.car.CarWallpaper.setMode(context, it) },
|
||||||
|
|||||||
Reference in new issue
Block a user