accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[Insets] Scaffold bottomBar cutout is not working

Open Zeliret opened this issue 2 years ago • 9 comments

Hello! I've noticed that if I replace basic Scaffold with a new one from Insets library my cutout shape disappears.

Steps to reproduce Just replace default Scaffold with a new one.

Expected behavior Cutout shape should be applied.

Additional context Screenshot_1642340140 Screenshot_1642340431

Zeliret avatar Jan 16 '22 13:01 Zeliret

Hi Zeliret! For the basic Scaffold that does work (the one that isn't provided by Accompanist), is that a material Scaffold or a material3 scaffold?

alexvanyo avatar Feb 03 '22 01:02 alexvanyo

Hi. It is material.

Best regards, Artem

On Thu, Feb 3, 2022, 02:10 Alex Vanyo @.***> wrote:

Hi Zeliret! For the basic Scaffold that does work (the one that isn't provided by Accompanist), is that a material Scaffold or a material3 scaffold?

— Reply to this email directly, view it on GitHub https://github.com/google/accompanist/issues/958#issuecomment-1028509000, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOFJR7YYSDXAC3U3RLIR3UZHIYZANCNFSM5MCZCZLA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

Zeliret avatar Feb 03 '22 09:02 Zeliret

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 Mar 06 '22 03:03 github-actions[bot]

Still doesn't work. =(

Zeliret avatar May 14 '22 09:05 Zeliret

Seeing this with 0.24.9-beta

@alexvanyo could you check if this could be fixed, please?

When debugging, it seems that LocalFabPlacement yields null in the BottomBar, altough it gets correctly assigned.

brnhffmnn avatar Jun 05 '22 16:06 brnhffmnn

I was able to track down what's happening here:

There ends up being two LocalFabPlacement compositions locals.

One that is defined by androidx.compose.material, here.

And the other that is defined by accompanist/insets-ui.

Unfortunately, both of them are internal, which means that they can't be read by components outside of the respective libraries. In particular, the androidx.compose.material.BottomAppBar is reading its androidx.compose.material.LocalFabPlacement, but only the com.google.accompanist.insets.ui.LocalFabPlacement is being set by the accompanist Scaffold.

The fix for this on the accompanist side would look like duplicating all of BottomBar and its dependencies, so that the right LocalFabPlacement is used. That solution is also what the workaround would be right now for you: fork Scaffold and BottomBar yourself, and ensure your own LocalFabPlacement is being used.

Alternatively the only reason why Scaffold needed to be used was for passing the height of the top app bar to the content padding. If you aren't making use of that, or you can switch to material3, then you won't need to use the accompanist version of Scaffold.

alexvanyo avatar Jun 10 '22 23:06 alexvanyo

I saw that compose supports insets and migrated to it. And now I can use the original scaffold without any problem.

Zeliret avatar Jun 11 '22 06:06 Zeliret

As @Zeliret pointed out, compose foundation supports insets since 1.2.0-alpha03.

This yields visually the same result as with accompanist Scaffold with working FAB cut-out:

import androidx.compose.material.Scaffold
import androidx.compose.foundation.layout.statusBarsPadding

Scaffold(
  modifier = Modifier.statusBarsPadding(),
  // ...
 ) { scaffoldContentPadding ->
  // ...
}

brnhffmnn avatar Jun 14 '22 18:06 brnhffmnn

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 Jul 15 '22 03:07 github-actions[bot]

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 Aug 15 '22 03:08 github-actions[bot]

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 15 '22 04:09 github-actions[bot]

A change was just made to material3 that will include inset support for Scaffold, the BottomNavBar and Fab, so I'm going to close this issue as not planned.

A version of acccompanist/insets-ui for material3 should be unnecessary, as the relevant changes needed have been upstreamed.

alexvanyo avatar Sep 15 '22 15:09 alexvanyo