-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f3252d
commit f52f40c
Showing
8 changed files
with
2,404 additions
and
2,436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react" | ||
import { Modal as RNModal, TextStyle, View, ViewStyle } from "react-native" | ||
import { TxKeyPath } from "../i18n" | ||
import { colors, spacing } from "../theme" | ||
import { Button, ButtonProps } from "./Button" | ||
import { Text } from "./Text" | ||
|
||
interface OnPressProps extends ButtonProps { | ||
cta: () => void | ||
label: TxKeyPath | ||
} | ||
|
||
interface ModalProps { | ||
title: TxKeyPath | ||
subtitle?: TxKeyPath | ||
confirmOnPress: OnPressProps | ||
cancelOnPress: OnPressProps | ||
isVisible?: boolean | ||
} | ||
|
||
export const Modal = ({ | ||
title, | ||
subtitle, | ||
confirmOnPress, | ||
cancelOnPress, | ||
isVisible, | ||
}: ModalProps) => ( | ||
<RNModal animationType="slide" transparent={true} visible={isVisible}> | ||
<View style={$wrapper}> | ||
<View style={$card}> | ||
<Text preset="subheading" tx={title} style={$textColor} /> | ||
{subtitle ? <Text text="body" style={$subtitle} tx={subtitle} /> : null} | ||
<Button | ||
shadowStyle={$confirmButton} | ||
onPress={confirmOnPress.cta} | ||
tx={confirmOnPress.label} | ||
/> | ||
<Button | ||
preset="link" | ||
style={$cancelButton} | ||
onPress={cancelOnPress.cta} | ||
tx={cancelOnPress.label} | ||
/> | ||
</View> | ||
</View> | ||
</RNModal> | ||
) | ||
|
||
const $wrapper: ViewStyle = { | ||
flex: 1, | ||
alignItems: "center", | ||
justifyContent: "center", | ||
} | ||
|
||
const $card: ViewStyle = { | ||
backgroundColor: colors.palette.neutral100, | ||
borderRadius: spacing.medium, | ||
paddingHorizontal: spacing.large, | ||
paddingVertical: spacing.extraLarge, | ||
width: "80%", | ||
} | ||
|
||
const $textColor: TextStyle = { | ||
color: colors.palette.neutral800, | ||
} | ||
|
||
const $subtitle: TextStyle = { | ||
...$textColor, | ||
marginTop: spacing.medium, | ||
} | ||
|
||
const $confirmButton: ViewStyle = { | ||
marginTop: spacing.large, | ||
} | ||
|
||
const $cancelButton: ViewStyle = { | ||
alignSelf: "center", | ||
marginTop: spacing.extraLarge, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.