Swipeable Tab Rows - UX With Material3

Поділитися
Вставка
  • Опубліковано 16 січ 2025

КОМЕНТАРІ • 75

  • @Alchemist10241
    @Alchemist10241 Рік тому +2

    This is the simplest and easiest solution for implementing swipeable tab rows in jetpack compose I've seen so far, well done and thanks Phillips

  • @Luffy_2804
    @Luffy_2804 Рік тому +3

    you are one of the best just because of you i just switched to jetpack , initially i was hating this jetpack stuff and finding xml , easy as compared to jetpack , but now i started liking jetpack too much , it is really amazing , initially it becomes way to difficult , not able to understand what is happening with regular practice efforts and i am able to understand how it is working

  • @azickri
    @azickri 9 місяців тому

    This is the best of Tutorial, you explain all need we must learn without chitchat 🎉🎉🎉

  • @teovladusic
    @teovladusic Рік тому +7

    PagerState has a property called "targetPage", it works better than what Philipp suggested as there is some delay when waiting pager animation to finish.

    • @tonymont72
      @tonymont72 11 місяців тому

      How did you handle the delay?

    • @cyrdas
      @cyrdas 2 місяці тому

      @@tonymont72 I've used setup by @tusharbhatia6777 's comment, but replaced the pagerState.currentPage with pagerState.targetPage, that prevents the weird flickering issue happening otherwise as you scroll over the in-between pages.

  • @ChrisAthanas
    @ChrisAthanas Рік тому +7

    @Phillip Lackner The Source code link is responding with 404... is the link correct?

  • @tusharbhatia6777
    @tusharbhatia6777 11 місяців тому +16

    For anyone facing the delay in indicator changing , i fixed the issue
    code:
    val scope = rememberCoroutineScope()
    LaunchedEffect(pagerState.currentPage) {
    selectedTabIndex = pagerState.currentPage
    }
    in Tab ,onclick = {
    scope.launch {
    pagerState.animateScrollToPage(index)
    }
    selectedTabIndex = index
    }
    remove the other LauchedEffect he typed in video

    • @nadirseddaoui8136
      @nadirseddaoui8136 10 місяців тому +1

      thx bro !

    • @makix08
      @makix08 7 місяців тому

      This is the correct way to do it, thanks

    • @ritikrawat2447
      @ritikrawat2447 6 місяців тому

      What if we need to add composables in side these tab rows how can we do it can you help pls

    • @tusharbhatia6777
      @tusharbhatia6777 6 місяців тому

      We call that composable
      Like
      Screen A()
      Screen B()

    • @MuhammadUbaid-j4o
      @MuhammadUbaid-j4o 6 місяців тому

      great work bro

  • @JJSS90
    @JJSS90 10 місяців тому

    Philp you are the best

  • @nastenkaoo
    @nastenkaoo 11 місяців тому

    thanks Philipp, you are great

  • @kirwakelvinkering3122
    @kirwakelvinkering3122 Рік тому +1

    Philip you've been my best teacher in Kotlin .was just wondering if we could modify the Tab indicator to have rounded corners like that of twitter .

  • @zulhijananda5772
    @zulhijananda5772 Рік тому +1

    Source code is 404, where can i get it. I have problem, my pager does not change when tab is changed

  • @abada-s
    @abada-s Рік тому +3

    Why didn't you use the pagerState.currentPage as the index of the selected tab? also tab onClick will animate the pager state to the selected index

    • @PhilippLackner
      @PhilippLackner  Рік тому

      Does that also behave correctly when switching from start to end tab?

    • @abada-s
      @abada-s Рік тому

      @@PhilippLackner I didn't test it but it should be fine because we are dealing with one state

    • @PhilippLackner
      @PhilippLackner  Рік тому +2

      @@abada-s if that works well, it seems like the better solution. Thanks for adding 👍🏼

    • @wesd3fer
      @wesd3fer Рік тому

      @@abada-s Just wanted to chime in and say that I tested this and it works as expected. The only minor thing is that for the onClick you have to account for PagerState.animateScrollToPage being a suspending function.

  • @unknownBoy85lover
    @unknownBoy85lover Рік тому

    Thank you so useful it's I need it just right now 😂❤

  • @wikigerman
    @wikigerman Рік тому

    Thank you very much Philipp,, is it possible to reduce the space between tabs?
    the current default value is: private val ScrollableTabRowMinimumTabWidth = 90.dp

  • @funclips767
    @funclips767 Рік тому +1

    keep the good work❤

  • @anthonydanyameabuah4542
    @anthonydanyameabuah4542 Рік тому

    Funny thing I spent almost the last two days figuring this thing out and now it's here. Should've waited.
    Question : When using the scrollable tab, how do you keep the selected tab focused on the screen when swiping the horizontal pager to a tab that isn't on the screen yet(say the last screen). I hope my question is clear

  • @luciferGOD1234
    @luciferGOD1234 Рік тому

    What will be best way achieve bottom bar? I mean viewpager is better or bottom bar layout?

  • @david_whyte
    @david_whyte 7 місяців тому

    Hi why are you not using button nav bar in the scaffold?

  • @wyneci
    @wyneci Рік тому +1

    Hi Phillip, please make a tutorial with MongoDB 🙏

  • @Leon-un2ii
    @Leon-un2ii Рік тому

    So this could also easily be bottom Navigation bar or should we then stick to the other video for this topic? I am a bit confused. Your way in this video now looks better and has more features.

  • @gamecool2110
    @gamecool2110 11 місяців тому

    thanks so much you saved me

  • @saeedghiassy5435
    @saeedghiassy5435 Рік тому

    Like always great videos , thanks you very much ! :)

  • @Ayor88
    @Ayor88 10 місяців тому

    First, thank you very much for all of your content, I watch almost all of your videos.
    While it works, The tab doesn't update until the end of the scrolling. It would be better if booth where synchronized

  • @DmitryZatuchny
    @DmitryZatuchny 8 місяців тому

    Page not found for repo in description

  • @lucachangretta2025
    @lucachangretta2025 7 місяців тому

    Dude ur so so so underrated

  • @dreW1-
    @dreW1- Рік тому

    you just solved me a bug with the horizontal pager to get the index, i was executing a method inside the horizontal pager instead of launched effect.... those timings insane

  • @nijithebuji
    @nijithebuji Рік тому +2

    Source code link is saying 404 not found

  • @TheFlexath
    @TheFlexath Рік тому

    Thank you Sir

  • @GandhiWibowo-h7f
    @GandhiWibowo-h7f Рік тому

    Hy Philip.
    Sorry if asking off topic.
    I've seen your video creating an Instagram profile page. I want to ask, how can the list of "content" that appears continue to scroll down?

  • @rakam.a8070
    @rakam.a8070 Рік тому +1

    Can you make a video how to combine TabRows with TopAppBar that has scroll behaviour?

    • @anthonydanyameabuah4542
      @anthonydanyameabuah4542 Рік тому

      Especially how to keep the selected tab in focus. This would be very helpful as I'm struggling to figure out

  • @wilianc.b.3065
    @wilianc.b.3065 10 місяців тому +1

    Hi! Thanks for the video.
    One question please: When I use isScrollInProgress, there is a bit of a lag to move the selectedTabIndex in the TabRow. Is there a solution for this lag?

    • @nadirseddaoui8136
      @nadirseddaoui8136 10 місяців тому

      Hi! I have the same issue. Did you got any solution ?
      when i dont use isScrollInProgress there is still a very little lag. I mean this is not smooth as Watsapp swip for exemple.

    • @itsusinn
      @itsusinn 10 місяців тому

      i came into this wired situation too

    • @itsusinn
      @itsusinn 10 місяців тому +2

      @wilianc.b.3065 @nadirseddaoui8136
      LaunchedEffect(pagerState.targetPage){
      selectedTabIndex= pagerState.targetPage
      }
      should fix this problem

    • @JJSS90
      @JJSS90 10 місяців тому

      @@itsusinn Thanks, this fixed the issue

  • @johnoricha7088
    @johnoricha7088 Рік тому

    Did something very similar on flutter very recently 😅. My implementation was for 2 tabs and 2 pages.

  • @lariniabdellah1820
    @lariniabdellah1820 Рік тому

    tabrow is deprecated now so what alternative can i use

  • @divyathakur5885
    @divyathakur5885 Рік тому

    How can I make multiple pages with different stateflow list?? spwiping pages are worling terrible and recreating multiple ties if using live data inside it.

  • @thelight786
    @thelight786 8 місяців тому

    github url not taking me to the code. ?

  • @m777rmc3
    @m777rmc3 Рік тому

    Thank you!!!!!

  • @John-qt6qk
    @John-qt6qk Рік тому

    Awesome!! well done

  • @denisk3852
    @denisk3852 Рік тому

    Great 👍

  • @padmakargarg9720
    @padmakargarg9720 Рік тому

    Hi ,XIaomi device does not dismiss lockscreen when opening Activity from background (VOIP Call) please help me out regarding this
    point

  • @زيد_اليماني
    @زيد_اليماني Рік тому

    amazing

  • @ritikrawat2447
    @ritikrawat2447 6 місяців тому

    What if we need to add composables in side these tab rows how can we do it can anyone help pls

    • @ritikrawat2447
      @ritikrawat2447 6 місяців тому

      Answer
      HorizontalPager(state = pagerState, modifier = Modifier
      .fillMaxWidth()
      .weight(1f)
      ){ index ->
      Box(
      modifier = Modifier.fillMaxSize(),
      contentAlignment = Alignment.Center
      ){
      when ( index ){
      0 -> PersonalScreen()
      1 -> ServicesScreen()
      2 -> BusinessScreen()
      }
      }
      }

  • @tushar_mahale
    @tushar_mahale Рік тому

    Please provide a good promo code for your " Ultimate PL course bundle"

  • @jishnupdileep3143
    @jishnupdileep3143 9 місяців тому

  • @DasBy768
    @DasBy768 Рік тому

    Hi everyone, I repeated exactly the code from the video, but when I got to two Lauchedeffect's, they did not change the operation of the application in any way and even with them the application works the same as without them. I don't understand what's wrong here. Thanks to everyone who can help me

  • @dr.paradoxdelusionsofgrandeur
    @dr.paradoxdelusionsofgrandeur Рік тому +3

    I still have difficulty in using jetpack compose because it doesn't have the xml view where you can just drag and drop your designs (from figma) then code the functions in the background.

  • @goole-k3z
    @goole-k3z 6 місяців тому

    고아워여

  • @lawrence1519
    @lawrence1519 Рік тому

    heeey :D Can you make a video about cucumber(BDD) in android (with hilt)?

  • @SOULGAME7
    @SOULGAME7 5 місяців тому

    Mool😮😅

  • @goole-k3z
    @goole-k3z 6 місяців тому

    😂😂

  • @goole-k3z
    @goole-k3z 6 місяців тому

    방해해..누가

  • @goole-k3z
    @goole-k3z 6 місяців тому

    😂

  • @GRIFTYRODRIGUEZ
    @GRIFTYRODRIGUEZ Рік тому +1

    bruh why you make your voice sound so weird. sounds like metal gear solid and the codec is running out of batteries

  • @Relax-4-Relax
    @Relax-4-Relax 9 місяців тому +1

    Hello, I am writing through a translator so it may not be clear...
    In the place where there is a comment ( //Some screen)
    I place my screen.
    In your example, there are a lot of unnecessary recompositions.
    see if I made the changes correctly.
    Thank you
    Surface(
    modifier = Modifier.fillMaxSize(),
    color = MaterialTheme.colorScheme.background
    ) {

    val pagerState = rememberPagerState { tabItem.size }
    val coroutineScope = rememberCoroutineScope()
    Column(
    modifier = Modifier.fillMaxSize()
    ) {
    TabRow(selectedTabIndex = pagerState.currentPage) {
    tabItem.forEachIndexed { index, tabItem ->
    Tab(
    selected = true,
    onClick = {
    coroutineScope.launch { pagerState.animateScrollToPage(index) }
    },
    text = { Text(text = tabItem.title) },
    icon = {
    Icon(
    imageVector =
    if (index == pagerState.currentPage) tabItem.selected else tabItem.unselected,
    contentDescription = null
    )
    })
    }
    }
    HorizontalPager(
    modifier = Modifier.weight(1f),
    state = pagerState
    ) { index ->
    //Some screen
    }
    }
    }

    • @enriqueajin6016
      @enriqueajin6016 7 місяців тому

      Thanks! I this approach works perfectly.

    • @tech_ch1211
      @tech_ch1211 7 місяців тому +1

      This solution is better than the one provided in the video, and without lags and workarounds.
      Thanks