How To Create And Use a Custom Theme in Jetpack Compose

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 27

  • @jam4l
    @jam4l 4 หลายเดือนก่อน +2

    Why the algorithm has never recommended your channel for me ?
    I love your explanations, fast (no stallings), precise, in point, and rich of information, BRAVO 👏👏👏

    • @jov_mit
      @jov_mit  4 หลายเดือนก่อน +1

      First - thank you so much for the kind words, and I am glad the content works good for you 🙏
      The way the algorithm works is: it recommends videos that the user is more likely to click on, and watch start to end.
      They want you to stay on the platform.
      For my videos unfortunately, people click off rather soon. And so, since folks don't watch start to end - the algo sees it as a bad video and it won't recommend.
      If you want to be notified tho, you can subscribe to the channel and click on the notification bell. That way you'll never miss a video.
      Hope that helps 🙏

    • @jam4l
      @jam4l 4 หลายเดือนก่อน +1

      ​@@jov_mit Yeah I did activated the notifications. Your content is great don't stop making it 🤟

    • @jov_mit
      @jov_mit  4 หลายเดือนก่อน +1

      I definitely won't. Thank you for the encouragement my friend 🙏💯

  • @mohnishkumarchittoory
    @mohnishkumarchittoory 11 หลายเดือนก่อน +2

    Thank you for the video, your tutorial helped me a lot to solve the problem that I was facing.

    • @jov_mit
      @jov_mit  11 หลายเดือนก่อน +1

      I'm very glad it was helpful for you, and thank you so much for the feedback. I appreciate it a lot 🙏🏻

  • @sooshil
    @sooshil 11 หลายเดือนก่อน +1

    This is a very great explanation regarding the custom theme in compose. Great job. 👍

    • @jov_mit
      @jov_mit  11 หลายเดือนก่อน

      Thank you so much, I'm glad it was helpful 🙏🏻

  • @Sok4h
    @Sok4h ปีที่แล้ว +1

    thank you, really great explanation. now i feel confident to create my own themes :D

    • @jov_mit
      @jov_mit  ปีที่แล้ว +1

      I'm very glad it ended up helpful for you. Thank you so much for the feedback, I really appreciate it 🙏🏻

  • @xkall
    @xkall 3 หลายเดือนก่อน +1

    Great video bro! It was very easy to follow, and you did a great job at explaining. Subscribed.

    • @jov_mit
      @jov_mit  3 หลายเดือนก่อน +1

      Thank you for the feedback mate, glad you found it helpful 🙏💯

  • @anasabubakar4125
    @anasabubakar4125 9 หลายเดือนก่อน +1

    Iam learning a lot from this guy. thank you

    • @jov_mit
      @jov_mit  9 หลายเดือนก่อน +1

      Thank you for the kind words my friend 🙏🏻❤️

  • @U4Universe
    @U4Universe 4 หลายเดือนก่อน +1

    Very well explained. Can I use the same steps for defining a custom theme for Compose Multiplatform project?

    • @jov_mit
      @jov_mit  4 หลายเดือนก่อน

      Yes, it will work fine.

  • @sooshil
    @sooshil 11 หลายเดือนก่อน +1

    Could you please elaborate more on what the danger you talked about is at 3:20?
    How it can occur and how it an be avoided?

    • @jov_mit
      @jov_mit  11 หลายเดือนก่อน +2

      Hi there wave 👋
      Sure thing, thanks for the question. Let me try to explain.
      There are 2 functions we can use to pass value(s) down the composition: `compositionLocalOf{}` and `staticCompositionLocalOf{}`
      When we use the first one, the composer keeps track of the values, and where (in which composable) they are read. Then, when a value changes, the composer will cause recomposition only for the composable that reads the value that changed.
      When we use the second function (staticCompositionLocalOf{}) the composer doesn't keep track. When a value changes- the whole composition tree is going to be recomposed.
      Now, if you think about themes/colors - those aren't things that change a lot. And when they change (for example we apply dark theme system-wide) - we do want the entire composition to re-compose so that the new theme values will be applied.
      So, to avoid possible mistakes - any time you use the `staticCompositionLocalOf{}` function - ask yourself when those values that you are wrapping inside are going to change, and if a possible change should re-compose the whole composition tree.
      Please let me know if that answered the question, or you are still missing something.

    • @sooshil
      @sooshil 11 หลายเดือนก่อน

      So, changing the values usually won't happen, right? As you mentioned, changing the color values happens when we switch the system them to dark or light. Or changing the shape may be in screen rotation, where we may want to recompose the whole screen to display different layout....
      So, isn't the staticCompositionLocalOf always the best way to go with? What could be the use case of a non static version of it? Please forgive me if my question doesn't make sense.

    • @jov_mit
      @jov_mit  11 หลายเดือนก่อน +1

      No no, it absolutely makes sense. You want to understand better, which is great. No worries.
      So, when you change orientation - you don't want the entire composition to recompose. You might want to change only the layout of your current screen that is displayed.
      To your question: "Isn't the staticCompositionLocalOf always the best way to go with" - the short answer is NO. When you wrap a value inside `staticCompositionLocalOf` you are not telling the composer not to recompose, rather you are telling: "Hey when any value inside this block changes - recompose the whole tree". And that is a very intensive and inefficient thing. You want to avoid that. Hope that makes sense.

  • @alanesaugarciagutierrez6025
    @alanesaugarciagutierrez6025 11 หลายเดือนก่อน +1

    So you need to create a wrapper for everysingle ui component in order to use your theme right?

    • @jov_mit
      @jov_mit  11 หลายเดือนก่อน +2

      No, in the video, it was an example of creating one to show more options.
      You can still use your theme properties on the built-in composables, like so:
      Text(
      modifier = Modifier.
      background(AppTheme.colorScheme.onPrimary),
      text = "Example"
      )
      No need to introduce wrappers

  • @sahilmhapsekar9
    @sahilmhapsekar9 3 หลายเดือนก่อน +1

    Getting error at 03:35 : Unresolved reference: Unspecified

    • @jov_mit
      @jov_mit  3 หลายเดือนก่อน

      Check if you have the correct Color import. It should be the one coming from the compose package

  • @HumayoonSiddique-l6l
    @HumayoonSiddique-l6l ปีที่แล้ว +1

    @Composable
    fun AppTheme(
    isDarkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
    ) {
    val colorScheme = if (isDarkTheme) darkColorScheme else lightColorScheme
    val rippleIndication = rememberRipple()
    CompositionLocalProvider(
    LocalAppColorScheme provides colorScheme,
    LocalAppTypography provides typography,
    LocalAppShape provides shape,
    LocalAppSize provides size,
    LocalIndication provides rippleIndication,
    content = content
    )
    }
    getting error on LocalApp related provides can you help me out

    • @jov_mit
      @jov_mit  ปีที่แล้ว

      Yes, ofcorse I can help.
      Could you please elaborate a little bit in more details - what is the issue you encounter?
      Here is the reference to the repository and the corresponding file, in case it might be helpful: github.com/mitrejcevski/android-devs-app/blob/main/core/view/src/main/java/nl/jovmit/androiddevs/core/view/theme/AppTheme.kt