fix bottommsheet layout
This commit is contained in:
@@ -52,6 +52,7 @@ dependencies {
|
|||||||
implementation(libs.androidx.ui.graphics)
|
implementation(libs.androidx.ui.graphics)
|
||||||
implementation(libs.androidx.ui.tooling.preview)
|
implementation(libs.androidx.ui.tooling.preview)
|
||||||
implementation(libs.androidx.material3)
|
implementation(libs.androidx.material3)
|
||||||
|
implementation(libs.androidx.foundation.layout.android)
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
androidTestImplementation(libs.androidx.junit)
|
androidTestImplementation(libs.androidx.junit)
|
||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|||||||
@@ -170,9 +170,6 @@ fun SearchTextFieldPrev() {
|
|||||||
fun SearchContextMenu(
|
fun SearchContextMenu(
|
||||||
onSearch: (LksRequest) -> Unit
|
onSearch: (LksRequest) -> Unit
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var name by remember { mutableStateOf("") }
|
var name by remember { mutableStateOf("") }
|
||||||
var surname by remember { mutableStateOf("") }
|
var surname by remember { mutableStateOf("") }
|
||||||
var family by remember { mutableStateOf("") }
|
var family by remember { mutableStateOf("") }
|
||||||
@@ -180,63 +177,62 @@ fun SearchContextMenu(
|
|||||||
var group by remember { mutableStateOf("") }
|
var group by remember { mutableStateOf("") }
|
||||||
var departamnet by remember { mutableStateOf("") }
|
var departamnet by remember { mutableStateOf("") }
|
||||||
|
|
||||||
ContextMenuContainer {
|
Column(
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
modifier = Modifier.padding(horizontal = 24.dp)
|
||||||
|
) {
|
||||||
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
SearchTextField(
|
||||||
|
value = family,
|
||||||
|
onValueChange = {family = it},
|
||||||
|
label = "Фамилия"
|
||||||
|
)
|
||||||
|
|
||||||
SearchTextField(
|
SearchTextField(
|
||||||
value = family,
|
value = name,
|
||||||
onValueChange = {family = it},
|
onValueChange = {name = it},
|
||||||
label = "Фамилия"
|
label = "Имя"
|
||||||
)
|
)
|
||||||
|
|
||||||
SearchTextField(
|
SearchTextField(
|
||||||
value = name,
|
value = surname,
|
||||||
onValueChange = {name = it},
|
onValueChange = {surname = it},
|
||||||
label = "Имя"
|
label = "Отчество"
|
||||||
)
|
)
|
||||||
|
|
||||||
SearchTextField(
|
Spacer(Modifier.height(1.dp))
|
||||||
value = surname,
|
HorizontalDivider(color = MaterialTheme.colorScheme.onBackground)
|
||||||
onValueChange = {surname = it},
|
|
||||||
label = "Отчество"
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(Modifier.height(1.dp))
|
SearchTextField(
|
||||||
HorizontalDivider(color = MaterialTheme.colorScheme.onBackground)
|
value = group,
|
||||||
|
onValueChange = {group = it},
|
||||||
|
label = "Учебная группа"
|
||||||
|
)
|
||||||
|
|
||||||
SearchTextField(
|
SearchTextField(
|
||||||
value = group,
|
value = departamnet,
|
||||||
onValueChange = {group = it},
|
onValueChange = { departamnet = it },
|
||||||
label = "Учебная группа"
|
label = "Подразделение"
|
||||||
)
|
)
|
||||||
|
|
||||||
SearchTextField(
|
Button(
|
||||||
value = departamnet,
|
shape = OutlinedTextFieldDefaults.shape,
|
||||||
onValueChange = { departamnet = it },
|
modifier = Modifier.fillMaxWidth(),
|
||||||
label = "Подразделение"
|
onClick = {
|
||||||
)
|
val lksRequest = LksRequest(
|
||||||
|
student = Student(
|
||||||
Button(
|
name = name.ifEmpty { null },
|
||||||
shape = OutlinedTextFieldDefaults.shape,
|
surname = family.ifEmpty { null },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
patronymic = surname.ifEmpty { null },
|
||||||
onClick = {
|
),
|
||||||
val lksRequest = LksRequest(
|
group = group.ifEmpty { null },
|
||||||
student = Student(
|
department = departamnet.ifEmpty { null }
|
||||||
name = name.ifEmpty { null },
|
)
|
||||||
surname = family.ifEmpty { null },
|
onSearch(lksRequest)
|
||||||
patronymic = surname.ifEmpty { null },
|
//bottomSheetNavigator?.hide()
|
||||||
),
|
|
||||||
group = group.ifEmpty { null },
|
|
||||||
department = departamnet.ifEmpty { null }
|
|
||||||
)
|
|
||||||
onSearch(lksRequest)
|
|
||||||
//bottomSheetNavigator?.hide()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text("Поиск")
|
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
Text("Поиск")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -314,29 +310,27 @@ fun LongPressCardContextMenu(
|
|||||||
onCopyName: (String) -> Unit,
|
onCopyName: (String) -> Unit,
|
||||||
onCopyGroup: (String) -> Unit
|
onCopyGroup: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
ContextMenuContainer {
|
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
"${lksStudent.studentFullName} ${lksStudent.group}"
|
"${lksStudent.studentFullName} ${lksStudent.group}"
|
||||||
)
|
)
|
||||||
HorizontalDivider(color = MaterialTheme.colorScheme.onBackground)
|
HorizontalDivider(color = MaterialTheme.colorScheme.onBackground)
|
||||||
ContextMenuButton(
|
ContextMenuButton(
|
||||||
icon = R.drawable.vk_ic.asPainter(),
|
icon = R.drawable.vk_ic.asPainter(),
|
||||||
label = "Переидти в VK",
|
label = "Переидти в VK",
|
||||||
onClick = onGoToVk
|
onClick = onGoToVk
|
||||||
)
|
)
|
||||||
ContextMenuButton(
|
ContextMenuButton(
|
||||||
icon = rememberVectorPainter(Icons.Outlined.AccountCircle),
|
icon = rememberVectorPainter(Icons.Outlined.AccountCircle),
|
||||||
label = "Скопировать имя пользователя",
|
label = "Скопировать имя пользователя",
|
||||||
onClick = { onCopyName.invoke(lksStudent.studentFullName ?: "") }
|
onClick = { onCopyName.invoke(lksStudent.studentFullName ?: "") }
|
||||||
)
|
)
|
||||||
ContextMenuButton(
|
ContextMenuButton(
|
||||||
icon = rememberVectorPainter(Icons.Outlined.Person),
|
icon = rememberVectorPainter(Icons.Outlined.Person),
|
||||||
label = "Скопировать группу",
|
label = "Скопировать группу",
|
||||||
onClick = { onCopyGroup.invoke(lksStudent.group ?: "") }
|
onClick = { onCopyGroup.invoke(lksStudent.group ?: "") }
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,25 @@
|
|||||||
package ru.megboyzz.lks.profile.ui.screens.sub
|
package ru.megboyzz.lks.profile.ui.screens.sub
|
||||||
|
|
||||||
|
import android.view.ViewTreeObserver
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.ime
|
||||||
|
import androidx.compose.material3.BottomSheetDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.ModalBottomSheet
|
import androidx.compose.material3.ModalBottomSheet
|
||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalView
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import ru.megboyzz.lks.profile.ui.components.SearchContextMenu
|
import ru.megboyzz.lks.profile.ui.components.SearchContextMenu
|
||||||
import ru.megboyzz.lks.profile.ui.model.SearchViewModel
|
import ru.megboyzz.lks.profile.ui.model.SearchViewModel
|
||||||
@@ -18,15 +32,41 @@ fun SearchBottomSheet(onDismiss: () -> Unit) {
|
|||||||
|
|
||||||
val viewModel by LocalMainActivity.current.viewModels<SearchViewModel>()
|
val viewModel by LocalMainActivity.current.viewModels<SearchViewModel>()
|
||||||
|
|
||||||
val sheetState = rememberModalBottomSheetState()
|
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
val view = LocalView.current
|
||||||
|
var isImeVisible by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
// Observe keyboard visibility using ViewTreeObserver
|
||||||
|
DisposableEffect(Unit) {
|
||||||
|
val listener = ViewTreeObserver.OnPreDrawListener {
|
||||||
|
// Check if the IME (keyboard) is visible
|
||||||
|
isImeVisible = ViewCompat.getRootWindowInsets(view)
|
||||||
|
?.isVisible(WindowInsetsCompat.Type.ime()) == true
|
||||||
|
true
|
||||||
|
}
|
||||||
|
view.viewTreeObserver.addOnPreDrawListener(listener)
|
||||||
|
onDispose {
|
||||||
|
view.viewTreeObserver.removeOnPreDrawListener(listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
onDismissRequest = onDismiss
|
onDismissRequest = onDismiss,
|
||||||
|
windowInsets = WindowInsets.ime,
|
||||||
|
dragHandle = { BottomSheetDefaults.DragHandle() },
|
||||||
|
modifier = Modifier.then(
|
||||||
|
if (isImeVisible)
|
||||||
|
Modifier.fillMaxHeight(1.0F) // Full height when keyboard is visible
|
||||||
|
else
|
||||||
|
Modifier.fillMaxHeight(0.73F) // Partial height when keyboard is hidden
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
SearchContextMenu { lksRequest ->
|
SearchContextMenu { lksRequest ->
|
||||||
viewModel.newSearch(lksRequest)
|
viewModel.newSearch(lksRequest)
|
||||||
|
onDismiss()
|
||||||
coroutineScope.launch { sheetState.hide() }
|
coroutineScope.launch { sheetState.hide() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ jetbrainsKotlinJvm = "2.0.0"
|
|||||||
composeNavigation = "2.8.0-alpha08"
|
composeNavigation = "2.8.0-alpha08"
|
||||||
room_version = "2.6.1"
|
room_version = "2.6.1"
|
||||||
serialization = "1.6.3"
|
serialization = "1.6.3"
|
||||||
|
foundationLayoutAndroid = "1.6.6"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room_version" }
|
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room_version" }
|
||||||
@@ -38,6 +39,7 @@ androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit
|
|||||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "composeNavigation" }
|
navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "composeNavigation" }
|
||||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization"}
|
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization"}
|
||||||
|
androidx-foundation-layout-android = { group = "androidx.compose.foundation", name = "foundation-layout-android", version.ref = "foundationLayoutAndroid" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Reference in New Issue
Block a user