Skip to content

Commit 45e3a55

Browse files
committed
feat: implement subscription plan change management with proration previews and lifecycle hooks
1 parent 14734c6 commit 45e3a55

30 files changed

Lines changed: 375 additions & 190 deletions

app/screens/AnalyticsDashboard.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
170170
container: { flex: 1, backgroundColor: colors.background.primary },
171171
scrollView: { flex: 1 },
172172
header: { padding: spacing.lg, paddingBottom: spacing.sm },
173-
title: { ...typography.h1, color: colors.text },
173+
title: { ...typography.h1, color: colors.text.primary },
174174
subtitle: { ...typography.body, color: colors.textSecondary, marginTop: spacing.xs },
175175
row: {
176176
flexDirection: 'row',
@@ -180,19 +180,19 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
180180
},
181181
metricCard: { flex: 1, alignItems: 'center' },
182182
metricLabel: { ...typography.caption, color: colors.textSecondary, marginBottom: spacing.xs },
183-
metricValue: { ...typography.h2, color: colors.text },
183+
metricValue: { ...typography.h2, color: colors.text.primary },
184184
card: { marginHorizontal: spacing.lg, marginBottom: spacing.md },
185-
sectionTitle: { ...typography.h3, color: colors.text, marginBottom: spacing.md },
185+
sectionTitle: { ...typography.h3, color: colors.text.primary, marginBottom: spacing.md },
186186
statRow: {
187187
flexDirection: 'row',
188188
justifyContent: 'space-between',
189189
paddingVertical: spacing.sm,
190190
borderBottomWidth: 1,
191-
borderBottomColor: colors.border,
191+
borderBottomColor: colors.border.default,
192192
},
193193
lastRow: { borderBottomWidth: 0 },
194194
statLabel: { ...typography.body, color: colors.textSecondary },
195-
statValue: { ...typography.body, color: colors.text, fontWeight: '600' },
195+
statValue: { ...typography.body, color: colors.text.primary, fontWeight: '600' },
196196
emptyText: { ...typography.body, color: colors.textSecondary, textAlign: 'center' },
197197
exportContainer: { padding: spacing.lg, paddingTop: 0, marginBottom: spacing.xl },
198198
loadingText: { ...typography.body, color: colors.textSecondary, padding: spacing.lg },

app/screens/PaymentMethodsScreen.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
255255
container: { flex: 1, backgroundColor: colors.background.primary },
256256
scrollView: { flex: 1 },
257257
card: { margin: spacing.lg, marginBottom: spacing.md },
258-
sectionTitle: { ...typography.h3, color: colors.text, marginBottom: spacing.md },
258+
sectionTitle: { ...typography.h3, color: colors.text.primary, marginBottom: spacing.md },
259259
input: {
260260
...typography.body,
261261
borderWidth: 1,
262-
borderColor: colors.border,
262+
borderColor: colors.border.default,
263263
borderRadius: borderRadius.md,
264264
padding: spacing.md,
265-
color: colors.text,
265+
color: colors.text.primary,
266266
backgroundColor: colors.surface,
267267
marginBottom: spacing.md,
268268
},
@@ -273,20 +273,20 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
273273
padding: spacing.sm,
274274
borderRadius: borderRadius.md,
275275
borderWidth: 1,
276-
borderColor: colors.border,
276+
borderColor: colors.border.default,
277277
alignItems: 'center',
278278
},
279279
priorityOptionActive: { backgroundColor: colors.primary, borderColor: colors.primary },
280-
priorityOptionText: { ...typography.caption, color: colors.text },
281-
priorityOptionTextActive: { color: colors.text, fontWeight: '600' },
280+
priorityOptionText: { ...typography.caption, color: colors.text.primary },
281+
priorityOptionTextActive: { color: colors.text.inverse, fontWeight: '600' },
282282
methodsSection: { padding: spacing.lg, paddingTop: 0 },
283283
methodCard: { marginBottom: spacing.md },
284284
methodHeader: {
285285
flexDirection: 'row',
286286
justifyContent: 'space-between',
287287
marginBottom: spacing.sm,
288288
},
289-
methodLabel: { ...typography.body, color: colors.text, fontWeight: '600' },
289+
methodLabel: { ...typography.body, color: colors.text.primary, fontWeight: '600' },
290290
methodToken: { ...typography.caption, color: colors.textSecondary },
291291
methodBadges: { flexDirection: 'row', gap: spacing.sm, alignItems: 'center' },
292292
priorityBadge: { paddingHorizontal: spacing.sm, paddingVertical: 2, borderRadius: borderRadius.sm },
@@ -299,14 +299,14 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
299299
flexWrap: 'wrap',
300300
marginTop: spacing.sm,
301301
},
302-
expiringItem: { ...typography.body, color: colors.text, marginBottom: spacing.xs },
302+
expiringItem: { ...typography.body, color: colors.text.primary, marginBottom: spacing.xs },
303303
emptyText: { ...typography.body, color: colors.textSecondary, textAlign: 'center' },
304304
attemptRow: {
305305
flexDirection: 'row',
306306
justifyContent: 'space-between',
307307
paddingVertical: spacing.xs,
308308
},
309-
attemptLabel: { ...typography.caption, color: colors.text },
309+
attemptLabel: { ...typography.caption, color: colors.text.primary },
310310
attemptStatus: { ...typography.caption, fontWeight: '600' },
311311
});
312312
}

