refactor: replace Scaffold with internal component

This commit is contained in:
andrekir 2025-01-06 19:17:55 -03:00 committed by Andre K
parent 1c863f35f6
commit 7794c08190
7 changed files with 72 additions and 135 deletions

View file

@ -40,7 +40,6 @@ import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.material.TextField
@ -80,7 +79,6 @@ import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
@ -94,6 +92,7 @@ import com.geeksville.mesh.database.entity.QuickChatAction
import com.geeksville.mesh.model.Node
import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.model.getChannel
import com.geeksville.mesh.ui.components.BaseScaffold
import com.geeksville.mesh.ui.components.NodeKeyStatusIcon
import com.geeksville.mesh.ui.components.NodeMenuAction
import com.geeksville.mesh.ui.message.components.MessageList
@ -139,7 +138,6 @@ class MessagesFragment : Fragment(), Logging {
return ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setBackgroundColor(ContextCompat.getColor(context, R.color.colorAdvancedBackground))
setContent {
AppTheme {
MessageScreen(
@ -213,7 +211,7 @@ internal fun MessageScreen(
)
}
Scaffold(
BaseScaffold(
topBar = {
if (inSelectionMode) {
ActionModeTopBar(selectedIds.value) { action ->
@ -269,13 +267,12 @@ internal fun MessageScreen(
TextInput(isConnected, messageInput) { viewModel.sendMessage(it, contactKey) }
}
}
) { innerPadding ->
) {
if (messages.isNotEmpty()) {
MessageList(
messages = messages,
selectedIds = selectedIds,
onUnreadChanged = { viewModel.clearUnreadCount(contactKey, it) },
contentPadding = innerPadding,
onSendReaction = { emoji, id -> viewModel.sendReaction(emoji, id, contactKey) },
) { action ->
when (action) {

View file

@ -18,7 +18,6 @@
package com.geeksville.mesh.ui.message.components
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
@ -54,7 +53,6 @@ internal fun MessageList(
messages: List<Message>,
selectedIds: MutableState<Set<Long>>,
onUnreadChanged: (Long) -> Unit,
contentPadding: PaddingValues,
onSendReaction: (String, Int) -> Unit,
onNodeMenuAction: (NodeMenuAction) -> Unit = {}
) {
@ -89,7 +87,6 @@ internal fun MessageList(
modifier = Modifier.fillMaxSize(),
state = listState,
reverseLayout = true,
contentPadding = contentPadding
) {
items(messages, key = { it.uuid }) { msg ->
val fromLocal = msg.node.user.id == DataPacket.ID_LOCAL