-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from Crossbell-Box/develop
Develop
- Loading branch information
Showing
22 changed files
with
179 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": patch | ||
--- | ||
|
||
Fixed the wrong events key of GA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": patch | ||
--- | ||
|
||
Only enable GA in production envrionment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": patch | ||
--- | ||
|
||
Typo fixes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": patch | ||
--- | ||
|
||
Fixed the problem of inaccurate recording of reading time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": minor | ||
--- | ||
|
||
Fixed crush error when go back on iOS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"xlog": minor | ||
--- | ||
|
||
Support network checking. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const generateCode = require("@expo/config-plugins/build/utils/generateCode"); | ||
const configPlugins = require("expo/config-plugins"); | ||
|
||
const code = ` pod 'Firebase', :modular_headers => true | ||
pod 'nanopb', :modular_headers => true | ||
pod 'FirebaseSessions', :modular_headers => true | ||
pod 'FirebaseCore', :modular_headers => true | ||
pod 'FirebaseCoreExtension', :modular_headers => true | ||
pod 'FirebaseInstallations', :modular_headers => true | ||
pod 'GoogleDataTransport', :modular_headers => true | ||
pod 'GoogleUtilities', :modular_headers => true | ||
$RNFirebaseAsStaticFramework = true`; | ||
|
||
const withReactNativeFirebase = (config) => { | ||
return configPlugins.withDangerousMod(config, [ | ||
"ios", | ||
async (config) => { | ||
const filePath = path.join( | ||
config.modRequest.platformProjectRoot, | ||
"Podfile", | ||
); | ||
const contents = fs.readFileSync(filePath, "utf-8"); | ||
|
||
const addCode = generateCode.mergeContents({ | ||
tag: "withReactNativeFirebase", | ||
src: contents, | ||
newSrc: code, | ||
anchor: /\s*get_default_flags\(\)/i, | ||
offset: 2, | ||
comment: "#", | ||
}); | ||
|
||
if (!addCode.didMerge) { | ||
console.error( | ||
"ERROR: Cannot add withReactNativeFirebase to the project's ios/Podfile because it's malformed.", | ||
); | ||
return config; | ||
} | ||
|
||
fs.writeFileSync(filePath, addCode.contents); | ||
|
||
return config; | ||
}, | ||
]); | ||
}; | ||
|
||
module.exports = withReactNativeFirebase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type React from "react"; | ||
|
||
import { useNetworkChecker } from "@/hooks/use-network-checker"; | ||
|
||
interface Props {} | ||
|
||
export const NetworkChecker: React.FC<Props> = (props) => { | ||
useNetworkChecker(); | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
|
||
import { useNetInfo } from "@react-native-community/netinfo"; | ||
|
||
interface Props { | ||
ifConnected?: React.ReactNode | ||
ifReachable?: React.ReactNode | ||
ifNotConnected?: React.ReactNode | ||
ifNotReachable?: React.ReactNode | ||
} | ||
|
||
export const NetworkSafeView: React.FC<Props> = (props) => { | ||
const { ifConnected, ifReachable, ifNotConnected, ifNotReachable } = props; | ||
const { isConnected, isInternetReachable } = useNetInfo(); | ||
|
||
return ( | ||
<> | ||
{isConnected && ifConnected} | ||
{isInternetReachable && ifReachable} | ||
{!isConnected && ifNotConnected} | ||
{!isInternetReachable && ifNotReachable} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useCallback, useEffect, useRef } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import NetInfo from "@react-native-community/netinfo"; | ||
import { useToastController } from "@tamagui/toast"; | ||
|
||
import { debounce } from "@/utils/debounce"; | ||
|
||
export const useNetworkChecker = () => { | ||
const toast = useToastController(); | ||
const i18n = useTranslation("common"); | ||
const disposer = useRef<() => void>(); | ||
|
||
const onNetworkError = useCallback(debounce(() => { | ||
toast.show(i18n.t("Network Error"), { | ||
burntOptions: { | ||
preset: "error", | ||
haptic: "warning", | ||
}, | ||
}); | ||
}, 5 * 1000), []); | ||
|
||
useEffect(() => { | ||
if (disposer.current) { | ||
disposer.current(); | ||
} | ||
|
||
disposer.current = NetInfo.addEventListener((state) => { | ||
if (state.isConnected === false || state.isInternetReachable === false) { | ||
onNetworkError(); | ||
} | ||
}); | ||
|
||
return () => disposer.current(); | ||
}, [toast]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import analytics from "@react-native-firebase/analytics"; | ||
|
||
export const GA = analytics(); | ||
import { IS_PROD } from "@/constants"; | ||
|
||
const analyticsInstance = analytics(); | ||
|
||
analyticsInstance.setAnalyticsCollectionEnabled(IS_PROD); | ||
|
||
export const GA = analyticsInstance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters