Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: receive screen #2442

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
853c018
refactor: trying to combine both receive screens - deleted individuals
sandipndev Jun 29, 2023
4ac6eaf
feat: button group
sandipndev Jun 30, 2023
4f81b05
feat: receive ways
sandipndev Jun 30, 2023
6433358
fix: styleS
sandipndev Jul 3, 2023
5d23382
save, doesn't compile but has the simpler payment request
sandipndev Jul 4, 2023
bb7d81d
chore: dont use constriants ts now
sandipndev Jul 4, 2023
7017f55
feat: payment request
sandipndev Jul 11, 2023
7a2ab6b
feat: payment quotation
sandipndev Jul 11, 2023
bd3d3be
feat: expiresIn and sets
sandipndev Jul 11, 2023
b10373b
feat: feesInfo and detect paid
sandipndev Jul 11, 2023
4374ab1
feat: qr view
sandipndev Jul 11, 2023
7f4d6b3
refactor: rename payment-request and payment-request-creation-data
sandipndev Jul 12, 2023
7bc623d
feat: screen initial looks good
sandipndev Jul 12, 2023
caf49ff
feat: amount and note working
sandipndev Jul 12, 2023
1c5f020
feat: note input separate and expires in info
sandipndev Jul 12, 2023
ffaf2d4
feat: added copy and share invoice
sandipndev Jul 12, 2023
a4ea64f
feat: paycode also working
sandipndev Jul 12, 2023
d969844
feat: paycode await
sandipndev Jul 13, 2023
aeb73e3
feat: regenerate invoice
sandipndev Jul 13, 2023
9c3816e
feat: animate qr code and copy on tap
sandipndev Jul 13, 2023
307a49a
feat: paycode username modal
sandipndev Jul 13, 2023
f82890a
feat: onchain receive fees
sandipndev Jul 13, 2023
1f7a2b7
feat: small nit picks
sandipndev Jul 13, 2023
890fc7e
feat: more nit picks
sandipndev Jul 13, 2023
112f079
feat: more language stiff
sandipndev Jul 13, 2023
b8e65be
chore: feedback from sam
sandipndev Jul 13, 2023
a08f00e
feat: use account icons as in home
sandipndev Jul 14, 2023
d71e892
feat: default memo
sandipndev Jul 14, 2023
53de678
fix: retrigger of generation
sandipndev Jul 14, 2023
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
3 changes: 2 additions & 1 deletion .storybook/storybook.requires.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const getStories = () => {
"./app/components/currency-keyboard/currency-keyboard.stories.tsx": require("../app/components/currency-keyboard/currency-keyboard.stories.tsx"),
"./app/components/custom-modal/custom-modal.stories.tsx": require("../app/components/custom-modal/custom-modal.stories.tsx"),
"./app/components/menu-select/menu-select.stories.tsx": require("../app/components/menu-select/menu-select.stories.tsx"),
"./app/components/button-group/button-group.stories.tsx": require("../app/components/button-group/button-group.stories.tsx"),
"./app/components/modal-nfc/modal-nfc.stories.tsx": require("../app/components/modal-nfc/modal-nfc.stories.tsx"),
"./app/components/set-default-account-modal/set-default-account-modal.stories.tsx": require("../app/components/set-default-account-modal/set-default-account-modal.stories.tsx"),
"./app/components/set-lightning-address-modal/set-lightning-address-modal.stories.tsx": require("../app/components/set-lightning-address-modal/set-lightning-address-modal.stories.tsx"),
Expand Down Expand Up @@ -79,7 +80,7 @@ const getStories = () => {
"./app/screens/home-screen/home-screen.stories.tsx": require("../app/screens/home-screen/home-screen.stories.tsx"),
"./app/screens/phone-auth-screen/phone-flow.stories.tsx": require("../app/screens/phone-auth-screen/phone-flow.stories.tsx"),
"./app/screens/phone-auth-screen/phone-validation.stories.tsx": require("../app/screens/phone-auth-screen/phone-validation.stories.tsx"),
"./app/screens/receive-bitcoin-screen/receive-wrapper.stories.tsx": require("../app/screens/receive-bitcoin-screen/receive-wrapper.stories.tsx"),
"./app/screens/receive-bitcoin-screen/receive-screen.stories.tsx": require("../app/screens/receive-bitcoin-screen/receive-screen.stories.tsx"),
"./app/screens/redeem-lnurl-withdrawal-screen/redeem-bitcoin-detail-screen.stories.tsx": require("../app/screens/redeem-lnurl-withdrawal-screen/redeem-bitcoin-detail-screen.stories.tsx"),
"./app/screens/redeem-lnurl-withdrawal-screen/redeem-bitcoin-result-screen.stories.tsx": require("../app/screens/redeem-lnurl-withdrawal-screen/redeem-bitcoin-result-screen.stories.tsx"),
"./app/screens/send-bitcoin-screen/confirm-destination-modal.stories.tsx": require("../app/screens/send-bitcoin-screen/confirm-destination-modal.stories.tsx"),
Expand Down
4 changes: 2 additions & 2 deletions __tests__/screens/receive.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import { act, render } from "@testing-library/react-native"
import { ContextForScreen } from "./helper"
import ReceiveWrapperScreen from "@app/screens/receive-bitcoin-screen/receive-wrapper"
import ReceiveScreen from "@app/screens/receive-bitcoin-screen/receive-wrapper"

Check failure on line 5 in __tests__/screens/receive.spec.tsx

View workflow job for this annotation

GitHub Actions / Check Code

Cannot find module '@app/screens/receive-bitcoin-screen/receive-wrapper' or its corresponding type declarations.

it("Receive", async () => {
render(
<ContextForScreen>
<ReceiveWrapperScreen />
<ReceiveScreen />
</ContextForScreen>,
)
await act(async () => {})
Expand Down
10 changes: 9 additions & 1 deletion app/components/amount-input/amount-input-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type AmountInputButtonProps = {
disabled?: boolean
secondaryValue?: string
primaryTextTestProps?: string
showValuesIfDisabled?: boolean
} & PressableProps

export const AmountInputButton: React.FC<AmountInputButtonProps> = ({
Expand All @@ -22,6 +23,7 @@ export const AmountInputButton: React.FC<AmountInputButtonProps> = ({
disabled,
secondaryValue,
primaryTextTestProps,
showValuesIfDisabled = true,
...props
}) => {
const {
Expand All @@ -46,6 +48,7 @@ export const AmountInputButton: React.FC<AmountInputButtonProps> = ({
case disabled:
colorStyles = {
backgroundColor: colors.grey5,
opacity: 0.5,
}
break
default:
Expand All @@ -65,13 +68,18 @@ export const AmountInputButton: React.FC<AmountInputButtonProps> = ({
return [colorStyles, sizeStyles]
}

if (!showValuesIfDisabled) {
value = ""
secondaryValue = ""
}

const primaryText = value || placeholder || ""

return (
<Pressable {...props} style={pressableStyle} disabled={disabled}>
<View style={styles.contentContainerStyle}>
<Text
type="p1"
type="p2"
color={error ? colors.error : undefined}
numberOfLines={1}
ellipsizeMode="middle"
Expand Down
5 changes: 5 additions & 0 deletions app/components/amount-input/amount-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type AmountInputProps = {
minAmount?: MoneyAmount<WalletOrDisplayCurrency>
canSetAmount?: boolean
isSendingMax?: boolean
showValuesIfDisabled?: boolean
}

export const AmountInput: React.FC<AmountInputProps> = ({
Expand All @@ -33,6 +34,7 @@ export const AmountInput: React.FC<AmountInputProps> = ({
convertMoneyAmount,
canSetAmount = true,
isSendingMax = false,
showValuesIfDisabled = true,
}) => {
const [isSettingAmount, setIsSettingAmount] = React.useState(false)
const { formatMoneyAmount, getSecondaryAmountIfCurrencyIsDifferent } =
Expand Down Expand Up @@ -117,10 +119,13 @@ export const AmountInput: React.FC<AmountInputProps> = ({

return (
<AmountInputButton
placeholder={LL.AmountInputButton.tapToSetAmount()}
iconName="pencil"
value={formattedPrimaryAmount}
secondaryValue={formattedSecondaryAmount}
disabled={true}
primaryTextTestProps={"Amount Input Button Amount"}
showValuesIfDisabled={showValuesIfDisabled}
{...testProps("Amount Input Button")}
/>
)
Expand Down
26 changes: 26 additions & 0 deletions app/components/button-group/button-group.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react"
import { Story, UseCase } from "../../../.storybook/views"
import { ButtonGroup } from "."

export default {
title: "ButtonGroup",
component: ButtonGroup,
}

export const Default = () => {
return (
<Story>
<UseCase text="Default">
<ButtonGroup
selectedId="paycode"
onPress={() => {}}
buttons={[
{ id: "invoice", text: "Invoice", icon: "md-flash" },
{ id: "paycode", text: "Paycode", icon: "md-at" },
{ id: "onchain", text: "On-chain", icon: "logo-bitcoin" },
]}
/>
</UseCase>
</Story>
)
}
90 changes: 90 additions & 0 deletions app/components/button-group/button-group.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from "react"
import { StyleProp, TouchableWithoutFeedback, View, ViewStyle } from "react-native"
import { Text, makeStyles } from "@rneui/themed"
import Icon from "react-native-vector-icons/Ionicons"

type ButtonForButtonGroupProps = {
id: string
text: string
icon: string | React.ReactElement
}

const ButtonForButtonGroup: React.FC<
ButtonForButtonGroupProps & {
selected: boolean
onPress: () => void
}
> = ({ text, icon, selected, onPress }) => {
const styles = useStyles(Boolean(selected))
return (
<TouchableWithoutFeedback onPress={onPress}>
<View style={styles.button}>
<Text style={styles.text}>{text}</Text>
{typeof icon === "string" ? <Icon style={styles.text} name={icon} /> : icon}
</View>
</TouchableWithoutFeedback>
)
}

export type ButtonGroupProps = {
selectedId: string
buttons: ButtonForButtonGroupProps[]
style?: StyleProp<ViewStyle>
disabled?: boolean
onPress: (id: string) => void
}

export const ButtonGroup: React.FC<ButtonGroupProps> = ({
buttons,
selectedId,
onPress,
style,
disabled,
}) => {
const styles = useStyles()
const selectedButton = buttons.find(({ id }) => id === selectedId)

return (
<View style={[styles.buttonGroup, style]}>
{!disabled &&
buttons.map((props) => (
<ButtonForButtonGroup
key={props.id}
{...props}
onPress={() => {
if (selectedId !== props.id) {
onPress(props.id)
}
}}
selected={selectedId === props.id}
/>
))}
{disabled && selectedButton && (
<ButtonForButtonGroup {...selectedButton} selected={true} onPress={() => {}} />
)}
</View>
)
}

const useStyles = makeStyles(({ colors }, selected: boolean) => ({
button: {
flex: 1,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: 10,
paddingVertical: 10,
marginHorizontal: 3,
borderRadius: 5,
backgroundColor: selected ? colors.grey5 : colors.grey4,
},
text: {
fontSize: 16,
color: selected ? colors.primary : colors.grey1,
},
buttonGroup: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
},
}))
1 change: 1 addition & 0 deletions app/components/button-group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./button-group"
1 change: 1 addition & 0 deletions app/components/note-input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./note-input"
85 changes: 85 additions & 0 deletions app/components/note-input/note-input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from "react"

import { makeStyles } from "@rneui/themed"
import { View, TextInput, StyleProp, ViewStyle } from "react-native"

import { useI18nContext } from "@app/i18n/i18n-react"
import NoteIcon from "@app/assets/icons/note.svg"
import { useTheme } from "@rneui/themed"

export type NoteInputProps = {
onBlur?: (() => void) | undefined
onChangeText?: ((text: string) => void) | undefined
value?: string | undefined
editable?: boolean | undefined
style?: StyleProp<ViewStyle>
}

export const NoteInput: React.FC<NoteInputProps> = ({
onChangeText,
value,
editable,
onBlur,
style,
}) => {
const styles = useStyles(Boolean(editable))
const {
theme: { colors },
} = useTheme()
const { LL } = useI18nContext()

return (
<View style={[styles.fieldBackground, style]}>
<View style={styles.noteContainer}>
<TextInput
style={styles.noteInput}
placeholder={"Add Note"}
placeholderTextColor={colors.black}
onChangeText={onChangeText}
onBlur={onBlur}
value={value}
editable={editable}
selectTextOnFocus
maxLength={500}
/>
<View style={styles.noteIconContainer}>
<NoteIcon style={styles.noteIcon} />
</View>
</View>
</View>
)
}

const useStyles = makeStyles(({ colors }, editable: boolean) => ({
fieldBackground: {
flexDirection: "row",
borderStyle: "solid",
overflow: "hidden",
backgroundColor: colors.grey5,
paddingHorizontal: 10,
borderRadius: 10,
alignItems: "center",
height: 60,
opacity: editable ? 1 : 0.5,
},
fieldContainer: {
marginBottom: 12,
},
noteContainer: {
flex: 1,
flexDirection: "row",
},
noteIconContainer: {
justifyContent: "center",
alignItems: "flex-start",
},
noteIcon: {
justifyContent: "center",
alignItems: "center",
},
noteInput: {
flex: 1,
color: colors.black,
fontSize: 16,
},
}))
Loading
Loading