Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions frontend-challenge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts

# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

app-example

# generated native folders
/ios
/android
1 change: 1 addition & 0 deletions frontend-challenge/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "recommendations": ["expo.vscode-expo-tools"] }
7 changes: 7 additions & 0 deletions frontend-challenge/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
"source.sortMembers": "explicit"
}
}
50 changes: 50 additions & 0 deletions frontend-challenge/EXPO_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Welcome to your Expo app 👋

This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).

## Get started

1. Install dependencies

```bash
npm install
```

2. Start the app

```bash
npx expo start
```

In the output, you'll find options to open the app in a

- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo

You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).

## Get a fresh project

When you're ready, run:

```bash
npm run reset-project
```

This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.

## Learn more

To learn more about developing your project with Expo, look at the following resources:

- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.

## Join the community

Join our community of developers creating universal apps.

- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
49 changes: 49 additions & 0 deletions frontend-challenge/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"expo": {
"name": "frontend-challenge",
"slug": "frontend-challenge",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "frontendchallenge",
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"backgroundColor": "#E6F4FE",
"foregroundImage": "./assets/images/android-icon-foreground.png",
"backgroundImage": "./assets/images/android-icon-background.png",
"monochromeImage": "./assets/images/android-icon-monochrome.png"
},
"edgeToEdgeEnabled": true,
"predictiveBackGestureEnabled": false
},
"web": {
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
[
"expo-splash-screen",
{
"image": "./assets/images/splash-icon.png",
"imageWidth": 200,
"resizeMode": "contain",
"backgroundColor": "#ffffff",
"dark": {
"backgroundColor": "#000000"
}
}
],
"expo-maps"
],
"experiments": {
"typedRoutes": true,
"reactCompiler": true
}
}
}
30 changes: 30 additions & 0 deletions frontend-challenge/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CourtsProvider } from "@/providers/CourtsProvider";
import {
DarkTheme,
DefaultTheme,
ThemeProvider,
} from "@react-navigation/native";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import "react-native-reanimated";

import { useColorScheme } from "@/hooks/use-color-scheme";

export default function RootLayout() {
const colorScheme = useColorScheme();

return (
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
<CourtsProvider>
<Stack>
<Stack.Screen name="index" options={{ headerShown: false }} />
<Stack.Screen
name="court/[courtId]"
options={{ headerShown: false, title: "Court" }}
/>
</Stack>
<StatusBar style="auto" />
</CourtsProvider>
</ThemeProvider>
);
}
115 changes: 115 additions & 0 deletions frontend-challenge/app/court/[courtId].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { Image } from "expo-image";
import { useState } from "react";
import { StyleSheet, TouchableOpacity } from "react-native";

import ParallaxScrollView from "@/components/parallax-scroll-view";
import { Review } from "@/components/Review";
import { ReviewModal } from "@/components/ReviewModal";
import { ThemedText } from "@/components/themed-text";
import { ThemedView } from "@/components/themed-view";
import { useCourts } from "@/hooks/useCourts";
import { getCourtMetadata } from "@/utils/court";
import { useLocalSearchParams } from "expo-router";

