react-native-fpay 0.2.9 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/lib/module/FountainPayProvider.js +5 -1
  2. package/lib/module/FountainPayProvider.js.map +1 -1
  3. package/lib/module/core/api/index.js +22 -12
  4. package/lib/module/core/api/index.js.map +1 -1
  5. package/lib/module/engine/BLEReceiverService.js.map +1 -1
  6. package/lib/module/engine/FPEngine.js +24 -13
  7. package/lib/module/engine/FPEngine.js.map +1 -1
  8. package/lib/module/engine/useIsForeground.js +17 -0
  9. package/lib/module/engine/useIsForeground.js.map +1 -0
  10. package/lib/module/ui/components/AnimatedDots.js +68 -0
  11. package/lib/module/ui/components/AnimatedDots.js.map +1 -0
  12. package/lib/module/ui/components/ConfirmScreen.js +333 -0
  13. package/lib/module/ui/components/ConfirmScreen.js.map +1 -0
  14. package/lib/module/ui/modals/FPPaymentRequestModal.js +6 -8
  15. package/lib/module/ui/modals/FPPaymentRequestModal.js.map +1 -1
  16. package/lib/module/ui/modals/FPShell.js +7 -4
  17. package/lib/module/ui/modals/FPShell.js.map +1 -1
  18. package/lib/module/ui/screens/ReceiveScreen.js +379 -274
  19. package/lib/module/ui/screens/ReceiveScreen.js.map +1 -1
  20. package/lib/module/ui/screens/SendScreen.js +154 -45
  21. package/lib/module/ui/screens/SendScreen.js.map +1 -1
  22. package/lib/module/ui/screens/styles.js +89 -0
  23. package/lib/module/ui/screens/styles.js.map +1 -0
  24. package/lib/module/ui/screens/sub/receivePayment/Nfc/index.js +361 -0
  25. package/lib/module/ui/screens/sub/receivePayment/Nfc/index.js.map +1 -0
  26. package/lib/module/ui/screens/sub/receivePayment/Qr/index.js +338 -0
  27. package/lib/module/ui/screens/sub/receivePayment/Qr/index.js.map +1 -0
  28. package/lib/module/ui/screens/sub/receivePayment/Transfer/index.js +453 -0
  29. package/lib/module/ui/screens/sub/receivePayment/Transfer/index.js.map +1 -0
  30. package/lib/module/ui/screens/sub/{BluetoothSubScreen.js → sendPayment/BluetoothSubScreen.js} +25 -32
  31. package/lib/module/ui/screens/sub/sendPayment/BluetoothSubScreen.js.map +1 -0
  32. package/lib/module/ui/screens/sub/sendPayment/NFCSubScreen.js +354 -0
  33. package/lib/module/ui/screens/sub/sendPayment/NFCSubScreen.js.map +1 -0
  34. package/lib/module/ui/screens/sub/sendPayment/NQRSubScreen.js +440 -0
  35. package/lib/module/ui/screens/sub/sendPayment/NQRSubScreen.js.map +1 -0
  36. package/lib/module/ui/screens/sub/{ProximitySubScreen.js → sendPayment/ProximitySubScreen.js} +20 -111
  37. package/lib/module/ui/screens/sub/sendPayment/ProximitySubScreen.js.map +1 -0
  38. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js +327 -0
  39. package/lib/module/ui/screens/sub/sendPayment/TransferSubScreen.js.map +1 -0
  40. package/lib/typescript/src/FountainPayProvider.d.ts.map +1 -1
  41. package/lib/typescript/src/core/api/index.d.ts +20 -27
  42. package/lib/typescript/src/core/api/index.d.ts.map +1 -1
  43. package/lib/typescript/src/core/types/index.d.ts +56 -13
  44. package/lib/typescript/src/core/types/index.d.ts.map +1 -1
  45. package/lib/typescript/src/engine/BLEReceiverService.d.ts +2 -0
  46. package/lib/typescript/src/engine/BLEReceiverService.d.ts.map +1 -1
  47. package/lib/typescript/src/engine/FPEngine.d.ts +3 -1
  48. package/lib/typescript/src/engine/FPEngine.d.ts.map +1 -1
  49. package/lib/typescript/src/engine/useIsForeground.d.ts +2 -0
  50. package/lib/typescript/src/engine/useIsForeground.d.ts.map +1 -0
  51. package/lib/typescript/src/ui/components/AnimatedDots.d.ts +2 -0
  52. package/lib/typescript/src/ui/components/AnimatedDots.d.ts.map +1 -0
  53. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts +10 -0
  54. package/lib/typescript/src/ui/components/ConfirmScreen.d.ts.map +1 -0
  55. package/lib/typescript/src/ui/components/OtpInput/Styles.d.ts +3 -3
  56. package/lib/typescript/src/ui/modals/FPPaymentRequestModal.d.ts.map +1 -1
  57. package/lib/typescript/src/ui/modals/FPShell.d.ts.map +1 -1
  58. package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts +2 -9
  59. package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/ui/screens/SendScreen.d.ts +4 -2
  61. package/lib/typescript/src/ui/screens/SendScreen.d.ts.map +1 -1
  62. package/lib/typescript/src/ui/screens/styles.d.ts +1390 -0
  63. package/lib/typescript/src/ui/screens/styles.d.ts.map +1 -0
  64. package/lib/typescript/src/ui/screens/sub/receivePayment/Nfc/index.d.ts +10 -0
  65. package/lib/typescript/src/ui/screens/sub/receivePayment/Nfc/index.d.ts.map +1 -0
  66. package/lib/typescript/src/ui/screens/sub/receivePayment/Qr/index.d.ts +10 -0
  67. package/lib/typescript/src/ui/screens/sub/receivePayment/Qr/index.d.ts.map +1 -0
  68. package/lib/typescript/src/ui/screens/sub/receivePayment/Transfer/index.d.ts +5 -0
  69. package/lib/typescript/src/ui/screens/sub/receivePayment/Transfer/index.d.ts.map +1 -0
  70. package/lib/typescript/src/ui/screens/sub/{BluetoothSubScreen.d.ts → sendPayment/BluetoothSubScreen.d.ts} +2 -11
  71. package/lib/typescript/src/ui/screens/sub/sendPayment/BluetoothSubScreen.d.ts.map +1 -0
  72. package/lib/typescript/src/ui/screens/sub/sendPayment/NFCSubScreen.d.ts +3 -0
  73. package/lib/typescript/src/ui/screens/sub/sendPayment/NFCSubScreen.d.ts.map +1 -0
  74. package/lib/typescript/src/ui/screens/sub/sendPayment/NQRSubScreen.d.ts +3 -0
  75. package/lib/typescript/src/ui/screens/sub/sendPayment/NQRSubScreen.d.ts.map +1 -0
  76. package/lib/typescript/src/ui/screens/sub/{ProximitySubScreen.d.ts → sendPayment/ProximitySubScreen.d.ts} +2 -10
  77. package/lib/typescript/src/ui/screens/sub/sendPayment/ProximitySubScreen.d.ts.map +1 -0
  78. package/lib/typescript/src/ui/screens/sub/sendPayment/TransferSubScreen.d.ts +3 -0
  79. package/lib/typescript/src/ui/screens/sub/sendPayment/TransferSubScreen.d.ts.map +1 -0
  80. package/package.json +1 -1
  81. package/src/FountainPayProvider.tsx +7 -1
  82. package/src/core/api/index.ts +34 -19
  83. package/src/core/types/index.ts +67 -13
  84. package/src/engine/BLEReceiverService.ts +2 -0
  85. package/src/engine/FPEngine.ts +29 -14
  86. package/src/engine/useIsForeground.ts +18 -0
  87. package/src/ui/components/AnimatedDots.tsx +81 -0
  88. package/src/ui/components/ConfirmScreen.tsx +421 -0
  89. package/src/ui/modals/FPPaymentRequestModal.tsx +7 -6
  90. package/src/ui/modals/FPShell.tsx +9 -9
  91. package/src/ui/screens/ReceiveScreen.tsx +266 -115
  92. package/src/ui/screens/SendScreen.tsx +141 -19
  93. package/src/ui/screens/styles.ts +101 -0
  94. package/src/ui/screens/sub/receivePayment/Nfc/index.tsx +418 -0
  95. package/src/ui/screens/sub/receivePayment/Qr/index.tsx +391 -0
  96. package/src/ui/screens/sub/receivePayment/Transfer/index.tsx +512 -0
  97. package/src/ui/screens/sub/{BluetoothSubScreen.tsx → sendPayment/BluetoothSubScreen.tsx} +27 -46
  98. package/src/ui/screens/sub/sendPayment/NFCSubScreen.tsx +302 -0
  99. package/src/ui/screens/sub/sendPayment/NQRSubScreen.tsx +490 -0
  100. package/src/ui/screens/sub/{ProximitySubScreen.tsx → sendPayment/ProximitySubScreen.tsx} +24 -44
  101. package/src/ui/screens/sub/sendPayment/TransferSubScreen.tsx +345 -0
  102. package/lib/module/ui/screens/sub/BluetoothSubScreen.js.map +0 -1
  103. package/lib/module/ui/screens/sub/NFCSubScreen.js +0 -164
  104. package/lib/module/ui/screens/sub/NFCSubScreen.js.map +0 -1
  105. package/lib/module/ui/screens/sub/NQRSubScreen.js +0 -131
  106. package/lib/module/ui/screens/sub/NQRSubScreen.js.map +0 -1
  107. package/lib/module/ui/screens/sub/ProximitySubScreen.js.map +0 -1
  108. package/lib/module/ui/screens/sub/TransferSubScreen.js +0 -353
  109. package/lib/module/ui/screens/sub/TransferSubScreen.js.map +0 -1
  110. package/lib/typescript/src/ui/screens/sub/BluetoothSubScreen.d.ts.map +0 -1
  111. package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts +0 -18
  112. package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts.map +0 -1
  113. package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts +0 -12
  114. package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts.map +0 -1
  115. package/lib/typescript/src/ui/screens/sub/ProximitySubScreen.d.ts.map +0 -1
  116. package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts +0 -11
  117. package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts.map +0 -1
  118. package/src/ui/screens/sub/NFCSubScreen.tsx +0 -86
  119. package/src/ui/screens/sub/NQRSubScreen.tsx +0 -62
  120. package/src/ui/screens/sub/TransferSubScreen.tsx +0 -147
