Share Dialog Compose#253
Open
TheTerminatorOfProgramming wants to merge 2 commits intomardous:masterfrom
Open
Conversation
Convert Share Dialog to Compose
Contributor
Reviewer's GuideConverts the previous imperative ShareSongDialog usage into a navigation-driven BottomSheetDialogFragment implemented with Jetpack Compose, wiring it into the main nav graph and configuring its behavior and layout. Sequence diagram for the new Compose-based share song flowsequenceDiagram
actor User
participant AbsPlayerFragment
participant NavController
participant ShareSongFragment
participant ShareSongBottomSheet
participant AndroidShareSheet
User->>AbsPlayerFragment: Tap action_share_now_playing
AbsPlayerFragment->>NavController: navigate(nav_share)
NavController->>ShareSongFragment: Create and show dialog
ShareSongFragment->>ShareSongFragment: Configure BottomSheetDialog behavior
ShareSongFragment->>ShareSongBottomSheet: Set Compose content with PlayerViewModel and Context
User->>ShareSongBottomSheet: Tap share audio file button
ShareSongBottomSheet->>AndroidShareSheet: startActivity(getShareSongIntent.toChooser)
User->>ShareSongBottomSheet: Tap share now playing button
ShareSongBottomSheet->>AndroidShareSheet: startActivity(getShareNowPlayingIntent.toChooser)
Updated class diagram for ShareSongFragment and Compose share screenclassDiagram
class BottomSheetDialogFragment
class PlayerViewModel
class ShareSongFragment {
+playerViewModel PlayerViewModel
+onCreateView(inflater LayoutInflater, container ViewGroup, savedInstanceState Bundle) View
}
class ShareSongBottomSheet {
+ShareSongBottomSheet(playerViewModel PlayerViewModel, context Context) void
}
class BottomSheetDialog {
+behavior BottomSheetBehavior
}
class BottomSheetBehavior {
+isFitToContents Boolean
+skipCollapsed Boolean
+peekHeight Int
+maxHeight Int
}
ShareSongFragment --|> BottomSheetDialogFragment
ShareSongFragment --> PlayerViewModel
ShareSongFragment --> BottomSheetDialog
ShareSongFragment --> ShareSongBottomSheet
ShareSongBottomSheet --> PlayerViewModel
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
ShareSongBottomSheet, prefer usingLocalContext.currentandstringResourceinstead of passingContextinto the composable and callingcontext.getString, to keep the composable more idiomatic and easier to preview/test. - The explicit
interactionSource = remember { MutableInteractionSource() }for bothButtons inShareSongBottomSheetis redundant; you can omit it and rely on the defaultinteractionSourceunless you need custom interaction handling. - The new
shuffle_heightdimen is being used as the bottom sheetpeekHeightandmaxHeight; consider naming it specifically for the share bottom sheet (e.g.,share_sheet_height) to better reflect its purpose and avoid confusion with shuffle-related UI.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ShareSongBottomSheet`, prefer using `LocalContext.current` and `stringResource` instead of passing `Context` into the composable and calling `context.getString`, to keep the composable more idiomatic and easier to preview/test.
- The explicit `interactionSource = remember { MutableInteractionSource() }` for both `Button`s in `ShareSongBottomSheet` is redundant; you can omit it and rely on the default `interactionSource` unless you need custom interaction handling.
- The new `shuffle_height` dimen is being used as the bottom sheet `peekHeight` and `maxHeight`; consider naming it specifically for the share bottom sheet (e.g., `share_sheet_height`) to better reflect its purpose and avoid confusion with shuffle-related UI.
## Individual Comments
### Comment 1
<location> `app/src/main/java/com/mardous/booming/ui/screen/sharesong/ShareSongFragment.kt:39-42` </location>
<code_context>
+
+ return ComposeView(requireContext()).apply {
+ setContent {
+ BoomingMusicTheme() {
+ ShareSongBottomSheet(
+ playerViewModel = playerViewModel,
+ context = requireContext()
+ )
+ }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Avoid calling requireContext() inside the composable content lambda to reduce lifecycle coupling.
Calling `requireContext()` here couples recomposition to the Fragment’s attached state and can crash if recomposition occurs after detachment. Since this is already in a `ComposeView`, prefer `LocalContext.current` inside `ShareSongBottomSheet` (dropping the `context` parameter), or capture `val ctx = context` before `setContent` and pass that stable reference instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Removed files not needed and fixed code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert Share Dialog to Compose
Summary by Sourcery
Convert the song sharing dialog to a Compose-based bottom sheet and wire it into the navigation graph.
New Features:
Enhancements: