@umang-thakkar/base-template 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +40 -304
  2. package/package.json +11 -2
  3. package/template/.eslintrc +16 -46
  4. package/template/.prettierrc.js +8 -0
  5. package/template/App.tsx +11 -15
  6. package/template/Main.tsx +29 -5
  7. package/template/__mocks__/react-native-mmkv.ts +4 -4
  8. package/template/__tests__/App.test.tsx +6 -1
  9. package/template/__tests__/helpers.test.ts +43 -0
  10. package/template/babel.config.js +2 -1
  11. package/template/constants/API_Routes.ts +19 -0
  12. package/template/constants/AppConstants.tsx +1 -1
  13. package/template/constants/AppString.ts +36 -0
  14. package/template/constants/StoragePreferences.ts +16 -31
  15. package/template/jest.config.js +5 -0
  16. package/template/jest.setup.js +5 -0
  17. package/template/package.json +2 -3
  18. package/template/src/api/AxiosActions.ts +65 -28
  19. package/template/src/api/AxiosClient.ts +13 -7
  20. package/template/src/api/queries.ts +59 -29
  21. package/template/src/api/service.ts +23 -9
  22. package/template/src/components/ErrorBoundary.tsx +27 -31
  23. package/template/src/components/SnackbarHost.tsx +86 -0
  24. package/template/src/helper/colors.ts +22 -22
  25. package/template/src/helper/common-functions.ts +56 -10
  26. package/template/src/helper/matrics.ts +4 -6
  27. package/template/src/helper/navigation-service.ts +21 -24
  28. package/template/src/helper/snackbar.ts +41 -0
  29. package/template/src/helper/typography.ts +2 -2
  30. package/template/src/helper/utility-functions.ts +10 -16
  31. package/template/src/hooks/ThemeContext.tsx +60 -30
  32. package/template/src/hooks/usePaginatedAPI.ts +96 -0
  33. package/template/src/navigation/AppStack.tsx +36 -27
  34. package/template/src/navigation/screens.ts +17 -11
  35. package/template/src/redux/slice.ts +17 -12
  36. package/template/src/redux/slices/authSlice.ts +11 -14
  37. package/template/src/redux/store.ts +13 -9
  38. package/template/src/redux/types.d.ts +40 -19
  39. package/template/src/screens/HomeScreen.tsx +103 -29
  40. package/template/src/screens/LoginScreen.tsx +101 -69
  41. package/template/src/screens/SplashScreen.tsx +36 -25
  42. package/template/src/theme/darkTheme.ts +13 -6
  43. package/template/src/theme/index.ts +4 -3
  44. package/template/src/theme/lightTheme.ts +13 -5
  45. package/template/ios/.xcode.env.local +0 -1
@@ -1,32 +1,41 @@
1
- // navigation/AppStack.tsx
2
- import React from "react";
1
+ import React from 'react';
3
2
  import {
4
- createStackNavigator,
5
- StackNavigationOptions,
6
- } from "@react-navigation/stack";
7
- import { NavigationProp } from "@react-navigation/native";
8
- import { AppStackParams } from "./AppStackParams";
9
- import { screens } from "./screens";
3
+ createNativeStackNavigator,
4
+ NativeStackNavigationOptions,
5
+ NativeStackNavigationProp,
6
+ } from '@react-navigation/native-stack';
7
+ import { AppStackParams } from './AppStackParams';
8
+ import { screens } from './screens';
10
9
 
11
- const App = createStackNavigator<AppStackParams>();
12
- const options: StackNavigationOptions = { headerShown: false };
10
+ const Stack = createNativeStackNavigator<AppStackParams>();
13
11
 
