Skip to content

Unwrap MainDesign#138

Merged
Goooler merged 4 commits into
trunkfrom
unwrap-main-design
Apr 26, 2026
Merged

Unwrap MainDesign#138
Goooler merged 4 commits into
trunkfrom
unwrap-main-design

Conversation

@Goooler
Copy link
Copy Markdown
Owner

@Goooler Goooler commented Apr 26, 2026

Refs #119.

@Goooler Goooler force-pushed the unwrap-main-design branch from b035743 to f68765a Compare April 26, 2026 03:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR follows up on #119 by removing the legacy MainDesign wrapper and splitting the main screen into a pure @Composable UI (MainScreen) backed by a new MainViewModel, with navigation handled by MainActivity.

Changes:

  • Introduces MainViewModel to own main-screen state, events, and polling logic.
  • Refactors MainScreen into a ViewModel-driven Compose entrypoint plus a stateless MainContent.
  • Updates MainActivity to use setContent {} and wire navigation callbacks directly into MainScreen.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt New ViewModel for main screen state/event handling, service start/stop, and traffic polling.
app/src/main/kotlin/com/github/kr328/clash/main/ui/MainScreen.kt Replaces MainDesign with a Compose screen that binds to MainViewModel and renders MainContent.
app/src/main/kotlin/com/github/kr328/clash/main/MainActivity.kt Converts main activity to a Compose setContent host and provides navigation callbacks.
Comments suppressed due to low confidence (1)

app/src/main/kotlin/com/github/kr328/clash/main/ui/MainScreen.kt:118

  • Inside LaunchedEffect(eventState) the snackbar calls are wrapped in scope.launch { ... }, but LaunchedEffect already runs in a coroutine. Launching a second coroutine means consumeEvent() runs immediately and the snackbar work becomes fire-and-forget, which can lead to multiple snackbars overlapping/out-of-order. Prefer calling snackbarHostState.showSnackbar(...) directly in the LaunchedEffect block and only consuming the event after the snackbar/action handling completes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt Outdated
Comment thread app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt Outdated
Comment thread app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt Outdated
Goooler and others added 2 commits April 26, 2026 13:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

app/src/main/kotlin/com/github/kr328/clash/main/ui/MainScreen.kt:116

  • Inside LaunchedEffect(eventState), the snackbar calls are wrapped in scope.launch { ... }. Those launched coroutines aren’t cancelled if the LaunchedEffect is restarted (e.g., event changes quickly), which can lead to snackbars/actions running for stale events and adds avoidable coroutine nesting. Since LaunchedEffect is already a coroutine scope, call snackbarHostState.showSnackbar(...) directly in the when branch and handle the result there.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt Outdated
@Goooler Goooler requested a review from Copilot April 26, 2026 05:23
@Goooler Goooler merged commit fd69826 into trunk Apr 26, 2026
7 checks passed
@Goooler Goooler deleted the unwrap-main-design branch April 26, 2026 05:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

app/src/main/kotlin/com/github/kr328/clash/main/ui/MainScreen.kt:140

  • Because the app uses edge-to-edge (BaseActivity.enableEdgeToEdge()), placing SnackbarHost at Alignment.BottomCenter without any WindowInsets padding can cause snackbars to be drawn under the navigation/gesture bar on some devices. Apply WindowInsets.safeDrawing (or equivalent bottom inset padding) to the snackbar host/container so it always appears above system bars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/kotlin/com/github/kr328/clash/main/vm/MainViewModel.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants