Skip to content

Commit 64b8c92

Browse files
committed
add boosplash, fake adapter network
1 parent 4a06784 commit 64b8c92

81 files changed

Lines changed: 3270 additions & 3619 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bundle/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SENTRY_DSN=
2+
CODEPUSH_KEY_IOS=
3+
CODEPUSH_KEY_ANDROID=
4+
USE_MOCK_API=1
5+
API_URL=

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
API_URL=
1+
API_URL=http://localhost:3000
22
SENTRY_DSN=
33
CODEPUSH_KEY_IOS=
44
CODEPUSH_KEY_ANDROID=
5+
USE_MOCK_API=true

App.tsx

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,57 @@
1-
// FILE: App.tsx
2-
// ROOT ENTRY POINT
3-
// -------------------------------------------------------
4-
// WRAPS:
5-
// - ThemeProvider (light/dark)
6-
// - i18n initialization (side-effect import)
7-
// - React Query (persisted via MMKV)
8-
// - NavigationContainer
9-
// - RootNavigator
10-
// - OfflineBanner
11-
// -------------------------------------------------------
12-
13-
import React from 'react';
1+
import React, { useEffect } from 'react';
2+
import BootSplash from 'react-native-bootsplash';
143
import { NavigationContainer } from '@react-navigation/native';
4+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
5+
import { SafeAreaProvider } from 'react-native-safe-area-context';
6+
import { StatusBar, StyleSheet } from 'react-native';
157

16-
// THEME
178
import { ThemeProvider } from '@/core/theme/ThemeProvider';
18-
19-
// i18n (auto-init via side-effect)
209
import '@/core/i18n/i18n';
2110

22-
// NAVIGATION ROOT + helpers
2311
import RootNavigator from '@/app/navigation/root/root-navigator';
2412
import { navigationRef } from '@/app/navigation/helpers/navigation-helpers';
2513
import { useBackButtonHandler } from '@/app/navigation/helpers/use-back-handler';
2614
import { ROUTES } from '@/app/navigation/routes';
2715

28-
// REACT QUERY (persisted)
29-
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
30-
import { createQueryClient } from '@/infra/query/client/query-client';
31-
import { mmkvPersister } from '@/infra/query/persistence/mmkv-persister';
32-
33-
// OFFLINE/SYNC: wire QueryClient + tag maps + NetInfo bridge
34-
import { initNetInfoBridge } from '@/infra/network/netinfo';
35-
import {
36-
setQueryClientForSync,
37-
setTagMapsForSync,
38-
} from '@/infra/offline/sync-engine';
16+
import { QueryProvider } from '@/infra/query/client/provider';
3917
import { authKeys } from '@/features/auth/api/keys';
4018
import { userKeys } from '@/features/user/api/keys';
41-
42-
// Global offline UI
4319
import { OfflineBanner } from '@/app/components/OfflineBanner';
4420

45-
// Create client once
46-
const queryClient = createQueryClient();
47-
setQueryClientForSync(queryClient);
48-
setTagMapsForSync([authKeys.tagMap, userKeys.tagMap]);
49-
initNetInfoBridge();
21+
import { setTransport } from '@/infra/transport/transport';
22+
import { mockAdapter } from '@/infra/transport/adapters/mock.adapter';
23+
import { restAdapter } from '@/infra/transport/adapters/rest.adapter';
24+
import { flags } from '@/core/config/constants';
5025