14
- export type StackNavigation = NavigationProp<AppStackParams>;
15
-
16
- const AppStack = () => {
17
- return (
18
- <App.Navigator initialRouteName="SplashScreen">
19
- {screens.map((item) => (
20
- <App.Screen
21
- key={item.name}
22
- name={item.name as any}
23
- component={item.component as any}
24
- options={options}
25
- />
26
- ))}
27
- {/* 🚀 Later you can add HomeDrawer, Tabs, or other screens separately */}
28
- </App.Navigator>
29
- );
12
+ /**
13
+ * Defaults for every screen. Native stack uses UINavigationController on iOS
14
+ * and Fragments on Android, so transitions and swipe-back run natively.
15
+ */
16
+ export const defaultScreenOptions: NativeStackNavigationOptions = {
17
+ headerShown: false,
18
+ // Same slide on both platforms (Android's default is a fade-from-bottom).
19
+ animation: 'ios_from_right',
20
+ // Off-screen screens stop re-rendering until they're focused again.
21
+ freezeOnBlur: true,
30
22
  };
31
23
 
32
- export default AppStack;
24
+ /** Use with `useNavigation<StackNavigation>()` in nested components. */
25
+ export type StackNavigation = NativeStackNavigationProp<AppStackParams>;
26
+
27
+ const AppStack = () => (
28
+ <Stack.Navigator initialRouteName="SplashScreen" screenOptions={defaultScreenOptions}>
29
+ {screens.map(item => (
30
+ <Stack.Screen
31
+ key={item.name}
32
+ name={item.name}
33
+ component={item.component}
34
+ options={item.options}
35
+ />
36
+ ))}
37
+ {/* Tabs or a drawer can be registered here as screens (see docs/navigation.md). */}
38
+ </Stack.Navigator>
39
+ );
40
+
41
+ export default AppStack;
@@ -1,16 +1,22 @@
1
- import { StackNavigationOptions } from "@react-navigation/stack";
2
- import HomeScreen from "../screens/HomeScreen";
3
- import SplashScreen from "../screens/SplashScreen";
4
- import LoginScreen from "../screens/LoginScreen";
5
- import { AppStackParams } from "./AppStackParams";
1
+ import type React from 'react';
2
+ import type { NativeStackNavigationOptions } from '@react-navigation/native-stack';
3
+ import HomeScreen from '../screens/HomeScreen';
4
+ import SplashScreen from '../screens/SplashScreen';
5
+ import LoginScreen from '../screens/LoginScreen';
6
+ import { AppStackParams } from './AppStackParams';
6
7
 
7
- export const screens: Array<{
8
+ export type ScreenConfig = {
8
9
  name: keyof AppStackParams;
9
10
  component: React.ComponentType<any>;
10
- options?: StackNavigationOptions;
11
- }> = [
12
- { name: "SplashScreen", component: SplashScreen },
13
- { name: "LoginScreen", component: LoginScreen },
14
- { name: "HomeScreen", component: HomeScreen },
11
+ /** Merged over `defaultScreenOptions` in AppStack.tsx. */
12
+ options?: NativeStackNavigationOptions;
13
+ };
14
+
15
+ export const screens: ScreenConfig[] = [
16
+ { name: 'SplashScreen', component: SplashScreen },
17
+ // Login and Home replace the whole stack (navigation.reset), so a fade
18
+ // reads better than a slide.
19
+ { name: 'LoginScreen', component: LoginScreen, options: { animation: 'fade' } },
20
+ { name: 'HomeScreen', component: HomeScreen, options: { animation: 'fade' } },
15
21
  // Add your other screens here
16
22
  ];
@@ -1,21 +1,26 @@
1
1
  import { createSlice, PayloadAction } from '@reduxjs/toolkit';
2
2
 
3
- const initialState: any = {
4
- value: 0,
3
+ /** Example app-wide slice. Replace or remove once the app has real global state. */
4
+ interface GlobalState {
5
+ value: number;
6
+ }
7
+
8
+ const initialState: GlobalState = {
9
+ value: 0,
5
10
  };
6
11
 
7
12
  const appSlice = createSlice({
8
- name: 'global',
9
- initialState,
10
- reducers: {
11
- setValue: (state, action: PayloadAction<number>) => {
12
- state.value = action.payload;
13
- },
14
- resetValue: (state) => {
15
- state.value = 0;
16
- },
13
+ name: 'global',
14
+ initialState,
15
+ reducers: {
16
+ setValue: (state, action: PayloadAction<number>) => {
17
+ state.value = action.payload;
18
+ },
19
+ resetValue: state => {
20
+ state.value = 0;
17
21
  },
22
+ },
18
23
  });
19
24
 
20
25
  export const { setValue, resetValue } = appSlice.actions;
21
- export default appSlice.reducer;
26
+ export default appSlice.reducer;
@@ -1,9 +1,9 @@
1
- import { createSlice, PayloadAction } from "@reduxjs/toolkit";
2
-
3
- type User = { [key: string]: any } | null;
1
+ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
2
+ import type { User } from '../types';
3
+ import type { RootStore } from '../store';
4
4
 
5
5
  interface AuthState {
6
- user: User;
6
+ user: User | null;
7
7
  accessToken: string | null;
8
8
  }
9
9
 
@@ -13,17 +13,14 @@ const initialState: AuthState = {
13
13
  };
14
14
 
15
15
  const authSlice = createSlice({
16
- name: "auth",
16
+ name: 'auth',
17
17
  initialState,
18
18
  reducers: {
19
- setCredentials(
20
- state,
21
- action: PayloadAction<{ user: User; accessToken: string }>,
22
- ) {
19
+ setCredentials(state, action: PayloadAction<{ user: User; accessToken: string }>) {
23
20
  state.user = action.payload.user;
24
21
  state.accessToken = action.payload.accessToken;
25
22
  },
26
- setUser(state, action: PayloadAction<User>) {
23
+ setUser(state, action: PayloadAction<User | null>) {
27
24
  state.user = action.payload;
28
25
  },
29
26
  setAccessToken(state, action: PayloadAction<string | null>) {
@@ -36,10 +33,10 @@ const authSlice = createSlice({
36
33
  },
37
34
  });
38
35
 
39
- export const { setCredentials, setUser, setAccessToken, clearAuth } =
40
- authSlice.actions;
36
+ export const { setCredentials, setUser, setAccessToken, clearAuth } = authSlice.actions;
41
37
 
42
- export const selectCurrentUser = (state: any) => state.auth?.user;
43
- export const selectAccessToken = (state: any) => state.auth?.accessToken;
38
+ export const selectCurrentUser = (state: RootStore) => state.auth.user;
39
+ export const selectAccessToken = (state: RootStore) => state.auth.accessToken;
40
+ export const selectIsLoggedIn = (state: RootStore) => !!state.auth.accessToken;
44
41
 
45
42
  export default authSlice.reducer;
@@ -1,23 +1,27 @@
1
- import { combineReducers, configureStore } from "@reduxjs/toolkit";
2
- import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
3
- import { persistReducer, persistStore } from "redux-persist";
4
- import reducer from "./slice";
5
- import authReducer from "./slices/authSlice";
6
- import { reduxStorage } from "../../constants/StoragePreferences";
1
+ import { combineReducers, configureStore } from '@reduxjs/toolkit';
2
+ import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
3
+ import { persistReducer, persistStore } from 'redux-persist';
4
+ import reducer from './slice';
5
+ import authReducer from './slices/authSlice';
6
+ import { reduxStorage } from '../../constants/StoragePreferences';
7
+
7
8
  const persistConfig = {
8
- key: "root",
9
+ key: 'root',
9
10
  storage: reduxStorage,
10
- whitelist: ["auth"],
11
+ // Only these slices are written to MMKV. Server data belongs in React Query.
12
+ whitelist: ['auth'],
11
13
  };
12
14
 
13
15
  const rootReducer = combineReducers({
14
16
  global: reducer,
15
17
  auth: authReducer,
16
18
  });
19
+
17
20
  const persistedReducer = persistReducer(persistConfig, rootReducer);
21
+
18
22
  export const store = configureStore({
19
23
  reducer: persistedReducer,
20
- middleware: (getDefaultMiddleware) =>
24
+ middleware: getDefaultMiddleware =>
21
25
  getDefaultMiddleware({
22
26
  serializableCheck: false,
23
27
  }),
@@ -1,40 +1,61 @@
1
1
  /**
2
- * API Error Response Type
2
+ * Shared types: API request bodies, response models and app entities.
3
+ * Component props stay in their component file; route params live in
4
+ * src/navigation/AppStackParams.ts.
3
5
  */
6
+
7
+ // ---------- API envelopes ----------
8
+
4
9
  export interface ApiErrorResponse {
5
10
  message: string;
6
11
  statusCode?: number;
7
12
  code?: string;
8
- details?: Record<string, any>;
13
+ details?: Record<string, unknown>;
9
14
  }
10
15
 
11
- /**
12
- * API Success Response Type
13
- */
14
16
  export interface ApiSuccessResponse<T> {
15
17
  data: T;
16
18
  message?: string;
17
19
  statusCode?: number;
18
20
  }
19
21
 
20
- /**
21
- * Todo Item Type
22
- */
22
+ export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;
23
+
24
+ export interface PaginationOptions {
25
+ page: number;
26
+ limit: number;
27
+ }
28
+
29
+ // ---------- Auth ----------
30
+
31
+ export interface User {
32
+ id: string;
33
+ name: string;
34
+ email: string;
35
+ avatarUrl?: string;
36
+ }
37
+
38
+ export interface LoginForm {
39
+ email: string;
40
+ password: string;
41
+ }
42
+
43
+ export interface LoginResponse {
44
+ user: User;
45
+ accessToken: string;
46
+ refreshToken?: string;
47
+ }
48
+
49
+ // ---------- Todos (demo) ----------
50
+
23
51
  export interface TodoItem {
24
52
  id: number;
25
53
  title: string;
26
54
  completed: boolean;
27
55
  }
28
56
 
29
- /**
30
- * Pagination Type
31
- */
32
- export interface PaginationOptions {
33
- page: number;
34
- limit: number;
57
+ export interface TodoListParams {
58
+ _page: number;
59
+ _limit: number;
60
+ q?: string;
35
61
  }
36
-
37
- /**
38
- * Generic API Response
39
- */
40
- export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;
@@ -1,38 +1,112 @@
1
- import * as React from 'react';
2
- import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
1
+ import React from 'react';
2
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
3
3
  import { SafeAreaView } from 'react-native-safe-area-context';
4
+
5
+ // Hooks / state
4
6
  import { useTheme } from '../hooks/ThemeContext';
7
+ import { useAppDispatch, useAppSelector } from '../redux/store';
8
+ import { clearAuth, selectCurrentUser } from '../redux/slices/authSlice';
9
+
10
+ // Helpers / constants
11
+ import { navigateAndSimpleReset } from '../helper/navigation-service';
12
+ import { Typography } from '../helper/typography';
13
+ import { horizontalScale, moderateScale, verticalScale } from '../helper/matrics';
14
+ import { AppString } from '../../constants/AppString';
15
+
16
+ const HomeScreen = () => {
17
+ const { theme, mode, preference, toggleTheme, setPreference } = useTheme();
18
+ const user = useAppSelector(selectCurrentUser);
19
+ const dispatch = useAppDispatch();
20
+
21
+ const onLogout = () => {
22
+ dispatch(clearAuth());
23
+ navigateAndSimpleReset('LoginScreen');
24
+ };
25
+
26
+ const outlineButton = [styles.button, styles.outline, { borderColor: theme.border }];
27
+
28
+ return (
29
+ <SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
30
+ <View style={styles.container}>
31
+ <Text style={[Typography.title1, { color: theme.text }]}>
32
+ {AppString.hello}
33
+ {user?.name ? `, ${user.name}` : ''}
34
+ </Text>
35
+
36
+ <View style={[styles.card, { backgroundColor: theme.card, borderColor: theme.border }]}>
37
+ <Text style={[Typography.caption1, styles.overline, { color: theme.muted }]}>
38
+ {AppString.currentTheme}
39
+ </Text>
40
+ <Text style={[Typography.headline, styles.capitalize, { color: theme.text }]}>
41
+ {mode} · {preference}
42
+ </Text>
43
+ </View>
5
44
 
6
- interface Props { }
7
-
8
- const HomeScreen = (props: Props) => {
9
- const { theme, toggleTheme, mode } = useTheme();
10
- return (
11
- <SafeAreaView style={{ flex: 1, backgroundColor: theme.background }}>
12
- <View style={[styles.container, { backgroundColor: theme.background }]}>
13
- <Text style={{ color: theme.text }}>Current theme: {mode}</Text>
14
- <TouchableOpacity
15
- style={[styles.button, { backgroundColor: theme.primary }]}
16
- onPress={toggleTheme}
17
- >
18
- <Text style={{ color: theme.text }}>Toggle Theme</Text>
19
- </TouchableOpacity>
20
- </View>
21
- </SafeAreaView>
22
- );
45
+ <View style={styles.actions}>
46
+ <Pressable
47
+ onPress={toggleTheme}
48
+ accessibilityRole="button"
49
+ style={[styles.button, { backgroundColor: theme.primary }]}>
50
+ <Text style={[Typography.headline, { color: theme.onPrimary }]}>
51
+ {AppString.toggleTheme}
52
+ </Text>
53
+ </Pressable>
54
+ <Pressable
55
+ onPress={() => setPreference('system')}
56
+ disabled={preference === 'system'}
57
+ accessibilityRole="button"
58
+ style={[outlineButton, preference === 'system' && styles.disabled]}>
59
+ <Text style={[Typography.headline, { color: theme.text }]}>
60
+ {AppString.followSystem}
61
+ </Text>
62
+ </Pressable>
63
+ <Pressable onPress={onLogout} accessibilityRole="button" style={outlineButton}>
64
+ <Text style={[Typography.headline, { color: theme.error }]}>{AppString.logout}</Text>
65
+ </Pressable>
66
+ </View>
67
+ </View>
68
+ </SafeAreaView>
69
+ );
23
70
  };
24
71
 
25
72
  export default HomeScreen;
26
73
 
27
74
  const styles = StyleSheet.create({
28
- container: {
29
- flex: 1,
30
- justifyContent: 'center',
31
- alignItems: 'center',
32
- },
33
- button: {
34
- marginTop: 20,
35
- padding: 12,
36
- borderRadius: 8,
37
- },
75
+ safeArea: {
76
+ flex: 1,
77
+ },
78
+ container: {
79
+ flex: 1,
80
+ justifyContent: 'center',
81
+ paddingHorizontal: horizontalScale(24),
82
+ },
83
+ card: {
84
+ marginTop: verticalScale(32),
85
+ borderRadius: moderateScale(16),
86
+ borderWidth: 1,
87
+ padding: moderateScale(20),
88
+ },
89
+ overline: {
90
+ textTransform: 'uppercase',
91
+ },
92
+ capitalize: {
93
+ marginTop: verticalScale(4),
94
+ textTransform: 'capitalize',
95
+ },
96
+ actions: {
97
+ marginTop: verticalScale(24),
98
+ gap: moderateScale(12),
99
+ },
100
+ button: {
101
+ height: 48,
102
+ borderRadius: moderateScale(12),
103
+ alignItems: 'center',
104
+ justifyContent: 'center',
105
+ },
106
+ outline: {
107
+ borderWidth: 1,
108
+ },
109
+ disabled: {
110
+ opacity: 0.5,
111
+ },
38
112
  });
@@ -1,76 +1,101 @@
1
- import React, { useState } from "react";
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- TextInput,
7
- TouchableOpacity,
8
- } from "react-native";
9
- import { SafeAreaView } from "react-native-safe-area-context";
10
- import { useTheme } from "../hooks/ThemeContext";
11
- import { useAppDispatch } from "../redux/store";
12
- import { setCredentials } from "../redux/slices/authSlice";
13
- import { NativeStackNavigationProp } from "@react-navigation/native-stack";
14
- import { RouteProp } from "@react-navigation/native";
15
- import { AppStackParams } from "../navigation/AppStackParams";
1
+ import React, { useState } from 'react';
2
+ import { KeyboardAvoidingView, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
3
+ import { SafeAreaView } from 'react-native-safe-area-context';
4
+ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
5
+ import { RouteProp } from '@react-navigation/native';
6
+
7
+ // Types
8
+ import { AppStackParams } from '../navigation/AppStackParams';
9
+
10
+ // Hooks / state
11
+ import { useTheme } from '../hooks/ThemeContext';
12
+ import { useAppDispatch } from '../redux/store';
13
+ import { setCredentials } from '../redux/slices/authSlice';
14
+
15
+ // Helpers / constants
16
+ import { showSnackbar } from '../helper/common-functions';
17
+ import { isIOS } from '../helper/utility-functions';
18
+ import { Typography } from '../helper/typography';
19
+ import { horizontalScale, moderateScale, verticalScale } from '../helper/matrics';
20
+ import { AppString } from '../../constants/AppString';
16
21
 
17
22
  type Props = {
18
- navigation: NativeStackNavigationProp<AppStackParams, "LoginScreen">;
19
- route: RouteProp<AppStackParams, "LoginScreen">;
23
+ navigation: NativeStackNavigationProp<AppStackParams, 'LoginScreen'>;
24
+ route: RouteProp<AppStackParams, 'LoginScreen'>;
20
25
  };
21
26
 
22
27
  const LoginScreen = ({ navigation }: Props) => {
23
28
  const { theme } = useTheme();
24
29
  const dispatch = useAppDispatch();
25
- const [email, setEmail] = useState("");
26
- const [password, setPassword] = useState("");
30
+ const [email, setEmail] = useState('');
31
+ const [password, setPassword] = useState('');
32
+
33
+ const inputStyle = [
34
+ styles.input,
35
+ Typography.body1,
36
+ { backgroundColor: theme.card, borderColor: theme.border, color: theme.text },
37
+ ];
27
38
 
28
39
  const onLogin = () => {
29
- // store dummy data in auth reducer
40
+ // Demo only: stores dummy credentials. With a real backend, call the
41
+ // mutation instead:
42
+ // const { mutate: login, isPending } = useLogin();
43
+ // login({ email, password }, {
44
+ // onSuccess: res => dispatch(setCredentials(res)),
45
+ // onError: err => showErrorSnackbar(getErrorMessage(err)),
46
+ // });
30
47
  dispatch(
31
48
  setCredentials({
32
- user: { id: "1", name: "Demo User", email: email || "demo@local" },
33
- accessToken: "dummy-access-token-123",
49
+ user: { id: '1', name: 'Demo User', email: email || 'demo@local' },
50
+ accessToken: 'dummy-access-token-123',
34
51
  }),
35
52
  );
36
- navigation.reset({ index: 0, routes: [{ name: "HomeScreen" }] });
53
+ showSnackbar(AppString.loginSuccess);
54
+ navigation.reset({ index: 0, routes: [{ name: 'HomeScreen' }] });
37
55
  };
38
56
 
39
57
  return (
40
- <SafeAreaView style={{ flex: 1, backgroundColor: theme.background }}>
41
- <View style={[styles.container, { backgroundColor: theme.background }]}>
42
- <Text style={[styles.title, { color: theme.text }]}>Welcome back</Text>
43
- <TextInput
44
- placeholder="Email"
45
- placeholderTextColor={theme.text + "88"}
46
- style={[
47
- styles.input,
48
- { backgroundColor: theme.card, color: theme.text },
49
- ]}
50
- value={email}
51
- onChangeText={setEmail}
52
- keyboardType="email-address"
53
- autoCapitalize="none"
54
- />
55
- <TextInput
56
- placeholder="Password"
57
- placeholderTextColor={theme.text + "88"}
58
- style={[
59
- styles.input,
60
- { backgroundColor: theme.card, color: theme.text },
61
- ]}
62
- value={password}
63
- onChangeText={setPassword}
64
- secureTextEntry
65
- />
58
+ <SafeAreaView style={[styles.safeArea, { backgroundColor: theme.background }]}>
59
+ <KeyboardAvoidingView behavior={isIOS ? 'padding' : undefined} style={styles.container}>
60
+ <Text style={[Typography.title1, styles.center, { color: theme.text }]}>
61
+ {AppString.welcomeBack}
62
+ </Text>
63
+ <Text style={[Typography.body2, styles.center, styles.subtitle, { color: theme.muted }]}>
64
+ {AppString.signInToContinue}
65
+ </Text>
66
+
67
+ <View style={styles.fields}>
68
+ <TextInput
69
+ placeholder={AppString.email}
70
+ placeholderTextColor={theme.muted}
71
+ style={inputStyle}
72
+ value={email}
73
+ onChangeText={setEmail}
74
+ keyboardType="email-address"
75
+ autoCapitalize="none"
76
+ autoComplete="email"
77
+ />
78
+ <TextInput
79
+ placeholder={AppString.password}
80
+ placeholderTextColor={theme.muted}
81
+ style={inputStyle}
82
+ value={password}
83
+ onChangeText={setPassword}
84
+ secureTextEntry
85
+ autoComplete="password"
86
+ />
87
+ </View>
66
88
 
67
- <TouchableOpacity
68
- style={[styles.button, { backgroundColor: theme.primary }]}
89
+ <Pressable
69
90
  onPress={onLogin}
70
- >
71
- <Text style={{ color: theme.text }}>Sign in</Text>
72
- </TouchableOpacity>
73
- </View>
91
+ accessibilityRole="button"
92
+ style={({ pressed }) => [
93
+ styles.button,
94
+ { backgroundColor: theme.primary, opacity: pressed ? 0.8 : 1 },
95
+ ]}>
96
+ <Text style={[Typography.headline, { color: theme.onPrimary }]}>{AppString.login}</Text>
97
+ </Pressable>
98
+ </KeyboardAvoidingView>
74
99
  </SafeAreaView>
75
100
  );
76
101
  };
@@ -78,28 +103,35 @@ const LoginScreen = ({ navigation }: Props) => {
78
103
  export default LoginScreen;
79
104
 
80
105
  const styles = StyleSheet.create({
106
+ safeArea: {
107
+ flex: 1,
108
+ },
81
109
  container: {
82
110
  flex: 1,
83
- justifyContent: "center",
84
- padding: 24,
111
+ justifyContent: 'center',
112
+ paddingHorizontal: horizontalScale(24),
113
+ },
114
+ center: {
115
+ textAlign: 'center',
116
+ },
117
+ subtitle: {
118
+ marginTop: verticalScale(8),
119
+ marginBottom: verticalScale(32),
85
120
  },
86
- title: {
87
- fontSize: 28,
88
- fontWeight: "600",
89
- marginBottom: 24,
90
- textAlign: "center",
121
+ fields: {
122
+ gap: moderateScale(12),
91
123
  },
92
124
  input: {
93
125
  height: 48,
94
- borderRadius: 8,
95
- paddingHorizontal: 12,
96
- marginBottom: 12,
126
+ borderRadius: moderateScale(12),
127
+ borderWidth: 1,
128
+ paddingHorizontal: horizontalScale(16),
97
129
  },
98
130
  button: {
99
131
  height: 48,
100
- borderRadius: 8,
101
- alignItems: "center",
102
- justifyContent: "center",
103
- marginTop: 12,
132
+ borderRadius: moderateScale(12),
133
+ alignItems: 'center',
134
+ justifyContent: 'center',
135
+ marginTop: verticalScale(24),
104
136
  },
105
137
  });