Skip to content
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

Statusbar color changes to black #2522

Closed
HenrikZabel opened this issue Aug 28, 2024 · 2 comments · Fixed by #2538
Closed

Statusbar color changes to black #2522

HenrikZabel opened this issue Aug 28, 2024 · 2 comments · Fixed by #2538

Comments

@HenrikZabel
Copy link

HenrikZabel commented Aug 28, 2024

Issue Description

When navigating to a screen with the GiftedChat component following is happening:

untitled.webm

Steps to Reproduce / Code Snippets

https://github.com/FaridSafi/react-native-gifted-chat?tab=readme-ov-file#example

I've used the official example

Expected Results

Not changing the statusbar color to black

Additional Information

  • Nodejs version: v21.5.0
  • React version: 18.2.0
  • React Native version: 0.74.3
  • react-native-gifted-chat version: ^2.6.0
  • Platform(s) (iOS, Android, or both?): Android (Couldn't test iOS)
  • TypeScript version: ~5.3.3

I am using Expo with the expo router.

// app/(main)/_layout.tsx
import { color } from '@/constants/Colors';
import { Stack } from 'expo-router';
import React from 'react';
import { Text, View } from 'react-native';

export default function AppLayout() {
  return (
    <Stack
      screenOptions={{
        headerStyle: {
          backgroundColor: color.white,
        },
        headerShadowVisible: false,
      }}>
      <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
      <Stack.Screen
        name="chat"
        options={{
          title: '',
          headerBackTitleVisible: false,
          headerTitle: () => (
            <View
              style={{
                flexDirection: 'row',
                width: 220,
                alignItems: 'center',
                gap: 10,
                paddingBottom: 4,
              }}>
              <View
                style={{
                  width: 40,
                  height: 40,
                  borderRadius: 20,
                  backgroundColor: color.gray,
                }}
              />
              <Text style={{ fontSize: 16, fontWeight: '500' }}>@henrik</Text>
            </View>
          ),
        }}
      />
    </Stack>
  );
}
// app/(main)/chat.tsx
import React, { useCallback, useEffect, useState } from 'react';
import { GiftedChat, IMessage } from 'react-native-gifted-chat';

export default function ChatScreen() {
  const [messages, setMessages] = useState<IMessage[]>([]);

  useEffect(() => {
    setMessages([
      {
        _id: 1,
        text: 'Hello developer',
        createdAt: new Date(),
        user: {
          _id: 2,
          name: 'React Native',
          avatar: 'https://placeimg.com/140/140/any',
        },
      },
    ]);
  }, []);

  const onSend = useCallback((messages: IMessage[] = []) => {
    setMessages(previousMessages =>
      GiftedChat.append(previousMessages, messages),
    );
  }, []);

  return (
    <GiftedChat
      messages={messages}
      onSend={messages => onSend(messages)}
      user={{
        _id: 1,
      }}
    />
  );
}
@Inzenith
Copy link

@HenrikZabel Hi, I had this issue too. You have to edit "react-native-gifted-chat/lib/GiftedChat.js" and add "{isStatusBarTranslucentAndroid:true}" prop to "useAnimatedKeyboard()" command. You can use patch-package and patch this file.

@pnthach95
Copy link
Contributor

@HenrikZabel Hi, I had this issue too. You have to edit "react-native-gifted-chat/lib/GiftedChat.js" and add "{isStatusBarTranslucentAndroid:true}" prop to "useAnimatedKeyboard()" command. You can use patch-package and patch this file.

Thank you, it worked. And if you enable edge to edge mode, you have to wait for this PR software-mansion/react-native-reanimated#6431 to be merged and released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants