1- import React , { PropsWithChildren , useCallback , useState } from 'react' ;
2- import { Modal , SafeAreaView as RNSafeAreaView , ViewStyle } from 'react-native' ;
3- import {
4- SafeAreaProvider ,
5- SafeAreaView as SafeAreaViewOriginal ,
6- } from 'react-native-safe-area-context' ;
1+ import React , { useCallback , useState } from 'react' ;
2+ import { Modal } from 'react-native' ;
73
84import { GenericPollButton , PollButtonProps } from './Button' ;
95import { PollAnswersList } from './PollAnswersList' ;
@@ -13,22 +9,9 @@ import { PollAllOptions } from './PollOption';
139import { PollResults } from './PollResults' ;
1410
1511import { useChatContext , usePollContext , useTheme , useTranslationContext } from '../../../contexts' ;
12+ import { SafeAreaViewWrapper } from '../../UIComponents/SafeAreaViewWrapper' ;
1613import { usePollState } from '../hooks/usePollState' ;
1714
18- // This is a workaround to support SafeAreaView on React Native 0.81.0+
19- const SafeAreaViewWrapper = ( { children, style } : PropsWithChildren < { style : ViewStyle } > ) => {
20- if ( SafeAreaViewOriginal ) {
21- return (
22- < SafeAreaProvider >
23- < SafeAreaViewOriginal edges = { [ 'bottom' , 'top' ] } style = { style } >
24- { children }
25- </ SafeAreaViewOriginal >
26- </ SafeAreaProvider >
27- ) ;
28- }
29- return < RNSafeAreaView style = { style } > { children } </ RNSafeAreaView > ;
30- } ;
31-
3215export const ViewResultsButton = ( props : PollButtonProps ) => {
3316 const { t } = useTranslationContext ( ) ;
3417 const { message, poll } = usePollContext ( ) ;
@@ -59,12 +42,10 @@ export const ViewResultsButton = (props: PollButtonProps) => {
5942 < GenericPollButton onPress = { onPressHandler } title = { t ( 'View Results' ) } />
6043 { showResults ? (
6144 < Modal animationType = 'slide' onRequestClose = { onRequestClose } visible = { showResults } >
62- < SafeAreaProvider >
63- < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
64- < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Results' ) } />
65- < PollResults message = { message } poll = { poll } />
66- </ SafeAreaViewWrapper >
67- </ SafeAreaProvider >
45+ < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
46+ < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Results' ) } />
47+ < PollResults message = { message } poll = { poll } />
48+ </ SafeAreaViewWrapper >
6849 </ Modal >
6950 ) : null }
7051 </ >
@@ -107,12 +88,10 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
10788 ) : null }
10889 { showAllOptions ? (
10990 < Modal animationType = 'slide' onRequestClose = { onRequestClose } visible = { showAllOptions } >
110- < SafeAreaProvider >
111- < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
112- < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Options' ) } />
113- < PollAllOptions message = { message } poll = { poll } />
114- </ SafeAreaViewWrapper >
115- </ SafeAreaProvider >
91+ < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
92+ < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Options' ) } />
93+ < PollAllOptions message = { message } poll = { poll } />
94+ </ SafeAreaViewWrapper >
11695 </ Modal >
11796 ) : null }
11897 </ >
@@ -155,12 +134,10 @@ export const ShowAllCommentsButton = (props: PollButtonProps) => {
155134 ) : null }
156135 { showAnswers ? (
157136 < Modal animationType = 'slide' onRequestClose = { onRequestClose } visible = { showAnswers } >
158- < SafeAreaProvider >
159- < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
160- < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Comments' ) } />
161- < PollAnswersList message = { message } poll = { poll } />
162- </ SafeAreaViewWrapper >
163- </ SafeAreaProvider >
137+ < SafeAreaViewWrapper style = { { backgroundColor : white , flex : 1 } } >
138+ < PollModalHeader onPress = { onRequestClose } title = { t ( 'Poll Comments' ) } />
139+ < PollAnswersList message = { message } poll = { poll } />
140+ </ SafeAreaViewWrapper >
164141 </ Modal >
165142 ) : null }
166143 </ >
0 commit comments