Skip to content

Commit c9b8b45

Browse files
authored
Merge branch 'main' into authscreen
2 parents 6f262cf + 4e99617 commit c9b8b45

File tree

19 files changed

+988
-166
lines changed

19 files changed

+988
-166
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
.eslintrc.js
3+
metro.config.js

.eslintrc.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native',
4-
};
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaFeatures: { jsx: true },
6+
ecmaVersion: 2022,
7+
sourceType: 'module',
8+
project: ['./tsconfig.json'],
9+
},
10+
plugins: ['@typescript-eslint', 'react', 'react-native', 'prettier'],
11+
extends: [
12+
'eslint:recommended',
13+
'plugin:@typescript-eslint/recommended',
14+
'plugin:react/recommended',
15+
'plugin:react-native/all',
16+
'plugin:prettier/recommended', // Prettier integration
17+
],
18+
env: {
19+
es2022: true,
20+
node: true,
21+
browser: true,
22+
'react-native/react-native': true,
23+
},
24+
settings: {
25+
react: { version: 'detect' },
26+
},
27+
rules: {
28+
// TypeScript rules
29+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
30+
'@typescript-eslint/explicit-module-boundary-types': 'off',
31+
32+
// React rules
33+
'react/prop-types': 'off', // TS handles props types
34+
35+
// React Native rules
36+
'react-native/no-inline-styles': 'warn',
37+
'react-native/split-platform-components': 'warn',
38+
'react-native/no-color-literals': 'off',
39+
40+
// Prettier formatting rules
41+
'prettier/prettier': [
42+
'error',
43+
{
44+
singleQuote: true,
45+
trailingComma: 'all',
46+
printWidth: 100,
47+
tabWidth: 2,
48+
semi: true,
49+
},
50+
],
51+
},
52+
};

.github/workflows/eslint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# ESLint is a tool for identifying and reporting on patterns
6+
# found in ECMAScript/JavaScript code.
7+
# More details at https://github.com/eslint/eslint
8+
# and https://eslint.org
9+
10+
name: ESLint
11+
12+
on:
13+
push:
14+
branches: [ "main" ]
15+
pull_request:
16+
# The branches below must be a subset of the branches above
17+
branches: [ "main" ]
18+
schedule:
19+
- cron: '17 23 * * 6'
20+
21+
jobs:
22+
eslint:
23+
name: Run eslint scanning
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
security-events: write
28+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Install dependencies
34+
run: npm install
35+
36+
- name: Run ESLint
37+
env:
38+
SARIF_ESLINT_IGNORE_SUPPRESSED: "true"
39+
run: npx eslint .
40+
--config .eslintrc.js
41+
--ext .js,.jsx,.ts,.tsx
42+
--max-warnings=0
43+
continue-on-error: false

.prettierrc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
2-
arrowParens: 'avoid',
3-
singleQuote: true,
4-
trailingComma: 'all',
5-
};
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 100,
5+
"tabWidth": 2,
6+
"semi": true
7+
}

App.tsx

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,66 @@
11
import { NavigationContainer } from '@react-navigation/native';
2-
import React from 'react';
2+
import React, { createContext, ReactNode, useEffect, useState } from 'react';
33
import { SafeAreaProvider } from 'react-native-safe-area-context';
44
import { AppEnvironmentProvider } from './AppEnvironment';
55
import AuthContextProvider from './Auth/AuthContextProvider';
6+
import { useColorScheme } from 'react-native';
67
import RootStack from './Navigation/RootStack';
8+
import { DarkMode, LightMode, Theme } from './Themes/Themes';
79