@@ -1,119 +1,270 @@
1
- import React, { useState } from 'react';
2
- import { View, Text, TouchableOpacity, StyleSheet, ScrollView } from 'react-native';
3
- import { C, R, S, F, shadow } from '../theme';
4
- import { NQRSubScreen } from './sub/NQRSubScreen';
5
- import { NFCSubScreen } from './sub/NFCSubScreen';
6
- import type { FPCurrency, FPCallbacks, FPUserInfo } from '../../core/types';
7
-
8
- type Channel = 'transfer' | 'nqr' | 'nfc';
9
-
10
- const CHANNELS: { id: Channel; emoji: string; title: string; desc: string }[] = [
11
- { id: 'transfer', emoji: '🏦', title: 'Bank Transfer', desc: 'Share your account number' },
12
- { id: 'nqr', emoji: '⬛', title: 'NQR Code', desc: 'Generate a QR for others to scan' },
13
- { id: 'nfc', emoji: '📲', title: 'NFC Tap', desc: 'Let someone tap to pay you' },
14
- ];
15
-
16
- interface Props extends FPCallbacks {
17
- amount?: number;
18
- currency?: FPCurrency;
19
- user?: FPUserInfo;
20
- onClose: () => void;
21
- }
22
-
23
- export function ReceiveScreen({ amount, currency = 'NGN', user, onClose, onPaymentReceived, onError }: Props) {
24
- const [channel, setChannel] = useState<Channel | null>(null);
25
-
26
- const myWallet = {
27
- accountName: user?.accountName ?? '',
28
- accountNumber: user?.accountNumber ?? '',
29
- bankName: user?.bankName ?? '',
30
- bankCode: user?.bankCode ?? '',
31
- };
32
-
33
- if (channel === 'nqr') return <NQRSubScreen mode="receive" amount={amount} currency={currency} onDone={onClose} onError={onError} />;
34
- if (channel === 'nfc') return <NFCSubScreen mode="receive" myWallet={myWallet} onDone={onClose} onError={onError} />;
35
-
36
- // Transfer just show account details inline
37
- if (channel === 'transfer') return (
38
- <View style={styles.container}>
39
- <TouchableOpacity onPress={() => setChannel(null)} style={styles.back}>
40
- <Text style={styles.backText}>‹ Back</Text>
41
- </TouchableOpacity>
42
- <Text style={styles.sectionTitle}>Your Account Details</Text>
43
- <View style={styles.accountCard}>
44
- <Row label="Account Name" value={user?.accountName ?? ''} />
45
- <Row label="Account Number" value={user?.accountNumber ?? ''} large copyable />
46
- <Row label="Bank" value={user?.bankName ?? ''} />
47
- {amount && <Row label="Expected Amount" value={`${currency} ${amount.toLocaleString('en-NG', { minimumFractionDigits: 2 })}`} highlight />}
48
- </View>
49
- <Text style={styles.hint}>Share these details with whoever is paying you</Text>
50
- </View>
51
- );
1
+ import React, { useState, useEffect } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ TextInput,
6
+ TouchableOpacity,
7
+ Dimensions,
8
+ ScrollView,
9
+ } from 'react-native';
10
+ import styled from 'styled-components/native';
11
+ import Ionicons from 'react-native-vector-icons/Ionicons';
12
+ import Svg, { Path } from "react-native-svg";
13
+ import Transfer from './sub/receivePayment/Transfer';
14
+ import Qr from './sub/receivePayment/Qr';
15
+ import Nfc from './sub/receivePayment/Nfc';
16
+
17
+
18
+ const { width, height } = Dimensions.get('window');
19
+
20
+ // Styled Components
21
+ const Container = styled(View)`
22
+ flex: 1;
23
+ background-color: #000000;
24
+ `;
25
+
26
+
27
+ // Bottom Sheet Styles
28
+ const BottomSheet = styled(View)`
29
+ position: absolute;
30
+ bottom: 0;
31
+ left: 0;
32
+ right: 0;
33
+ background-color: #ffffff;
34
+ border-top-left-radius: 24px;
35
+ border-top-right-radius: 24px;
36
+ padding: 20px 20px 32px;
37
+ elevation: 20;
38
+ shadow-color: #000;
39
+ shadow-offset: 0px -4px;
40
+ shadow-opacity: 0.15;
41
+ shadow-radius: 12px;
42
+ max-height: ${height * 0.5}px;
43
+ `;
44
+
45
+ const SheetHandle = styled(View)`
46
+ width: 40px;
47
+ height: 4px;
48
+ background-color: #d1d5db;
49
+ border-radius: 2px;
50
+ align-self: center;
51
+ margin-bottom: 20px;
52
+ `;
53
+
54
+ const SheetScrollView = styled(ScrollView)`
55
+ flex: 1;
56
+ `;
57
+
58
+ const SectionTitle = styled(Text)`
59
+ font-size: 18px;
60
+ font-weight: 700;
61
+ color: #1f2937;
62
+ margin-bottom: 16px;
63
+ `;
64
+
65
+ const ActionsRow = styled(View)`
66
+ flex-direction: row;
67
+ gap: 16px;
68
+ margin-bottom: 24px;
69
+ `;
70
+
71
+ const ActionButton = styled(TouchableOpacity)`
72
+ align-items: center;
73
+ gap: 8px;
74
+ flex: 1;
75
+ `;
76
+
77
+ const ActionIconContainer = styled(View)<{ color: string }>`
78
+ width: 56px;
79
+ height: 56px;
80
+ border-radius: 100%;
81
+ background-color: ${props => props.color};
82
+ justify-content: center;
83
+ align-items: center;
84
+ elevation: 3;
85
+ shadow-color: #000;
86
+ shadow-offset: 0px 2px;
87
+ shadow-opacity: 0.12;
88
+ shadow-radius: 4px;
89
+ `;
90
+
91
+ const ActionLabel = styled(Text)`
92
+ font-size: 11px;
93
+ color: #374151;
94
+ text-align: center;
95
+ line-height: 14px;
96
+ `;
97
+
98
+ const SearchContainer = styled(View)`
99
+ flex-direction: row;
100
+ align-items: center;
101
+ background-color: #f9fafb;
102
+ border-radius: 12px;
103
+ padding: 14px 16px;
104
+ margin-bottom: 24px;
105
+ border: 1px solid #e5e7eb;
106
+ `;
107
+
108
+ const SearchInput = styled(TextInput)`
109
+ flex: 1;
110
+ margin-left: 10px;
111
+ font-size: 14px;
112
+ color: #1f2937;
113
+ padding: 0;
114
+ `;
115
+
116
+ const AddContactButton = styled.TouchableOpacity`
117
+ align-items: center;
118
+ margin-right: 20px;
119
+
120
+ flex-direction: row;
121
+ gap: 20px;
122
+
123
+ `;
124
+
125
+ const Icon = styled(Text)<{ size?: number; color?: string }>`
126
+ font-size: ${props => props.size || 24}px;
127
+ color: ${props => props.color || '#000000'};
128
+ `;
129
+
130
+ const AddCircle = styled.View`
131
+ width: 44px;
132
+ height: 44px;
133
+ border-radius: 32px;
134
+ background-color: #fff;
135
+ border-width: 2px;
136
+ border-color: #e0e0e0;
137
+ border-style: dashed;
138
+ justify-content: center;
139
+ align-items: center;
140
+ margin-bottom: 8px;
141
+ `;
142
+
143
+
144
+ const ContactName = styled.Text`
145
+ font-size: 12px;
146
+ color: #000;
147
+ `;
148
+
149
+ const ScanIcon = ({ color = "#111", size = 22 }) => (
150
+ <Svg width={size} height={size} strokeWidth="0.9" viewBox="0 0 24 24" fill="none" color={color}>
151
+ <Path d="M6 3H3V6" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
152
+ <Path d="M2 12H12L22 12" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
153
+ <Path d="M9 19V17V15" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
154
+ <Path d="M12 16V15.5V15" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
155
+ <Path d="M15 17V16V15" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
156
+ <Path d="M12 21V19.5V18" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
157
+ <Path d="M18 3H21V6" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
158
+ <Path d="M6 21H3V18" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
159
+ <Path d="M18 21H21V18" stroke="#000000" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
160
+ </Svg>
161
+ );
162
+
163
+ const BluetoothIcon =({ color = "#111", size = 22 })=>(
164
+ <Svg width={size} height={size} strokeWidth="0.9" viewBox="0 0 24 24" fill="none" color={color}>
165
+ <Path d="M6 19.0007C3.57111 17.1763 2 14.2716 2 11C2 5.47715 6.47715 1 12 1C17.5228 1 22 5.47715 22 11C22 14.2716 20.4289 17.1763 18 19.0007" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
166
+ <Path d="M6 19.0007C3.57111 17.1763 2 14.2716 2 11C2 5.47715 6.47715 1 12 1C17.5228 1 22 5.47715 22 11C22 14.2716 20.4289 17.1763 18 19.0007" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
167
+ <Path d="M7.52779 15C6.57771 13.9385 6 12.5367 6 11C6 7.68629 8.68629 5 12 5C15.3137 5 18 7.68629 18 11C18 12.5367 17.4223 13.9385 16.4722 15" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
168
+ <Path fillRule="evenodd" clipRule="evenodd" d="M9.25 11C9.25 9.48122 10.4812 8.25 12 8.25C13.5188 8.25 14.75 9.48122 14.75 11C14.75 12.5188 13.5188 13.75 12 13.75C10.4812 13.75 9.25 12.5188 9.25 11Z" fill="#fff" />
169
+ <Path d="M15.0776 21.4865C14.8566 22.8126 13.7093 23.7844 12.365 23.7844H11.7536C10.4093 23.7844 9.262 22.8126 9.041 21.4865L8.53213 18.4333C8.29232 16.9946 9.43086 15.8854 10.5339 15.15C11.9123 14.231 12.3864 14.3406 13.5847 15.1396C14.6421 15.8445 15.8263 16.9946 15.5865 18.4333L15.0776 21.4865Z" fill="#fff" />
170
+ </Svg>
171
+ )
172
+
173
+ const NFCIcon =({ color = "#111", size = 22 })=>(
174
+ <Svg width={size} height={size} strokeWidth="0.9" viewBox="0 0 24 24" fill="none" color={color}>
175
+ <Path d="M12 19.51L12.01 19.4989" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
176
+ <Path d="M2 8C8 3.5 16 3.5 22 8" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
177
+ <Path d="M5 12C9 9 15 9 19 12" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
178
+ <Path d="M8.5 15.5C10.7504 14.1 13.2498 14.0996 15.5001 15.5" stroke="#fff" strokeWidth="0.9" strokeLinecap="round" strokeLinejoin="round" />
179
+ </Svg>
180
+ )
181
+
182
+ const QRIcon =({ color = "#111", size = 22 })=>(
183
+ <Svg width={size} height={size} strokeWidth="0.9" viewBox="0 0 24 24" fill="none" color={color}>
184
+ <Path fillRule="evenodd" clipRule="evenodd" d="M2.25 3C2.25 2.58579 2.58579 2.25 3 2.25H6C6.41421 2.25 6.75 2.58579 6.75 3C6.75 3.41421 6.41421 3.75 6 3.75H3.75V6C3.75 6.41421 3.41421 6.75 3 6.75C2.58579 6.75 2.25 6.41421 2.25 6V3Z" fill="#fff" />
185
+ <Path fillRule="evenodd" clipRule="evenodd" d="M17.25 3C17.25 2.58579 17.5858 2.25 18 2.25H21C21.4142 2.25 21.75 2.58579 21.75 3V6C21.75 6.41421 21.4142 6.75 21 6.75C20.5858 6.75 20.25 6.41421 20.25 6V3.75H18C17.5858 3.75 17.25 3.41421 17.25 3Z" fill="#fff" />
186
+ <Path fillRule="evenodd" clipRule="evenodd" d="M3 17.25C3.41421 17.25 3.75 17.5858 3.75 18V20.25H6C6.41421 20.25 6.75 20.5858 6.75 21C6.75 21.4142 6.41421 21.75 6 21.75H3C2.58579 21.75 2.25 21.4142 2.25 21V18C2.25 17.5858 2.58579 17.25 3 17.25Z" fill="#fff" />
187
+ <Path fillRule="evenodd" clipRule="evenodd" d="M21 17.25C21.4142 17.25 21.75 17.5858 21.75 18V21C21.75 21.4142 21.4142 21.75 21 21.75H18C17.5858 21.75 17.25 21.4142 17.25 21C17.25 20.5858 17.5858 20.25 18 20.25H20.25V18C20.25 17.5858 20.5858 17.25 21 17.25Z" fill="#fff" />
188
+ <Path fillRule="evenodd" clipRule="evenodd" d="M12.9004 6.6654C12.3462 6.33289 11.6538 6.33289 11.0996 6.6654L7.09963 9.0654C6.57252 9.38167 6.25 9.95131 6.25 10.566V14.4336C6.25 15.0483 6.57252 15.618 7.09963 15.9342L11.0996 18.3342C11.6538 18.6668 12.3462 18.6668 12.9004 18.3342L16.9004 15.9342C17.4275 15.618 17.75 15.0483 17.75 14.4336V10.566C17.75 9.95131 17.4275 9.38167 16.9004 9.0654L12.9004 6.6654ZM9.3642 10.6785C9.00209 10.4773 8.5455 10.6078 8.34437 10.9699C8.14324 11.332 8.27373 11.7886 8.63583 11.9898L11.25 13.4418V16.0001C11.25 16.4144 11.5858 16.7501 12 16.7501C12.4142 16.7501 12.75 16.4144 12.75 16.0001V13.4456C12.9152 13.3554 13.1243 13.241 13.3607 13.1115C13.9447 12.7916 14.6961 12.3787 15.3642 12.0077C15.7263 11.8066 15.8568 11.35 15.6557 10.9879C15.4546 10.6257 14.998 10.4952 14.6359 10.6964C13.9716 11.0653 13.223 11.4766 12.6401 11.796C12.3908 11.9325 12.172 12.0521 12.0032 12.1443L9.3642 10.6785Z" fill="#fff" />
189
+ </Svg>
190
+ );
191
+
192
+ type PAYMENTCHANNEL = "TRANSFER" | "QRCODE" | "NFC" | "BTH"
193
+
194
+ // Main Component
195
+ const ReceiveScreen = ({ amount, currency = 'NGN', user, account, onClose, onPaymentReceived, onError }: any) => {
196
+ const [mode, setMode] = useState<PAYMENTCHANNEL>('TRANSFER');
52
197
 
53
- return (
54
- <View style={styles.container}>
55
- {amount && (
56
- <View style={styles.amountBanner}>
57
- <Text style={styles.amountLabel}>Receiving</Text>
58
- <Text style={styles.amountValue}>{currency} {amount.toLocaleString('en-NG', { minimumFractionDigits: 2 })}</Text>
59
- </View>
60
- )}
61
- <Text style={styles.sectionTitle}>How do you want to receive?</Text>
62
- <ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={styles.list}>
63
- {CHANNELS.map(ch => (
64
- <TouchableOpacity key={ch.id} style={styles.card} onPress={() => setChannel(ch.id)} activeOpacity={0.8}>
65
- <View style={styles.cardIcon}><Text style={styles.cardEmoji}>{ch.emoji}</Text></View>
66
- <View style={styles.cardText}>
67
- <Text style={styles.cardTitle}>{ch.title}</Text>
68
- <Text style={styles.cardDesc}>{ch.desc}</Text>
69
- </View>
70
- <Text style={styles.arrow}>›</Text>
71
- </TouchableOpacity>
72
- ))}
73
- </ScrollView>
74
- </View>
75
- );
76
- }
77
198
 
