Skip to content

Commit c923ee5

Browse files
committed
feat: implement poll input dialog design
1 parent 198b31d commit c923ee5

File tree

1 file changed

+106
-67
lines changed

1 file changed

+106
-67
lines changed
Lines changed: 106 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import React, { useState } from 'react';
1+
import React, { useMemo, useState } from 'react';
22
import {
33
KeyboardAvoidingView,
44
Modal,
55
Platform,
6-
Pressable,
76
StyleSheet,
87
Text,
98
TextInput,
@@ -14,6 +13,8 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
1413
import Animated, { LinearTransition, ZoomIn } from 'react-native-reanimated';
1514

1615
import { useTheme, useTranslationContext } from '../../../contexts';
16+
import { primitives } from '../../../theme';
17+
import { Button } from '../../ui';
1718

1819
export type PollInputDialogProps = {
1920
closeDialog: () => void;
@@ -35,20 +36,15 @@ export const PollInputDialog = ({
3536

3637
const {
3738
theme: {
38-
colors: { accent_dark_blue, black, white },
39+
semantics,
3940
poll: {
40-
inputDialog: {
41-
button,
42-
buttonContainer,
43-
container,
44-
input,
45-
title: titleStyle,
46-
transparentContainer,
47-
},
41+
inputDialog: { buttonContainer, container, input, title: titleStyle, transparentContainer },
4842
},
4943
},
5044
} = useTheme();
5145

46+
const styles = useStyles();
47+
5248
return (
5349
<Modal animationType='fade' onRequestClose={closeDialog} transparent={true} visible={visible}>
5450
<GestureHandlerRootView style={styles.modalRoot}>
@@ -59,36 +55,59 @@ export const PollInputDialog = ({
5955
<Animated.View
6056
entering={ZoomIn.duration(200)}
6157
layout={LinearTransition.duration(200)}
62-
style={[styles.container, { backgroundColor: white }, container]}
58+
style={[styles.container, container]}
6359
>
64-
<Text style={[styles.title, { color: black }, titleStyle]}>{title}</Text>
65-
<TextInput
66-
autoFocus={true}
67-
onChangeText={setDialogInput}
68-
placeholder={t('Ask a question')}
69-
style={[styles.input, { color: black }, input]}
70-
value={dialogInput}
71-
/>
60+
<View style={styles.inputContainer}>
61+
<Text style={[styles.title, titleStyle]}>{title}</Text>
62+
<TextInput
63+
autoFocus={true}
64+
onChangeText={setDialogInput}
65+
placeholder={t('Ask a question')}
66+
placeholderTextColor={semantics.inputTextPlaceholder}
67+
style={[styles.input, input]}
68+
value={dialogInput}
69+
/>
70+
</View>
7271
<View style={[styles.buttonContainer, buttonContainer]}>
73-
<Pressable
72+
<Button
73+
variant={'secondary'}
74+
type={'ghost'}
75+
label={t('Cancel')}
76+
size='md'
7477
onPress={closeDialog}
75-
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1 })}
76-
>
77-
<Text style={[styles.button, { color: accent_dark_blue }, button]}>
78-
{t('Cancel')}
79-
</Text>
80-
</Pressable>
81-
<Pressable
78+
style={styles.button}
79+
/>
80+
{/*<Pressable*/}
81+
{/* onPress={closeDialog}*/}
82+
{/* style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1 })}*/}
83+
{/*>*/}
84+
{/* <Text style={[styles.button, { color: accent_dark_blue }, button]}>*/}
85+
{/* {t('Cancel')}*/}
86+
{/* </Text>*/}
87+
{/*</Pressable>*/}
88+
<Button
89+
variant={'secondary'}
90+
type={'solid'}
91+
label={t('Send')}
92+
size='md'
8293
onPress={() => {
8394
onSubmit(dialogInput);
8495
closeDialog();
8596
}}
86-
style={({ pressed }) => ({ marginLeft: 32, opacity: pressed ? 0.5 : 1 })}
87-
>
88-
<Text style={[styles.button, { color: accent_dark_blue }, button]}>
89-
{t('SEND')}
90-
</Text>
91-
</Pressable>
97+
style={styles.button}
98+
disabled={!dialogInput}
99+
/>
100+
{/*<Pressable*/}
101+
{/* onPress={() => {*/}
102+
{/* onSubmit(dialogInput);*/}
103+
{/* closeDialog();*/}
104+
{/* }}*/}
105+
{/* style={({ pressed }) => ({ marginLeft: 32, opacity: pressed ? 0.5 : 1 })}*/}
106+
{/*>*/}
107+
{/* <Text style={[styles.button, { color: accent_dark_blue }, button]}>*/}
108+
{/* {t('SEND')}*/}
109+
{/* </Text>*/}
110+
{/*</Pressable>*/}
92111
</View>
93112
</Animated.View>
94113
</KeyboardAvoidingView>
@@ -97,36 +116,56 @@ export const PollInputDialog = ({
97116
);
98117
};
99118

100-
const styles = StyleSheet.create({
101-
button: { fontSize: 16, fontWeight: '500' },
102-
buttonContainer: { flexDirection: 'row', justifyContent: 'flex-end', marginTop: 52 },
103-
container: {
104-
backgroundColor: 'white',
105-
borderRadius: 16,
106-
paddingBottom: 20,
107-
paddingHorizontal: 16,
108-
paddingTop: 32,
109-
width: '80%',
110-
},
111-
modalRoot: {
112-
flex: 1,
113-
},
114-
input: {
115-
alignItems: 'center',
116-
borderColor: 'gray',
117-
borderRadius: 18,
118-
borderWidth: 1,
119-
fontSize: 16,
120-
height: 36,
121-
marginTop: 16,
122-
padding: 0,
123-
paddingHorizontal: 16,
124-
},
125-
title: { fontSize: 17, fontWeight: '500', lineHeight: 20 },
126-
transparentContainer: {
127-
alignItems: 'center',
128-
backgroundColor: 'rgba(0, 0, 0, 0.4)',
129-
flex: 1,
130-
justifyContent: 'center',
131-
},
132-
});
119+
const useStyles = () => {
120+
const {
121+
theme: {
122+
semantics,
123+
poll: {
124+
inputDialog: { button },
125+
},
126+
},
127+
} = useTheme();
128+
return useMemo(
129+
() =>
130+
StyleSheet.create({
131+
button: { flex: 1, width: undefined, ...button },
132+
buttonContainer: { flexDirection: 'row', gap: primitives.spacingXs },
133+
container: {
134+
backgroundColor: semantics.backgroundCoreElevation1,
135+
borderRadius: primitives.radiusXl,
136+
paddingBottom: primitives.spacingXl,
137+
paddingHorizontal: primitives.spacingXl,
138+
paddingTop: primitives.spacing2xl,
139+
gap: primitives.spacing2xl,
140+
width: 304,
141+
},
142+
modalRoot: {
143+
flex: 1,
144+
},
145+
inputContainer: {
146+
gap: primitives.spacingXs,
147+
},
148+
input: {
149+
alignItems: 'center',
150+
borderColor: semantics.borderCoreDefault,
151+
borderRadius: primitives.radiusMd,
152+
borderWidth: 1,
153+
fontSize: primitives.typographyFontSizeMd,
154+
padding: primitives.spacingSm,
155+
},
156+
title: {
157+
color: semantics.textPrimary,
158+
fontSize: primitives.typographyFontSizeMd,
159+
fontWeight: primitives.typographyFontWeightMedium,
160+
lineHeight: primitives.typographyLineHeightNormal,
161+
},
162+
transparentContainer: {
163+
alignItems: 'center',
164+
backgroundColor: 'rgba(0, 0, 0, 0.4)',
165+
flex: 1,
166+
justifyContent: 'center',
167+
},
168+
}),
169+
[button, semantics],
170+
);
171+
};

0 commit comments

Comments
 (0)