nx-react-native-cli 1.0.17 → 1.0.18

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 (82) hide show
  1. package/lib/index.cjs +13 -13
  2. package/package.json +1 -1
  3. package/templates/.eslintrc.json +1 -0
  4. package/templates/.nvmrc +1 -1
  5. package/templates/apps/mobile/android/app/build.gradle +1 -1
  6. package/templates/apps/mobile/android/app/proguard-rules.pro +20 -0
  7. package/templates/apps/mobile/package.json +3 -1
  8. package/templates/apps/mobile/react-native.config.js +7 -0
  9. package/templates/apps/mobile/src/app/index.tsx +7 -1
  10. package/templates/apps/mobile/src/assets/fonts/InterBlack.ttf +0 -0
  11. package/templates/apps/mobile/src/assets/fonts/InterBlackItalic.ttf +0 -0
  12. package/templates/apps/mobile/src/assets/fonts/InterBold.ttf +0 -0
  13. package/templates/apps/mobile/src/assets/fonts/InterBoldItalic.ttf +0 -0
  14. package/templates/apps/mobile/src/assets/fonts/InterExtraBold.ttf +0 -0
  15. package/templates/apps/mobile/src/assets/fonts/InterExtraBoldItalic.ttf +0 -0
  16. package/templates/apps/mobile/src/assets/fonts/InterExtraLight.ttf +0 -0
  17. package/templates/apps/mobile/src/assets/fonts/InterExtraLightItalic.ttf +0 -0
  18. package/templates/apps/mobile/src/assets/fonts/InterItalic.ttf +0 -0
  19. package/templates/apps/mobile/src/assets/fonts/InterLight.ttf +0 -0
  20. package/templates/apps/mobile/src/assets/fonts/InterLightItalic.ttf +0 -0
  21. package/templates/apps/mobile/src/assets/fonts/InterMedium.ttf +0 -0
  22. package/templates/apps/mobile/src/assets/fonts/InterMediumItalic.ttf +0 -0
  23. package/templates/apps/mobile/src/assets/fonts/InterRegular.ttf +0 -0
  24. package/templates/apps/mobile/src/assets/fonts/InterSemiBold.ttf +0 -0
  25. package/templates/apps/mobile/src/assets/fonts/InterSemiBoldItalic.ttf +0 -0
  26. package/templates/apps/mobile/src/assets/fonts/InterThin.ttf +0 -0
  27. package/templates/apps/mobile/src/assets/fonts/InterThinItalic.ttf +0 -0
  28. package/templates/apps/mobile/src/assets/fonts/MontserratBlack.ttf +0 -0
  29. package/templates/apps/mobile/src/assets/fonts/MontserratBlackItalic.ttf +0 -0
  30. package/templates/apps/mobile/src/assets/fonts/MontserratBold.ttf +0 -0
  31. package/templates/apps/mobile/src/assets/fonts/MontserratBoldItalic.ttf +0 -0
  32. package/templates/apps/mobile/src/assets/fonts/MontserratExtraBold.ttf +0 -0
  33. package/templates/apps/mobile/src/assets/fonts/MontserratExtraBoldItalic.ttf +0 -0
  34. package/templates/apps/mobile/src/assets/fonts/MontserratExtraLight.ttf +0 -0
  35. package/templates/apps/mobile/src/assets/fonts/MontserratExtraLightItalic.ttf +0 -0
  36. package/templates/apps/mobile/src/assets/fonts/MontserratItalic.ttf +0 -0
  37. package/templates/apps/mobile/src/assets/fonts/MontserratLight.ttf +0 -0
  38. package/templates/apps/mobile/src/assets/fonts/MontserratLightItalic.ttf +0 -0
  39. package/templates/apps/mobile/src/assets/fonts/MontserratMedium.ttf +0 -0
  40. package/templates/apps/mobile/src/assets/fonts/MontserratMediumItalic.ttf +0 -0
  41. package/templates/apps/mobile/src/assets/fonts/MontserratRegular.ttf +0 -0
  42. package/templates/apps/mobile/src/assets/fonts/MontserratSemiBold.ttf +0 -0
  43. package/templates/apps/mobile/src/assets/fonts/MontserratSemiBoldItalic.ttf +0 -0
  44. package/templates/apps/mobile/src/assets/fonts/MontserratThin.ttf +0 -0
  45. package/templates/apps/mobile/src/assets/fonts/MontserratThinItalic.ttf +0 -0
  46. package/templates/apps/mobile/src/components/atoms/BottomSheet/bottom-sheet.component.tsx +9 -7
  47. package/templates/apps/mobile/src/components/atoms/Box/box.component.tsx +21 -0
  48. package/templates/apps/mobile/src/components/atoms/Box/index.ts +1 -0
  49. package/templates/apps/mobile/src/components/atoms/Button/button.component.tsx +24 -8
  50. package/templates/apps/mobile/src/components/atoms/Button/index.ts +0 -1
  51. package/templates/apps/mobile/src/components/atoms/Divider/divider-component.tsx +2 -2
  52. package/templates/apps/mobile/src/components/atoms/InputLayout/input-layout.component.tsx +12 -11
  53. package/templates/apps/mobile/src/components/atoms/ListLoadingItem/list-loading-item.component.tsx +17 -17
  54. package/templates/apps/mobile/src/components/atoms/Modal/modal.component.tsx +5 -4
  55. package/templates/apps/mobile/src/components/atoms/ScreenLoader/screen-loader.component.tsx +5 -4
  56. package/templates/apps/mobile/src/components/atoms/Skeleton/skeleton.component.tsx +2 -2
  57. package/templates/apps/mobile/src/components/atoms/TextInput/text-input.component.tsx +5 -5
  58. package/templates/apps/mobile/src/components/atoms/Typography/index.ts +1 -0
  59. package/templates/apps/mobile/src/components/atoms/{Text/text.component.tsx → Typography/typography.component.tsx} +1 -1
  60. package/templates/apps/mobile/src/components/atoms/index.ts +2 -1
  61. package/templates/apps/mobile/src/components/molecules/BackButton/back-button.component.tsx +4 -4
  62. package/templates/apps/mobile/src/components/molecules/BottomActionsContainer/BottomActionsContainer.component.tsx +1 -4
  63. package/templates/apps/mobile/src/components/molecules/ScreenContainer/screen-container.component.tsx +11 -9
  64. package/templates/apps/mobile/src/components/molecules/ScreenHeader/screen-header.component.tsx +13 -19
  65. package/templates/apps/mobile/src/components/molecules/StorageManager/StorageManager.component.tsx +1 -3
  66. package/templates/apps/mobile/src/hooks/index.ts +2 -1
  67. package/templates/apps/mobile/src/hooks/useToggleDarkMode.hook.tsx +9 -0
  68. package/templates/apps/mobile/src/routes/index.tsx +3 -3
  69. package/templates/apps/mobile/src/routes/privateRoutes.tsx +10 -7
  70. package/templates/apps/mobile/src/routes/publicRoutes.tsx +12 -9
  71. package/templates/apps/mobile/src/routes/screen-options.ts +0 -1
  72. package/templates/apps/mobile/src/routes/screens.enum.ts +1 -1
  73. package/templates/apps/mobile/src/screens/HomeScreen/home.screen.tsx +2 -2
  74. package/templates/apps/mobile/src/screens/LandingScreen/landing.screen.tsx +37 -0
  75. package/templates/apps/mobile/src/types/component.type.ts +1 -6
  76. package/templates/apps/mobile/src/utils/axios.util.ts +10 -0
  77. package/templates/apps/mobile/src/utils/index.ts +4 -0
  78. package/templates/apps/mobile/src/utils/log.util.ts +40 -0
  79. package/templates/apps/mobile/src/utils/route.util.ts +48 -0
  80. package/templates/apps/mobile/src/components/atoms/Button/outlined-button.component.tsx +0 -59
  81. package/templates/apps/mobile/src/components/atoms/Text/index.ts +0 -1
  82. package/templates/apps/mobile/src/screens/LoginScreen/login.screen.tsx +0 -13
