accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

Pager's pagerTabIndicatorOffset doesn't work with androidx.compose.material3

Open developerfromjokela opened this issue 3 years ago • 12 comments

I'm trying to sync tabrow and HorizontalPager with Modifier.pagerTabIndicatorOffset.

It seems like it requires material 2 TabPosition. I'm using Material 3 library and I would like to use one material3 supplies. Could this be fixed, or is there any other way to circumvent this issue?

developerfromjokela avatar Mar 09 '22 21:03 developerfromjokela

That is correct, accompanist would need to provide a material3-compatible version (it looks like it would also need to adjust some of the color handling to work with material3 too).

In the meantime, your best bet is probably to adapt the code you need to Material 3 yourself: https://github.com/google/accompanist/tree/main/pager-indicators/src/main/java/com/google/accompanist/pager

alexvanyo avatar Mar 09 '22 22:03 alexvanyo

For anyone trying to get this to work with material3, simply create a new Modifier using the code from PagerTab.kt from the link above and use import androix.compose.material3.TabPosition instead of import androidx.compose.material.TabPosition.

Ironova avatar Apr 04 '22 12:04 Ironova

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 05 '22 03:05 github-actions[bot]

Why was this issue closed as completed? Was it really fixed or was just the bot that closed because nothing happened for 1 month? And, if the latter, does it really make sense to close issues that are stale for 1 month?

leinardi avatar Aug 29 '22 12:08 leinardi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 29 '22 04:09 github-actions[bot]

Please don't close it automatically.

leinardi avatar Sep 29 '22 07:09 leinardi

Add support for this, please. You can't just make this api without full support for actually good-looking material3

therealbluepandabear avatar Oct 14 '22 04:10 therealbluepandabear

For anyone trying to get this to work with material3, simply create a new Modifier using the code from PagerTab.kt from the link above and use import androix.compose.material3.TabPosition instead of import androidx.compose.material.TabPosition.

Bro it doesn't work

therealbluepandabear avatar Oct 14 '22 04:10 therealbluepandabear

For anyone trying to get this to work with material3, simply create a new Modifier using the code from PagerTab.kt from the link above and use import androix.compose.material3.TabPosition instead of import androidx.compose.material.TabPosition.

Bro it doesn't work

"Bro", it sure does work.

Make sure you're using the material3 version of Tab, TabRow and TabRowDefaults.Indicator.

I've just tested it again on latest versions of material3, pager and pager-indicators.

Ironova avatar Oct 14 '22 06:10 Ironova

For anyone trying to get this to work with material3, simply create a new Modifier using the code from PagerTab.kt from the link above and use import androix.compose.material3.TabPosition instead of import androidx.compose.material.TabPosition.

Bro it doesn't work

"Bro", it sure does work.

Make sure you're using the material3 version of Tab, TabRow and TabRowDefaults.Indicator.

I've just tested it again on latest versions of material3, pager and pager-indicators.

Can you send me some example code? 🙂

therealbluepandabear avatar Oct 14 '22 07:10 therealbluepandabear

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 14 '22 03:11 github-actions[bot]

Please don't close it automatically.

Please don't close it automatically.

leinardi avatar Nov 14 '22 07:11 leinardi

Unfortunate that there's still not a material 3 version of pager. This is still broken.

dessalines avatar Dec 22 '22 02:12 dessalines

For anyone trying to get this to work with material3, simply create a new Modifier using the code from PagerTab.kt from the link above and use import androix.compose.material3.TabPosition instead of import androidx.compose.material.TabPosition.

Can you send me some example code? 🙂

This worked as explained above. Here's a sample project using the latest Compose BOM (2022.12.00), Material3, and Accompanist (0.28.0): https://github.com/c5inco/Material3Pager

Unfortunate that there's still not a material 3 version of pager. This is still broken.

FWIW I don't think the Accompanist Pager is meant to be Material-specific. Given the new Pager (its successor available as experimental in 1.4.0) is in Compose Foundation, it's a clear signal this is the case.

The Pager Indicators do take a dependency on Material Tabs, but the APIs called in Material2 are identical in Material3, albeit some references to LocalContentColor and LocalContentAlpha which can easily be substituted for any other colors since they are just used as good defaults for tab colors. Additionally, what is being done in the library to synchronize with tabs can be relatively simple to adapt to other scrollable UIs in Compose.

That is all to say, yes you can get the Accompanist Pager Indicators to work with Material3 Tabs with a copy-paste-replace, and given the new Pager is upstream in Compose Foundation, its unlikely the team will make any further changes to Pager or Pager Indicators in Accompanist.

With that I think we can close this issue.

c5inco avatar Dec 23 '22 10:12 c5inco

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Feb 07 '23 03:02 github-actions[bot]

Please don't close it automatically.

Please don't close it automatically.

Please don't close it automatically.

leinardi avatar Feb 07 '23 08:02 leinardi

Can we have more info on why it was closed as completed?

leinardi avatar Feb 13 '23 09:02 leinardi

Can we have more info on why it was closed as completed?

Because Accompanist's Pager is getting deprecated, Horizontal and Vertical pagers have been added to Compose Foundation and there is a material3 version of the .tabIndicatorOffset modifier which you can use in combination with the TabRow of compose.material3.

Ironova avatar Feb 13 '23 10:02 Ironova

@leinardi what resolution are you expecting for this issue?

c5inco avatar Feb 13 '23 18:02 c5inco

@c5inco closing the issue without a PR link to the M3 version or an explanation on how to migrate from the M2 to the M3 version wasn't what I was expecting.

leinardi avatar Feb 14 '23 10:02 leinardi

Gotcha @leinardi . I believe I provided one approach on how to migrate in the previous comment: https://github.com/google/accompanist/issues/1076#issuecomment-1363805668

It's a little old now, but I don't think Material3 or the new Pager APIs have changed that significantly that it's no longer applicable.

And to my knowledge there are no plans for an M3 version as pager indicators aren't in the Material3 Design spec, which is the criteria for warranting inclusion in the Compose Material library.

c5inco avatar Jul 11 '23 23:07 c5inco