78
- function Row({ label, value, large, copyable, highlight }: { label: string; value: string; large?: boolean; copyable?: boolean; highlight?: boolean }) {
79
- const [copied, setCopied] = React.useState(false);
80
199
  return (
81
- <View style={rowStyles.row}>
82
- <Text style={rowStyles.label}>{label}</Text>
83
- <TouchableOpacity onPress={copyable ? () => { require('react-native').Clipboard.setString(value); setCopied(true); setTimeout(() => setCopied(false), 2000); } : undefined}>
84
- <Text style={[rowStyles.value, large && rowStyles.large, highlight && rowStyles.highlight]}>
85
- {value}{copyable && <Text style={rowStyles.copy}> {copied ? '✓' : 'Copy'}</Text>}
86
- </Text>
87
- </TouchableOpacity>
88
- </View>
200
+ <Container>
201
+ {mode === 'TRANSFER' && (<Transfer
202
+ amount={amount as any}
203
+ description={""}
204
+ user={user}
205
+ recipient={account}
206
+ onClose={onClose}
207
+ onPaymentReceived={onPaymentReceived}
208
+ />)}
209
+
210
+ {mode === 'QRCODE' && (<Qr
211
+ amount={amount as any}
212
+ description={""}
213
+ onClose={onClose}
214
+ onPaymentReceived={onPaymentReceived}
215
+ />)}
216
+
217
+ {mode === 'NFC' && (<Nfc
218
+ amount={amount as any}
219
+ description={""}
220
+ onClose={onClose}
221
+ onPaymentReceived={onPaymentReceived}
222
+ />)}
223
+
224
+
225
+
226
+ {/* Bottom Sheet */}
227
+ <BottomSheet>
228
+ <SheetHandle />
229
+
230
+ <SheetScrollView showsVerticalScrollIndicator={false}>
231
+ <SectionTitle>Receive with</SectionTitle>
232
+
233
+ <ActionsRow>
234
+ <ActionButton onPress={() => setMode('TRANSFER')}>
235
+ <ActionIconContainer color="#0a3d2e">
236
+ <Ionicons name="business-sharp" size={26} color="#ffffff" />
237
+ </ActionIconContainer>
238
+ <ActionLabel>With{'\n'}transfer</ActionLabel>
239
+ </ActionButton>
240
+
241
+ <ActionButton onPress={() => setMode('QRCODE')}>
242
+ <ActionIconContainer color="#0a3d2e">
243
+ <QRIcon color="#FFF" size={22} />
244
+ </ActionIconContainer>
245
+ <ActionLabel>With{'\n'}QR</ActionLabel>
246
+ </ActionButton>
247
+
248
+ <ActionButton onPress={() => setMode('NFC')}>
249
+ <ActionIconContainer color="#0a3d2e">
250
+ <NFCIcon size={26} color="#ffffff" />
251
+ </ActionIconContainer>
252
+ <ActionLabel>With{'\n'}NFC</ActionLabel>
253
+ </ActionButton>
254
+
255
+ <ActionButton onPress={() => setMode('BTH')}>
256
+ <ActionIconContainer color="#0a3d2e">
257
+ <BluetoothIcon size={26} color="#ffffff" />
258
+ </ActionIconContainer>
259
+ <ActionLabel>With{'\n'}Bluetooth</ActionLabel>
260
+ </ActionButton>
261
+ </ActionsRow>
262
+
263
+ </SheetScrollView>
264
+ </BottomSheet>
265
+
266
+ </Container>
89
267
  );
90
- }
91
-
92
- const rowStyles = StyleSheet.create({
93
- row: { paddingVertical: S.sm, borderBottomWidth: 1, borderBottomColor: C.border },
94
- label: { fontSize: F.xs, color: C.muted, marginBottom: 2 },
95
- value: { fontSize: F.md, color: C.ink, fontWeight: '600' },
96
- large: { fontSize: F.xl, fontWeight: '800', letterSpacing: 2 },
97
- highlight: { color: C.green, fontWeight: '800' },
98
- copy: { fontSize: F.sm, color: C.brand, fontWeight: '700' },
99
- });
100
-
101
- const styles = StyleSheet.create({
102
- container: { flex: 1, padding: S.lg },
103
- back: { marginBottom: S.md },
104
- backText: { color: C.brand, fontSize: F.md, fontWeight: '600' },
105
- amountBanner: { backgroundColor: C.greenLight, borderRadius: R.xl, padding: S.lg, alignItems: 'center', marginBottom: S.lg },
106
- amountLabel: { color: C.green, fontSize: F.sm, marginBottom: 4 },
107
- amountValue: { color: C.green, fontSize: F.hero, fontWeight: '800' },
108
- sectionTitle: { fontSize: F.sm, color: C.muted, fontWeight: '600', letterSpacing: 0.6, textTransform: 'uppercase', marginBottom: S.md },
109
- list: { paddingBottom: S.xl },
110
- card: { flexDirection: 'row', alignItems: 'center', backgroundColor: C.surface, borderRadius: R.lg, padding: S.md, marginBottom: S.sm, ...shadow.sm },
111
- cardIcon: { width: 48, height: 48, borderRadius: R.md, backgroundColor: C.white, justifyContent: 'center', alignItems: 'center', marginRight: S.md },
112
- cardEmoji: { fontSize: 24 },
113
- cardText: { flex: 1 },
114
- cardTitle: { fontSize: F.md, fontWeight: '700', color: C.ink },
115
- cardDesc: { fontSize: F.sm, color: C.muted, marginTop: 2 },
116
- arrow: { fontSize: F.xl, color: C.ghost },
117
- accountCard: { backgroundColor: C.surface, borderRadius: R.lg, padding: S.md, marginBottom: S.md },
118
- hint: { fontSize: F.sm, color: C.muted, textAlign: 'center' },
119
- });
268
+ };
269
+ export default ReceiveScreen;
270
+
@@ -7,29 +7,29 @@ import React, { useState } from 'react';
7
7
  import { View, Text, TouchableOpacity, StyleSheet, ScrollView, Dimensions, TextInput } from 'react-native';