@@ -1,4 +1,5 @@
1
1
  export * from './BottomSheet';
2
+ export * from './Box';
2
3
  export * from './Button';
3
4
  export * from './Divider';
4
5
  export * from './InputLayout';
@@ -6,5 +7,5 @@ export * from './ListLoadingItem';
6
7
  export * from './Modal';
7
8
  export * from './ScreenLoader';
8
9
  export * from './Skeleton';
9
- export * from './Text';
10
10
  export * from './TextInput';
11
+ export * from './Typography';
@@ -6,7 +6,6 @@ import {
6
6
  PressableProps,
7
7
  StyleProp,
8
8
  TouchableOpacity,
9
- View,
10
9
  ViewStyle,
11
10
  } from 'react-native';
12
11
 
@@ -15,6 +14,7 @@ import { ArrowLeftIcon } from '../../../icons';
15
14
  import { Screens } from '../../../routes';
16
15
  import { tw } from '../../../tailwind';
17
16
  import { DefaultComponentProps } from '../../../types/component.type';
17
+ import { Box } from '../../atoms';
18
18
 
19
19
  type Props = DefaultComponentProps &
20
20
  PressableProps & {
@@ -24,7 +24,7 @@ type Props = DefaultComponentProps &
24
24
  };
25
25
 
26
26
  const ACTIVE_OPACITY = 0.5;