src/context/ThemeContext.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jest.mock('@react-native-async-storage/async-storage', () =>
99
);
1010

1111
const mockRemove = jest.fn();
12-
const mockAddChangeListener = jest.fn(() => ({ remove: mockRemove }));
12+
const mockAddChangeListener = jest.fn((_cb: any) => ({ remove: mockRemove }));
1313
const mockGetColorScheme = jest.fn();
1414

1515
jest.mock('react-native/Libraries/Utilities/Appearance', () => ({
16-
getColorScheme: (...args: unknown[]) => mockGetColorScheme(...args),
17-
addChangeListener: (...args: unknown[]) => mockAddChangeListener(...args),
16+
getColorScheme: () => mockGetColorScheme(),
17+
addChangeListener: (cb: any) => mockAddChangeListener(cb),
1818
}));
1919

2020
const wrapper = ({ children }: { children: React.ReactNode }) => (

src/context/ThemeContext.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ function resolveSystemScheme(scheme: ColorSchemeName): boolean {
2323

2424
export function ThemeProvider({ children }: { children: React.ReactNode }) {
2525
const [mode, setModeState] = useState<ThemeMode>('system');
26-
const [systemScheme, setSystemScheme] = useState<ColorSchemeName>(Appearance.getColorScheme());
26+
const [systemScheme, setSystemScheme] = useState<ColorSchemeName>(
27+
Appearance.getColorScheme() || 'light'
28+
);
2729

2830
useEffect(() => {
2931
let mounted = true;

src/screens/AnalyticsScreen.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ const AnalyticsScreen: React.FC = () => {
257257
y1={10}
258258
x2={30}
259259
y2={CHART_HEIGHT - 30}
260-
stroke={colors.border}
260+
stroke={colors.border.default}
261261
strokeWidth={1}
262262
/>
263263
<Line
264264
x1={30}
265265
y1={CHART_HEIGHT - 30}
266266
x2={CHART_WIDTH - 10}
267267
y2={CHART_HEIGHT - 30}
268-
stroke={colors.border}
268+
stroke={colors.border.default}
269269
strokeWidth={1}
270270
/>
271271
{monthlyData.map((data, index) => {
@@ -295,7 +295,7 @@ const AnalyticsScreen: React.FC = () => {
295295
x={x + barWidth / 2}
296296
y={y - 5}
297297
fontSize={10}
298-
fill={colors.text}
298+
fill={colors.text.primary}
299299
textAnchor="middle">
300300
{formatCurrency(data.amount, preferredCurrency)}
301301
</SvgText>
@@ -397,7 +397,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
397397
container: { flex: 1, backgroundColor: colors.background.primary },
398398
scrollView: { flex: 1 },
399399
header: { padding: spacing.lg, paddingBottom: spacing.md },
400-
title: { ...typography.h1, color: colors.text, marginBottom: spacing.xs },
400+
title: { ...typography.h1, color: colors.text.primary, marginBottom: spacing.xs },
401401
subtitle: { ...typography.body, color: colors.textSecondary },
402402
dateRangeContainer: {
403403
flexDirection: 'row',
@@ -412,12 +412,12 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
412412
borderRadius: borderRadius.md,
413413
backgroundColor: colors.surface,
414414
borderWidth: 1,
415-
borderColor: colors.border,
415+
borderColor: colors.border.default,
416416
alignItems: 'center',
417417
},
418418
dateRangeButtonActive: { backgroundColor: colors.primary, borderColor: colors.primary },
419-
dateRangeButtonText: { ...typography.body, color: colors.text },
420-
dateRangeButtonTextActive: { color: colors.text, fontWeight: '600' },
419+
dateRangeButtonText: { ...typography.body, color: colors.text.primary },
420+
dateRangeButtonTextActive: { color: colors.text.inverse, fontWeight: '600' },
421421
summaryContainer: {
422422
flexDirection: 'row',
423423
paddingHorizontal: spacing.lg,
@@ -426,14 +426,14 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
426426
},
427427
summaryCard: { flex: 1, alignItems: 'center' },
428428
summaryLabel: { ...typography.caption, color: colors.textSecondary, marginBottom: spacing.xs },
429-
summaryValue: { ...typography.h2, color: colors.text },
429+
summaryValue: { ...typography.h2, color: colors.text.primary },
430430
chartCard: { marginHorizontal: spacing.lg, marginBottom: spacing.md },
431-
chartTitle: { ...typography.h3, color: colors.text, marginBottom: spacing.md },
431+
chartTitle: { ...typography.h3, color: colors.text.primary, marginBottom: spacing.md },
432432
categoryList: { gap: spacing.md },
433433
categoryItem: { marginBottom: spacing.sm },
434434
categoryLeft: { flexDirection: 'row', alignItems: 'center', marginBottom: spacing.xs },
435435
categoryIcon: { fontSize: 20, marginRight: spacing.sm },
436-
categoryName: { ...typography.body, color: colors.text, flex: 1 },
436+
categoryName: { ...typography.body, color: colors.text.primary, flex: 1 },
437437
categoryRight: {
438438
flexDirection: 'row',
439439
alignItems: 'center',
@@ -442,7 +442,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
442442
right: 0,
443443
top: 0,
444444
},
445-
categoryCount: { ...typography.body, color: colors.text, fontWeight: '600' },
445+
categoryCount: { ...typography.body, color: colors.text.primary, fontWeight: '600' },
446446
categoryPercentage: {
447447
...typography.caption,
448448
color: colors.textSecondary,
@@ -451,7 +451,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
451451
},
452452
categoryBarContainer: {
453453
height: 8,
454-
backgroundColor: colors.border,
454+
backgroundColor: colors.border.default,
455455
borderRadius: borderRadius.full,
456456
overflow: 'hidden',
457457
},
@@ -468,14 +468,14 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
468468
justifyContent: 'space-between',
469469
paddingVertical: spacing.md,
470470
borderBottomWidth: 1,
471-
borderBottomColor: colors.border,
471+
borderBottomColor: colors.border.default,
472472
},
473473
projectionItemLast: { borderBottomWidth: 0 },
474474
projectionLabel: { ...typography.body, color: colors.textSecondary },
475-
projectionValue: { ...typography.body, color: colors.text, fontWeight: '600' },
475+
projectionValue: { ...typography.body, color: colors.text.primary, fontWeight: '600' },
476476
emptyState: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: spacing.xl },
477477
emptyIcon: { fontSize: 64, marginBottom: spacing.md },
478-
emptyTitle: { ...typography.h2, color: colors.text, marginBottom: spacing.sm },
478+
emptyTitle: { ...typography.h2, color: colors.text.primary, marginBottom: spacing.sm },
479479
emptyText: { ...typography.body, color: colors.textSecondary, textAlign: 'center' },
480480
});
481481
}

src/screens/ChangePlanScreen.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,15 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
240240
container: { flex: 1, backgroundColor: colors.background.primary },
241241
scrollView: { flex: 1 },
242242
card: { margin: spacing.lg, marginBottom: spacing.md },
243-
sectionTitle: { ...typography.h3, color: colors.text, marginBottom: spacing.sm },
244-
currentPrice: { ...typography.h2, color: colors.text },
243+
sectionTitle: { ...typography.h3, color: colors.text.primary, marginBottom: spacing.sm },
244+
currentPrice: { ...typography.h2, color: colors.text.primary },
245245
input: {
246246
...typography.body,
247247
borderWidth: 1,
248-
borderColor: colors.border,
248+
borderColor: colors.border.default,
249249
borderRadius: borderRadius.md,
250250
padding: spacing.md,
251-
color: colors.text,
251+
color: colors.text.primary,
252252
backgroundColor: colors.surface,
253253
marginBottom: spacing.md,
254254
},
@@ -258,12 +258,12 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
258258
padding: spacing.sm,
259259
borderRadius: borderRadius.md,
260260
borderWidth: 1,
261-
borderColor: colors.border,
261+
borderColor: colors.border.default,
262262
alignItems: 'center',
263263
},
264264
typeButtonActive: { backgroundColor: colors.primary, borderColor: colors.primary },
265-
typeButtonText: { ...typography.caption, color: colors.text },
266-
typeButtonTextActive: { color: colors.text, fontWeight: '600' },
265+
typeButtonText: { ...typography.caption, color: colors.text.primary },
266+
typeButtonTextActive: { color: colors.text.inverse, fontWeight: '600' },
267267
typeDesc: { ...typography.caption, color: colors.textSecondary },
268268
previewRow: {
269269
flexDirection: 'row',
@@ -281,7 +281,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
281281
justifyContent: 'space-between',
282282
marginBottom: spacing.xs,
283283
},
284-
changeLabel: { ...typography.body, color: colors.text, fontWeight: '600' },
284+
changeLabel: { ...typography.body, color: colors.text.primary, fontWeight: '600' },
285285
changeBadge: { ...typography.caption, fontWeight: '600' },
286286
changeDesc: { ...typography.caption, color: colors.textSecondary, marginBottom: spacing.xs },
287287
changeDate: { ...typography.caption, color: colors.textSecondary },

src/screens/CommunityScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const PostItem: React.FC<{
8484

8585
const CommunityScreen: React.FC = () => {
8686
const navigation = useNavigation<CommunityNavigationProp>();
87-
const address = useWalletStore((state) => state.address);
87+
const address = useWalletStore((state) => state.connection?.address);
8888
const {
8989
currentSubscriber,
9090
setCurrentSubscriber,

src/screens/CryptoPaymentScreen.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import { useNavigation, useRoute } from '@react-navigation/native';
1616
import { colors, spacing, typography, borderRadius } from '../utils/constants';
1717
import { Button } from '../components/common/Button';
1818
import { Card } from '../components/common/Card';
19-
import walletServiceManager, {
20-
GasEstimate,
21-
WalletConnection,
22-
TokenBalance,
23-
} from '../services/walletService';
19+
import walletServiceManager, { WalletConnection, TokenBalance } from '../services/walletService';
20+
import { GasEstimate } from '../types/wallet';
2421
import { ADDRESS_CONSTANTS } from '../utils/constants/values';
2522
import { useTransactionQueueStore } from '../store/transactionQueueStore';
2623

src/screens/ErrorDashboardScreen.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
169169
},
170170
title: {
171171
...typography.h1,
172-
color: colors.text,
172+
color: colors.text.primary,
173173
marginBottom: spacing.xs,
174174
},
175175
subtitle: {
@@ -198,7 +198,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
198198
},
199199
statValue: {
200200
...typography.h2,
201-
color: colors.text,
201+
color: colors.text.primary,
202202
fontWeight: 'bold',
203203
},
204204
statTitle: {
@@ -218,7 +218,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
218218
},
219219
sectionTitle: {
220220
...typography.h2,
221-
color: colors.text,
221+
color: colors.text.primary,
222222
},
223223
clearButton: {
224224
backgroundColor: colors.error,
@@ -237,7 +237,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
237237
padding: spacing.md,
238238
marginVertical: spacing.xs,
239239
borderWidth: 1,
240-
borderColor: colors.border,
240+
borderColor: colors.border.default,
241241
},
242242
errorHeader: {
243243
flexDirection: 'row',
@@ -257,7 +257,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
257257
},
258258
errorMessage: {
259259
...typography.body,
260-
color: colors.text,
260+
color: colors.text.primary,
261261
marginBottom: spacing.sm,
262262
},
263263
errorTimestamp: {
@@ -273,7 +273,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
273273
},
274274
separator: {
275275
height: 1,
276-
backgroundColor: colors.border,
276+
backgroundColor: colors.border.default,
277277
marginVertical: spacing.xs,
278278
},
279279
emptyState: {
@@ -282,7 +282,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
282282
},
283283
emptyStateText: {
284284
...typography.h3,
285-
color: colors.text,
285+
color: colors.text.primary,
286286
marginBottom: spacing.sm,
287287
},
288288
emptyStateSubtext: {

src/screens/GDPRSettingsScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
150150
backgroundColor: colors.background.card,
151151
marginBottom: 10,
152152
borderBottomWidth: 1,
153-
borderBottomColor: colors.border,
153+
borderBottomColor: colors.border.default,
154154
},
155155
sectionTitle: {
156156
fontSize: 18,
157157
fontWeight: '700',
158-
color: colors.text,
158+
color: colors.text.primary,
159159
marginBottom: 8,
160160
},
161161
description: {
@@ -177,7 +177,7 @@ function createStyles(colors: ReturnType<typeof useThemeColors>) {
177177
label: {
178178
fontSize: 16,
179179
fontWeight: '600',
180-
color: colors.text,
180+
color: colors.text.primary,
181181
},
182182
subLabel: {
183183
fontSize: 12,

0 commit comments

Comments
 (0)