8
8
  import { C, R, S, F, shadow } from '../theme';
9
9
  import { FPButton } from '../components/FPButton';
10
- import { TransferSubScreen } from './sub/TransferSubScreen';
11
- import { NQRSubScreen } from './sub/NQRSubScreen';
12
- import { ProximitySubScreen } from './sub/ProximitySubScreen';
13
- import { BluetoothSubScreen } from './sub/BluetoothSubScreen';
14
- import { NFCSubScreen } from './sub/NFCSubScreen';
15
- import type { FPCurrency, FPCallbacks } from '../../core/types';
10
+ import { TransferSubScreen } from './sub/sendPayment/TransferSubScreen';
11
+ import { NQRSubScreen } from './sub/sendPayment/NQRSubScreen';
12
+ import { ProximitySubScreen } from './sub/sendPayment/ProximitySubScreen';
13
+ import { BluetoothSubScreen } from './sub/sendPayment/BluetoothSubScreen';
14
+ import { NFCSubScreen } from './sub/sendPayment/NFCSubScreen';
15
+ import type { FPCurrency, FPCallbacks, FPTransaction, FPError, FPSendPaymentRequest, FPUserInfo, FPTransferRecipient } from '../../core/types';
16
16
  import styled from 'styled-components/native';
17
17
  import Ionicons from 'react-native-vector-icons/Ionicons';
