Skip to content

Commit

Permalink
ft(splash screen):splash screen commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Franklin-pro committed May 3, 2024
2 parents 864d102 + 2962aec commit 59ede87
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 24 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Pull Request Trigger Workflow

on:
pull_request:
branches:
- develop

jobs:
build-and-test:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '>=18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test -- --ci

19 changes: 19 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Push Trigger Workflow

on:
push:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '>=18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test -- --ci
20 changes: 11 additions & 9 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"userInterfaceStyle": "dark",

"assetBundlePatterns": [
"**/*"
],
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
"supportsTablet": true,
"config": {
"usesNonExemptEncryption": false
}
},
"android": {
"adaptiveIcon": {
Expand All @@ -25,9 +29,7 @@
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router"
],
"plugins": ["expo-router", "expo-secure-store"],
"experiments": {
"typedRoutes": true
}
Expand Down
4 changes: 4 additions & 0 deletions app/(auth)/SignIn&SignOut/SetYourFingerPrint.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Text, View } from "@/components/Themed";
import { LeftArrow } from "@/components/UI/icons";
import { ThemeContext } from "@/ctx/ThemeContext";
import { useContext, useEffect } from "react";
import { SvgUri, SvgXml } from "react-native-svg";

export default function SetYourFingerPrint() {
const { theme, changeTheme } = useContext(ThemeContext);

return (
<>
<Text>Set Your Finger Print</Text>
Expand Down
54 changes: 40 additions & 14 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import FontAwesome from "@expo/vector-icons/FontAwesome";
import {
DarkTheme,
DefaultTheme,
ThemeProvider,
} from "@react-navigation/native";
import { useFonts } from "expo-font";
import { Stack } from "expo-router";
import * as SplashScreen from "expo-splash-screen";
import * as SecureStore from "expo-secure-store";

import { useEffect, useState } from "react";
import { useContext, useEffect, useState } from "react";

import { useColorScheme } from "@/components/useColorScheme";
import ThemeProvider, { ThemeContext } from "@/ctx/ThemeContext";
import { Pressable, View, useColorScheme } from "react-native";
import { ThemeType } from "@/constants/Types";
import { Text } from "@/components/Themed";

export {

Expand All @@ -33,33 +32,60 @@ export default function RootLayout() {
...FontAwesome.font,
});

const systemTheme = useColorScheme() as ThemeType;

const [favoredTheme, setFavoredTheme] = useState<ThemeType>(null);

useEffect(() => {
async function getCustomTheme() {
try {
let favoredTheme = (await SecureStore.getItemAsync(
"theme"
)) as ThemeType;

if (!favoredTheme) {
favoredTheme = systemTheme;
}

setFavoredTheme(favoredTheme);
} catch (e) {
console.log(e);
}
}

getCustomTheme();
}, []);

// Expo Router uses Error Boundaries to catch errors in the navigation tree.
useEffect(() => {
if (error) throw error;
}, [error]);

useEffect(() => {
if (loaded) {
if (loaded && favoredTheme) {
SplashScreen.hideAsync();
}
}, [loaded]);
}, [loaded, favoredTheme]);

if (!loaded) {
return null;
}

return <RootLayoutNav />;
return (
<ThemeProvider theme={favoredTheme}>
<RootLayoutNav />
</ThemeProvider>
);
}

function RootLayoutNav() {
const colorScheme = useColorScheme();

return (
<ThemeProvider value={colorScheme === "light" ? DarkTheme : DefaultTheme}>
<>
<Stack initialRouteName="(auth)">
<Stack.Screen name="(auth)" options={{ headerShown: false }} />
<Stack.Screen name="index" options={{ headerShown: false }} />
<Stack.Screen name="modal" options={{ presentation: "modal" }} />
</Stack>
</ThemeProvider>
</>
);
}
18 changes: 18 additions & 0 deletions components/__tests__/__snapshots__/StyledText-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders correctly 1`] = `
<Text
style={
[
{
"color": "#000",
},
[
undefined,
],
]
}
>
Snapshot test!
</Text>
`;
1 change: 1 addition & 0 deletions constants/Types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type ThemeType = "light" | "dark" | null
33 changes: 33 additions & 0 deletions ctx/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ThemeType } from "@/constants/Types";
import React, { createContext, useState } from "react";
import * as SecureStore from "expo-secure-store";

interface ContextType {
theme: ThemeType;
changeTheme: (theme: "light" | "dark") => void;
}

export const ThemeContext = createContext<ContextType>({
theme: null,
changeTheme: (theme: "light" | "dark") => {},
});

interface Props {
children: React.JSX.Element | React.JSX.Element[];
theme: ThemeType;
}

export default function ThemeProvider({ children, theme: value }: Props) {
const [theme, setTheme] = useState<ThemeType>(value);

async function changeTheme(theme: "light" | "dark") {
setTheme(theme);
await SecureStore.setItemAsync("theme", theme!);
}

return (
<ThemeContext.Provider value={{ theme: theme, changeTheme: changeTheme }}>
{children}
</ThemeContext.Provider>
);
}
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"test": "jest --watchAll"
"test": "jest",
"test:watch": "jest --watchAll",
"test:update": "jest --updateSnapshot",
"ci-start": "expo build:web"
},
"jest": {
"preset": "jest-expo"
Expand All @@ -20,6 +23,7 @@
"expo-linear-gradient": "~12.7.2",
"expo-linking": "~6.2.2",
"expo-router": "~3.4.10",
"expo-secure-store": "~12.8.1",
"expo-splash-screen": "~0.26.5",
"expo-status-bar": "~1.11.1",
"expo-system-ui": "~2.9.3",
Expand Down

0 comments on commit 59ede87

Please sign in to comment.