8-
function App() {
10+
type AuthContextType = {
11+
authenticated: boolean | null;
12+
setAuthenticated: (u: boolean) => void;
13+
};
14+
15+
type AuthProviderProps = {
16+
children: ReactNode;
17+
};
18+
19+
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
20+
21+
function AuthProvider({ children }: AuthProviderProps) {
22+
const [authenticated, setAuthenticated] = useState(false);
23+
return (
24+
<AuthContext.Provider value={{ authenticated, setAuthenticated }}>
25+
{children}
26+
</AuthContext.Provider>
27+
);
28+
}
29+
30+
type ThemeContextType = {
31+
currentTheme: Theme | null | undefined;
32+
setTheme: (t: Theme) => void;
33+
};
34+
35+
type ThemeProviderProps = {
36+
children: ReactNode;
37+
};
938

39+
export const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
40+
41+
function ThemeProvider({ children }: ThemeProviderProps) {
42+
const [currentTheme, setTheme] = useState<Theme>(LightMode);
43+
const currentSystemTheme = useColorScheme();
44+
45+
useEffect(() => {
46+
currentSystemTheme === 'light' ? setTheme(LightMode) : setTheme(DarkMode);
47+
}, [currentSystemTheme]);
48+
49+
return (
50+
<ThemeContext.Provider value={{ currentTheme, setTheme }}>{children}</ThemeContext.Provider>
51+
);
52+
}
53+
54+
function App() {
1055
return (
1156
<AppEnvironmentProvider>
1257
<SafeAreaProvider>
1358
<AuthContextProvider>
14-
<NavigationContainer>
15-
<RootStack />
16-
</NavigationContainer>
59+
<ThemeProvider>
60+
<NavigationContainer>
61+
<RootStack />
62+
</NavigationContainer>
63+
</ThemeProvider>
1764
</AuthContextProvider>
1865
</SafeAreaProvider>
1966
</AppEnvironmentProvider>

Attendance/AttendanceScreen.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import { Text, View } from 'react-native';
33

44
function AttendanceScreen() {
5-
6-
return (
5+
return (
6+
// eslint-disable-next-line react-native/no-inline-styles
77
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
8-
<Text>Attendance Screen</Text>
8+
<Text>Attendance Screen</Text>
99
</View>
10-
);
10+
);
1111
}
1212

13-
export default AttendanceScreen;
13+
export default AttendanceScreen;

Auth/AuthenticationScreen.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ import * as Authentication from './Authentication';
1010
import { authError } from './Authentication';
1111
import EnvironmentSelect from './EnvironmentSelect';
1212

13-
1413
function AuthenticationScreen() {
15-
14+
const auth = useContext(AuthContext);
1615
const auth = useContext(AuthContext);
1716
const {environment} = useAppEnvironment();
1817
const [envChangeVisible, setEnvChangeVisible] = useState<boolean>(false);
@@ -51,4 +50,4 @@ const styles = StyleSheet.create({
5150
lower: { flexShrink: 1, padding: 10, alignItems: "center" },
5251
});
5352

54-
export default AuthenticationScreen;
53+
export default AuthenticationScreen;

Merchandise/MerchandiseScreen.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import { Text, View } from 'react-native';
33

44
function MerchandiseScreen() {
5-
6-
return (
5+
return (
6+
// eslint-disable-next-line react-native/no-inline-styles
77
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
88
<Text>Merchandise Screen</Text>
99
</View>
10-
);
10+
);
1111
}
1212

13-
export default MerchandiseScreen;
13+
export default MerchandiseScreen;

Navigation/NavBar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import React from 'react';
55
import AttendanceScreen from '../Attendance/AttendanceScreen';
66
import MerchandiseScreen from '../Merchandise/MerchandiseScreen';
77
import SettingsScreen from '../Settings/SettingsScreen';
8-
98
type NavBarProps = {
10-
hidden?: boolean | null;
11-
}
9+
hidden?: boolean | null;
10+
};
1211

1312
const Tab = createBottomTabNavigator();
1413

@@ -69,4 +68,4 @@ function NavBar(props: NavBarProps) {
6968
)
7069
}
7170

72-
export default NavBar;
71+
export default NavBar;

0 commit comments

Comments
 (0)