Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate share fragment to Jetpack Compose #1185

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CalebKL
Copy link
Contributor

@CalebKL CalebKL commented Jul 20, 2023

Description

This PR migrates the share Fragment views to Jetpack Compose.
The Compose version is the exact replica from the views.
In case of any padding values I missed, I would be glad to counter check
Fixes #

Testing Instructions

Screenshots or Screencast

Checklist

  • If this is a user-facing change, I have added an entry in CHANGELOG.md
  • I have considered whether it makes sense to add tests for my changes
  • All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
  • Any jetpack compose components I added or changed are covered by compose previews

I have tested any UI changes...

  • with different themes
  • with a landscape orientation
  • with the device set to have a large display and font size
  • for accessibility with TalkBack

@CalebKL CalebKL requested a review from a team as a code owner July 20, 2023 06:42
Comment on lines 66 to 71
private var disposable: Disposable? = null

override fun onPause() {
super.onPause()

disposable?.dispose()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we're not using disposable anywhere. Can we remove the variable and onPause override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing

(dialog as? BottomSheetDialog)?.behavior?.state = BottomSheetBehavior.STATE_EXPANDED
}
@Composable
private fun Pill(
Copy link
Contributor

Choose a reason for hiding this comment

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

There can be reusable components that can be extracted out like this Pill and the component for each option. Can you describe the challenges you had in using the OptionsDialog() that you initially proposed to use?

This will help us decide the architecture for the rest of the "Playback Effects" dialogs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, the pill can be reused. Regarding the Options Dialog, it would work but one concern:
If we migrate all fragments using BaseDialogFragment() to optionsDialog(), we would have to add new rows for each specific fragment. That means for each fragment that is being migrated, we would add new custom composables on the dialog. But if this would not be a problem, it would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

That means for each fragment that is being migrated, we would add new custom composables on the dialog.

Could we pass a custom option component (which is only shown on a single screen) to the OptionsDialog() so that we don't increase the class size too much and yet be able to have a common class across all these option fragments?

@mchowning, @geekygecko any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Mzazi25 👋

I had a brief discussion with the team, with OptionsDialog() we'll be able to reuse common components and see some advantages. Can we give it a try?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. Let me work on that

color = Color.LightGray.copy(0.3f),
thickness = 1.dp,
)
Divider(thickness = 1.dp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate divider? There's one above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay

@mchowning
Copy link
Contributor

👋 @Mzazi25 ! Are you still planning to work on this?

@CalebKL
Copy link
Contributor Author

CalebKL commented Oct 18, 2023

👋 @Mzazi25 ! Are you still planning to work on this?

Since we decided to use the option dialog, the only blocker we had is we have to work on the optionDialog configuration first.
When we change the configuration, the dialog doesn't update the state as expected.

SourceView.PLAYER,
analyticsTracker
).showShareDialogDirect()
@Suppress("DEPRECATION")
Copy link
Contributor

Choose a reason for hiding this comment

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

onActivityCreated has been deprecated. Should we consider to use OnViewCreated function? wdyt?


@Composable
private fun ShareScreen(
podcast: Podcast?,
Copy link
Contributor

Choose a reason for hiding this comment

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

As we are passing Podcast and BaseEpisode object to composable function, Should we mark these classes with @stable for compose-runtime?

onClick = onShareEpisode
)
Divider(
color = Color.LightGray.copy(0.3f),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider to use MaterialTheme outline color as divider colours rather than hardcoding them. Wdyt?

.fillMaxWidth()
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(color = Color.LightGray)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider to use MaterialTheme outline color as divider colours rather than hardcoding them. Wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants