-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #2
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
Merged
Merged
Develop #2
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f41bfdc
feat: Use SafeAreaView in the hidden route for consistency
devcedrick de9ce3b
feat: Register custom fonts and load it to the app
devcedrick 4232520
feat: Create a currecy formatting function and declare types globally
devcedrick 4643592
Move the hidden route into tabs groups
devcedrick 2664c06
feat: Implement home screen dashboard
devcedrick cd60893
fix: Keep splash screen visible until fonts are fully loaded
devcedrick d2a1c4e
feat: Add live currency conversion to formatCurrency for USD-to-PHP e…
devcedrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,37 +1,99 @@ | ||
| import ListHeading from "@/components/ListHeading"; | ||
| import SubscriptionCard from "@/components/SubscriptionCard"; | ||
| import UpcomingSubscriptionCard from "@/components/UpcomingSubscriptionCard"; | ||
| import { | ||
| HOME_BALANCE, | ||
| HOME_SUBSCRIPTIONS, | ||
| HOME_USER, | ||
| UPCOMING_SUBSCRIPTIONS, | ||
| } from "@/constants/data"; | ||
| import icons from "@/constants/icons"; | ||
| import images from "@/constants/images"; | ||
| import "@/global.css"; | ||
| import { Link } from "expo-router"; | ||
| import { formatCurrency } from "@/lib/utils/currency"; | ||
| import dayjs from "dayjs"; | ||
| import { useRouter } from "expo-router"; | ||
| import { styled } from "nativewind"; | ||
| import { Text } from "react-native"; | ||
| import { useState } from "react"; | ||
| import { FlatList, Image, Text, View } from "react-native"; | ||
| import { SafeAreaView as RNSafeAreaView } from "react-native-safe-area-context"; | ||
|
|
||
| const SafeAreaView = styled(RNSafeAreaView); | ||
|
|
||
| export default function App() { | ||
| const router = useRouter(); | ||
| const [expandedSubscriptionId, setExpandedSubscriptionId] = useState< | ||
| string | null | ||
| >(null); | ||
|
|
||
| return ( | ||
| <SafeAreaView className="flex-1 bg-background p-5"> | ||
| <Text className="text-xl font-bold text-success"> | ||
| Welcome to Nativewind! | ||
| </Text> | ||
| <Link | ||
| href="/(auth)/sign-in" | ||
| className="bg-accent text-white text-xl p-3 rounded-md m-5" | ||
| > | ||
| Sign In | ||
| </Link> | ||
| <Link | ||
| href="/(auth)/sign-up" | ||
| className="bg-accent text-white text-xl p-3 rounded-md m-5" | ||
| > | ||
| Sign Up | ||
| </Link> | ||
| <FlatList | ||
| showsVerticalScrollIndicator={false} | ||
| ListHeaderComponent={() => ( | ||
| <> | ||
| <View className="home-header"> | ||
| <View className="home-user"> | ||
| <Image source={images.avatar} className="home-avatar" /> | ||
| <Text className="home-user-name">{HOME_USER.name}</Text> | ||
| </View> | ||
| <Image source={icons.add} className="home-add-icon" /> | ||
| </View> | ||
|
|
||
| <View className="home-balance-card"> | ||
| <Text className="home-balance-label">Balance</Text> | ||
|
|
||
| <View className="home-balance-row"> | ||
| <Text className="home-balance-amount"> | ||
| {formatCurrency(HOME_BALANCE.amount)} | ||
| </Text> | ||
| <Text className="home-balance-date"> | ||
| {dayjs(HOME_BALANCE.nextRenewalDate).format("MM/DD")} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="mb-5"> | ||
| <ListHeading title="Upcoming" onPress={() => router.push("/(tabs)/subscriptions")} /> | ||
| <FlatList | ||
| data={UPCOMING_SUBSCRIPTIONS} | ||
| renderItem={({ item }) => ( | ||
| <UpcomingSubscriptionCard {...item} /> | ||
| )} | ||
| keyExtractor={(item) => item.id} | ||
| horizontal | ||
| showsHorizontalScrollIndicator={false} | ||
| ListEmptyComponent={ | ||
| <Text className="home-empty-state"> | ||
| No upcoming subscriptions yet. | ||
| </Text> | ||
| } | ||
| /> | ||
| </View> | ||
|
|
||
| {/* Subscription Examples */} | ||
| <Link | ||
| href={{ pathname: "/subscriptions/[id]", params: { id: "claude-ai" } }} | ||
| className="bg-accent text-white text-xl p-3 rounded-md m-5" | ||
| > | ||
| Claude Max Subscription | ||
| </Link> | ||
| <ListHeading title="All Subscriptions" onPress={() => router.push("/(tabs)/subscriptions")} /> | ||
| </> | ||
| )} | ||
| data={HOME_SUBSCRIPTIONS} | ||
| keyExtractor={(item) => item.id} | ||
| renderItem={({ item }) => ( | ||
| <SubscriptionCard | ||
| {...item} | ||
| expanded={expandedSubscriptionId === item.id} | ||
| onPress={() => { | ||
| setExpandedSubscriptionId((currentId) => | ||
| currentId === item.id ? null : item.id, | ||
| ); | ||
| }} | ||
| /> | ||
| )} | ||
| extraData={expandedSubscriptionId} | ||
| ItemSeparatorComponent={() => <View className="h-4" />} | ||
| ListEmptyComponent={ | ||
| <Text className="home-empty-state">No subscriptions yet.</Text> | ||
| } | ||
| contentContainerClassName="pb-28" | ||
| /> | ||
| </SafeAreaView> | ||
| ); | ||
| } |
10 changes: 7 additions & 3 deletions
10
app/subscriptions/[id].tsx → app/(tabs)/subscriptions/[id].tsx
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,16 @@ | ||
| import React from "react"; | ||
| import { Text, TouchableOpacity, View } from "react-native"; | ||
|
|
||
| const ListHeading = ({ title, onPress }: ListHeadingProps) => { | ||
| return ( | ||
| <View className="list-head"> | ||
| <Text className="list-title">{title}</Text> | ||
|
|
||
| <TouchableOpacity className="list-action" onPress={onPress}> | ||
| <Text className="list-action-text">View All</Text> | ||
| </TouchableOpacity> | ||
|
devcedrick marked this conversation as resolved.
|
||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| export default ListHeading; | ||
This file contains hidden or 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,127 @@ | ||
| import { formatCurrency } from "@/lib/utils/currency"; | ||
| import { formatSubscriptionDateTime } from "@/lib/utils/date"; | ||
| import { formatStatusLabel } from "@/lib/utils/status"; | ||
| import clsx from "clsx"; | ||
| import React from "react"; | ||
| import { Image, Pressable, Text, View } from "react-native"; | ||
|
|
||
| const SubscriptionCard = ({ | ||
| name, | ||
| price, | ||
| currency, | ||
| icon, | ||
| billing, | ||
| color, | ||
| category, | ||
| plan, | ||
| paymentMethod, | ||
| renewalDate, | ||
| startDate, | ||
| status, | ||
| expanded, | ||
| onPress, | ||
| }: SubscriptionCardProps) => { | ||
| return ( | ||
| <Pressable | ||
| className={clsx("sub-card ", expanded ? "sub-card-expanded" : "bg-card")} | ||
| style={!expanded && color ? { backgroundColor: color } : undefined} | ||
| onPress={onPress} | ||
| > | ||
| <View className="sub-head"> | ||
| <View className="sub-main"> | ||
| <Image source={icon} className="sub-icon" /> | ||
| <View className="sub-copy"> | ||
| <Text numberOfLines={1} className="sub-title"> | ||
| {name} | ||
| </Text> | ||
| <Text className="sub-meta" numberOfLines={1} ellipsizeMode="tail"> | ||
| {category?.trim() || | ||
| plan?.trim() || | ||
| formatSubscriptionDateTime(renewalDate)} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="sub-price-box"> | ||
| <Text className="sub-price"> | ||
| {formatCurrency(price, currency)} | ||
| </Text> | ||
| <Text className="sub-billing">{billing}</Text> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </View> | ||
| </View> | ||
|
|
||
| {expanded && ( | ||
| <View className="sub-body"> | ||
| <View className="sub-details"> | ||
| <View className="sub-row"> | ||
| <View className="sub-row-copy"> | ||
| <Text className="sub-label">Payment: </Text> | ||
| <Text | ||
| className="sub-value" | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| > | ||
| {paymentMethod?.trim()} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="sub-row"> | ||
| <View className="sub-row-copy"> | ||
| <Text className="sub-label">Category: </Text> | ||
| <Text | ||
| className="sub-value" | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| > | ||
| {category?.trim() || plan?.trim()} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="sub-row"> | ||
| <View className="sub-row-copy"> | ||
| <Text className="sub-label">Started: </Text> | ||
| <Text | ||
| className="sub-value" | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| > | ||
| {startDate ? formatSubscriptionDateTime(startDate) : ""} | ||
|
devcedrick marked this conversation as resolved.
|
||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="sub-row"> | ||
| <View className="sub-row-copy"> | ||
| <Text className="sub-label">Renewal Date: </Text> | ||
| <Text | ||
| className="sub-value" | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| > | ||
| {renewalDate ? formatSubscriptionDateTime(renewalDate) : ""} | ||
|
devcedrick marked this conversation as resolved.
|
||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <View className="sub-row"> | ||
| <View className="sub-row-copy"> | ||
| <Text className="sub-label">Status: </Text> | ||
| <Text | ||
| className="sub-value" | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| > | ||
| {status ? formatStatusLabel(status) : ""} | ||
|
devcedrick marked this conversation as resolved.
|
||
| </Text> | ||
| </View> | ||
| </View> | ||
| </View> | ||
| </View> | ||
| )} | ||
| </Pressable> | ||
| ); | ||
| }; | ||
|
|
||
| export default SubscriptionCard; | ||
This file contains hidden or 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,31 @@ | ||
| import { formatCurrency } from "@/lib/utils/currency"; | ||
| import React from "react"; | ||
| import { Image, Text, View } from "react-native"; | ||
|
|
||
| const UpcomingSubscriptionCard = ({ | ||
| name, | ||
| price, | ||
| daysLeft, | ||
| icon, | ||
| currency, | ||
| }: UpcomingSubscriptionCardProps) => { | ||
| return ( | ||
| <View className="upcoming-card"> | ||
| <View className="upcoming-row"> | ||
| <Image source={icon} className="upcoming-icon" /> | ||
| <View> | ||
| <Text className="upcoming-price">{formatCurrency(price, currency)}</Text> | ||
| <Text className="upcoming-meta" numberOfLines={1}> | ||
| {daysLeft} {daysLeft > 1 ? "days" : "day"} left | ||
|
devcedrick marked this conversation as resolved.
|
||
| </Text> | ||
| </View> | ||
| </View> | ||
|
|
||
| <Text className="upcoming-name" numberOfLines={1}> | ||
| {name} | ||
| </Text> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| export default UpcomingSubscriptionCard; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.