Skip to content

Share Dialog Compose#253

Open
TheTerminatorOfProgramming wants to merge 2 commits intomardous:masterfrom
TheTerminatorOfProgramming:share_dialog_compose
Open

Share Dialog Compose#253
TheTerminatorOfProgramming wants to merge 2 commits intomardous:masterfrom
TheTerminatorOfProgramming:share_dialog_compose

Conversation

@TheTerminatorOfProgramming
Copy link
Contributor

@TheTerminatorOfProgramming TheTerminatorOfProgramming commented Jan 10, 2026

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:

  • Introduce a Compose-based bottom sheet UI for sharing the current song.

Enhancements:

  • Replace the imperative ShareSongDialog usage with navigation to a ShareSongFragment hosting the Compose share sheet.
  • Adjust bottom sheet sizing via a new dimension to control the share sheet’s expanded height.

Convert Share Dialog to Compose
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 10, 2026

Reviewer's Guide

Converts 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 flow

sequenceDiagram
    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)
Loading

Updated class diagram for ShareSongFragment and Compose share screen

classDiagram
    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
Loading

File-Level Changes

Change Details Files
Route share action through NavController instead of instantiating the dialog directly
  • Replace direct ShareSongDialog.show(...) call from the player fragment with a navigation action to a new nav_share dialog destination
  • Use findActivityNavController helper with the host fragment container ID to perform navigation
app/src/main/java/com/mardous/booming/ui/component/base/AbsPlayerFragment.kt
Register a new dialog destination for the share sheet in the navigation graph
  • Add a nav_share destination pointing to ShareSongFragment in the main navigation graph
app/src/main/res/navigation/graph_main.xml
Introduce a Compose-based bottom sheet UI for sharing the current song
  • Create ShareSongBottomSheet composable using BottomSheetDialogSurface and Material3 components
  • Provide two share buttons that launch share intents via getShareSongIntent and getShareNowPlayingIntent wrapped in a chooser
  • Use PlayerViewModel.currentSong and a passed-in Context to construct and dispatch the intents
app/src/main/java/com/mardous/booming/ui/screen/sharesong/ShareSongScreen.kt
Wrap the Compose share UI in a BottomSheetDialogFragment wired to navigation and PlayerViewModel
  • Create ShareSongFragment as a BottomSheetDialogFragment hosting a ComposeView with BoomingMusicTheme and ShareSongBottomSheet
  • Obtain PlayerViewModel via activityViewModel Koin delegate
  • Configure BottomSheetDialog behavior (fit to contents, skip collapsed, custom peekHeight and maxHeight based on a dimension resource)
app/src/main/java/com/mardous/booming/ui/screen/sharesong/ShareSongFragment.kt
Add dimension resource to control share bottom sheet height
  • Introduce shuffle_height dimension used as peekHeight/maxHeight for the share bottom sheet
app/src/main/res/values/dimens.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • 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 Buttons 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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
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.

1 participant