18
18
  import Svg, { Path } from 'react-native-svg';
19
+ import { nfcAPI, nqrAPI, transferAPI } from '../../core/api';
20
+ import { ButtonContainer, ContentContainer, CTAButton, CTAText, InputBox, InputContainer, StyledTextInput } from './styles';
21
+ import OTPInputs from '../components/OtpInput';
22
+ import ConfirmScreen from '../components/ConfirmScreen';
23
+ import LoadingAnimation from '../components/LoadingAnimation';
19
24
 
20
25
  const { width, height } = Dimensions.get('window');
21
26
 
22
27
  type Channel = 'TRANSFER' | 'QRCODE' | 'NFC' | 'BTH' | 'PXTR';
23
28
 
24
- const CHANNELS: { id: Channel; emoji: string; title: string; desc: string }[] = [
25
- { id: 'TRANSFER', emoji: '🏦', title: 'Bank Transfer', desc: 'Send to any Nigerian bank account' },
26
- { id: 'QRCODE', emoji: '⬛', title: 'NQR Scan', desc: 'Scan a merchant or person QR code' },
27
- { id: 'PXTR', emoji: '📡', title: 'Nearby', desc: 'People within 100m of you' },
28
- { id: 'BTH', emoji: '📶', title: 'Bluetooth', desc: 'Pair wirelessly and send' },
29
- { id: 'NFC', emoji: '📲', title: 'NFC Tap', desc: 'Tap another phone to pay' },
30
- ];
31
29
 
