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

Use safe area insets as offset value #1804

Merged
merged 4 commits into from
Sep 14, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[unreleased]

* Fixes empty space between chat's input and a soft keyboard on iOS devices.

* Changed registration process - user connects to the libp2p network directly instead of using registrar. Invitation link format changed. User csr is now saved to database.

* Fixed android stucking on username registration screen introduced in previous alpha.
Expand Down
6 changes: 5 additions & 1 deletion packages/mobile/src/components/Chat/Chat.component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC, useState, useEffect, useRef } from 'react'
import { Keyboard, View, FlatList, TextInput, KeyboardAvoidingView, Platform } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { Appbar } from '../../components/Appbar/Appbar.component'
import { ImagePreviewModal } from '../../components/ImagePreview/ImagePreview.component'
import { Spinner } from '../Spinner/Spinner.component'
Expand Down Expand Up @@ -43,7 +44,10 @@ export const Chat: FC<ChatProps & FileActionsProps> = ({

const messageInputRef = useRef<null | TextInput>(null)

const insets = useSafeAreaInsets()

const defaultPadding = 20

const areFilesUploaded = uploadedFiles && Object.keys(uploadedFiles).length > 0

useEffect(() => {
Expand Down Expand Up @@ -125,7 +129,7 @@ export const Chat: FC<ChatProps & FileActionsProps> = ({
<Appbar title={`#${channel?.name}`} back={handleBackButton} contextMenu={contextMenu} />
<KeyboardAvoidingView
behavior={Platform.select({ ios: 'padding', android: undefined })}
keyboardVerticalOffset={Platform.select({ ios: 60, android: 0 })}
keyboardVerticalOffset={Platform.select({ ios: insets.bottom, android: 0 })}
enabled={Platform.select({ ios: true, android: false })}
style={{
flex: 1,
Expand Down
8 changes: 8 additions & 0 deletions packages/mobile/src/setupTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ jest.mock('socket.io-client', () => ({
// could not be found. Verify that a module by this name is registered in the native binary."
jest.mock('react-native-document-picker', () => { })

jest.mock('react-native-safe-area-context', () => ({
useSafeAreaInsets: () => {
return {
bottom: 0
}
}
}))

export const ioMock = io as jest.Mock

jest.resetAllMocks()