export default function CourtScreen() {
const { courtId } = useLocalSearchParams<{ courtId: string }>();
const { data: courts, submitNewReview } = useCourts();
const court = courts?.find((c) => c.id === courtId);
const { id, name, reviews, numberOfCourts, surfaceType } = court!;

const { distanceFromUser, averageRating } = getCourtMetadata(court!);

const [reviewModalOpen, setReviewModalOpen] = useState(false);

return (
<ParallaxScrollView
headerBackgroundColor={{ light: "#A1CEDC", dark: "#1D3D47" }}
headerImage={
<Image
source={require("@/assets/images/tennis.jpg")}
style={styles.tennisLogo}
/>
}
>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">
{court ? court.name : `Court ${id}`}
</ThemedText>
</ThemedView>
<ThemedView>
<ThemedText type="subtitle" style={{ margin: 18 }}>
{distanceFromUser} away
</ThemedText>

<ThemedText style={{ marginTop: 12 }}>
{numberOfCourts} {numberOfCourts === 1 ? "court" : "courts"}
</ThemedText>
<ThemedText>{surfaceType} surface</ThemedText>
</ThemedView>

<ThemedView>
<ThemedText type="subtitle" style={{ marginVertical: 18 }}>
{averageRating} ⭐ ({court!.reviews.length}{" "}
{reviews.length === 1 ? "review" : "reviews"})
</ThemedText>
</ThemedView>
<TouchableOpacity
onPress={() => {
console.log("WRITING A REVIEW");
setReviewModalOpen(true);
}}
>
<ThemedText
style={{
marginTop: 12,
borderRadius: 8,
padding: 8,
backgroundColor: "#999",
textAlign: "center",
}}
>
Write a Review
</ThemedText>
<ReviewModal
visible={reviewModalOpen}
onClose={() => setReviewModalOpen(false)}
onSubmit={(review) => {
console.log("Submitted review:", review);
submitNewReview(review);
}}
id={id}
/>
</TouchableOpacity>
{reviews.length ? (
reviews.map((review) => <Review key={review.id} review={review} />)
) : (
<ThemedText>No reviews yet.</ThemedText>
)}
</ParallaxScrollView>
);
}

const styles = StyleSheet.create({
titleContainer: {
flexDirection: "row",
alignItems: "center",
gap: 8,
},
stepContainer: {
gap: 8,
marginBottom: 8,
},
tennisLogo: {
height: "100%",
width: "100%",
bottom: 0,
left: 0,
position: "absolute",
},
loadingContainer: {
alignItems: "center",
gap: 8,
marginTop: 16,
fontSize: 36,
},
});
71 changes: 71 additions & 0 deletions frontend-challenge/app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Image } from "expo-image";
import { StyleSheet } from "react-native";

import { CourtCard } from "@/components/CourtCard";
import ParallaxScrollView from "@/components/parallax-scroll-view";
import { TennisSpinner } from "@/components/Spinner";
import { ThemedText } from "@/components/themed-text";
import { ThemedView } from "@/components/themed-view";
import { useCourts } from "@/hooks/useCourts";

export default function HomeScreen() {
const { loading, error, data: courts } = useCourts();

return (
<ParallaxScrollView
headerBackgroundColor={{ light: "#A1CEDC", dark: "#1D3D47" }}
headerImage={
<Image
source={require("@/assets/images/tennis.jpg")}
style={styles.tennisLogo}
/>
}
>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Welcome!</ThemedText>
</ThemedView>
{loading ? (
<ThemedView style={styles.loadingContainer}>
<ThemedText>Loading courts...</ThemedText>
<TennisSpinner />
</ThemedView>
) : error ? (
<ThemedText>Error loading courts: {error.message}</ThemedText>
) : (
<ThemedView>
<ThemedText>
We have {courts?.length ?? 0} tennis courts available.
</ThemedText>
{courts?.map((court) => (
<CourtCard key={court.id} court={court} />
))}
</ThemedView>
)}
</ParallaxScrollView>
);
}

const styles = StyleSheet.create({
titleContainer: {
flexDirection: "row",
alignItems: "center",
gap: 8,
},
stepContainer: {
gap: 8,
marginBottom: 8,
},
tennisLogo: {
height: "100%",
width: "100%",
bottom: 0,
left: 0,
position: "absolute",
},
loadingContainer: {
alignItems: "center",
gap: 8,
marginTop: 16,
fontSize: 36,
},
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 frontend-challenge/assets/images/favicon.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 frontend-challenge/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 frontend-challenge/assets/images/react-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 frontend-challenge/assets/images/splash-icon.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 frontend-challenge/assets/images/tennis.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading