-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
4159 migrate help fragment to compose #4217
base: main
Are you sure you want to change the base?
4159 migrate help fragment to compose #4217
Conversation
@MohitMaliFtechiz sir I would like to put a thing in notice that whenever i sync the gradel using sync now after sync some string.xml files are automatically changed or updated. I am not able to know why. The above image shows before sync and after sync status of the files. |
@SOUMEN-PAL This is due to our gradle task, which we have added to fix #3176. Please do not include this automate change in commit. kiwix-android/app/build.gradle.kts Line 144 in 687fbe0
|
@SOUMEN-PAL Any update? |
The ui is working I ensured the version and gradel dependencies the only problem is the strings that are getting updated in gradel sync and I am not able to fix the changes the jetpack compose code is working seemlesly. I am not able to figure out the Tarak file thing |
@SOUMEN-PAL Apart from the |
Yes The UI is ready for review. |
b81ad3c
to
6873bd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL Thanks for your changes. Please see the review comments.
val isDarkTheme = isSystemInDarkTheme() | ||
val itemColor = if (isDarkTheme) Color.White else Color.Black | ||
val arrowRotation by animateFloatAsState( | ||
targetValue = if (isOpen) 180f else 0f, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL This is giving the MagicNumber
lint error. Please fix it.
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun HelpScreen( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here lint is giving the LongMethod
error, please fix it.
throw IllegalArgumentException("Invalid description resource type for title: $title") | ||
} | ||
} | ||
protected abstract val navHostFragmentId: Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is abstract
so why we are not implementing it in CustomHelpFragment
like we are doing it in KiwixHelpFragment
? It will not allow us to build the Custom
module without implementing this in CustomHelpFragment
.
implementation(Libs.androidx_compose_material3) | ||
implementation(Libs.androidx_activity_compose) | ||
|
||
implementation(Libs.androidx_compose_ui) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have added androidx.compose.ui:ui-android:1.7.7
in our project. Due to this, we are facing a PrivateResouce
lint issue for our close_drawer
string. Can you please fix that? IMO add this in in lintConfig file since our app can have the same resource name, and we are getting this name from our R
package so it will not conflict with compose internal string.
<issue id="PrivateResource" severity="warning" />
navigationIcon = { | ||
IconButton(onClick = navController::popBackStack) { | ||
Icon( | ||
imageVector = Icons.Filled.ArrowBack, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icons.Filled.ArrowBack
is deprecated we should use Icons.AutoMirrored.Filled.ArrowBack
instead.
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) { | ||
Image( | ||
painter = painterResource(R.drawable.ic_feedback_orange_24dp), | ||
contentDescription = "Feedback", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contentDescription
should be Send diagnostic report
as it is for "Send diagnostic report" we have a string for this send_report
which we are using in the fragment_help.xml
so we should use that.
fragmentHelpBinding?.activityHelpRecyclerView?.addItemDecoration( | ||
DividerItemDecoration(activity, DividerItemDecoration.VERTICAL) | ||
) | ||
fragmentHelpBinding?.activityHelpRecyclerView?.adapter = HelpAdapter(titleDescriptionMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After moving HelpScreen
to compose our HelpAdapter
is unused so we should remove the unused code.
.padding(start = 16.dp, end = 16.dp) | ||
) { | ||
Text( | ||
text = data.description, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The internal text is showing bigger and looks different from the previous one. Also, the side image
for opening and closing the menu items is bigger which does not look good. See the difference:
Previous design | Current design |
---|---|
You can take the reference from xml design how we have used sizes, margins, paddings, etc, for text and images.
@SOUMEN-PAL I have rebased the PR and resolved the tarask file conflicts. Now only add the files in which you have made the changes.
I have reviewed your PR, please have a look at the review changes. |
I more question regarding the workflow I mean I was thinking for getting the upstream then updating my branch to the branch that is added after rebase from https://github.com/kiwix/kiwix-android/tree/4159-migrate-help-fragment-to-compose Other wise i wont be able to see the changes in my forked repository. I just want to confirm my workflow for the post rebase step |
@SOUMEN-PAL Your branch has the latest code, so you can directly get it via running
If your local branch does not have the origin, you can do it. |
@SOUMEN-PAL What is going on here? Do you still work on this PR? |
Yes it's done I gave an update to check up on the review comment. There i also commented on the difference between the XML based dp and dp in jetpack compose so I asked up there should I manually use required sizes that will look the same? |
Where you have commented and asked the question? I do not see your comment in the review comments. However, we have set up the theme(sizes, shapes, etc) for our textView, button, etc in #4253, you can take reference from that PR. |
@MohitMaliFtechiz sir, |
@SOUMEN-PAL Yes correct, we are not using the XML_base R.dimen file for setting the sizes for images and icons. But hardcoding this |
… the requested changes
@MohitMaliFtechiz Major changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL Sorry for late review, please see the review changes.
Edited
Now we have migrated the helpFragment
in compose, so there is no need for item_help.xml
, and fragment_help.xml
so please remove them.
Can you please refactor the HelpFragmentTest
as now it will fail because of migration. you can take reference from already written test cases in #4258, and #4253.
const val androidx_compose_ui: String = | ||
"androidx.compose.ui:ui:" + Versions.androidx_compose_ui_version | ||
|
||
const val androidx_compose_bom: String = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL Why are we adding both the bom
and the normal version of dependencies? We should only add and manage the dependencies. See how we done in https://github.com/kiwix/kiwix-android/pull/4253/files#diff-df8b4af8cccf28e19228317a74d3fba23fed6c067665f72670b7d4986515ad39.
@@ -13,6 +13,8 @@ buildscript { | |||
} | |||
plugins { | |||
`android-library` | |||
id("org.jetbrains.kotlin.android") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase on the main branch, there we have added the support for compose in a proper way.
rawTitleDescriptionMap() | ||
) | ||
// Retrieve the NavController if your composable needs it. | ||
val navController = Navigation.findNavController(requireActivity(), navHostFragmentId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the already defined navController
in CoreMainActivity
. Like:
val navController = (requireActivity() as CoreMainActivity).navController
After using this, you don't need to define this:
protected abstract val navHostFragmentId: Int
So remove this from HelpFragment
as well as from the child fragments.
// Already Applied ad TopAppBAr in scaffold in composable | ||
null | ||
} | ||
override val fragmentTitle: String? by lazy { getString(R.string.menu_help) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these fragmentToolbar
and fragmentTitle
, as well as the onViewCreated
method as they are unused now.
override val navHostFragmentId: Int | ||
get() = org.kiwix.kiwixmobile.custom.R.id.custom_nav_controller | ||
|
||
override fun rawTitleDescriptionMap() = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in custom apps we are not showing these rows, so please don't add these.
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
HelpTopAppBar(navController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use KiwixAppBar
for the toolbar it has the all capabilities e.g. handling the menu button, title, back button, etc with the proper theme of our application for both night/day modes.
fun HelpContent( | ||
data: List<HelpScreenItemDataClass>, | ||
dividerColor: Color, | ||
innerPadding: androidx.compose.foundation.layout.PaddingValues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of writing full packageName
just import this package and use the PaddingValues
directly.
Text( | ||
text = stringResource(R.string.send_report), | ||
color = if (isDarkTheme) Color.LightGray else Color.DarkGray, | ||
fontSize = SendDiagnosticReportFontSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hardcoding the size of text use style = MaterialTheme.typography.titleMedium
from the KiwixTheme
or any better which fits in this.
Also, add the divider here at the last which will show the line at the bottom of "Send diagnostic report" to make the row completed.
.fillMaxWidth() | ||
) { | ||
itemsIndexed(data, key = { _, item -> item.title }) { _, item -> | ||
HorizontalDivider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add this divider after the HelpScreenItem
so that it will be below the content, and remove the last extra item added here(The below code) to simplify the design and code.
item {
HorizontalDivider(
color = dividerColor
)
}
private const val HelpItemArrowRotationClosed = 0f | ||
|
||
@Composable | ||
fun HelpScreenItem( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #4159
📌 Summary
Migrated
HelpFragment
from XML-based UI to Jetpack Compose.🔄 Changes Made
Created new Composable components
HomeScreen.kt
andHomeScreenItem.kt
to handle the UI logic in Jetpack Compose.Updated
HelpFragment.kt
HelpFragment
to return a Composable UI instead of using View Binding.Updated dependencies
Libs.kt
andVersions.kt
inbuildSrc
.Handled Navigation
KiwixHelpFragment.kt
, as the host fragment ID is required for Composable-to-Fragment and vice versa navigation.🖼️ Screenshots / GIFs