Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package io.getstream.reactnative.sampleapp

import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
Expand All @@ -17,28 +13,12 @@ class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null)

if (Build.VERSION.SDK_INT >= 35) {
val rootView = findViewById<View>(android.R.id.content)
window.navigationBarColor = Color.TRANSPARENT
window.statusBarColor = Color.TRANSPARENT

val initial = Insets.of(
rootView.paddingLeft,
rootView.paddingTop,
rootView.paddingRight,
rootView.paddingBottom
)

ViewCompat.setOnApplyWindowInsetsListener(rootView) { v, insets ->
val ime = insets.getInsets(WindowInsetsCompat.Type.ime())

v.updatePadding(
left = initial.left,
top = initial.top,
right = initial.right,
bottom = initial.bottom + ime.bottom
)

insets
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
window.isNavigationBarContrastEnforced = false
window.isStatusBarContrastEnforced = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:enforceNavigationBarContrast">false</item>
</style>

</resources>
23 changes: 18 additions & 5 deletions examples/SampleApp/src/components/ChannelDetailProfileSection.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { useMemo } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { useTheme } from 'stream-chat-react-native';

import { ChannelPreviewMutedStatus, useTheme } from 'stream-chat-react-native';

type ChannelDetailProfileSectionProps = {
avatar: React.ReactNode;
muted?: boolean;
subtitle: string;
title: string;
};

export const ChannelDetailProfileSection = React.memo(
({ avatar, subtitle, title }: ChannelDetailProfileSectionProps) => {
({ avatar, muted, subtitle, title }: ChannelDetailProfileSectionProps) => {
const {
theme: { semantics },
} = useTheme();
Expand All @@ -19,9 +21,12 @@ export const ChannelDetailProfileSection = React.memo(
<View style={styles.container}>
{avatar}
<View style={styles.heading}>
<Text style={[styles.title, { color: semantics.textPrimary }]} numberOfLines={2}>
{title}
</Text>
<View style={styles.titleRow}>
<Text style={[styles.title, { color: semantics.textPrimary }]} numberOfLines={2}>
{title}
</Text>
{muted ? <ChannelPreviewMutedStatus /> : null}
</View>
{subtitle ? (
<Text style={[styles.subtitle, { color: semantics.textSecondary }]} numberOfLines={1}>
{subtitle}
Expand Down Expand Up @@ -49,8 +54,16 @@ const useStyles = () =>
gap: 8,
width: '100%',
},
titleRow: {
alignItems: 'center',
flexDirection: 'row',
gap: 4,
justifyContent: 'center',
maxWidth: '100%',
},
title: {
fontSize: 22,
flexShrink: 1,
fontWeight: '600',
lineHeight: 24,
textAlign: 'center',
Expand Down
2 changes: 1 addition & 1 deletion examples/SampleApp/src/screens/ChannelScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({ navigation, route
messageInputFloating={messageInputFloating}
onPressMessage={onPressMessage}
initialScrollToFirstUnreadMessage
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : -300}
keyboardVerticalOffset={0}
messageActions={messageActions}
MessageLocation={MessageLocation}
messageId={messageId}
Expand Down
18 changes: 10 additions & 8 deletions examples/SampleApp/src/screens/GroupChannelDetailsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React, { useCallback, useMemo, useState } from 'react';
import { Pressable, ScrollView, StyleSheet, Switch, Text, View } from 'react-native';

import { SafeAreaView } from 'react-native-safe-area-context';

import { RouteProp, useNavigation } from '@react-navigation/native';

import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import type { ChannelMemberResponse, UserResponse } from 'stream-chat';

import {
ChannelAvatar,
useChannelPreviewDisplayName,
useIsChannelMuted,
useOverlayContext,
useTheme,
Pin,
Expand All @@ -26,9 +33,6 @@ import { GoForward } from '../icons/GoForward';
import { LeaveGroup } from '../icons/LeaveGroup';
import { Mute } from '../icons/Mute';
import { Picture } from '../icons/Picture';

import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import type { ChannelMemberResponse, UserResponse } from 'stream-chat';
import type { StackNavigatorParamList } from '../types';

const MAX_VISIBLE_MEMBERS = 5;
Expand All @@ -55,6 +59,7 @@ export const GroupChannelDetailsScreen: React.FC<GroupChannelDetailsProps> = ({
const {
theme: { semantics },
} = useTheme();
const { muted: channelMuted } = useIsChannelMuted(channel);

const [muted, setMuted] = useState(
chatClient?.mutedChannels.some((mute) => mute.channel?.id === channel?.id),
Expand Down Expand Up @@ -197,6 +202,7 @@ export const GroupChannelDetailsScreen: React.FC<GroupChannelDetailsProps> = ({
<ScrollView contentContainerStyle={styles.scrollContent} style={styles.container}>
<ChannelDetailProfileSection
avatar={<ChannelAvatar channel={channel} size='2xl' />}
muted={channelMuted}
title={displayName}
subtitle={memberStatusText}
/>
Expand Down Expand Up @@ -317,11 +323,7 @@ export const GroupChannelDetailsScreen: React.FC<GroupChannelDetailsProps> = ({
onClose={closeContactDetail}
visible={selectedMember !== null}
/>
<EditGroupBottomSheet
channel={channel}
onClose={closeEditSheet}
visible={editVisible}
/>
<EditGroupBottomSheet channel={channel} onClose={closeEditSheet} visible={editVisible} />
</SafeAreaView>
);
};
Expand Down
19 changes: 15 additions & 4 deletions examples/SampleApp/src/screens/NewDirectMessagingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from 'react';
import { Platform, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
import { SafeAreaView } from 'react-native-safe-area-context';
import {
Expand Down Expand Up @@ -204,9 +204,20 @@ export const NewDirectMessagingScreen: React.FC<NewDirectMessagingScreenProps> =
initChannel();
}, [chatClient, selectedUserIds, selectedUsersLength]);

const onBackPress = useCallback(() => {
reset();

if (!navigation.canGoBack()) {
navigation.reset({ index: 0, routes: [{ name: 'MessagingScreen' }] });
return;
}

navigation.goBack();
}, [navigation, reset]);

const renderUserSearch = ({ inSafeArea }: { inSafeArea: boolean }) => (
<View style={[{ backgroundColor: white }, focusOnSearchInput ? styles.container : undefined]}>
<ScreenHeader inSafeArea={inSafeArea} onBack={reset} titleText='New Chat' />
<ScreenHeader inSafeArea={inSafeArea} onBack={onBackPress} titleText='New Chat' />
<TouchableOpacity
activeOpacity={1}
onPress={() => {
Expand Down Expand Up @@ -341,7 +352,7 @@ export const NewDirectMessagingScreen: React.FC<NewDirectMessagingScreenProps> =
channel={currentChannel.current}
EmptyStateIndicator={EmptyMessagesIndicator}
enforceUniqueReaction
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : -300}
keyboardVerticalOffset={0}
onChangeText={setMessageInputText}
overrideOwnCapabilities={{ sendMessage: true }}
SendButton={NewDirectMessagingSendButton}
Expand Down
15 changes: 13 additions & 2 deletions examples/SampleApp/src/screens/NewGroupChannelAddMemberScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import { FlatList, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
import { Search, useTheme } from 'stream-chat-react-native';

Expand Down Expand Up @@ -79,6 +79,17 @@ export const NewGroupChannelAddMemberScreen: React.FC<Props> = ({ navigation })
const { onChangeSearchText, onFocusInput, removeUser, reset, searchText, selectedUsers } =
useUserSearchContext();

const onBackPress = useCallback(() => {
reset();

if (!navigation.canGoBack()) {
navigation.reset({ index: 0, routes: [{ name: 'MessagingScreen' }] });
return;
}

navigation.goBack();
}, [navigation, reset]);

const onRightArrowPress = () => {
if (selectedUsers.length === 0) {
return;
Expand All @@ -93,7 +104,7 @@ export const NewGroupChannelAddMemberScreen: React.FC<Props> = ({ navigation })
return (
<View style={styles.container}>
<ScreenHeader
onBack={reset}
onBack={onBackPress}
// eslint-disable-next-line react/no-unstable-nested-components
RightContent={() => (
<RightArrowButton disabled={selectedUsers.length === 0} onPress={onRightArrowPress} />
Expand Down
20 changes: 15 additions & 5 deletions examples/SampleApp/src/screens/OneOnOneChannelDetailScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import React, { useCallback, useState } from 'react';
import { ScrollView, StyleSheet, Switch } from 'react-native';
import { ChannelAvatar, Delete, useTheme, Pin, CircleBan } from 'stream-chat-react-native';
import { SafeAreaView } from 'react-native-safe-area-context';

import type { RouteProp } from '@react-navigation/native';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';

import {
ChannelAvatar,
CircleBan,
Delete,
useChannelMuteActive,
Pin,
useTheme,
} from 'stream-chat-react-native';

import { ChannelDetailProfileSection } from '../components/ChannelDetailProfileSection';
import { ConfirmationBottomSheet } from '../components/ConfirmationBottomSheet';
import { ListItem } from '../components/ListItem';
Expand All @@ -13,11 +24,8 @@ import { File } from '../icons/File';
import { GoForward } from '../icons/GoForward';
import { Mute } from '../icons/Mute';
import { Picture } from '../icons/Picture';
import { getUserActivityStatus } from '../utils/getUserActivityStatus';

import type { RouteProp } from '@react-navigation/native';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import type { StackNavigatorParamList } from '../types';
import { getUserActivityStatus } from '../utils/getUserActivityStatus';

type OneOnOneChannelDetailScreenRouteProp = RouteProp<
StackNavigatorParamList,
Expand All @@ -44,6 +52,7 @@ export const OneOnOneChannelDetailScreen: React.FC<Props> = ({
theme: { semantics },
} = useTheme();
const { chatClient } = useAppContext();
const userMuted = useChannelMuteActive(channel);

const [confirmationVisible, setConfirmationVisible] = useState(false);
const [blockUserConfirmationVisible, setBlockUserConfirmationVisible] = useState(false);
Expand Down Expand Up @@ -141,6 +150,7 @@ export const OneOnOneChannelDetailScreen: React.FC<Props> = ({
<ScrollView contentContainerStyle={styles.scrollContent} style={styles.container}>
<ChannelDetailProfileSection
avatar={<ChannelAvatar channel={channel} size='2xl' />}
muted={userMuted}
title={user.name || user.id}
subtitle={activityStatus}
/>
Expand Down
6 changes: 3 additions & 3 deletions examples/SampleApp/src/screens/ThreadScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback } from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { StyleSheet, View } from 'react-native';

import {
AlsoSentToChannelHeaderPressPayload,
Expand Down Expand Up @@ -149,11 +149,11 @@ export const ThreadScreen: React.FC<ThreadScreenProps> = ({
return (
<View style={[styles.container, { backgroundColor: white }]}>
<Channel
audioRecordingEnabled={false}
audioRecordingEnabled={true}
AttachmentPickerSelectionBar={CustomAttachmentPickerSelectionBar}
channel={channel}
enforceUniqueReaction
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : -300}
keyboardVerticalOffset={0}
messageActions={messageActions}
messageInputFloating={messageInputFloating}
MessageLocation={MessageLocation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../../../contexts';
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
import { useAttachmentPickerState, useStableCallback } from '../../../hooks';
import { Camera, FilePickerIcon, PollThumbnail, Recorder } from '../../../icons';
import { Camera, FilePickerIcon, PollThumbnail, VideoIcon } from '../../../icons';
import { primitives } from '../../../theme';
import { CommandSuggestionItem } from '../../AutoCompleteInput/AutoCompleteSuggestionItem';

Expand Down Expand Up @@ -197,7 +197,7 @@ export const AttachmentCameraPicker = (
/>
) : (
<AttachmentPickerGenericContent
Icon={videoOnly ? Recorder : Camera}
Icon={videoOnly ? VideoIcon : Camera}
onPress={openCameraPicker}
height={height}
buttonText={t('Open Camera')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useAttachmentPickerState } from '../../../hooks/useAttachmentPickerStat
import {
Camera,
Picture,
Recorder,
VideoIcon,
FilePickerIcon,
PollThumbnail,
CommandsIcon,
Expand Down Expand Up @@ -121,7 +121,7 @@ export const CameraPickerButton = () => {
/>
{Platform.OS === 'android' ? (
<AttachmentTypePickerButton
Icon={Recorder}
Icon={VideoIcon}
selected={selectedPicker === 'camera-video'}
onPress={onVideoRecorderPickerPress}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('useChannelActionItems', () => {
'destructive',
]);
expect(result.current.map((item) => item.placement)).toEqual([
'both',
'swipe',
'both',
'sheet',
'sheet',
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('getChannelActionItems', () => {

expect(actionItems[0].action).toBe(channelActions.unmuteChannel);
expect(actionItems[0].label).toBe('Unmute Group');
expect(actionItems[0].placement).toBe('both');
expect(actionItems[0].placement).toBe('swipe');

expect(actionItems[1].action).toBe(channelActions.unarchive);
expect(actionItems[1].label).toBe('Unarchive Group');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const buildDefaultChannelActionItems: BuildDefaultChannelActionItems = (
: muteActive
? t('Unmute Group')
: t('Mute Group'),
placement: isDirectChat ? 'sheet' : 'both',
placement: isDirectChat ? 'sheet' : 'swipe',
type: 'standard',
},
];
Expand Down
Loading
Loading