27
- export function BackButton(props: Props): JSX.Element {
27
+ export function BackButton(props: Props) {
28
28
  const { fallbackRoute, onPress, style } = props;
29
29
  const navigation = useNavigation<ParamListBase>();
30
30
 
@@ -50,9 +50,9 @@ export function BackButton(props: Props): JSX.Element {
50
50
  style={[tw`h-[48px] w-[48px]`, style]}
51
51
  onPress={handleOnPress}
52
52
  >
53
- <View style={[tw`flex-1 items-center justify-center rounded-full`, style]}>
53
+ <Box style={[tw`flex-1 items-center justify-center rounded-full`, style]}>
54
54
  <ArrowLeftIcon style={tw`text-gray-950`} />
55
- </View>
55
+ </Box>
56
56
  </TouchableOpacity>
57
57
  );
58
58
  }
@@ -16,10 +16,7 @@ export function BottomActionsContainer(props: Props) {
16
16
  return (
17
17
  <SafeAreaView
18
18
  edges={['left', 'right', 'bottom']}
19
- style={[
20
- tw`border-geyser-200 absolute bottom-0 left-0 right-0 flex flex-col gap-y-2 border-b-0 border-t bg-gray-50 p-4`,
21
- style,
22
- ]}
19
+ style={[tw`absolute bottom-0 left-0 right-0`, style]}
23
20
  {...rest}
24
21
  >
25
22
  {children}
@@ -6,7 +6,6 @@ import {
6
6
  Platform,
7
7
  StatusBar,
8
8
  StyleProp,
9
- View,
10
9
  ViewStyle,
11
10
  } from 'react-native';
12
11
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
@@ -15,8 +14,10 @@ import { Edge, SafeAreaProviderProps, SafeAreaView } from 'react-native-safe-are
15
14
 
16
15
  import CONFIG from '../../../config';
17
16
  import { tw } from '../../../tailwind';
17
+ import { Box } from '../../atoms';
18
18
 
19
19
  type Props = SafeAreaProviderProps & {
20
+ scrollViewRef?: React.RefObject<KeyboardAwareScrollView>;
20
21
  containerStyle?: StyleProp<ViewStyle>;
21
22
  excludedEdges?: Edge[];
22
23
  extraBottomPadding?: number;
@@ -28,21 +29,20 @@ type Props = SafeAreaProviderProps & {
28
29
  onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
29
30
  };
30
31
 
31
- const defaultStyle = tw.style('grow', {
32
- paddingTop: StatusBar.currentHeight ? StatusBar.currentHeight - 1 : 0,
33
- });
32
+ const defaultStyle = tw`grow`;
34
33
 
35
34
  const safeAreaViewEdges: Edge[] = Platform.select({
36
- android: ['left', 'right', 'bottom'],
35
+ android: ['top', 'left', 'right', 'bottom'],
37
36
  default: [],
38
- ios: ['left', 'right', 'bottom', 'top'],
37
+ ios: ['top', 'left', 'right', 'bottom'],
39
38
  });
40
39
 
41
40
  const AnimatedKeyboardAwareScrollView = Animated.createAnimatedComponent(KeyboardAwareScrollView);
42
41
 
43
- export function ScreenContainer(props: Props): JSX.Element {
42
+ export function ScreenContainer(props: Props) {
44
43
  const {
45
44
  children,
45
+ scrollViewRef,
46
46
  containerStyle,
47
47
  excludedEdges = [],
48
48
  extraBottomPadding = 0,
@@ -81,10 +81,12 @@ export function ScreenContainer(props: Props): JSX.Element {
81
81
  ];
82
82
 
83
83
  return (
84
- <SafeAreaView edges={edges} style={[tw`flex-1 bg-gray-50`, style]}>
84
+ <SafeAreaView edges={edges} style={[tw`flex-1 bg-gray-50 dark:bg-gray-900`, style]}>
85
85
  {hasScroll ? (
86
86
  <AnimatedKeyboardAwareScrollView
87
+ scrollViewRef={scrollViewRef}
87
88
  contentContainerStyle={defaultContainerStyle}
89
+ enableResetScrollToCoords={false}
88
90
  keyboardShouldPersistTaps="handled"
89
91
  refreshControl={refreshControl}
90
92
  scrollEventThrottle={16}
@@ -93,7 +95,7 @@ export function ScreenContainer(props: Props): JSX.Element {
93
95
  {children}
94
96
  </AnimatedKeyboardAwareScrollView>
95
97
  ) : (
96
- <View style={defaultContainerStyle}>{children}</View>
98
+ <Box style={defaultContainerStyle}>{children}</Box>
97
99
  )}
98
100
  </SafeAreaView>
99
101
  );
@@ -1,16 +1,16 @@
1
- import React, { ReactNode } from 'react';
2
- import { StyleProp, TouchableOpacity, View, ViewStyle } from 'react-native';
1
+ import React from 'react';
2
+ import { StyleProp, TouchableOpacity, ViewStyle } from 'react-native';
3
3
 
4
4
  import { GearIcon } from '../../../icons';
5
5
  import { tw } from '../../../tailwind';
6
6
  import { DefaultComponentProps } from '../../../types/component.type';
7
- import { Text } from '../../atoms/Text';
7
+ import { Box } from '../../atoms';
8
+ import { Typography } from '../../atoms/Typography';
8
9
  import { BackButton } from '../BackButton';
9
10
 
10
11
  type Props = DefaultComponentProps & {
11
12
  hasBackButton?: boolean;
12
- extraActionComponent?: ReactNode;
13
- shouldShowBorder?: boolean;
13
+ extraActionComponent?: React.ReactNode;
14
14
  title: string;
15
15
  titleStyle?: StyleProp<ViewStyle>;
16
16
  onBackPress?: () => void;
@@ -24,7 +24,6 @@ export function ScreenHeader(props: Props) {
24
24
  hasBackButton = true,
25
25
  onBackPress,
26
26
  onExtraActionPress,
27
- shouldShowBorder = false,
28
27
  style,
29
28
  title,
30
29
  titleStyle,
@@ -37,35 +36,30 @@ export function ScreenHeader(props: Props) {
37
36
  style={tw`z-10 h-[48px] w-[48px]`}
38
37
  onPress={onExtraActionPress}
39
38
  >
40
- <View style={[tw`flex-1 items-center justify-center rounded-full`, style]}>
39
+ <Box style={[tw`flex-1 items-center justify-center rounded-full`, style]}>
41
40
  {extraActionComponent ? (
42
41
  extraActionComponent
43
42
  ) : (
44
43
  <GearIcon height={25} style={tw`text-black-950`} width={25} />
45
44
  )}
46
- </View>
45
+ </Box>
47
46
  </TouchableOpacity>
48
47
  );
49
48
 
50
49
  return (
51
- <View style={[tw`h-[64px] border border-transparent bg-gray-50`, style]}>
52
- <View
53
- style={[
54
- tw`flex-row items-center justify-between border border-transparent p-4 pt-2`,
55
- shouldShowBorder && tw`elevation-2 -m-[5px]`,
56
- ]}
57
- >
50
+ <Box style={[tw`h-[64px] border border-transparent`, style]}>
51
+ <Box style={[tw`flex-row items-center justify-between border border-transparent p-4 pt-2`]}>
58
52
  {hasBackButton && <BackButton style={tw`z-10`} onPress={onBackPress} />}
59
- <Text
53
+ <Typography
60
54
  style={[
61
55
  tw`text-primary-700 absolute inset-x-0 top-4 text-center text-xl font-medium`,
62
56
  titleStyle,
63
57
  ]}
64
58
  >
65
59
  {title}
66
- </Text>
60
+ </Typography>
67
61
  {extraActionComponentDisplay}
68
- </View>
69
- </View>
62
+ </Box>
63
+ </Box>
70
64
  );
71
65
  }
@@ -1,9 +1,7 @@
1
- import { ReactNode } from 'react';
2
-
3
1
  import { useLocalStorageState } from '../../../stores';
4
2
 
5
3
  type Props = {
6
- children: ReactNode;
4
+ children: JSX.Element;
7
5
  };
8
6
 
9
7
  export function StorageManager(props: Props) {
@@ -1,5 +1,5 @@
1
- export * from './useAppState.hook';
2
1
  export * from './useApplicationDimensions.hook';
2
+ export * from './useAppState.hook';
3
3
  export * from './useDebounce.hook';
4
4
  export * from './useGetLayoutHeight.hook';
5
5
  export * from './useGetLayoutWidth.hook';
@@ -7,3 +7,4 @@ export * from './useNavigation.hook';
7
7
  export * from './useShakeAnimation.hook';
8
8
  export * from './useTextInputChangeFocus.hook';
9
9
  export * from './useThrottle.hook';
10
+ export * from './useToggleDarkMode.hook';
@@ -0,0 +1,9 @@
1
+ import { useAppColorScheme } from 'twrnc';
2
+
3
+ import { tw } from '../tailwind';
4
+
5
+ export function useToggleDarkMode() {
6
+ const [, toggleColorScheme] = useAppColorScheme(tw);
7
+
8
+ return toggleColorScheme;
9
+ }
@@ -1,5 +1,5 @@
1
1
  import { DefaultTheme, NavigationContainer, Theme } from '@react-navigation/native';
2
- import { createStackNavigator } from '@react-navigation/stack';
2
+ import { createNativeStackNavigator } from '@react-navigation/native-stack';
3
3
  import React, { useEffect } from 'react';
4
4
  import { StatusBar } from 'react-native';
5
5
 
@@ -11,7 +11,7 @@ import PublicRoutes from './publicRoutes';
11
11
  import { Routes } from './routes.enum';
12
12
  import { screenOptions } from './screen-options';
13
13
 
14
- const RootStack = createStackNavigator();
14
+ const RootStack = createNativeStackNavigator();
15
15
 
16
16
  export const noAnimation = {
17
17
  animationEnabled: false,
@@ -25,7 +25,7 @@ const navigationTheme: Theme = {
25
25
  },
26
26
  };
27
27
 
28
- export default function ApplicationRoutes(): JSX.Element {
28
+ export default function ApplicationRoutes() {
29
29
  // const { isLoading } = useAuth();
30
30
  // const isUserAuthenticated = useLocalStorageState((state) => !!state.accessToken);
31
31
  const isUserAuthenticated = false;
@@ -1,5 +1,6 @@
1
+ import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
1
2
  import { MaterialTopTabScreenProps } from '@react-navigation/material-top-tabs';
2
- import { createStackNavigator, StackScreenProps } from '@react-navigation/stack';
3
+ import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
3
4
  import React from 'react';
4
5
 
5
6
  import { HomeScreen } from '../screens/HomeScreen/home.screen';
@@ -7,13 +8,13 @@ import { HomeScreen } from '../screens/HomeScreen/home.screen';
7
8
  import { screenOptions } from './screen-options';
8
9
  import { Screens } from './screens.enum';
9
10
 
10
- const PrivateStack = createStackNavigator<PrivateStackParams>();
11
+ const PrivateStack = createNativeStackNavigator<PrivateStackParams>();
11
12
 
12
13
  export type PrivateStackParams = {
13
14
  [Screens.HOME]: undefined;
14
15
  };
15
16
 
16
- export type PrivateScreenProps<T extends keyof PrivateStackParams> = StackScreenProps<
17
+ export type PrivateScreenProps<T extends keyof PrivateStackParams> = NativeStackScreenProps<
17
18
  PrivateStackParams,
18
19
  T
19
20
  >;
@@ -23,10 +24,12 @@ export type PrivateTabScreenProps<T extends keyof PrivateStackParams> = Material
23
24
  T
24
25
  >;
25
26
 
26
- export default function PrivateRoutes(): JSX.Element {
27
+ export default function PrivateRoutes() {
27
28
  return (
28
- <PrivateStack.Navigator initialRouteName={Screens.HOME} screenOptions={screenOptions}>
29
- <PrivateStack.Screen component={HomeScreen} name={Screens.HOME} />
30
- </PrivateStack.Navigator>
29
+ <BottomSheetModalProvider>
30
+ <PrivateStack.Navigator initialRouteName={Screens.HOME} screenOptions={screenOptions}>
31
+ <PrivateStack.Screen component={HomeScreen} name={Screens.HOME} />
32
+ </PrivateStack.Navigator>
33
+ </BottomSheetModalProvider>
31
34
  );
32
35
  }
@@ -1,26 +1,29 @@
1
- import { createStackNavigator, StackScreenProps } from '@react-navigation/stack';
1
+ import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
2
+ import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
2
3
  import React from 'react';
3
4
 
4
- import { LoginScreen } from '../screens/LoginScreen/login.screen';
5
+ import { LandingScreen } from '../screens/LandingScreen/landing.screen';
5
6
 
6
7
  import { screenOptions } from './screen-options';
7
8
  import { Screens } from './screens.enum';
8
9
 
9
- const PublicStack = createStackNavigator<PublicStackParams>();
10
+ const PublicStack = createNativeStackNavigator<PublicStackParams>();
10
11
 
11
12
  export type PublicStackParams = {
12
- [Screens.LOGIN]: undefined;
13
+ [Screens.LANDING]: undefined;
13
14
  };
14
15
 
15
- export type PublicScreenProps<T extends keyof PublicStackParams> = StackScreenProps<
16
+ export type PublicScreenProps<T extends keyof PublicStackParams> = NativeStackScreenProps<
16
17
  PublicStackParams,
17
18
  T
18
19
  >;
19
20
 
20
- export default function PublicRoutes(): JSX.Element {
21
+ export default function PublicRoutes() {
21
22
  return (
22
- <PublicStack.Navigator initialRouteName={Screens.LOGIN} screenOptions={screenOptions}>
23
- <PublicStack.Screen component={LoginScreen} name={Screens.LOGIN} />
24
- </PublicStack.Navigator>
23
+ <BottomSheetModalProvider>
24
+ <PublicStack.Navigator initialRouteName={Screens.LANDING} screenOptions={screenOptions}>
25
+ <PublicStack.Screen component={LandingScreen} name={Screens.LANDING} />
26
+ </PublicStack.Navigator>
27
+ </BottomSheetModalProvider>
25
28
  );
26
29
  }
@@ -1,4 +1,3 @@
1
-
2
1
  export const screenOptions = {
3
2
  gestureEnabled: true,
4
3
  headerShown: false,
@@ -1,4 +1,4 @@
1
1
  export enum Screens {
2
2
  HOME = '/home',
3
- LOGIN = '/login',
3
+ LANDING = '/landing',
4
4
  }
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
 
3
- import { ScreenContainer, Text } from '../../components';
3
+ import { ScreenContainer, Typography } from '../../components';
4
4
  import { PrivateScreenProps, Screens } from '../../routes';
5
5
 
6
6
  export function HomeScreen(props: PrivateScreenProps<Screens.HOME>) {
7
7
  return (
8
8
  <ScreenContainer>
9
- <Text>Home</Text>
9
+ <Typography>Home</Typography>
10
10
  </ScreenContainer>
11
11
  );
12
12
  }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ BottomSheet,
5
+ Box,
6
+ Button,
7
+ OutlinedButton,
8
+ ScreenContainer,
9
+ ScreenHeader,
10
+ Typography,
11
+ useBottomSheet,
12
+ } from '../../components';
13
+ import { useToggleDarkMode } from '../../hooks';
14
+ import { PublicScreenProps, Screens } from '../../routes';
15
+ import { tw } from '../../tailwind';
16
+
17
+ export function LandingScreen(props: PublicScreenProps<Screens.LANDING>) {
18
+ const toggleDarkMode = useToggleDarkMode();
19
+ const { expandSheet, sheetRef } = useBottomSheet();
20
+
21
+ return (
22
+ <ScreenContainer>
23
+ <ScreenHeader title="Landing" onExtraActionPress={toggleDarkMode} />
24
+ <Box style={tw`mx-4`}>
25
+ <Box row style={tw`gap-2`}>
26
+ <Button title="Show Bottom Sheet" onPress={expandSheet} />
27
+ <OutlinedButton title="Login" />
28
+ </Box>
29
+ </Box>
30
+ <BottomSheet sheetRef={sheetRef}>
31
+ <Box>
32
+ <Typography>Bottom Sheet</Typography>
33
+ </Box>
34
+ </BottomSheet>
35
+ </ScreenContainer>
36
+ );
37
+ }
@@ -1,13 +1,8 @@
1
- import { Atom, SetStateAction, WritableAtom } from 'jotai';
2
1
  import { StyleProp, ViewStyle } from 'react-native';
3
2
 
4
3
  export type DefaultComponentProps = {
5
4
  error?: string;
6
5
  isDisabled?: boolean;
7
- style?: StyleProp<ViewStyle>;
8
- };
9
-
10
- export type DefaultInputComponentProps<T> = DefaultComponentProps & {
11
- atom?: WritableAtom<T, [SetStateAction<T>], void> | Atom<T>;
12
6
  isLoading?: boolean;
7
+ style?: StyleProp<ViewStyle>;
13
8
  };
@@ -0,0 +1,10 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import axios, { HttpStatusCode } from 'axios';
3
+
4
+ export function isNetworkError(error: any) {
5
+ return axios.isAxiosError(error) && !error.response;
6
+ }
7
+
8
+ export function isUnauthorizedError(error: any) {
9
+ return axios.isAxiosError(error) && error.response?.status === HttpStatusCode.Unauthorized;
10
+ }
@@ -0,0 +1,4 @@
1
+ export * from './axios.util';
2
+ export * from './log.util';
3
+ export * from './route.util';
4
+
@@ -0,0 +1,40 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable no-console */
3
+ /* global __DEV__ */
4
+ import SimpleToast from 'react-native-simple-toast';
5
+
6
+ export const devLog = (message?: any, ...optionalParams: any[]) => {
7
+ if (__DEV__) {
8
+ console.log(message, ...optionalParams);
9
+ }
10
+ };
11
+
12
+ export const logToast = (message?: any, ...optionalParams: any[]) => {
13
+ if (__DEV__) {
14
+ devLog(message, ...optionalParams);
15
+ SimpleToast.show(message, SimpleToast.SHORT);
16
+ }
17
+ };
18
+
19
+ export const toast = (message: string) => {
20
+ SimpleToast.show(message, SimpleToast.SHORT);
21
+ };
22
+
23
+ export function comingSoon() {
24
+ toast('Feature coming soon');
25
+ }
26
+
27
+ export const prettyJSON = (obj: any) => JSON.stringify(obj, null, 2);
28
+
29
+ export const startTimer = () => Date.now();
30
+
31
+ export const endTimer = (startTime: number, label = 'total duration', enableDebug = false) => {
32
+ const endTime = Date.now();
33
+ const duration = endTime - startTime;
34
+
35
+ if (enableDebug) {
36
+ devLog(`${label}: ${duration}ms`);
37
+ }
38
+
39
+ return duration;
40
+ };
@@ -0,0 +1,48 @@
1
+ /* eslint-disable max-params */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { CommonActions, NavigationState, ParamListBase, Route } from '@react-navigation/native';
4
+
5
+ export function getPreviousRouteName(navigationState: NavigationState<ParamListBase>) {
6
+ const routes = navigationState.routes;
7
+ const currentIndex = navigationState.index;
8
+
9
+ if (currentIndex > 0) {
10
+ return routes[currentIndex - 1].name;
11
+ }
12
+
13
+ return null;
14
+ }
15
+
16
+ export function getCurrentRouteName(navigation: any) {
17
+ return navigation.getState().routes[navigation.getState().index].name;
18
+ }
19
+
20
+ export function navigationPop(navigation: any, frequency = 2) {
21
+ navigation.dispatch((state: any) => {
22
+ const routes = state.routes.slice(0, -frequency);
23
+
24
+ return CommonActions.reset({
25
+ ...state,
26
+ index: routes.length - 1,
27
+ routes,
28
+ });
29
+ });
30
+ }
31
+
32
+ export function navigationNavigateAndReset(
33
+ navigation: any,
34
+ routeName: string,
35
+ frequency = 1,
36
+ params?: any,
37
+ ) {
38
+ navigation.dispatch((state: any) => {
39
+ const routes = state.routes.slice(0, -frequency);
40
+ routes.push({ name: routeName, params });
41
+
42
+ return CommonActions.reset({
43
+ ...state,
44
+ index: routes.length - 1,
45
+ routes,
46
+ });
47
+ });
48
+ }
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- import {
3
- ActivityIndicator,
4
- StyleProp,
5
- TextStyle,
6
- TouchableOpacity,
7
- TouchableOpacityProps,
8
- View,
9
- ViewStyle,
10
- } from 'react-native';
11
-
12
- import { colors, disabledInputStyle, tw } from '../../../tailwind';
13
- import { DefaultComponentProps } from '../../../types/component.type';
14
- import { Text } from '../Text';
15
-
16
- type Props = DefaultComponentProps &
17
- TouchableOpacityProps & {
18
- buttonStyle?: StyleProp<ViewStyle>;
19
- children?: React.ReactNode;
20
- isLoading?: boolean;
21
- textStyle?: StyleProp<TextStyle>;
22
- title?: string;
23
- };
24
-
25
- const ACTIVE_OPACITY = 0.5;
26
-
27
- export function OutlinedButton(props: Props): JSX.Element {
28
- const {
29
- activeOpacity = ACTIVE_OPACITY,
30
- buttonStyle,
31
- children,
32
- isDisabled = false,
33
- isLoading = false,
34
- style,
35
- textStyle,
36
- title = 'Button',
37
- ...rest
38
- } = props;
39
- const disabled = isDisabled || isLoading;
40
- const display = children ? (
41
- children
42
- ) : (
43
- <Text style={[tw`text-primary-700 font-medium`, textStyle]}>{title}</Text>
44
- );
45
-
46
- return (
47
- <TouchableOpacity activeOpacity={activeOpacity} disabled={disabled} style={[style]} {...rest}>
48
- <View
49
- style={[
50
- tw`border-primary-700 items-center justify-center rounded-md border-2 bg-white p-4`,
51
- buttonStyle,
52
- disabledInputStyle(disabled),
53
- ]}
54
- >
55
- {isLoading ? <ActivityIndicator color={colors.primary[100]} /> : display}
56
- </View>
57
- </TouchableOpacity>
58
- );
59
- }
@@ -1 +0,0 @@
1
- export * from './text.component';
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
-
3
- import { ScreenContainer, Text } from '../../components';
4
- import { PublicScreenProps, Screens } from '../../routes';
5
- import { tw } from '../../tailwind';
6
-
7
- export function LoginScreen(props: PublicScreenProps<Screens.LOGIN>) {
8
- return (
9
- <ScreenContainer style={tw`bg-gray-50`}>
10
- <Text>Login</Text>
11
- </ScreenContainer>
12
- );
13
- }