From 6cec5fce74bbae68ba1ac449a984dfd0e6470bd4 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Tue, 9 Aug 2022 10:27:32 -0300 Subject: [PATCH 1/8] migrate to hooks and fix types --- app/containers/touch.tsx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/containers/touch.tsx diff --git a/app/containers/touch.tsx b/app/containers/touch.tsx new file mode 100644 index 00000000000..190a74a2c04 --- /dev/null +++ b/app/containers/touch.tsx @@ -0,0 +1,29 @@ +import React from 'react'; +import { RectButton, RectButtonProps } from 'react-native-gesture-handler'; + +import { useTheme } from '../theme'; + +export interface ITouchProps extends RectButtonProps { + children: React.ReactNode; + accessibilityLabel?: string; + testID?: string; +} + +const Touch = React.forwardRef(({ children, onPress, underlayColor, ...props }, ref) => { + const { colors } = useTheme(); + + return ( + + {children} + + ); +}); + +export default Touch; From 77d1079a691a1054a2b532020a3c892a9d1cd639 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Tue, 9 Aug 2022 10:30:12 -0300 Subject: [PATCH 2/8] fix import and remove theme prop --- .../ActionSheet/BottomSheetContent.tsx | 4 +- app/containers/ActionSheet/Button.ts | 5 +-- app/containers/ActionSheet/Item.tsx | 7 +-- app/containers/DirectoryItem/index.tsx | 4 +- app/containers/List/ListItem.tsx | 3 +- .../LoginServices/ButtonService.tsx | 5 +-- app/containers/Passcode/Base/Button.tsx | 3 +- app/containers/RoomItem/Touchable.tsx | 5 +-- app/lib/methods/helpers/touch.tsx | 43 ------------------- .../Dropdown/DropdownItem.tsx | 4 +- app/views/DirectoryView/Options.tsx | 11 ++--- app/views/DirectoryView/index.tsx | 4 +- app/views/NewMessageView.tsx | 4 +- app/views/NewServerView/ServerInput/Item.tsx | 4 +- app/views/ProfileView/index.tsx | 3 +- app/views/RoomActionsView/index.tsx | 3 +- app/views/RoomView/List/NavBottomFAB.tsx | 4 +- app/views/RoomView/LoadMore/index.tsx | 4 +- app/views/RoomView/index.tsx | 4 +- app/views/SidebarView/SidebarItem.tsx | 3 +- .../Dropdown/DropdownItem.tsx | 6 +-- 21 files changed, 34 insertions(+), 99 deletions(-) delete mode 100644 app/lib/methods/helpers/touch.tsx diff --git a/app/containers/ActionSheet/BottomSheetContent.tsx b/app/containers/ActionSheet/BottomSheetContent.tsx index f614b8cb5c1..4dc5a7c0c7f 100644 --- a/app/containers/ActionSheet/BottomSheetContent.tsx +++ b/app/containers/ActionSheet/BottomSheetContent.tsx @@ -18,15 +18,13 @@ interface IBottomSheetContentProps { } const BottomSheetContent = React.memo(({ options, hasCancel, hide, children }: IBottomSheetContentProps) => { - const { theme, colors } = useTheme(); + const { colors } = useTheme(); const renderFooter = () => hasCancel ? ( diff --git a/app/containers/Passcode/Base/Button.tsx b/app/containers/Passcode/Base/Button.tsx index 5a0b06d086b..b768fb50cf5 100644 --- a/app/containers/Passcode/Base/Button.tsx +++ b/app/containers/Passcode/Base/Button.tsx @@ -3,7 +3,7 @@ import { Text } from 'react-native'; import styles from './styles'; import { themes } from '../../../lib/constants'; -import Touch from '../../touch'; +import Touch from '../../Touch'; import { CustomIcon, TIconsName } from '../../CustomIcon'; import { useTheme } from '../../../theme'; diff --git a/app/containers/RoomItem/Touchable.tsx b/app/containers/RoomItem/Touchable.tsx index 8bf8cc37b2d..881a24cbf55 100644 --- a/app/containers/RoomItem/Touchable.tsx +++ b/app/containers/RoomItem/Touchable.tsx @@ -14,7 +14,7 @@ import { PanGestureHandlerEventPayload } from 'react-native-gesture-handler'; -import Touch from '../touch'; +import Touch from '../Touch'; import { ACTION_WIDTH, LONG_SWIPE, SMALL_SWIPE } from './styles'; import { LeftActions, RightActions } from './Actions'; import { ITouchableProps } from './interfaces'; diff --git a/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx b/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx index 7f7b3637fa8..5ecdae1aa5e 100644 --- a/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx +++ b/app/views/CannedResponsesListView/Dropdown/DropdownItem.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View } from 'react-native'; import { themes } from '../../../lib/constants'; import { useTheme } from '../../../theme'; -import Touch from '../../../containers/touch'; +import Touch from '../../../containers/Touch'; import { CustomIcon, TIconsName } from '../../../containers/CustomIcon'; import sharedStyles from '../../Styles'; diff --git a/app/views/DirectoryView/Options.tsx b/app/views/DirectoryView/Options.tsx index a545a5c7484..43c84fc0989 100644 --- a/app/views/DirectoryView/Options.tsx +++ b/app/views/DirectoryView/Options.tsx @@ -1,7 +1,7 @@ import React, { PureComponent } from 'react'; import { Animated, Easing, Switch, Text, TouchableWithoutFeedback, View } from 'react-native'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import { CustomIcon, TIconsName } from '../../containers/CustomIcon'; import Check from '../../containers/Check'; import I18n from '../../i18n'; diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index ab58dda05ac..aa72ea5a5f0 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -7,7 +7,7 @@ import { CompositeNavigationProp } from '@react-navigation/native'; import { ChatsStackParamList } from '../../stacks/types'; import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types'; import * as List from '../../containers/List'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import DirectoryItem from '../../containers/DirectoryItem'; import sharedStyles from '../Styles'; import I18n from '../../i18n'; diff --git a/app/views/NewMessageView.tsx b/app/views/NewMessageView.tsx index daedeaa05ff..c8f70ec9384 100644 --- a/app/views/NewMessageView.tsx +++ b/app/views/NewMessageView.tsx @@ -21,7 +21,7 @@ import UserItem from '../containers/UserItem'; import { withTheme } from '../theme'; import { goRoom, TGoRoomItem } from '../lib/methods/helpers/goRoom'; import log, { events, logEvent } from '../lib/methods/helpers/log'; -import Touch from '../containers/touch'; +import Touch from '../containers/Touch'; import sharedStyles from './Styles'; import { NewMessageStackParamList } from '../stacks/types'; import { search } from '../lib/methods'; diff --git a/app/views/NewServerView/ServerInput/Item.tsx b/app/views/NewServerView/ServerInput/Item.tsx index 477309693f4..0352d7ad385 100644 --- a/app/views/NewServerView/ServerInput/Item.tsx +++ b/app/views/NewServerView/ServerInput/Item.tsx @@ -5,7 +5,7 @@ import { BorderlessButton } from 'react-native-gesture-handler'; import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../containers/CustomIcon'; import sharedStyles from '../../Styles'; -import Touch from '../../../containers/touch'; +import Touch from '../../../containers/Touch'; import { TServerHistoryModel } from '../../../definitions/IServerHistory'; import { TSupportedThemes } from '../../../theme'; diff --git a/app/views/ProfileView/index.tsx b/app/views/ProfileView/index.tsx index 04305fadec6..c428a0d4e50 100644 --- a/app/views/ProfileView/index.tsx +++ b/app/views/ProfileView/index.tsx @@ -8,7 +8,7 @@ import { dequal } from 'dequal'; import omit from 'lodash/omit'; import { StackNavigationOptions } from '@react-navigation/stack'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import KeyboardView from '../../containers/KeyboardView'; import sharedStyles from '../Styles'; import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps'; diff --git a/app/views/RoomActionsView/index.tsx b/app/views/RoomActionsView/index.tsx index db39ede3991..df0707a70fd 100644 --- a/app/views/RoomActionsView/index.tsx +++ b/app/views/RoomActionsView/index.tsx @@ -28,7 +28,7 @@ import { ChatsStackParamList } from '../../stacks/types'; import { withTheme } from '../../theme'; import { showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers/info'; import log, { events, logEvent } from '../../lib/methods/helpers/log'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import sharedStyles from '../Styles'; import styles from './styles'; import { ERoomType } from '../../definitions/ERoomType'; diff --git a/app/views/RoomView/List/NavBottomFAB.tsx b/app/views/RoomView/List/NavBottomFAB.tsx index c83912f3e30..695c4ba3843 100644 --- a/app/views/RoomView/List/NavBottomFAB.tsx +++ b/app/views/RoomView/List/NavBottomFAB.tsx @@ -5,7 +5,7 @@ import Animated, { call, cond, greaterOrEq, useCode } from 'react-native-reanima import { themes } from '../../../lib/constants'; import { CustomIcon } from '../../../containers/CustomIcon'; import { useTheme } from '../../../theme'; -import Touch from '../../../containers/touch'; +import Touch from '../../../containers/Touch'; import { hasNotch } from '../../../lib/methods/helpers'; const SCROLL_LIMIT = 200; diff --git a/app/views/RoomView/LoadMore/index.tsx b/app/views/RoomView/LoadMore/index.tsx index b1282cb0c6b..d08d82460dc 100644 --- a/app/views/RoomView/LoadMore/index.tsx +++ b/app/views/RoomView/LoadMore/index.tsx @@ -4,7 +4,7 @@ import { ActivityIndicator, StyleSheet, Text } from 'react-native'; import { MessageTypeLoad, themes } from '../../../lib/constants'; import { MessageType } from '../../../definitions'; import { useTheme } from '../../../theme'; -import Touch from '../../../containers/touch'; +import Touch from '../../../containers/Touch'; import sharedStyles from '../../Styles'; import I18n from '../../../i18n'; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index ed2d6a5af5b..bb3c795cea3 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -9,7 +9,7 @@ import { EdgeInsets, withSafeAreaInsets } from 'react-native-safe-area-context'; import { Subscription } from 'rxjs'; import { getRoutingConfig } from '../../lib/services/restApi'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import { replyBroadcast } from '../../actions/messages'; import database from '../../lib/database'; import Message from '../../containers/message'; diff --git a/app/views/SidebarView/SidebarItem.tsx b/app/views/SidebarView/SidebarItem.tsx index 2a87b7f601f..422d90fe4f5 100644 --- a/app/views/SidebarView/SidebarItem.tsx +++ b/app/views/SidebarView/SidebarItem.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Text, View } from 'react-native'; -import Touch from '../../containers/touch'; +import Touch from '../../containers/Touch'; import { themes } from '../../lib/constants'; import { TSupportedThemes, withTheme } from '../../theme'; import styles from './styles'; diff --git a/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx b/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx index 636dd2ad8a8..95b2a819b48 100644 --- a/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx +++ b/app/views/ThreadMessagesView/Dropdown/DropdownItem.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { useTheme } from '../../../theme'; -import Touch from '../../../containers/touch'; +import Touch from '../../../containers/Touch'; import { CustomIcon, TIconsName } from '../../../containers/CustomIcon'; import sharedStyles from '../../Styles'; From caf781a4a993895fc336b5cf6cec418373ca18d8 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Tue, 9 Aug 2022 11:11:56 -0300 Subject: [PATCH 5/8] wip --- app/containers/{touch.tsx => Touchh.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/containers/{touch.tsx => Touchh.tsx} (100%) diff --git a/app/containers/touch.tsx b/app/containers/Touchh.tsx similarity index 100% rename from app/containers/touch.tsx rename to app/containers/Touchh.tsx From c3333f2b4b881709a04e6b277d9aa770c62a8c73 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Tue, 9 Aug 2022 11:12:19 -0300 Subject: [PATCH 6/8] rename --- app/containers/{Touchh.tsx => Touch.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/containers/{Touchh.tsx => Touch.tsx} (100%) diff --git a/app/containers/Touchh.tsx b/app/containers/Touch.tsx similarity index 100% rename from app/containers/Touchh.tsx rename to app/containers/Touch.tsx From 6283866aa17f223d752d1d17d3c6113c66c2b30b Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Thu, 11 Aug 2022 14:52:45 -0300 Subject: [PATCH 7/8] change to touch --- app/containers/MessageActions/Header.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/containers/MessageActions/Header.tsx b/app/containers/MessageActions/Header.tsx index b96163124c1..1e573dc0716 100644 --- a/app/containers/MessageActions/Header.tsx +++ b/app/containers/MessageActions/Header.tsx @@ -7,10 +7,10 @@ import { CustomIcon } from '../CustomIcon'; import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode'; import CustomEmoji from '../EmojiPicker/CustomEmoji'; import database from '../../lib/database'; -import { Button } from '../ActionSheet'; import { useDimensions } from '../../dimensions'; import sharedStyles from '../../views/Styles'; import { TAnyMessageModel, TFrequentlyUsedEmojiModel } from '../../definitions'; +import Touch from '../Touch'; type TItem = TFrequentlyUsedEmojiModel | string; @@ -75,7 +75,7 @@ const HeaderItem = ({ item, onReaction, server, theme }: THeaderItem) => { const emojiModel = item as TFrequentlyUsedEmojiModel; const emoji = (emojiModel.id ? emojiModel.content : item) as string; return ( - + ); }; const HeaderFooter = ({ onReaction, theme }: THeaderFooter) => ( - + ); const Header = React.memo(({ handleReaction, server, message, isMasterDetail }: IHeader) => { From 8ccaba5a8ed2ae7e595bb375e65694e093ba60b8 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Thu, 11 Aug 2022 14:53:05 -0300 Subject: [PATCH 8/8] remove button and change to touch --- app/containers/ActionSheet/BottomSheetContent.tsx | 6 +++--- app/containers/ActionSheet/Button.ts | 7 ------- app/containers/ActionSheet/Item.tsx | 6 +++--- app/containers/ActionSheet/index.ts | 1 - 4 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 app/containers/ActionSheet/Button.ts diff --git a/app/containers/ActionSheet/BottomSheetContent.tsx b/app/containers/ActionSheet/BottomSheetContent.tsx index 4dc5a7c0c7f..6d82682d429 100644 --- a/app/containers/ActionSheet/BottomSheetContent.tsx +++ b/app/containers/ActionSheet/BottomSheetContent.tsx @@ -2,13 +2,13 @@ import { Text } from 'react-native'; import React from 'react'; import { BottomSheetView, BottomSheetFlatList } from '@gorhom/bottom-sheet'; -import { Button } from './Button'; import I18n from '../../i18n'; import { useTheme } from '../../theme'; import { IActionSheetItem, Item } from './Item'; import { TActionSheetOptionsItem } from './Provider'; import styles from './styles'; import * as List from '../List'; +import Touch from '../Touch'; interface IBottomSheetContentProps { hasCancel?: boolean; @@ -22,13 +22,13 @@ const BottomSheetContent = React.memo(({ options, hasCancel, hide, children }: I const renderFooter = () => hasCancel ? ( - + ) : null; const renderItem = ({ item }: { item: IActionSheetItem['item'] }) => ; diff --git a/app/containers/ActionSheet/Button.ts b/app/containers/ActionSheet/Button.ts deleted file mode 100644 index c0ab659ba28..00000000000 --- a/app/containers/ActionSheet/Button.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TouchableOpacity } from 'react-native'; - -import { isAndroid } from '../../lib/methods/helpers'; -import Touch from '../Touch'; - -// Taken from https://github.com/rgommezz/react-native-scroll-bottom-sheet#touchables -export const Button = isAndroid ? Touch : TouchableOpacity; diff --git a/app/containers/ActionSheet/Item.tsx b/app/containers/ActionSheet/Item.tsx index 3b4b3486695..5268679ae98 100644 --- a/app/containers/ActionSheet/Item.tsx +++ b/app/containers/ActionSheet/Item.tsx @@ -4,9 +4,9 @@ import { Text, View } from 'react-native'; import { themes } from '../../lib/constants'; import { CustomIcon } from '../CustomIcon'; import { useTheme } from '../../theme'; -import { Button } from './Button'; import { TActionSheetOptionsItem } from './Provider'; import styles from './styles'; +import Touch from '../Touch'; export interface IActionSheetItem { item: TActionSheetOptionsItem; @@ -21,7 +21,7 @@ export const Item = React.memo(({ item, hide }: IActionSheetItem) => { }; return ( - + ); }); diff --git a/app/containers/ActionSheet/index.ts b/app/containers/ActionSheet/index.ts index d714d22bbf3..505094109df 100644 --- a/app/containers/ActionSheet/index.ts +++ b/app/containers/ActionSheet/index.ts @@ -1,2 +1 @@ export * from './Provider'; -export * from './Button';