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

Setup Jetpack Compose #406

Merged
merged 18 commits into from
May 29, 2023
Merged

Setup Jetpack Compose #406

merged 18 commits into from
May 29, 2023

Conversation

EdricChan03
Copy link
Owner

This PR is a preliminary requirement to migrating the whole project to Jetpack Compose (at some point...)

See #368 for more info on the progress

Additions

This PR adds the following changes:

  • Scaffold initial Gradle precompiled script for Compose-based modules
  • Add Compose dependencies
  • Initial theme composables (StudyBuddyTheme + StudyBuddyCompatTheme - the latter should be used for existing compatibility with the current app's theme)
    • Add unit test to verify the typography is set correctly
  • Initial compat/M3 colours (M3 colours were auto-generated from the Material Theme Builder using the custom preset - see 9b9ee71 for more info
  • Initial SetSystemBarsColor composable for insets support (this just sets the colour for the status bar/navigation bar)
  • Initial widgets module built with Jetpack Compose
    • Move existing views-based widgets to submodule (:ui:widgets:views)
  • Minor fix to GitHubHelpApiImpl where the help articles weren't refreshed correctly (this is because HttpClient.use actually closes the client once it's called, as per the implementation of AutoClosable.use from Kotlin stdlib, so it won't be usable again without creating a new HttpClient instance, and as we're sharing the instance throughout the app, hence the issue)

This fixes a bug where the help articles list couldn't be refreshed
correctly
The colour schemes were auto-generated by the [Material Theme Builder using
the custom preset](https://m3.material.io/theme-builder#/custom), with
the following colours:

* Primary: `#8d5fff`
* Secondary: `#c0b1c8`
* Tertiary: `#c87994`
* Neutral: `#938f94`

This commit also updates the `StudyBuddyTheme` composable's parameters
to allow for:

* whether dynamic colours should be used (defaults to `true` on devices that support it)
* whether to use the new M3 colour schemes (defaults to `true`)
The `StudyBuddyTheme` composable should be used instead
* Adds a single unit test to verify that the Baloo 2 font is used for all
  typography styles
* Remove example unit test
* Accompanist: `0.30.0` -> `0.30.1`
* Compose BoM: `2023.03.00` -> `2023.04.00-beta01.1`
In preparation of an upcoming Compose module 👀
@EdricChan03 EdricChan03 added enhancement Enhancements to the Android app. For the web version, please use the other repo instead. in progress PRs that are still not finished yet and/ or not yet ready for merging. comp: arch Issues/PRs related to the app's architecture. labels May 29, 2023
@EdricChan03 EdricChan03 marked this pull request as ready for review May 29, 2023 20:00
@EdricChan03 EdricChan03 merged commit ab1bf68 into main May 29, 2023
Copy link

@Iannnr Iannnr left a comment

Choose a reason for hiding this comment

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

Apart from the missing PendingIntent flags which I expect will actually crash on newer OS versions, good stuff dude!

package com.edricchan.studybuddy.library

plugins {
id("com.edricchan.studybuddy.library.android")
Copy link

Choose a reason for hiding this comment

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

this can be version cataloged 👀


android {
buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion = "1.4.7"
Copy link

Choose a reason for hiding this comment

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

version catalog? 👀

Copy link
Owner Author

Choose a reason for hiding this comment

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

Version catalogs aren't natively supported in convention plugins AFAICT - see gradle/gradle#15383

@@ -14,7 +14,7 @@ class GitHubHelpApiImpl @Inject constructor(
private val http: HttpClient
) : HelpApi {
override suspend fun fetchHelpArticles(): List<HelpArticle> {
return http.use { it.get(urlHelpFeatured).body<HelpArticles>().articles }
return http.get(urlHelpFeatured).body<HelpArticles>().articles
Copy link

Choose a reason for hiding this comment

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

Any plans for error handling?

*/
@Composable
fun StudyBuddyTheme(
context: Context = LocalContext.current,
Copy link

Choose a reason for hiding this comment

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

I don't see why a context is needed as a parameter here, there's nothing that you can pass in that'll actually affect dynamicDarkColorScheme/dynamicLightColorScheme, right?


private val defaultTypography = Typography()

val StudyBuddyTypography = Typography(
Copy link

Choose a reason for hiding this comment

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

oh this is unfortunate 🙃 hopefully they fix it soon!


import androidx.compose.ui.graphics.Color

val md_theme_light_primary = Color(0xFF6C39DC)
Copy link

Choose a reason for hiding this comment

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

Respect for straight up copying all the variable names too 😂

@@ -0,0 +1,38 @@
plugins {
id("com.edricchan.studybuddy.library.android-compose")
Copy link

Choose a reason for hiding this comment

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

version catalog 😛

class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
Copy link

Choose a reason for hiding this comment

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

good test 👍

EdricChan03 added a commit that referenced this pull request Jun 18, 2023
* Nuke `Defaults` object as we aren't passing in any custom tooltip/icon
  data
* Require `onClick` to be specified
* Improve preview
EdricChan03 added a commit that referenced this pull request Jun 23, 2023
* Address comments from #406
* Mark `moreExpanded` as a save-able
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: arch Issues/PRs related to the app's architecture. enhancement Enhancements to the Android app. For the web version, please use the other repo instead. in progress PRs that are still not finished yet and/ or not yet ready for merging.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants