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
Proposal: Merge with react-native-bars project #259
Comments
Hello @zoontek 👋 I understand the motivation to merge these projects (because of native code in Android). But I'm just thinking, that people who wants to control |
It's more the opposite IMHO: when installing Which means if system bars became transparent (not translucent), there's no way to control their content without another lib (here |
Yes @zoontek it makes sense what you are saying! I just was confused about SEO search (obviously name In order to merge projects we need:
Did I miss anything? |
@kirillzyusko I think there's no need for the For the rest, that's it, yeah. Maybe I could experiment on a branch if you are OK with that? |
@zoontek yes, sure, feel free to experiment with it 👍 😊 |
I noticed something: So, I enforce edge-to-edge like this: @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
// set up the edge-to-edge display
final boolean darkContentBars = true;
final Window window = getWindow();
final View view = window.getDecorView();
final WindowInsetsControllerCompat insetsController =
new WindowInsetsControllerCompat(window, view);
WindowCompat.setDecorFitsSystemWindows(window, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
window.clearFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
);
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
insetsController.setAppearanceLightStatusBars(darkContentBars);
insetsController.setAppearanceLightNavigationBars(darkContentBars);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
window.setStatusBarContrastEnforced(false);
window.setNavigationBarContrastEnforced(false);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.setStatusBarColor(Color.TRANSPARENT);
insetsController.setAppearanceLightStatusBars(darkContentBars);
} else {
window.addFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
);
}
} By doing so, this creates a shift that must be handled for each const { height: telegram } = useTelegramTransitions();
const { height: platform } = useReanimatedKeyboardAnimation();
const { bottom: bottomInset } = useSafeAreaInsets();
const height = useDerivedValue(
() => (isTGTransition ? telegram.value : platform.value) - bottomInset,
[isTGTransition, bottomInset]
); In this video, it's not handled on the first screen, but it is on the second: Screen.Recording.2023-12-10.at.14.08.45.mp4To handle it on the first screen, we need an WIP code: 3080d97 |
Hi @zoontek I think you also need to set And I think you are right, current implementation of RNKC has a bug - when I calculate keyboard height I always subtract And you are right, it seems like we don't need to subtract if Let me know what do you think :) |
Just tried it, removing |
Hm, interesting, I thought it should have an impact 🤔 I'll try to test your code tomorrow 👀 |
Hello @zoontek You'll need to change: val diff = Insets.subtract(typesInset, Insets.NONE).let {
Insets.max(it, Insets.NONE)
} Then the result will be (don't pay an attention to blue circle - it's replica of keyboard animation and was part of very early experiments): So my assumption is that we can pass Also as I said earlier similar changes should be reflected in Also you can reach out to me via discord (nickname is |
@kirillzyusko That's it! We can even simplify this to: // We coerce the insets to be >= 0, to make sure we don't use negative insets.
val diff = Insets.max(typesInset, Insets.NONE) I never actually realized that you shouldn't subtract system bars insets in edge-to-edge mode, given the fact that I blindly followed this page of their documentation (which say that edge-to-edge is a prerequisite) and their app examples (here and here). But this makes no sense at all when you draw under the system bars 🤔 Screen.Recording.2023-12-11.at.10.06.21.mp4I'm still in favor of having a proper edge-to-edge layout with fully transparent bars by default (and not really having a choice), as this kind of possibilities will be hard to compose with, given the fact that a user might have one of these 4 config (+ non transparent system bars does not exist on iOS, so this would actually reduce the fragmentation between the 2 platforms 😄):
Anyway, I will reach you on Discord next time, thanks for your help 🙂 |
Hi 👋
First, thanks for your work on this library, this is very much needed in the ecosystem!
I'm currently maintaining
react-native-bars
, a library for fully transparent (and fallback to translucent) system bars. Compared toKeyboardProvider
statusBarTranslucent
andnavigationBarTranslucent
, it provides an android theme that avoid the initial blink (before the React app kicks in) + provides some useful components to handlebarStyle
(similarly as the builtinStatusBar
component).As keyboard handling is super related to system bars, I think it could be great to merge those libs? (I even think that it should enforce fully transparent UI without any choice, exactly like
react-native-bars
or iOS + recommendreact-native-safe-area-context
for dealing with safe areas in a similar way on both OS, but it's my personal opinion 😅)The text was updated successfully, but these errors were encountered: