From 87c10339943276713ca77395103719fb68ab6484 Mon Sep 17 00:00:00 2001 From: David Leuliette Date: Tue, 17 Sep 2024 11:36:39 +0200 Subject: [PATCH] upate --- hackathon/spacecraft/.eslintrc.js | 5 +- hackathon/spacecraft/App.tsx | 8 ++-- hackathon/spacecraft/api/types.d.ts | 48 +++++++++---------- hackathon/spacecraft/metro.config.js | 4 +- .../src/components/Button.stories.tsx | 28 +++++------ .../src/components/ButtonSupport.tsx | 6 +-- .../src/components/FromInput.test.tsx | 3 +- .../spacecraft/src/components/FromInput.tsx | 5 +- .../spacecraft/src/components/Header.test.tsx | 1 - .../spacecraft/src/components/Header.tsx | 4 +- hackathon/spacecraft/src/components/Image.tsx | 6 +-- .../spacecraft/src/components/Offline.tsx | 1 - .../spacecraft/src/components/PeopleItem.tsx | 22 ++++----- .../src/components/ScreenContainer.tsx | 8 ++-- .../src/components/SkeletonList.tsx | 3 +- .../src/components/StarshipCard.test.tsx | 1 - .../src/components/StarshipCard.tsx | 16 +++---- .../src/components/StarshipLoadableList.tsx | 5 +- .../src/components/Text.stories.tsx | 1 - .../src/components/exercice/Offline.tsx | 1 - .../components/exercice/ScreenContainer.tsx | 9 ++-- .../spacecraft/src/context/Authentication.tsx | 2 +- hackathon/spacecraft/src/hooks/useImage.ts | 28 +++++------ hackathon/spacecraft/src/hooks/usePilot.ts | 2 +- .../src/navigation/AuthNavigator.tsx | 4 +- .../src/navigation/BottomTabNavigator.tsx | 26 +++++----- .../spacecraft/src/navigation/Navigator.tsx | 7 ++- .../src/navigation/PilotNavigator.tsx | 9 ++-- .../src/navigation/PlanetNavigator.tsx | 6 +-- .../src/navigation/PlusNavigator.tsx | 13 +++-- .../src/navigation/StarshipNavigator.tsx | 9 ++-- .../src/screens/DisappointedScreen.tsx | 11 ++--- .../src/screens/DoYouLikeScreen.tsx | 11 ++--- .../spacecraft/src/screens/LoginScreen.tsx | 26 +++++----- .../spacecraft/src/screens/LoveScreen.tsx | 14 +++--- .../src/screens/PilotDetailsScreen.tsx | 1 - .../spacecraft/src/screens/PilotScreen.tsx | 11 ++--- .../src/screens/PlanetDetailsScreen.tsx | 18 +++---- .../spacecraft/src/screens/PlanetsScreen.tsx | 12 ++--- .../spacecraft/src/screens/PlusScreen.tsx | 9 ++-- .../src/screens/StarshipDetailsScreen.tsx | 21 ++++---- .../src/screens/StarshipFeedScreen.tsx | 16 +++---- .../spacecraft/src/screens/TermsScreen.tsx | 13 +++-- .../src/screens/exercice/LoginScreen.tsx | 2 +- .../screens/exercice/StarshipFeedScreen.tsx | 1 - .../src/screens/exercice/TermsScreen.tsx | 13 +++-- hackathon/spacecraft/src/theme/theme.ts | 8 ++-- 47 files changed, 228 insertions(+), 250 deletions(-) diff --git a/hackathon/spacecraft/.eslintrc.js b/hackathon/spacecraft/.eslintrc.js index dfbfc0ad..01c6bdc5 100644 --- a/hackathon/spacecraft/.eslintrc.js +++ b/hackathon/spacecraft/.eslintrc.js @@ -9,6 +9,7 @@ module.exports = { "plugin:react/recommended", // React rules "plugin:react/jsx-runtime", // Support for React 17 JSX "plugin:prettier/recommended", // Prettier recommended rules + "plugin:perfectionist/recommended-natural-legacy", ], overrides: [ { @@ -30,18 +31,18 @@ module.exports = { camelcase: "off", // Disable camelcase rule "perfectionist/sort-imports": "error", // Perfectionist import sorting "perfectionist/sort-interfaces": ["error"], // Perfectionist interfaces sorting - "perfectionist/sort-objects": ["error", { type: "alphabetical" }], // Perfectionist objects sorting + "perfectionist/sort-objects": ["error", { type: "natural" }], // Perfectionist objects sorting "prettier/prettier": [ "warn", { usePrettierrc: true, }, ], + "react/no-unescaped-entities": "off", "react-native/no-color-literals": 2, // Enforce color literals are not used "react-native/no-raw-text": 0, // Detect raw text outside of Text component "react-native/no-unused-styles": 2, // Detect unused StyleSheet rules "react-native/sort-styles": 2, // Enforce style definitions are sorted - "react/no-unescaped-entities": "off", }, settings: { perfectionist: { diff --git a/hackathon/spacecraft/App.tsx b/hackathon/spacecraft/App.tsx index 0a1d0888..4fe68c2c 100644 --- a/hackathon/spacecraft/App.tsx +++ b/hackathon/spacecraft/App.tsx @@ -1,12 +1,12 @@ -import React from "react"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import Constants from "expo-constants"; + import { Provider as PaperProvider } from "react-native-paper"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { Navigator } from "~/navigation/Navigator"; +import { AuthenticationProvider } from "~/context/Authentication"; import { NetworkProvider } from "~/context/Network"; import { useAppearanceTheme } from "~/hooks/useAppearanceTheme"; -import { AuthenticationProvider } from "~/context/Authentication"; +import { Navigator } from "~/navigation/Navigator"; const queryClient = new QueryClient(); diff --git a/hackathon/spacecraft/api/types.d.ts b/hackathon/spacecraft/api/types.d.ts index cca499df..7007718d 100644 --- a/hackathon/spacecraft/api/types.d.ts +++ b/hackathon/spacecraft/api/types.d.ts @@ -1,39 +1,39 @@ export interface StarshipProps { - films?: []; - pilots?: []; - name: string; - url?: string; - MGLT?: string; + cargo_capacity?: string; + consumables?: string; + cost_in_credits?: string; + created?: string; crew?: string; - model: string; edited?: string; + films?: []; + hyperdrive_rating?: string; length?: string; - created?: string; - passengers?: string; - consumables?: string; manufacturer?: string; - cargo_capacity?: string; - starship_class?: string; - cost_in_credits?: string; - hyperdrive_rating?: string; max_atmosphering_speed?: string; + MGLT?: string; + model: string; + name: string; + passengers?: string; + pilots?: []; + starship_class?: string; + url?: string; } interface PeopleProps { - url: string; - name: string; - mass: string; - height: string; - gender: string; - edited: string; - films: string[]; + birth_year: string; created: string; + edited: string; eye_color: string; - homeworld: string; - species: string[]; + films: string[]; + gender: string; hair_color: string; + height: string; + homeworld: string; + mass: string; + name: string; skin_color: string; - birth_year: string; - vehicles: string[]; + species: string[]; starships: string[]; + url: string; + vehicles: string[]; } diff --git a/hackathon/spacecraft/metro.config.js b/hackathon/spacecraft/metro.config.js index 2e29d01f..6947fe6e 100644 --- a/hackathon/spacecraft/metro.config.js +++ b/hackathon/spacecraft/metro.config.js @@ -1,7 +1,7 @@ // metro.config.js -const path = require("path"); -const { getDefaultConfig } = require("expo/metro-config"); const { generate } = require("@storybook/react-native/scripts/generate"); +const { getDefaultConfig } = require("expo/metro-config"); +const path = require("path"); generate({ configPath: path.resolve(__dirname, "./.storybook"), diff --git a/hackathon/spacecraft/src/components/Button.stories.tsx b/hackathon/spacecraft/src/components/Button.stories.tsx index 74e3da24..d24eef89 100644 --- a/hackathon/spacecraft/src/components/Button.stories.tsx +++ b/hackathon/spacecraft/src/components/Button.stories.tsx @@ -8,61 +8,61 @@ export default { export const _Button = () => ( @@ -73,8 +73,8 @@ export const _ButtonSizes = () => ( diff --git a/hackathon/spacecraft/src/components/ButtonSupport.tsx b/hackathon/spacecraft/src/components/ButtonSupport.tsx index 22527c29..3f21f49a 100644 --- a/hackathon/spacecraft/src/components/ButtonSupport.tsx +++ b/hackathon/spacecraft/src/components/ButtonSupport.tsx @@ -1,7 +1,7 @@ -import React from "react"; -import { Button } from "react-native-paper"; import * as WebBrowser from "expo-web-browser"; +import { Button } from "react-native-paper"; + interface Props { mode?: "contained" | "text"; } @@ -15,8 +15,8 @@ export const ButtonSupport = ({ mode = "contained" }: Props) => { return ( } + title="" + withGoBack > { /> We are so sorry… diff --git a/hackathon/spacecraft/src/screens/DoYouLikeScreen.tsx b/hackathon/spacecraft/src/screens/DoYouLikeScreen.tsx index ee80db98..aa748d9c 100644 --- a/hackathon/spacecraft/src/screens/DoYouLikeScreen.tsx +++ b/hackathon/spacecraft/src/screens/DoYouLikeScreen.tsx @@ -1,9 +1,8 @@ -import React from "react"; import { Image } from "react-native"; import { List } from "react-native-paper"; -import { Routes } from "~/navigation/Routes"; import { ScreenContainer } from "~/components/ScreenContainer"; +import { Routes } from "~/navigation/Routes"; interface DoYouLikeScreenProps { navigation: any; @@ -30,24 +29,24 @@ export const DoYouLikeScreen = ({ navigation }: DoYouLikeScreenProps) => { /> ( )} + onPress={navigateToLoveScreen} + title="I love Spacecraft" /> ( )} + onPress={navigateToDisappointedScreen} + title="I am disappointed" /> ); diff --git a/hackathon/spacecraft/src/screens/LoginScreen.tsx b/hackathon/spacecraft/src/screens/LoginScreen.tsx index 57c45b15..7759985a 100644 --- a/hackathon/spacecraft/src/screens/LoginScreen.tsx +++ b/hackathon/spacecraft/src/screens/LoginScreen.tsx @@ -1,13 +1,13 @@ -import React, { useState } from "react"; import { useNavigation } from "@react-navigation/native"; +import { useState } from "react"; import { StyleSheet, TouchableOpacity, View } from "react-native"; import { Button, Checkbox, Text, useTheme } from "react-native-paper"; import { Header } from "~/components/Header"; -import { Routes } from "../navigation/Routes"; import { FormInput } from "../components/FromInput"; import { useAuthentication } from "../context/Authentication"; +import { Routes } from "../navigation/Routes"; export const LoginScreen = () => { const [email, setEmail] = useState(""); @@ -35,38 +35,38 @@ export const LoginScreen = () => {
setEmail(value)} returnKeyType="next" - keyboardType="email-address" - autoComplete="email" textContentType="emailAddress" - autoCapitalize="none" + value={email} /> setPassword(value)} - autoComplete="password" + secureTextEntry={!checked} + value={password} /> diff --git a/hackathon/spacecraft/src/screens/LoveScreen.tsx b/hackathon/spacecraft/src/screens/LoveScreen.tsx index d868325a..d093c9fe 100644 --- a/hackathon/spacecraft/src/screens/LoveScreen.tsx +++ b/hackathon/spacecraft/src/screens/LoveScreen.tsx @@ -1,7 +1,7 @@ -import React from "react"; import * as StoreReview from "expo-store-review"; -import { Button, Text } from "react-native-paper"; + import { Alert, Image, Platform, ScrollView, View } from "react-native"; +import { Button, Text } from "react-native-paper"; import { ButtonSupport } from "~/components/ButtonSupport"; import { ScreenContainer } from "~/components/ScreenContainer"; @@ -19,13 +19,11 @@ export const LoveScreen = () => { return ( @@ -54,10 +53,10 @@ export const PilotScreen = () => { people.name} - onEndReachedThreshold={0.01} onEndReached={handleLoadMore} + onEndReachedThreshold={0.01} + renderItem={renderItem} /> ); diff --git a/hackathon/spacecraft/src/screens/PlanetDetailsScreen.tsx b/hackathon/spacecraft/src/screens/PlanetDetailsScreen.tsx index e3f54f96..2714d6eb 100644 --- a/hackathon/spacecraft/src/screens/PlanetDetailsScreen.tsx +++ b/hackathon/spacecraft/src/screens/PlanetDetailsScreen.tsx @@ -1,4 +1,4 @@ -import { Text, View } from "react-native"; +import { Text } from "react-native-paper"; import { ScreenContainer } from "~/components/ScreenContainer"; @@ -6,20 +6,20 @@ import { ScreenContainer } from "~/components/ScreenContainer"; * @deprecated move this to typ please */ interface Planet { - url: string; - name: string; - edited: string; climate: string; - gravity: string; - terrain: string; - films: string[]; created: string; diameter: string; + edited: string; + films: string[]; + gravity: string; + name: string; + orbital_period: string; population: string; residents: string[]; - surface_water: string; - orbital_period: string; rotation_period: string; + surface_water: string; + terrain: string; + url: string; } interface Params { diff --git a/hackathon/spacecraft/src/screens/PlanetsScreen.tsx b/hackathon/spacecraft/src/screens/PlanetsScreen.tsx index 4679ae3e..624c9a8e 100644 --- a/hackathon/spacecraft/src/screens/PlanetsScreen.tsx +++ b/hackathon/spacecraft/src/screens/PlanetsScreen.tsx @@ -1,10 +1,10 @@ -import { Text } from "react-native-paper"; import { FlatList, TouchableOpacity, View } from "react-native"; +import { Text } from "react-native-paper"; -import { Routes } from "~/navigation/Routes"; +import { ScreenContainer } from "~/components/ScreenContainer"; import { usePlanets } from "~/hooks/usePlanets"; +import { Routes } from "~/navigation/Routes"; import { getTerrainColor } from "~/utils/getTerrainColor"; -import { ScreenContainer } from "~/components/ScreenContainer"; interface PlanetsScreenProps { navigation: any; @@ -47,8 +47,8 @@ export function PlanetsScreen({ navigation }: PlanetsScreenProps) { } > {item.name} @@ -70,9 +70,9 @@ export function PlanetsScreen({ navigation }: PlanetsScreenProps) { planet.name} horizontal={true} + keyExtractor={(planet) => planet.name} + renderItem={renderItem} /> ); diff --git a/hackathon/spacecraft/src/screens/PlusScreen.tsx b/hackathon/spacecraft/src/screens/PlusScreen.tsx index f97328bb..15fe3170 100644 --- a/hackathon/spacecraft/src/screens/PlusScreen.tsx +++ b/hackathon/spacecraft/src/screens/PlusScreen.tsx @@ -1,10 +1,9 @@ -import React from "react"; +import * as Application from "expo-application"; import { View } from "react-native"; import { List, Text } from "react-native-paper"; -import * as Application from "expo-application"; -import { Routes } from "~/navigation/Routes"; import { ScreenContainer } from "~/components/ScreenContainer"; +import { Routes } from "~/navigation/Routes"; interface Props {} @@ -17,14 +16,14 @@ export const PlusScreen = ({ navigation }: Props) => { ( )} + onPress={navigateToDoYouLikeScreen} + title="Do you like Spacecraft?" /> @@ -93,7 +92,6 @@ export const StarshipDetailsScreen = ({ ( )} + title={hyperdrive_rating} /> ( )} + title={max_atmosphering_speed} /> @@ -135,15 +134,17 @@ export const StarshipDetailsScreen = ({ { scale.value = withSpring(0.9); }} onPressOut={() => { scale.value = withSpring(1); }} - onPress={handleBuy} > diff --git a/hackathon/spacecraft/src/screens/StarshipFeedScreen.tsx b/hackathon/spacecraft/src/screens/StarshipFeedScreen.tsx index 70cb31cc..bfd5f4da 100644 --- a/hackathon/spacecraft/src/screens/StarshipFeedScreen.tsx +++ b/hackathon/spacecraft/src/screens/StarshipFeedScreen.tsx @@ -1,17 +1,17 @@ +import { useQuery } from "@tanstack/react-query"; import { FlatList } from "react-native"; import { Button } from "react-native-paper"; -import { useQuery } from "@tanstack/react-query"; import { fetchStarships } from "~/hooks/useStarships"; -import { StarshipCard } from "../components/StarshipCard"; import { ScreenContainer } from "../components/ScreenContainer"; +import { StarshipCard } from "../components/StarshipCard"; interface ShipProps { - name: string; - model: string; - manufacturer: string; cost_in_credits: string; + manufacturer: string; + model: string; + name: string; } interface RenderItemProps { @@ -25,8 +25,8 @@ const renderItem = (props: RenderItemProps) => { return ( ); }; @@ -45,8 +45,8 @@ export const StarshipFeedScreen = () => { return ( @@ -68,8 +68,8 @@ export const StarshipFeedScreen = () => { {/* SOLUTION 2: with a FlatList - more performant */} ship.model} + renderItem={renderItem} /> ); diff --git a/hackathon/spacecraft/src/screens/TermsScreen.tsx b/hackathon/spacecraft/src/screens/TermsScreen.tsx index 1baad735..274a8e41 100644 --- a/hackathon/spacecraft/src/screens/TermsScreen.tsx +++ b/hackathon/spacecraft/src/screens/TermsScreen.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Image, ScrollView, View } from "react-native"; import { Appbar, Text, useTheme } from "react-native-paper"; @@ -17,8 +16,8 @@ export function TermsScreen({ navigation }) { This Terms of Service, including all supplemental terms as amended from time to time, governs your use of the online game, service, or @@ -34,8 +33,8 @@ export function TermsScreen({ navigation }) { 1. Account A TOR Account ("Account") may be required to access and use TOR Services. If you have questions about Account registration, please @@ -62,8 +61,8 @@ export function TermsScreen({ navigation }) { 2. Service Some TOR Services require payment of a fee. You must have an Account and pay the subscription or other fees to participate in these @@ -73,8 +72,8 @@ export function TermsScreen({ navigation }) { 3. Privacy Your privacy is important to us. Please read the TOR Privacy Policy carefully for information relating to TOR collection and use of @@ -91,8 +90,8 @@ export function TermsScreen({ navigation }) { 4. Content "Content" on TOR Services may include software, technology, text, artwork, music, sound, and other audio visual material, and the design @@ -110,10 +109,10 @@ export function TermsScreen({ navigation }) { parties or for the failure or delay in removing any such Content. May the force be with you diff --git a/hackathon/spacecraft/src/screens/exercice/LoginScreen.tsx b/hackathon/spacecraft/src/screens/exercice/LoginScreen.tsx index ca13021a..f2bf63ba 100644 --- a/hackathon/spacecraft/src/screens/exercice/LoginScreen.tsx +++ b/hackathon/spacecraft/src/screens/exercice/LoginScreen.tsx @@ -1,5 +1,5 @@ -import React from "react"; import { StatusBar } from "expo-status-bar"; + import { StyleSheet, Text, View } from "react-native"; export const LoginScreen = () => { diff --git a/hackathon/spacecraft/src/screens/exercice/StarshipFeedScreen.tsx b/hackathon/spacecraft/src/screens/exercice/StarshipFeedScreen.tsx index 0bd0fe35..5953fc69 100644 --- a/hackathon/spacecraft/src/screens/exercice/StarshipFeedScreen.tsx +++ b/hackathon/spacecraft/src/screens/exercice/StarshipFeedScreen.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { StatusBar, StyleSheet, Text, View } from "react-native"; // import { default as data } from "../../api/data.json"; diff --git a/hackathon/spacecraft/src/screens/exercice/TermsScreen.tsx b/hackathon/spacecraft/src/screens/exercice/TermsScreen.tsx index 824b689b..c94650f4 100644 --- a/hackathon/spacecraft/src/screens/exercice/TermsScreen.tsx +++ b/hackathon/spacecraft/src/screens/exercice/TermsScreen.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Alert, Image, View } from "react-native"; import { Appbar, Text } from "react-native-paper"; @@ -17,8 +16,8 @@ export const TermsScreen = () => { This Terms of Service, including all supplemental terms as amended from time to time, governs your use of the online game, service, or @@ -34,8 +33,8 @@ export const TermsScreen = () => { 1. Account A TOR Account ("Account") may be required to access and use TOR Services. If you have questions about Account registration, please @@ -62,8 +61,8 @@ export const TermsScreen = () => { 2. Service Some TOR Services require payment of a fee. You must have an Account and pay the subscription or other fees to participate in these @@ -73,8 +72,8 @@ export const TermsScreen = () => { 3. Privacy Your privacy is important to us. Please read the TOR Privacy Policy carefully for information relating to TOR collection and use of @@ -91,8 +90,8 @@ export const TermsScreen = () => { 4. Content "Content" on TOR Services may include software, technology, text, artwork, music, sound, and other audio visual material, and the design @@ -110,10 +109,10 @@ export const TermsScreen = () => { parties or for the failure or delay in removing any such Content. May the force be with you diff --git a/hackathon/spacecraft/src/theme/theme.ts b/hackathon/spacecraft/src/theme/theme.ts index 88b5b5af..6090a949 100644 --- a/hackathon/spacecraft/src/theme/theme.ts +++ b/hackathon/spacecraft/src/theme/theme.ts @@ -1,13 +1,13 @@ +import { + DarkTheme as NavigationDarkTheme, + DefaultTheme as NavigationDefaultTheme, +} from "@react-navigation/native"; import merge from "deepmerge"; import { adaptNavigationTheme, MD3DarkTheme, MD3LightTheme, } from "react-native-paper"; -import { - DarkTheme as NavigationDarkTheme, - DefaultTheme as NavigationDefaultTheme, -} from "@react-navigation/native"; const { DarkTheme, LightTheme } = adaptNavigationTheme({ reactNavigationDark: NavigationDarkTheme,