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

native: reduce space within/between chat messages, fix keyboard offset in thread view #3606

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/ui/src/components/Channel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { UploadInfo } from '@tloncorp/shared/dist/api';
import * as db from '@tloncorp/shared/dist/db';
import { JSONContent, Story } from '@tloncorp/shared/dist/urbit';
import { useCallback, useMemo, useState } from 'react';
import { KeyboardAvoidingView, Platform } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { AnimatePresence } from 'tamagui';

Expand All @@ -31,6 +30,7 @@ import { FloatingActionButton } from '../FloatingActionButton';
import { GalleryPost } from '../GalleryPost';
import { GroupPreviewSheet } from '../GroupPreviewSheet';
import { Icon } from '../Icon';
import KeyboardAvoidingView from '../KeyboardAvoidingView';
import { MessageInput } from '../MessageInput';
import { NotebookPost } from '../NotebookPost';
import { ChannelFooter } from './ChannelFooter';
Expand Down Expand Up @@ -199,13 +199,7 @@ export function Channel({
showSpinner={isLoadingPosts}
showMenuButton={!isChatChannel}
/>
<KeyboardAvoidingView
behavior={
Platform.OS === 'ios' ? 'padding' : 'position'
}
style={{ flex: 1 }}
contentContainerStyle={{ flex: 1 }}
>
<KeyboardAvoidingView>
<YStack alignItems="center" flex={1}>
<AnimatePresence>
{showBigInput ? (
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/ChatMessage/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ const ChatMessage = ({
<YStack
onLongPress={handleLongPress}
key={post.id}
gap="$l"
paddingVertical="$m"
gap="$s"
paddingVertical="$xs"
paddingRight="$l"
>
{showAuthor ? (
<View paddingLeft="$l">
<View paddingLeft="$l" paddingTop="$s">
<AuthorRow
author={post.author}
authorId={post.authorId}
Expand Down
22 changes: 22 additions & 0 deletions packages/ui/src/components/KeyboardAvoidingView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Platform } from 'expo-modules-core';
import { ReactNode } from 'react';
import {
KeyboardAvoidingViewProps,
KeyboardAvoidingView as RNKeyboardAvoidingView,
} from 'react-native';

export default function KeyboardAvoidingView({
children,
...props
}: { children: ReactNode } & KeyboardAvoidingViewProps) {
return (
<RNKeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'position'}
style={{ flex: 1 }}
contentContainerStyle={{ flex: 1 }}
{...props}
>
{children}
</RNKeyboardAvoidingView>
);
}
56 changes: 25 additions & 31 deletions packages/ui/src/components/PostScreenView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type * as db from '@tloncorp/shared/dist/db';
import * as urbit from '@tloncorp/shared/dist/urbit';
import { Story } from '@tloncorp/shared/dist/urbit';
import { useMemo, useState } from 'react';
import { KeyboardAvoidingView, Platform } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { CalmProvider, CalmState, ContactsProvider } from '../contexts';
Expand All @@ -18,6 +17,7 @@ import UploadedImagePreview from './Channel/UploadedImagePreview';
import { ChatMessage } from './ChatMessage';
import { NotebookDetailView } from './DetailView';
import GalleryDetailView from './DetailView/GalleryDetailView';
import KeyboardAvoidingView from './KeyboardAvoidingView';
import { MessageInput } from './MessageInput';

export function PostScreenView({
Expand Down Expand Up @@ -79,7 +79,11 @@ export function PostScreenView({
<CalmProvider calmSettings={calmSettings}>
<ContactsProvider contacts={contacts}>
<ReferencesProvider>
<View backgroundColor="$background" flex={1}>
<View
paddingBottom={isChatChannel ? bottom : 'unset'}
backgroundColor="$background"
flex={1}
>
<YStack flex={1} backgroundColor={'$background'}>
<ChannelHeader
channel={channel}
Expand All @@ -93,12 +97,7 @@ export function PostScreenView({
currentUserId={currentUserId}
mode={headerMode}
/>
<KeyboardAvoidingView
//TODO: Standardize this component, account for tab bar in a better way
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
// keyboardVerticalOffset={70}
style={{ flex: 1 }}
>
<KeyboardAvoidingView>
{parentPost && channel.type === 'gallery' && (
<GalleryDetailView
post={parentPost}
Expand Down Expand Up @@ -144,7 +143,7 @@ export function PostScreenView({
posts &&
channel &&
isChatChannel && (
<View paddingBottom={bottom} flex={1}>
<View flex={1}>
<Scroller
inverted
renderItem={ChatMessage}
Expand All @@ -161,28 +160,23 @@ export function PostScreenView({
</View>
)
)}
{negotiationMatch && !editingPost && channel && canWrite && (
<View
position={isChatChannel ? undefined : 'absolute'}
backgroundColor="$background"
bottom={bottom}
width="100%"
>
{isChatChannel ? (
<MessageInput
shouldBlur={inputShouldBlur}
setShouldBlur={setInputShouldBlur}
send={sendReply}
channelId={channel.id}
uploadInfo={uploadInfo}
groupMembers={groupMembers}
storeDraft={storeDraft}
clearDraft={clearDraft}
getDraft={getDraft}
/>
) : null}
</View>
)}
{negotiationMatch &&
!editingPost &&
channel &&
canWrite &&
isChatChannel && (
<MessageInput
shouldBlur={inputShouldBlur}
setShouldBlur={setInputShouldBlur}
send={sendReply}
channelId={channel.id}
uploadInfo={uploadInfo}
groupMembers={groupMembers}
storeDraft={storeDraft}
clearDraft={clearDraft}
getDraft={getDraft}
/>
)}
{!negotiationMatch && channel && canWrite && (
<View
position={isChatChannel ? undefined : 'absolute'}
Expand Down