NavigationImage and padding
This commit is contained in:
@@ -20,12 +20,12 @@ android {
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
getByName("debug") {
|
||||
keyAlias = "alias"
|
||||
keyPassword = "alpha2000"
|
||||
storeFile = file("/home/kouros/work/keystore/keystoreDebug")
|
||||
storePassword = "alpha2000"
|
||||
}
|
||||
// getByName("debug") {
|
||||
// keyAlias = "alias"
|
||||
// keyPassword = "alpha2000"
|
||||
// storeFile = file("/home/kouros/work/keystore/keystoreRelease")
|
||||
// storePassword = "alpha2000"
|
||||
// }
|
||||
create("release") {
|
||||
keyAlias = "release"
|
||||
keyPassword = "zeta67#g"
|
||||
|
||||
@@ -256,6 +256,7 @@ class MainActivity : ComponentActivity() {
|
||||
fun Map() {
|
||||
val step: StepData? by instruction.observeAsState()
|
||||
Column {
|
||||
//SimpleSearchBar()
|
||||
if (step != null) {
|
||||
NavigationInfo(step)
|
||||
}
|
||||
|
||||
79
app/src/main/java/com/kouros/navigation/SearchBar.kt
Normal file
79
app/src/main/java/com/kouros/navigation/SearchBar.kt
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.kouros.navigation
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.input.TextFieldState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.SearchBar
|
||||
import androidx.compose.material3.SearchBarDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.isTraversalGroup
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.traversalIndex
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SimpleSearchBar(
|
||||
textFieldState: TextFieldState,
|
||||
onSearch: (String) -> Unit,
|
||||
searchResults: List<String>,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
// Controls expansion state of the search bar
|
||||
var expanded by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
Box(
|
||||
modifier
|
||||
.fillMaxSize()
|
||||
.semantics { isTraversalGroup = true }
|
||||
) {
|
||||
SearchBar(
|
||||
modifier = Modifier
|
||||
.align(Alignment.TopCenter)
|
||||
.semantics { traversalIndex = 0f },
|
||||
inputField = {
|
||||
SearchBarDefaults.InputField(
|
||||
query = textFieldState.text.toString(),
|
||||
onQueryChange = { textFieldState.edit { replace(0, length, it) } },
|
||||
onSearch = {
|
||||
onSearch(textFieldState.text.toString())
|
||||
expanded = false
|
||||
},
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = it },
|
||||
placeholder = { Text("Search") }
|
||||
)
|
||||
},
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = it },
|
||||
) {
|
||||
// Display search results in a scrollable column
|
||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
searchResults.forEach { result ->
|
||||
ListItem(
|
||||
headlineContent = { Text(result) },
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
textFieldState.edit { replace(0, length, result) }
|
||||
expanded = false
|
||||
}
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user