mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(navigation): Simplify adaptive back nav and state (#3860)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
1d17f4074d
commit
ebab2ee9ad
5 changed files with 30 additions and 80 deletions
|
|
@ -85,7 +85,6 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.platform.LocalClipboard
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
|
@ -144,7 +143,6 @@ private const val ROUNDED_CORNER_PERCENT = 100
|
|||
* @param contactKey A unique key identifying the contact or channel.
|
||||
* @param message An optional message to pre-fill in the input field.
|
||||
* @param viewModel The [MessageViewModel] instance for handling business logic and state.
|
||||
* @param navigateToMessages Callback to navigate to a different message thread.
|
||||
* @param navigateToNodeDetails Callback to navigate to a node's detail screen.
|
||||
* @param onNavigateBack Callback to navigate back from this screen.
|
||||
*/
|
||||
|
|
@ -154,7 +152,6 @@ fun MessageScreen(
|
|||
contactKey: String,
|
||||
message: String,
|
||||
viewModel: MessageViewModel = hiltViewModel(),
|
||||
navigateToMessages: (String) -> Unit,
|
||||
navigateToNodeDetails: (Int) -> Unit,
|
||||
navigateToQuickChatOptions: () -> Unit,
|
||||
onNavigateBack: () -> Unit,
|
||||
|
|
@ -270,7 +267,6 @@ fun MessageScreen(
|
|||
is MessageScreenEvent.NodeDetails -> navigateToNodeDetails(event.node.num)
|
||||
|
||||
is MessageScreenEvent.SetTitle -> viewModel.setTitle(event.title)
|
||||
is MessageScreenEvent.NavigateToMessages -> navigateToMessages(event.contactKey)
|
||||
is MessageScreenEvent.NavigateToNodeDetails -> navigateToNodeDetails(event.nodeNum)
|
||||
MessageScreenEvent.NavigateBack -> onNavigateBack()
|
||||
is MessageScreenEvent.CopyToClipboard -> {
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ internal sealed interface MessageScreenEvent {
|
|||
/** Set the title of the screen (typically the contact or channel name). */
|
||||
data class SetTitle(val title: String) : MessageScreenEvent
|
||||
|
||||
/** Navigate to a different message thread. */
|
||||
data class NavigateToMessages(val contactKey: String) : MessageScreenEvent
|
||||
|
||||
/** Navigate to the details screen for a specific node. */
|
||||
data class NavigateToNodeDetails(val nodeNum: Int) : MessageScreenEvent
|
||||
|
||||
|
|
|
|||
|
|
@ -43,19 +43,15 @@ import org.meshtastic.feature.node.model.NodeDetailAction
|
|||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
fun NodeDetailScreen(
|
||||
nodeId: Int,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: MetricsViewModel = hiltViewModel(),
|
||||
nodeDetailViewModel: NodeDetailViewModel = hiltViewModel(),
|
||||
navigateToMessages: (String) -> Unit = {},
|
||||
onNavigate: (Route) -> Unit = {},
|
||||
onNavigateUp: () -> Unit = {},
|
||||
overrideNodeId: Int? = null,
|
||||
) {
|
||||
LaunchedEffect(overrideNodeId) {
|
||||
if (overrideNodeId != null) {
|
||||
viewModel.setNodeId(overrideNodeId)
|
||||
}
|
||||
}
|
||||
LaunchedEffect(nodeId) { viewModel.setNodeId(nodeId) }
|
||||
|
||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||
val environmentState by viewModel.environmentState.collectAsStateWithLifecycle()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue