@umang-thakkar/base-template 1.0.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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/package.json +27 -0
  4. package/template/App.tsx +41 -0
  5. package/template/Gemfile +16 -0
  6. package/template/Gemfile.lock +124 -0
  7. package/template/Main.tsx +14 -0
  8. package/template/README.md +97 -0
  9. package/template/__tests__/App.test.tsx +13 -0
  10. package/template/_gitignore +75 -0
  11. package/template/android/app/build.gradle +119 -0
  12. package/template/android/app/debug.keystore +0 -0
  13. package/template/android/app/proguard-rules.pro +10 -0
  14. package/template/android/app/src/debug/AndroidManifest.xml +9 -0
  15. package/template/android/app/src/main/AndroidManifest.xml +26 -0
  16. package/template/android/app/src/main/java/com/basetemplate/MainActivity.kt +22 -0
  17. package/template/android/app/src/main/java/com/basetemplate/MainApplication.kt +38 -0
  18. package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  19. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  20. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  21. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  22. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  23. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  24. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  25. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  26. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  27. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  28. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  29. package/template/android/app/src/main/res/values/strings.xml +3 -0
  30. package/template/android/app/src/main/res/values/styles.xml +9 -0
  31. package/template/android/build.gradle +21 -0
  32. package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  33. package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  34. package/template/android/gradle.properties +44 -0
  35. package/template/android/gradlew +251 -0
  36. package/template/android/gradlew.bat +99 -0
  37. package/template/android/settings.gradle +6 -0
  38. package/template/app.json +4 -0
  39. package/template/babel.config.js +4 -0
  40. package/template/constants/AppConstants.tsx +1 -0
  41. package/template/constants/StoragePreferences.ts +94 -0
  42. package/template/index.js +9 -0
  43. package/template/ios/.xcode.env +11 -0
  44. package/template/ios/.xcode.env.local +1 -0
  45. package/template/ios/BaseTemplate/AppDelegate.swift +48 -0
  46. package/template/ios/BaseTemplate/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  47. package/template/ios/BaseTemplate/Images.xcassets/Contents.json +6 -0
  48. package/template/ios/BaseTemplate/Info.plist +53 -0
  49. package/template/ios/BaseTemplate/LaunchScreen.storyboard +47 -0
  50. package/template/ios/BaseTemplate/PrivacyInfo.xcprivacy +37 -0
  51. package/template/ios/BaseTemplate.xcodeproj/project.pbxproj +478 -0
  52. package/template/ios/BaseTemplate.xcodeproj/xcshareddata/xcschemes/BaseTemplate.xcscheme +88 -0
  53. package/template/ios/BaseTemplate.xcworkspace/contents.xcworkspacedata +10 -0
  54. package/template/ios/Podfile +35 -0
  55. package/template/jest.config.js +3 -0
  56. package/template/metro.config.js +11 -0
  57. package/template/package.json +54 -0
  58. package/template/src/api/AxiosActions.ts +37 -0
  59. package/template/src/api/AxiosClient.ts +17 -0
  60. package/template/src/api/queries.ts +22 -0
  61. package/template/src/api/service.ts +9 -0
  62. package/template/src/helper/colors.ts +24 -0
  63. package/template/src/helper/common-functions.ts +24 -0
  64. package/template/src/helper/font-family.ts +7 -0
  65. package/template/src/helper/navigation-service.ts +69 -0
  66. package/template/src/helper/typography.ts +91 -0
  67. package/template/src/helper/utility-functions.ts +85 -0
  68. package/template/src/navigation/AppStack.tsx +32 -0
  69. package/template/src/navigation/AppStackParams.ts +4 -0
  70. package/template/src/navigation/screens.ts +14 -0
  71. package/template/src/redux/action.ts +0 -0
  72. package/template/src/redux/slice.ts +21 -0
  73. package/template/src/redux/store.ts +16 -0
  74. package/template/src/redux/types.d.ts +1 -0
  75. package/template/src/screens/HomeScreen.tsx +21 -0
  76. package/template/src/screens/SplashScreen.tsx +18 -0
  77. package/template/tsconfig.json +5 -0
  78. package/template/yarn.lock +6935 -0
  79. package/template.config.js +12 -0
@@ -0,0 +1,37 @@
1
+ import { axiosClient } from './AxiosClient';
2
+
3
+ export async function postAPI(url: string, payload: any) {
4
+ try {
5
+ const result = await axiosClient.post(url, payload);
6
+ return result.data;
7
+ } catch (err: any) {
8
+ throw err.response?.data || err;
9
+ }
10
+ }
11
+
12
+ export async function putAPI(url: string, payload: any) {
13
+ try {
14
+ const result = await axiosClient.put(url, payload);
15
+ return result.data;
16
+ } catch (err: any) {
17
+ throw err.response?.data || err;
18
+ }
19
+ }
20
+
21
+ export async function deleteAPI(url: string, params?: any) {
22
+ try {
23
+ const result = await axiosClient.delete(url, { params });
24
+ return result.data;
25
+ } catch (err: any) {
26
+ throw err.response?.data || err;
27
+ }
28
+ }
29
+
30
+ export async function getAPI(url: string, params?: any) {
31
+ try {
32
+ const result = await axiosClient.get(url, { params });
33
+ return result.data;
34
+ } catch (err: any) {
35
+ throw err.response?.data || err;
36
+ }
37
+ }
@@ -0,0 +1,17 @@
1
+ import axios from 'axios';
2
+ import { API_BASE_URL } from '../../constants/AppConstants';
3
+
4
+ export const axiosClient = axios.create({
5
+ baseURL: API_BASE_URL,
6
+ timeout: 60000
7
+ });
8
+
9
+ axiosClient.interceptors.request.use(
10
+ async (config: any) => {
11
+
12
+ return config;
13
+ },
14
+ (error: any) => {
15
+ return Promise.reject(error);
16
+ }
17
+ );
@@ -0,0 +1,22 @@
1
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { addTodo, deleteTodo, fetchTodoById, fetchTodos } from "./service";
3
+ const queryClient = useQueryClient()
4
+
5
+ export const useTodos = useQuery({ queryKey: ['todos'], queryFn: fetchTodos });
6
+
7
+ export const useTodoById = (id: number) => useQuery({ queryKey: ['todo', id], queryFn: () => fetchTodoById(id) })
8
+
9
+ export const useAddTodo = useMutation({
10
+ mutationFn: addTodo,
11
+ onSuccess: () => {
12
+ queryClient.invalidateQueries({ queryKey: ['todos'] });
13
+ }
14
+ })
15
+
16
+ export const deleteTodoMutation = useMutation({
17
+ mutationFn: deleteTodo,
18
+ onSuccess: () => {
19
+ queryClient.invalidateQueries({ queryKey: ['todos'] });
20
+ }
21
+ });
22
+
@@ -0,0 +1,9 @@
1
+ import { getAPI, postAPI, putAPI, deleteAPI } from './AxiosActions';
2
+
3
+ // Todos API
4
+ export const fetchTodos = () => getAPI('/todos');
5
+ export const fetchTodoById = (id: number) => getAPI(`/todos/${id}`);
6
+ export const addTodo = (title: string) => postAPI('/todos', { title, completed: false });
7
+ export const updateTodo = (id: number, payload: { title?: string; completed?: boolean }) =>
8
+ putAPI(`/todos/${id}`, payload);
9
+ export const deleteTodo = (id: number) => deleteAPI(`/todos/${id}`);
@@ -0,0 +1,24 @@
1
+ export const colors = {
2
+ grayColor: '#9B9B9B',
3
+ dividerColor: '#BDBDBD',
4
+ fieldColor: '#F5F5F5',
5
+ yellowColor: '#FDC60A',
6
+ navyBlue: '#3C5A99',
7
+ kashmir: '#5D6D7E',
8
+ orangeColor: '#E5634D',
9
+ blueColor: '#5DADE2',
10
+ pinkColor: '#A569BD',
11
+ pinkLightColor: '#FF5E80',
12
+ pinkDarkColor: '#F90030',
13
+ accentColor: '#4A90A4',
14
+ //App colors
15
+ whiteColor: '#FFFFFF',
16
+ purple: '#6739B7',
17
+ green: '#4BB543',
18
+ suvaGrey: '#909090',
19
+ airForceBlue: '#6687A5',
20
+ red: '#D73F5A',
21
+ lightGray: '#B3B3B3',
22
+ black: '#000000',
23
+ kashmirBlue: '#566A90',
24
+ };
@@ -0,0 +1,24 @@
1
+ import axios from "axios";
2
+ import moment from "moment";
3
+
4
+ const errorMessage = (error: unknown): string => {
5
+ if (axios.isAxiosError(error)) {
6
+ return error.response?.data?.message || error.message;
7
+ }
8
+ return String(error);
9
+ };
10
+
11
+ export function toFormattedDate(
12
+ dateString: string,
13
+ format: string
14
+ ): string | any {
15
+ if (!dateString) { return null; }
16
+
17
+ const date = moment(dateString);
18
+
19
+ if (!date.isValid()) {
20
+ return null;
21
+ }
22
+
23
+ return date.format(format);
24
+ }
@@ -0,0 +1,7 @@
1
+ export const FontFamily = {
2
+ // Add your fonts here
3
+ regular: 'GeneralSans-Regular',
4
+ medium: 'GeneralSans-Medium',
5
+ semibold: 'GeneralSans-Semibold',
6
+ bold: 'GeneralSans-Bold',
7
+ };
@@ -0,0 +1,69 @@
1
+ // navigationService.ts
2
+ import * as React from "react";
3
+ import { CommonActions, StackActions } from "@react-navigation/native";
4
+ import type { NavigationContainerRef } from "@react-navigation/native";
5
+
6
+ // Create a ref to hold navigation
7
+ export const navigationRef = React.createRef<NavigationContainerRef<any>>();
8
+
9
+ /**
10
+ * Navigate to a screen by name
11
+ */
12
+ export function navigate(name: string, params?: object) {
13
+ navigationRef.current?.navigate(name, params);
14
+ }
15
+
16
+ /**
17
+ * Go back to the previous screen
18
+ */
19
+ export function goBack() {
20
+ navigationRef.current?.goBack();
21
+ }
22
+
23
+ /**
24
+ * Reset navigation with multiple routes
25
+ */
26
+ export function navigateAndReset(
27
+ routes: { name: string; params?: object }[] = [],
28
+ index = 0
29
+ ) {
30
+ navigationRef.current?.dispatch(
31
+ CommonActions.reset({
32
+ index,
33
+ routes,
34
+ })
35
+ );
36
+ }
37
+
38
+ /**
39
+ * Reset navigation with a single route
40
+ */
41
+ export function navigateAndSimpleReset(name: string, index = 0) {
42
+ navigationRef.current?.dispatch(
43
+ CommonActions.reset({
44
+ index,
45
+ routes: [{ name }],
46
+ })
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Push a new screen on top of the stack
52
+ */
53
+ export function push(name: string, params?: object) {
54
+ navigationRef.current?.dispatch(StackActions.push(name, params));
55
+ }
56
+
57
+ /**
58
+ * Pop the current screen
59
+ */
60
+ export function pop(count: number = 1) {
61
+ navigationRef.current?.dispatch(StackActions.pop(count));
62
+ }
63
+
64
+ /**
65
+ * Pop to the top of the stack
66
+ */
67
+ export function popToTop() {
68
+ navigationRef.current?.dispatch(StackActions.popToTop());
69
+ }
@@ -0,0 +1,91 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const FontWeight: any = {
4
+ thin: '100',
5
+ ultraLight: '200',
6
+ light: '300',
7
+ regular: '400',
8
+ medium: '500',
9
+ semibold: '600',
10
+ bold: '700',
11
+ heavy: '800',
12
+ black: '900',
13
+ };
14
+
15
+ export const Typography = StyleSheet.create({
16
+ header: {
17
+ fontSize: 34,
18
+ fontWeight: FontWeight.bold,
19
+ },
20
+ header2: {
21
+ fontSize: 20,
22
+ fontWeight: FontWeight.semibold,
23
+ },
24
+ title1: {
25
+ fontSize: 28,
26
+ fontWeight: FontWeight.bold,
27
+ },
28
+ title2: {
29
+ fontSize: 22,
30
+ fontWeight: FontWeight.bold,
31
+ },
32
+ title3: {
33
+ fontSize: 20,
34
+ fontWeight: FontWeight.bold,
35
+ },
36
+ title4: {
37
+ fontSize: 20,
38
+ fontWeight: FontWeight.semibold,
39
+ },
40
+ title5: {
41
+ fontSize: 17.5,
42
+ fontWeight: FontWeight.semibold,
43
+ },
44
+ title6: {
45
+ fontSize: 51,
46
+ fontWeight: FontWeight.semibold,
47
+ },
48
+ headline: {
49
+ fontSize: 17,
50
+ fontWeight: FontWeight.bold,
51
+ },
52
+ body1: {
53
+ fontSize: 17,
54
+ fontWeight: FontWeight.regular,
55
+ },
56
+ body2: {
57
+ fontSize: 14,
58
+ fontWeight: FontWeight.regular,
59
+ },
60
+ subhead: {
61
+ fontSize: 15,
62
+ fontWeight: FontWeight.regular,
63
+ },
64
+ footnote: {
65
+ fontSize: 13,
66
+ fontWeight: FontWeight.regular,
67
+ },
68
+ caption1: {
69
+ fontSize: 12,
70
+ fontWeight: FontWeight.regular,
71
+ },
72
+ caption3: {
73
+ fontSize: 12,
74
+ fontWeight: FontWeight.medium,
75
+ },
76
+ caption4: {
77
+ fontSize: 14,
78
+ fontWeight: FontWeight.medium,
79
+ },
80
+ caption2: {
81
+ fontSize: 11,
82
+ fontWeight: FontWeight.regular,
83
+ },
84
+ overline: {
85
+ fontSize: 10,
86
+ fontWeight: FontWeight.regular,
87
+ },
88
+ link: {
89
+ textDecorationLine: 'underline',
90
+ },
91
+ });
@@ -0,0 +1,85 @@
1
+ // utils.ts
2
+ import { Dimensions, Platform, PixelRatio, Keyboard, Alert } from "react-native";
3
+ const { width, height } = Dimensions.get("window");
4
+
5
+ // Get device dimensions
6
+ export const deviceWidth = width;
7
+ export const deviceHeight = height;
8
+
9
+ // Platform checks
10
+ export const isAndroid = Platform.OS === "android";
11
+ export const isIOS = Platform.OS === "ios";
12
+
13
+ // Responsive font size
14
+ export function responsiveFontSize(size: number) {
15
+ const scale = width / 375; // base width: iPhone 11
16
+ const newSize = size * scale;
17
+ return Math.round(PixelRatio.roundToNearestPixel(newSize));
18
+ }
19
+
20
+ export const responsiveHeight = (value: number) => {
21
+ let temp = value;
22
+ if (deviceHeight != 896) {
23
+ let temp2 = (value / 896).toFixed(4);
24
+ temp = PixelRatio.roundToNearestPixel(deviceHeight * Number(temp2));
25
+ }
26
+ return temp;
27
+ };
28
+
29
+ export const responsiveWidth = (value: number) => {
30
+ let temp = value;
31
+ if (deviceWidth !== 414) {
32
+ let temp2 = (value / 414).toFixed(4); // 414 is a common base width (e.g., iPhone 11)
33
+ temp = PixelRatio.roundToNearestPixel(deviceWidth * Number(temp2));
34
+ }
35
+ return temp;
36
+ };
37
+
38
+ // Check if device is small, medium, large (useful for UI adjustments)
39
+ export function getDeviceType() {
40
+ if (width < 360) return "small";
41
+ if (width < 768) return "medium";
42
+ return "large";
43
+ }
44
+
45
+ // Example: normalize size for both iOS/Android
46
+ export function normalize(size: number) {
47
+ const scale = width / 375;
48
+ const newSize = size * scale;
49
+ if (isIOS) {
50
+ return Math.round(PixelRatio.roundToNearestPixel(newSize));
51
+ } else {
52
+ return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2;
53
+ }
54
+ }
55
+
56
+ export const hideKeyboard = () => {
57
+ Keyboard.dismiss();
58
+ };
59
+
60
+ export const showAlert = (
61
+ title: string,
62
+ message: string,
63
+ settingsText = 'Open Settings',
64
+ rejectText = 'Reject',
65
+ onSettingsPress: () => void
66
+ ) => {
67
+ Alert.alert(
68
+ title,
69
+ message,
70
+ [
71
+ {
72
+ text: settingsText,
73
+ onPress: onSettingsPress,
74
+ style: 'default',
75
+ },
76
+ {
77
+ text: rejectText,
78
+ style: 'destructive',
79
+ },
80
+ ],
81
+ { cancelable: false }
82
+ );
83
+ };
84
+
85
+
@@ -0,0 +1,32 @@
1
+ // navigation/AppStack.tsx
2
+ import React from "react";
3
+ 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";
10
+
11
+ const App = createStackNavigator<AppStackParams>();
12
+ const options: StackNavigationOptions = { headerShown: false };
13
+
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
+ );
30
+ };
31
+
32
+ export default AppStack;
@@ -0,0 +1,4 @@
1
+ export type AppStackParams = {
2
+ SplashScreen: undefined
3
+ HomeScreen: undefined
4
+ }
@@ -0,0 +1,14 @@
1
+ import { StackNavigationOptions } from "@react-navigation/stack";
2
+ import HomeScreen from "../screens/HomeScreen";
3
+ import SplashScreen from "../screens/SplashScreen";
4
+ import { AppStackParams } from "./AppStackParams";
5
+
6
+ export const screens: Array<{
7
+ name: keyof AppStackParams;
8
+ component: React.ComponentType<any>;
9
+ options?: StackNavigationOptions;
10
+ }> = [
11
+ { name: 'SplashScreen', component: SplashScreen },
12
+ { name: 'HomeScreen', component: HomeScreen }
13
+ // Add your other screens here
14
+ ]
File without changes
@@ -0,0 +1,21 @@
1
+ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
2
+
3
+ const initialState: any = {
4
+ value: 0,
5
+ };
6
+
7
+ 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
+ },
17
+ },
18
+ });
19
+
20
+ export const { setValue, resetValue } = appSlice.actions;
21
+ export default appSlice.reducer;
@@ -0,0 +1,16 @@
1
+ import { configureStore } from '@reduxjs/toolkit';
2
+ import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
3
+ import reducer from './slice';
4
+
5
+ const store = configureStore({
6
+ reducer: {
7
+ global: reducer,
8
+ },
9
+ });
10
+ export default store;
11
+
12
+ export type RootStore = ReturnType<typeof store.getState>;
13
+ export type AppDispatch = typeof store.dispatch;
14
+
15
+ export const useAppDispatch = () => useDispatch<AppDispatch>();
16
+ export const useAppSelector: TypedUseSelectorHook<RootStore> = useSelector;
@@ -0,0 +1 @@
1
+ //Your types will be defined here.
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { Text, View, StyleSheet } from 'react-native';
3
+ import { SafeAreaView } from 'react-native-safe-area-context';
4
+
5
+ interface Props { }
6
+
7
+ const HomeScreen = (props: Props) => {
8
+ return (
9
+ <SafeAreaView>
10
+ <View style={styles.container}>
11
+ <Text>HomeScreen</Text>
12
+ </View>
13
+ </SafeAreaView>
14
+ );
15
+ };
16
+
17
+ export default HomeScreen;
18
+
19
+ const styles = StyleSheet.create({
20
+ container: {}
21
+ });
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { Text, View, StyleSheet } from 'react-native';
3
+
4
+ interface Props { }
5
+
6
+ const SplashScreen = (props: Props) => {
7
+ return (
8
+ <View style={styles.container}>
9
+ <Text>SplashScreen</Text>
10
+ </View>
11
+ );
12
+ };
13
+
14
+ export default SplashScreen;
15
+
16
+ const styles = StyleSheet.create({
17
+ container: {}
18
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@react-native/typescript-config",
3
+ "include": ["**/*.ts", "**/*.tsx"],
4
+ "exclude": ["**/node_modules", "**/Pods"]
5
+ }