Migrate Help Fragment to Compose#14756
Conversation
|
Hi there, thank you for your contribution, but I don't really want to take in things like full screen conversions. |
|
@greyson-signal Hi, but this screen is pretty small one, I can add more details on what was done, on testing, etc. |
|
@greyson-signal Also, I’m available ASAP if any bugs occur |
alex-signal
left a comment
There was a problem hiding this comment.
This is the right direction but we've adopted a Component(state, (event) -> Unit) pattern that we want to formalize throughout. Also concerned with some of the window adjustments, since this fragment will be shown in a split-pane in the near future.
| override fun onContactSupport() { | ||
| requireActivity().finish() | ||
| requireActivity().startActivity(AppSettingsActivity.help(requireContext(), HelpFragment.REMOTE_BACKUPS_INDEX)) | ||
| requireActivity().startActivity(AppSettingsActivity.help(requireContext(), REMOTE_BACKUPS_INDEX)) |
There was a problem hiding this comment.
This can be reverted, we don't directly import statics (or at least try not to)
|
|
||
| @Composable | ||
| override fun FragmentContent() { | ||
| val startCategoryIndex = arguments?.getInt(START_CATEGORY_INDEX, 0) ?: 6 |
There was a problem hiding this comment.
6 magic number. Should this be PAYMENT_INDEX?
| onFaqClick = { | ||
| val intent = Intent(Intent.ACTION_VIEW) | ||
| intent.setData(Uri.parse(getString(R.string.HelpFragment__link__faq))) | ||
| startActivity(intent) |
There was a problem hiding this comment.
CommunicationActions.openBrowserLink
| onNavigationClick = { requireActivity().onBackPressedDispatcher.onBackPressed() }, | ||
| onWhatIsDebugLogClick = { | ||
| val intent = Intent(Intent.ACTION_VIEW) | ||
| intent.setData(Uri.parse(getString(R.string.HelpFragment__link__debug_info))) |
There was a problem hiding this comment.
CommunicationActions.openBrowserLink
|
|
||
| class HelpViewModel(application: Application) : AndroidViewModel(application) { | ||
|
|
||
| private val _state = MutableStateFlow(HelpScreenState()) |
|
|
||
| DisposableEffect(Unit) { | ||
| activity?.window?.let { | ||
| WindowCompat.setDecorFitsSystemWindows(it, false) |
There was a problem hiding this comment.
This doesn't feel right at all. You should be using the insets modifiers if you need to space things correctly. Scaffolds.Settings should already be doing that for you.
There was a problem hiding this comment.
Totally agree with you, we don't need this, removed.
| .fillMaxSize() | ||
| .padding(paddingValues), | ||
| ) { | ||
| Column( |
There was a problem hiding this comment.
LazyColumn is likely a better and more performant choice.
There was a problem hiding this comment.
Maybe it is OK to leave Column here?
Pros:
- content is fixed and small
- it has .verticalScroll()
Cons:
- don't see for now :)
| val snackbarHostState = remember { SnackbarHostState() } | ||
|
|
||
| LaunchedEffect(startCategoryIndex) { | ||
| viewModel.onCategorySelected(startCategoryIndex) |
There was a problem hiding this comment.
This should just be passed to the ViewModel at construction time?
|
|
||
| package org.thoughtcrime.securesms.help | ||
|
|
||
| sealed interface HelpScreenEvents { |
There was a problem hiding this comment.
*Events is reserved for user-initiated actions like clicks and toggles.
| } | ||
|
|
||
| val subject = context.getString(R.string.HelpFragment__signal_android_support_request) | ||
| val body = SupportEmailUtil.generateSupportEmailBody( |
There was a problem hiding this comment.
You'll want to run the formatter with ./gradlew format
…ents class for user interaction
|
@alex-signal thank you for your time and comments! I’ve resolved all comments and I have a few to discuss. We can’t have HelpScreenRepository with sendEmail() fun to call from VM because we need activity context to open email app. So I made SideEffects flow which VM can use to send event and Compose screen can address it. Also I left ShowSnackbar in the same SideEffects flow because
Events was refactored to user interaction events So what do you think on having SideEffect flow in VM to communicate from VM to Compose screen? Can we leave Column as root compose component in Scaffold.Settings because screen is pretty small and content is fixed? I’ve added onEvent() param in Compose function, but left navigation back and open browsers clicks. |
First time contributor checklist
Contributor checklist
Description
Migrated HelpFragment screen to Compose & Kotlin.
Tested on playStagingDebug build variant.
Also checked compose screen in layout inspector and for overdraw.
Screenshots before/after attached.