Skip to content

Commit

Permalink
added card scan component and some changes on input group
Browse files Browse the repository at this point in the history
  • Loading branch information
Chathura authored and Chathura committed Jun 9, 2024
1 parent 6fd66c3 commit 5875176
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
Binary file added payment_sdk/src/assets/images/scan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added payment_sdk/src/assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion payment_sdk/src/components/CardInputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { StyleSheet, Text, View } from "react-native";
import React, { memo, useContext, useEffect, useRef } from "react";

import Input from "./Input";
import ScanCardButton from "./ScanCardButton";
import { Actions, DispatchContext, StateContext } from "../state";
import { isCardNumberValid, validateCardExpiry } from "../util/validator";
import { formatCreditCardNumber, formatExpiry } from "../util/helpers";
Expand All @@ -21,7 +22,10 @@ const CardInputGroup = memo(({ inputErrors, resetError }: Props) => {

return (
<View style={styles.parentContainer}>
<Text style={styles.label}>Card Number</Text>
<View style={styles.titleScanRow}>
<Text style={styles.label}>Card Number</Text>
<ScanCardButton />
</View>
<View style={styles.container}>
<View style={styles.cardNumberRow}>
<Input
Expand Down Expand Up @@ -126,4 +130,10 @@ const styles = StyleSheet.create({
borderTopRightRadius: 0,
borderBottomLeftRadius: 0,
},
titleScanRow: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 8,
}
});
31 changes: 31 additions & 0 deletions payment_sdk/src/components/ScanCardButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import React from 'react';

const ScanCardButton = () => {
return (
<TouchableOpacity
style={styles.scanIconRow}
onPress={() => console.log('save card number in context')}>
<Image style={styles.cardScan} source={require('../assets/images/scan.png')} />
<Text style={styles.label}>Scan Card</Text>
</TouchableOpacity>
);
};

export default ScanCardButton;

const styles = StyleSheet.create({
cardScan: {
width: 20,
height: 20,
marginRight: 8,
},
scanIconRow: {
flexDirection: 'row',
alignItems: 'center',
},
label: {
fontSize: 16,
color: '#172E44',
},
});

0 comments on commit 5875176

Please sign in to comment.