32
30
  interface Props extends FPCallbacks {
31
+ user: FPUserInfo | null;
32
+ account: FPTransferRecipient | null;
33
33
  amount: number;
34
34
  currency: FPCurrency;
35
35
  onClose: () => void;
@@ -233,20 +233,86 @@ const ProximityIcon =({ color = "#111", size = 22 })=>(
233
233
 
234
234
 
235
235
 
236
- const SendScreen = ({ amount, currency, onClose, onPaymentSent, onError }: Props) => {
236
+ const SendScreen = ({ user, account, amount, currency, onClose, onPaymentSent, onError }: Props) => {
237
237
  const [channel, setChannel] = useState<Channel>('TRANSFER');
238
+ const [transactionAmount, setTransactionAmount] = useState<string>('');
239
+ const [loading, setLoading] = useState<boolean>(false);
240
+ const [showAmountModal, setShowAmountModal] = useState<boolean>(false);
241
+ const [showConfirmationModal, setShowConfirmationModal] = useState<boolean>(false);
242
+
243
+
244
+ const [transactionPayload, setTransactionPayload] = useState<FPSendPaymentRequest>({} as FPSendPaymentRequest);
238
245
 
239
246
  const formatted = `${currency} ${(amount).toLocaleString('en-NG', { minimumFractionDigits: 2 })}`;
240
247
 
248
+ // { id: result.reference, reference: result.reference, type: 'debit', channel: 'transfer', amount: result.amount, currency: result.currency, status: result.status, recipient: { accountName: result.recipient.accountName }, createdAt: result.createdAt }
249
+
250
+ const handleContinue = (tx: FPSendPaymentRequest) => {
251
+
252
+ setTransactionPayload({...tx, sender: user ?? undefined});
253
+ if(tx.amount === 0){
254
+ setShowAmountModal(true);
255
+ }else{
256
+ setShowConfirmationModal(true);
257
+ }
258
+ }
259
+
260
+ const handleAmountContinue =()=>{
261
+ const updatedPayload: any = {...transactionPayload, amount: parseFloat(transactionAmount)}
262
+ setTransactionPayload(updatedPayload as FPSendPaymentRequest);
263
+ setShowConfirmationModal(true);
264
+ }
265
+
266
+ const validateOtp = async(otp: string)=>{
267
+
268
+ }
269
+
270
+ const handleProcessingTransaction = async () => {
271
+ try {
272
+ setLoading(true);
273
+ let response: FPTransaction | null= null;
274
+ switch(transactionPayload?.channel){
275
+ case 'transfer':
276
+ case 'bluetooth':
277
+ case 'proximity':
278
+ response = await transferAPI.send({...transactionPayload, sender: user ?? undefined, narration: `Send ${formatted} to ${transactionPayload.recipient.accountName}`})
279
+ break;
280
+ case 'nqr':
281
+ response = await nqrAPI.pay({...transactionPayload, sender: user ?? undefined, narration: `Send ${formatted} to ${transactionPayload.recipient.accountName}`})
282
+ break;
283
+ case 'nfc':
284
+ response = await nfcAPI.pay({...transactionPayload, sender: user ?? undefined, narration: `Send ${formatted} to ${transactionPayload.recipient.accountName}`})
285
+ break;
286
+ default:
287
+ onError?.({message: 'Invalid channel'} as FPError);
288
+ break;
289
+ }
290
+
291
+ if(response?.status !== 'successful'){
292
+ onError?.({message: 'Transaction failed'} as FPError);
293
+ return;
294
+ }
295
+
296
+ onPaymentSent?.(response);
297
+ } catch (error) {
298
+ onError?.(error as FPError);
299
+ }finally{
300
+ setLoading(false);
301
+ }
302
+ }
303
+
241
304
 
242
305
 
243
306
  return (
244
307
  <Container>
245
- {channel === 'TRANSFER' && (<TransferSubScreen amount={amount} currency={currency} onDone={onClose} onSuccess={onPaymentSent} onError={onError} />)}
246
- {channel === 'QRCODE' && (<NQRSubScreen mode="send" amount={amount} currency={currency} onDone={onClose} onSuccess={onPaymentSent} onError={onError} />)}
247
- {channel === 'NFC' && (<NFCSubScreen mode="send" amount={amount} currency={currency} onDone={onClose} onSuccess={onPaymentSent} onError={onError} />)}
248
- {channel === 'BTH' && (<BluetoothSubScreen mode="send" amount={amount} currency={currency} onDone={onClose} onSuccess={onPaymentSent} onError={onError} />)}
249
- {channel === 'PXTR' && (<ProximitySubScreen amount={amount} currency={currency} onDone={onClose} onSuccess={onPaymentSent} onError={onError} />)}
308
+ {loading && (
309
+ <LoadingAnimation />
310
+ )}
311
+ {channel === 'TRANSFER' && (<TransferSubScreen amount={amount} currency={currency} onClose={onClose} onProcessTransaction={handleContinue} onError={onError} />)}
312
+ {channel === 'QRCODE' && (<NQRSubScreen amount={amount} currency={currency} onClose={onClose} onProcessTransaction={handleContinue} onError={onError} />)}
313
+ {channel === 'NFC' && (<NFCSubScreen amount={amount} currency={currency} onClose={onClose} onProcessTransaction={handleContinue} onError={onError} />)}
314
+ {channel === 'BTH' && (<BluetoothSubScreen amount={amount} currency={currency} onClose={onClose} onProcessTransaction={handleContinue} onError={onError} />)}
315
+ {channel === 'PXTR' && (<ProximitySubScreen amount={amount} currency={currency} onClose={onClose} onProcessTransaction={handleContinue} onError={onError} />)}
250
316
 
251
317
  <BottomSheet>
252
318
  <SheetHandle />
@@ -292,6 +358,62 @@ const SendScreen = ({ amount, currency, onClose, onPaymentSent, onError }: Props
292
358
  </AddContactButton>
293
359
  </SheetScrollView>
294
360
  </BottomSheet>
361
+
362
+ {showAmountModal && (
363
+ <BottomSheet>
364
+ <SheetHandle />
365
+
366
+ <SheetScrollView showsVerticalScrollIndicator={false}>
367
+ <SectionTitle>Enter amount</SectionTitle>
368
+
369
+ <ActionsRow>
370
+ <InputContainer>
371
+ <InputBox>
372
+ <StyledTextInput
373
+ placeholder="Enter account number"
374
+ placeholderTextColor="#d1d5db"
375
+ value={transactionAmount}
376
+ keyboardType="number-pad"
377
+ returnKeyType='done'
378
+ maxLength={10}
379
+ onChangeText={(text) => {
380
+ const numericText = text.replace(/[^0-9]/g, '');
381
+ setTransactionAmount(numericText);
382
+ }}
383
+ />
384
+
385
+ </InputBox>
386
+ </InputContainer>
387
+
388
+ <ContentContainer>
389
+ <ButtonContainer>
390
+ <CTAButton activeOpacity={0.8} disabled={!transactionAmount} onPress={handleAmountContinue}>
391
+ <CTAText>Continue</CTAText>
392
+ </CTAButton>
393
+ </ButtonContainer>
394
+ </ContentContainer>
395
+ </ActionsRow>
396
+
397
+ <AddContactButton onPress={()=>setChannel('NFC')}>
398
+ <PrxyIconContainer color="#0a3d2e">
399
+ <NFCIcon size={26} color="#ffffff" />
400
+ </PrxyIconContainer>
401
+ <ContactName>Use NFC payment</ContactName>
402
+ </AddContactButton>
403
+ </SheetScrollView>
404
+ </BottomSheet>
405
+ )}
406
+ {showConfirmationModal && (
407
+ <BottomSheet>
408
+ <SheetHandle />
409
+
410
+ <SheetScrollView showsVerticalScrollIndicator={false}>
411
+ <SectionTitle>Summary</SectionTitle>
412
+
413
+ <ConfirmScreen transaction={transactionPayload} onRecheck={()=>setShowConfirmationModal(false)} onContinue={handleProcessingTransaction} />
414
+ </SheetScrollView>
415
+ </BottomSheet>
416
+ )}
295
417
  </Container>
296
418
  );
297
419
  }