Skip to content
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
39 changes: 9 additions & 30 deletions package/src/components/MessageInput/MessageComposer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useMemo } from 'react';
import { Modal, StyleSheet, View } from 'react-native';
import { StyleSheet, View } from 'react-native';

import { GestureHandlerRootView } from 'react-native-gesture-handler';
import Animated, {
Extrapolation,
interpolate,
Expand Down Expand Up @@ -52,9 +51,9 @@ import { MessageInputHeightState } from '../../state-store/message-input-height-
import { primitives } from '../../theme';
import { transitions } from '../../utils/animations/transitions';
import { type TextInputOverrideComponent } from '../AutoCompleteInput/AutoCompleteInput';
import { PollModal } from '../Poll/components/PollModal';
import { CreatePoll } from '../Poll/CreatePollContent';
import { PortalWhileClosingView } from '../UIComponents/PortalWhileClosingView';
import { SafeAreaViewWrapper } from '../UIComponents/SafeAreaViewWrapper';

const useStyles = () => {
const {
Expand All @@ -67,16 +66,6 @@ const useStyles = () => {
flexShrink: 1,
minWidth: 0,
},
pollModalWrapper: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
backgroundColor: semantics.backgroundCoreElevation1,
},
pollSafeArea: {
flex: 1,
backgroundColor: semantics.backgroundCoreElevation1,
},
container: {
alignItems: 'center',
flexDirection: 'row',
Expand Down Expand Up @@ -457,23 +446,13 @@ const MessageComposerWithContext = (props: MessageComposerPropsWithContext) => {
</Animated.View>

{showPollCreationDialog ? (
<View style={styles.pollModalWrapper}>
<Modal
animationType='slide'
onRequestClose={closePollCreationDialog}
visible={showPollCreationDialog}
>
<GestureHandlerRootView style={styles.pollSafeArea}>
<SafeAreaViewWrapper style={styles.pollSafeArea}>
<CreatePoll
closePollCreationDialog={closePollCreationDialog}
createPollOptionGap={createPollOptionGap}
sendMessage={sendMessage}
/>
</SafeAreaViewWrapper>
</GestureHandlerRootView>
</Modal>
</View>
<PollModal onRequestClose={closePollCreationDialog} visible={showPollCreationDialog}>
<CreatePoll
closePollCreationDialog={closePollCreationDialog}
createPollOptionGap={createPollOptionGap}
sendMessage={sendMessage}
/>
</PollModal>
) : null}
</MicPositionProvider>
);
Expand Down
17 changes: 12 additions & 5 deletions package/src/components/Poll/components/CreatePollHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyleSheet, Text, View } from 'react-native';
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
import { Check, IconProps } from '../../../icons';
import { ArrowLeft } from '../../../icons/arrow-left';
import { Cross } from '../../../icons/xmark-1';
import { primitives } from '../../../theme';
import { Button } from '../../ui';
import { useCanCreatePoll } from '../hooks/useCanCreatePoll';
Expand Down Expand Up @@ -43,9 +43,16 @@ export const CreatePollHeader = ({

const renderSendPollIcon = useCallback(
(props: IconProps) => {
return <Check {...props} height={18} stroke={semantics.textOnAccent} width={18} />;
return (
<Check
{...props}
height={18}
stroke={canCreatePoll ? semantics.textOnAccent : semantics.textDisabled}
width={18}
/>
);
},
[semantics.textOnAccent],
[canCreatePoll, semantics.textOnAccent, semantics.textDisabled],
);

return (
Expand All @@ -54,9 +61,9 @@ export const CreatePollHeader = ({
accessibilityLabelKey='a11y/Close poll creation'
variant='secondary'
onPress={onBackPressHandler}
type='ghost'
type='outline'
size='md'
LeadingIcon={ArrowLeft}
LeadingIcon={Cross}
iconOnly
/>

Expand Down
52 changes: 14 additions & 38 deletions package/src/components/Poll/components/PollButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { useCallback, useMemo } from 'react';
import { Modal, StyleSheet, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { StyleSheet, View } from 'react-native';

import { GenericPollButton, PollButtonProps } from './Button';
import { PollAnswersList } from './PollAnswersList';
import { PollInputDialog } from './PollInputDialog';
import { PollModal } from './PollModal';
import { PollModalHeader } from './PollModalHeader';
import { PollAllOptions } from './PollOption';
import { PollResults } from './PollResults';

import { useChatContext, usePollContext, useTheme, useTranslationContext } from '../../../contexts';
import { primitives } from '../../../theme';
import { defaultPollOptionCount } from '../../../utils/constants';
import { SafeAreaViewWrapper } from '../../UIComponents/SafeAreaViewWrapper';
import {
useAddCommentOpen,
useAllCommentsOpen,
Expand Down Expand Up @@ -51,14 +50,10 @@ export const ViewResultsButton = (props: PollButtonProps) => {
type='outline'
/>
{showResults ? (
<Modal animationType='slide' onRequestClose={closeViewResults} visible={showResults}>
<GestureHandlerRootView style={styles.modalRoot}>
<SafeAreaViewWrapper style={styles.safeArea}>
<PollModalHeader onPress={closeViewResults} title={t('Poll Results')} />
<PollResults message={message} poll={poll} />
</SafeAreaViewWrapper>
</GestureHandlerRootView>
</Modal>
<PollModal onRequestClose={closeViewResults} visible={showResults}>
<PollModalHeader onPress={closeViewResults} title={t('Poll Results')} />
<PollResults message={message} poll={poll} />
</PollModal>
) : null}
</>
);
Expand All @@ -81,8 +76,6 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
openAllOptions();
}, [message, onPress, openAllOptions, poll]);

const styles = useStyles();

return (
<>
{options && options.length > defaultPollOptionCount ? (
Expand All @@ -92,14 +85,10 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
/>
) : null}
{showAllOptions ? (
<Modal animationType='slide' onRequestClose={closeAllOptions} visible={showAllOptions}>
<GestureHandlerRootView style={styles.modalRoot}>
<SafeAreaViewWrapper style={styles.safeArea}>
<PollModalHeader onPress={closeAllOptions} title={t('Poll Options')} />
<PollAllOptions message={message} poll={poll} />
</SafeAreaViewWrapper>
</GestureHandlerRootView>
</Modal>
<PollModal onRequestClose={closeAllOptions} visible={showAllOptions}>
<PollModalHeader onPress={closeAllOptions} title={t('Poll Options')} />
<PollAllOptions message={message} poll={poll} />
</PollModal>
) : null}
</>
);
Expand All @@ -122,8 +111,6 @@ export const ShowAllCommentsButton = (props: PollButtonProps) => {
openAllComments();
}, [message, onPress, openAllComments, poll]);

const styles = useStyles();

return (
<>
{answersCount && answersCount > 0 ? (
Expand All @@ -133,14 +120,10 @@ export const ShowAllCommentsButton = (props: PollButtonProps) => {
/>
) : null}
{showAnswers ? (
<Modal animationType='slide' onRequestClose={closeAllComments} visible={showAnswers}>
<GestureHandlerRootView style={styles.modalRoot}>
<SafeAreaViewWrapper style={styles.safeArea}>
<PollModalHeader onPress={closeAllComments} title={t('Poll Comments')} />
<PollAnswersList message={message} poll={poll} />
</SafeAreaViewWrapper>
</GestureHandlerRootView>
</Modal>
<PollModal onRequestClose={closeAllComments} visible={showAnswers}>
<PollModalHeader onPress={closeAllComments} title={t('Poll Comments')} />
<PollAnswersList message={message} poll={poll} />
</PollModal>
) : null}
</>
);
Expand Down Expand Up @@ -254,9 +237,6 @@ const useStyles = () => {
return useMemo(() => {
return StyleSheet.create({
buttonsContainer: { gap: primitives.spacingXs },
modalRoot: {
flex: 1,
},
endVoteButton: {
borderColor: isPollCreatedByClient
? semantics.chatBorderOnChatOutgoing
Expand All @@ -267,10 +247,6 @@ const useStyles = () => {
? semantics.chatBorderOnChatOutgoing
: semantics.chatBorderOnChatIncoming,
},
safeArea: {
backgroundColor: semantics.backgroundCoreElevation1,
flex: 1,
},
});
}, [semantics, isPollCreatedByClient]);
};
24 changes: 12 additions & 12 deletions package/src/components/Poll/components/PollInputDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,26 @@ export const PollInputDialog = ({
/>
</View>
<View style={[styles.buttonContainer, buttonContainer]}>
<Button
variant={'secondary'}
type={'ghost'}
label={t('Cancel')}
size='md'
onPress={closeDialog}
style={styles.button}
/>
<Button
variant={'primary'}
type={'solid'}
label={t('Send')}
size='md'
size='lg'
onPress={() => {
onSubmit(dialogInput);
closeDialog();
}}
style={styles.button}
disabled={!dialogInput}
/>
<Button
variant={'secondary'}
type={'outline'}
label={t('Cancel')}
size='lg'
onPress={closeDialog}
style={styles.button}
/>
</View>
</Animated.View>
</KeyboardAvoidingView>
Expand All @@ -112,8 +112,8 @@ const useStyles = () => {
return useMemo(
() =>
StyleSheet.create({
button: { flex: 1, width: undefined, ...button },
buttonContainer: { flexDirection: 'row', gap: primitives.spacingXs },
button: { width: undefined, ...button },
buttonContainer: { gap: primitives.spacingXs },
container: {
backgroundColor: semantics.backgroundCoreElevation1,
borderRadius: primitives.radiusXl,
Expand All @@ -132,7 +132,7 @@ const useStyles = () => {
input: {
alignItems: 'center',
borderColor: semantics.borderUtilityActive,
borderRadius: primitives.radiusMd,
borderRadius: primitives.radiusLg,
borderWidth: 1,
fontSize: primitives.typographyFontSizeMd,
padding: primitives.spacingSm,
Expand Down
55 changes: 55 additions & 0 deletions package/src/components/Poll/components/PollModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { PropsWithChildren, useMemo } from 'react';
import { Modal, ModalProps, StyleSheet } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

import { useTheme } from '../../../contexts';
import { SafeAreaViewWrapper } from '../../UIComponents/SafeAreaViewWrapper';

export type PollModalProps = PropsWithChildren<{
animationType?: ModalProps['animationType'];
onRequestClose?: () => void;
visible?: boolean;
}>;

export const PollModal = ({
animationType = 'slide',
children,
onRequestClose,
visible,
}: PollModalProps) => {
const styles = useStyles();

return (
<Modal
animationType={animationType}
navigationBarTranslucent
onRequestClose={onRequestClose}
presentationStyle='pageSheet'
statusBarTranslucent
visible={visible}
>
<GestureHandlerRootView style={styles.root}>
<SafeAreaViewWrapper style={styles.safeArea}>{children}</SafeAreaViewWrapper>
</GestureHandlerRootView>
</Modal>
);
};

const useStyles = () => {
const {
theme: { semantics },
} = useTheme();
return useMemo(
() =>
StyleSheet.create({
root: {
flex: 1,
},
safeArea: {
flex: 1,
backgroundColor: semantics.backgroundCoreElevation1,
},
}),
[semantics],
);
};
6 changes: 3 additions & 3 deletions package/src/components/Poll/components/PollModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { useTheme } from '../../../contexts';
import { ArrowLeft } from '../../../icons/arrow-left';
import { Cross } from '../../../icons/xmark-1';
import { primitives } from '../../../theme';
import { Button } from '../../ui';

Expand All @@ -27,10 +27,10 @@ export const PollModalHeader = ({ onPress, title }: PollModalHeaderProps) => {
<Button
accessibilityLabelKey='a11y/Close poll'
variant='secondary'
type='ghost'
type='outline'
size='md'
iconOnly
LeadingIcon={ArrowLeft}
LeadingIcon={Cross}
onPress={onPress}
testID='poll-results-close-button'
/>
Expand Down
Loading
Loading