Skip to content

Commit 4d1aa5e

Browse files
chore(dialog): used text button in basic dialog
1 parent d9b1060 commit 4d1aa5e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/dialogs/basic-dialog/BasicDialog.component.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React, {forwardRef, type ReactNode} from 'react';
2-
import {Text, View, TouchableOpacity, type StyleProp, type TextStyle, type ViewProps} from 'react-native';
2+
import {Text, View, type StyleProp, type TextStyle, type ViewProps} from 'react-native';
33

44
import {styles} from './basic-dialog.styles';
55
import {useTheme} from '../../theme/useTheme.hook';
66
import {Dialog, type DialogRef} from '../dialog/Dialog.component';
77
import {useTypography} from '../../typography/useTypography.component';
8+
import {TextButton} from '../../buttons/common-buttons/text-button/TextButton.component';
89

910
export interface BasicDialogProps extends ViewProps {
1011
append?: ReactNode;
@@ -43,26 +44,23 @@ export const BasicDialog = forwardRef<DialogRef, BasicDialogProps>(
4344
},
4445
ref
4546
) => {
46-
const {bodyMedium, headlineSmall, labelLarge} = useTypography();
47-
const {surfaceContainer, primaryContainer} = useTheme();
47+
const {surfaceContainer} = useTheme();
48+
const {bodyMedium, headlineSmall} = useTypography();
49+
50+
const renderActionButtons = () => (
51+
<View style={styles.actions}>
52+
{secondActionTitle ? <TextButton style={styles.actionButton} onPress={onSecondActionPress} title={secondActionTitle} /> : null}
53+
{firstActionTitle ? <TextButton style={styles.actionButton} onPress={onFirstActionPress} title={firstActionTitle} /> : null}
54+
</View>
55+
);
4856

4957
return (
5058
<Dialog ref={ref} style={[style]} {...props}>
5159
{prepend}
5260
{title ? <Text style={[headlineSmall, styles.title, {color: surfaceContainer.text}, titleStyle]}>{title}</Text> : null}
5361
{subtitle ? <Text style={[bodyMedium, {color: surfaceContainer.textVariant}, subtitleStyle]}>{subtitle}</Text> : null}
5462
{append}
55-
{firstActionTitle && (
56-
<View style={styles.actions}>
57-
{/* Todo: replace with libriry's text buttons */}
58-
<TouchableOpacity onPress={onSecondActionPress}>
59-
<Text style={[labelLarge, {color: primaryContainer.text}]}>{secondActionTitle}</Text>
60-
</TouchableOpacity>
61-
<TouchableOpacity onPress={onFirstActionPress}>
62-
<Text style={[labelLarge, {color: primaryContainer.text}]}>{firstActionTitle}</Text>
63-
</TouchableOpacity>
64-
</View>
65-
)}
63+
{firstActionTitle ? renderActionButtons() : null}
6664
</Dialog>
6765
);
6866
}

src/dialogs/basic-dialog/basic-dialog.styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ export const styles = StyleSheet.create({
1111
paddingTop: 24,
1212
marginStart: 'auto',
1313
},
14+
actionButton: {
15+
paddingStart: 12,
16+
paddingEnd: 12,
17+
},
1418
});

0 commit comments

Comments
 (0)