5126
export default function App() {
52-
// Android back button handling (exit only on root tabs)
53-
useBackButtonHandler(routeName => {
54-
return routeName === ROUTES.HOME_TABS || routeName === ROUTES.TAB_HOME;
55-
});
27+
useEffect(() => {
28+
setTransport(flags.USE_MOCK ? mockAdapter : restAdapter);
29+
}, []);
5630

57-
return (
58-
<ThemeProvider>
59-
<PersistQueryClientProvider
60-
client={queryClient}
61-
persistOptions={{ persister: mmkvPersister }}
62-
>
63-
{/* Global offline status banner */}
64-
<OfflineBanner />
31+
useBackButtonHandler(
32+
routeName =>
33+
routeName === ROUTES.HOME_TABS || routeName === ROUTES.TAB_HOME,
34+
);
6535

66-
<NavigationContainer ref={navigationRef}>
67-
<RootNavigator />
68-
</NavigationContainer>
69-
</PersistQueryClientProvider>
70-
</ThemeProvider>
36+
return (
37+
<GestureHandlerRootView style={styles.flex}>
38+
<SafeAreaProvider>
39+
<StatusBar barStyle="dark-content" />
40+
<ThemeProvider>
41+
<QueryProvider tagMaps={[authKeys.tagMap, userKeys.tagMap]}>
42+
<OfflineBanner />
43+
44+
<NavigationContainer
45+
ref={navigationRef}
46+
onReady={() => BootSplash.hide({ fade: true })}
47+
>
48+
<RootNavigator />
49+
</NavigationContainer>
50+
</QueryProvider>
51+
</ThemeProvider>
52+
</SafeAreaProvider>
53+
</GestureHandlerRootView>
7154
);
7255
}
56+
57+
const styles = StyleSheet.create({ flex: { flex: 1 } });

android/app/build.gradle

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,38 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44

5+
// ✅ react-native-config MUST be applied AFTER com.android.application plugin
6+
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
7+
8+
// (optional) only if you really need per-variant files
9+
project.ext.envConfigFiles = [
10+
debug : ".env",
11+
release: ".env"
12+
]
513
/**
614
* This is the configuration block to customize your React Native Android app.
715
* By default you don't need to apply any configuration, just uncomment the lines you need.
816
*/
917
react {
1018
/* Folders */
11-
// The root of your project, i.e. where "package.json" lives. Default is '../..'
1219
// root = file("../../")
13-
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
1420
// reactNativeDir = file("../../node_modules/react-native")
15-
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
1621
// codegenDir = file("../../node_modules/@react-native/codegen")
17-
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
1822
// cliFile = file("../../node_modules/react-native/cli.js")
1923

2024
/* Variants */
21-
// The list of variants to that are debuggable. For those we're going to
22-
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23-
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
2425
// debuggableVariants = ["liteDebug", "prodDebug"]
2526

2627
/* Bundling */
27-
// A list containing the node command and its flags. Default is just 'node'.
2828
// nodeExecutableAndArgs = ["node"]
29-
//
30-
// The command to run when bundling. By default is 'bundle'
3129
// bundleCommand = "ram-bundle"
32-
//
33-
// The path to the CLI configuration file. Default is empty.
3430
// bundleConfig = file(../rn-cli.config.js)
35-
//
36-
// The name of the generated asset file containing your JS bundle
3731
// bundleAssetName = "MyApplication.android.bundle"
38-
//
39-
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
4032
// entryFile = file("../js/MyApplication.android.js")
41-
//
42-
// A list of extra flags to pass to the 'bundle' commands.
43-
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
4433
// extraPackagerArgs = []
4534

4635
/* Hermes Commands */
47-
// The hermes compiler command to run. By default it is 'hermesc'
4836
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49-
//
50-
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
5137
// hermesFlags = ["-O", "-output-source-map"]
5238

5339
/* Autolinking */
@@ -61,17 +47,12 @@ def enableProguardInReleaseBuilds = false
6147

6248
/**
6349
* The preferred build flavor of JavaScriptCore (JSC)
64-
*
65-
* For example, to use the international variant, you can use:
66-
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
67-
*
68-
* The international variant includes ICU i18n library and necessary data
69-
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70-
* give correct results when using with locales other than en-US. Note that
71-
* this variant is about 6MiB larger per architecture than default.
7250
*/
7351
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7452

53+
// ✅ make hermesEnabled safe even if gradle.properties doesn't define it
54+
def hermesEnabled = (project.findProperty("hermesEnabled") ?: "true")
55+
7556
android {
7657
ndkVersion rootProject.ext.ndkVersion
7758
buildToolsVersion rootProject.ext.buildToolsVersion
@@ -85,6 +66,7 @@ android {
8566
versionCode 1
8667
versionName "1.0"
8768
}
69+
8870
signingConfigs {
8971
debug {
9072
storeFile file('debug.keystore')
@@ -93,13 +75,12 @@ android {
9375
keyPassword 'android'
9476
}
9577
}
78+
9679
buildTypes {
9780
debug {
9881
signingConfig signingConfigs.debug
9982
}
10083
release {
101-
// Caution! In production, you need to generate your own keystore file.
102-
// see https://reactnative.dev/docs/signed-apk-android.
10384
signingConfig signingConfigs.debug
10485
minifyEnabled enableProguardInReleaseBuilds
10586
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET" />
23

3-
<uses-permission android:name="android.permission.INTERNET" />
4-
5-
<application
6-
android:name=".MainApplication"
4+
<application
5+
android:name=".MainApplication"
6+
android:label="@string/app_name"
7+
android:icon="@mipmap/ic_launcher"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:allowBackup="false"
10+
android:theme="@style/AppTheme"
11+
android:usesCleartextTraffic="${usesCleartextTraffic}"
12+
android:supportsRtl="true">
13+
<activity
14+
android:name=".MainActivity"
715
android:label="@string/app_name"
8-
android:icon="@mipmap/ic_launcher"
9-
android:roundIcon="@mipmap/ic_launcher_round"
10-
android:allowBackup="false"
11-
android:theme="@style/AppTheme"
12-
android:usesCleartextTraffic="${usesCleartextTraffic}"
13-
android:supportsRtl="true">
14-
<activity
15-
android:name=".MainActivity"
16-
android:label="@string/app_name"
17-
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
18-
android:launchMode="singleTask"
19-
android:windowSoftInputMode="adjustResize"
20-
android:exported="true">
21-
<intent-filter>
22-
<action android:name="android.intent.action.MAIN" />
23-
<category android:name="android.intent.category.LAUNCHER" />
24-
</intent-filter>
25-
</activity>
26-
</application>
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
17+
android:launchMode="singleTask"
18+
android:windowSoftInputMode="adjustResize"
19+
android:exported="true"
20+
android:theme="@style/BootTheme">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
</application>
2727
</manifest>
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package com.reactnativestarter
22

3+
import android.os.Bundle
34
import com.facebook.react.ReactActivity
45
import com.facebook.react.ReactActivityDelegate
56
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
67
import com.facebook.react.defaults.DefaultReactActivityDelegate
8+
import com.zoontek.rnbootsplash.RNBootSplash
79

810
class MainActivity : ReactActivity() {
911

10-
/**
11-
* Returns the name of the main component registered from JavaScript. This is used to schedule
12-
* rendering of the component.
13-
*/
1412
override fun getMainComponentName(): String = "ReactNativeStarter"
1513

16-
/**
17-
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18-
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19-
*/
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
RNBootSplash.init(this, R.style.BootTheme) // <- bootsplash theme name
16+
super.onCreate(savedInstanceState)
17+
// если вдруг используешь react-native-screens и шаблон требует:
18+
// super.onCreate(null)
19+
}
20+
2021
override fun createReactActivityDelegate(): ReactActivityDelegate =
21-
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
2223
}
6.58 KB
Loading
4.4 KB
Loading
8.25 KB
Loading

0 commit comments

Comments
 (0)