-
Notifications
You must be signed in to change notification settings - Fork 41
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 #983 from tonwhales/release/v2.3.8
Release/v2.3.8
- Loading branch information
Showing
108 changed files
with
2,348 additions
and
971 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 |
---|---|---|
@@ -1 +1 @@ | ||
201 | ||
202 |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { BlurView } from "expo-blur"; | ||
import { createContext, useContext, useRef, useState } from "react"; | ||
import { Platform } from "react-native"; | ||
import Animated, { Easing, FadeOut } from "react-native-reanimated"; | ||
|
||
export const AppBlurContext = createContext<{ | ||
blur: boolean, | ||
setBlur: (newState: boolean) => void, | ||
getBlur: () => boolean | ||
setAuthInProgress: (newState: boolean) => void | ||
} | null>(null); | ||
|
||
export const AppBlurContextProvider = ({ children }: { children: any }) => { | ||
const [blur, setBlurState] = useState(false); | ||
const blurRef = useRef(blur); | ||
const getBlur = () => blurRef.current; | ||
|
||
const authInProgressRef = useRef(false); | ||
const setAuthInProgress = (newState: boolean) => authInProgressRef.current = newState; | ||
|
||
const setBlur = (newState: boolean) => { | ||
// On iOS we don't want to show blur when auth is in progress (biometrics prompt is shown AppState is 'inactive') | ||
if (newState && authInProgressRef.current && Platform.OS === 'ios') { | ||
return; | ||
} | ||
blurRef.current = newState; | ||
setBlurState(newState); | ||
} | ||
|
||
return ( | ||
<AppBlurContext.Provider value={{ blur, setBlur, getBlur, setAuthInProgress }}> | ||
{children} | ||
{blur | ||
? ( | ||
<Animated.View | ||
exiting={FadeOut.duration(350).easing(Easing.bezier(0.23, 1, 0.32, 1).factory())} | ||
style={{ position: 'absolute', left: 0, right: 0, bottom: 0, top: 0 }} | ||
> | ||
<BlurView | ||
style={{ position: 'absolute', left: 0, right: 0, bottom: 0, top: 0 }} | ||
intensity={30} | ||
experimentalBlurMethod={'dimezisBlurView'} // android only custom blur view impl | ||
/> | ||
</Animated.View> | ||
) | ||
: null | ||
} | ||
</AppBlurContext.Provider> | ||
); | ||
}; | ||
|
||
export function useAppBlur() { | ||
let res = useContext(AppBlurContext); | ||
if (!res) { | ||
throw Error('No AppBlur found'); | ||
} | ||
return res; | ||
} |
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
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,61 @@ | ||
import { NavigationContainerRefWithCurrent } from "@react-navigation/native"; | ||
import { useEffect, useRef } from "react"; | ||
import { AppState, Platform } from "react-native"; | ||
import { useLockAppWithAuthState } from "../engine/hooks/settings"; | ||
import { getLastAuthTimestamp } from "./secure/AuthWalletKeys"; | ||
import { useAppBlur } from "./AppBlurContext"; | ||
|
||
const appLockTimeout = 1000 * 60 * 15; // 15 minutes | ||
|
||
export const SessionWatcher = (({ navRef }: { navRef: NavigationContainerRefWithCurrent<any> }) => { | ||
const [locked,] = useLockAppWithAuthState(); | ||
const lastStateRef = useRef<string | null>(null); | ||
const { setBlur } = useAppBlur(); | ||
useEffect(() => { | ||
if (!locked) { | ||
setBlur(false); | ||
return; | ||
} | ||
|
||
const checkAndNavigate = () => { | ||
const lastAuthAt = getLastAuthTimestamp() ?? 0; | ||
|
||
if (lastAuthAt + appLockTimeout < Date.now()) { | ||
navRef.navigate('AppAuth'); | ||
} else { | ||
setBlur(false); | ||
} | ||
} | ||
|
||
const subscription = AppState.addEventListener('change', (newState) => { | ||
|
||
if (Platform.OS === 'ios') { // ios goes to inactive on biometric auth | ||
if (newState === 'background') { | ||
setBlur(true); | ||
} else if (newState === 'inactive') { | ||
setBlur(true); | ||
} else if (newState === 'active' && lastStateRef.current === 'background') { | ||
checkAndNavigate(); | ||
} else { | ||
setBlur(false); | ||
} | ||
} else { | ||
if (newState === 'background') { | ||
setBlur(true); | ||
} else if (newState === 'active' && lastStateRef.current === 'background') { | ||
checkAndNavigate(); | ||
} else { | ||
setBlur(false); | ||
} | ||
} | ||
|
||
// update last state | ||
lastStateRef.current = newState; | ||
}); | ||
|
||
return () => { | ||
subscription.remove(); | ||
}; | ||
}, [locked]); | ||
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,7 @@ | ||
import { useTonconnectWatcher } from "../engine/tonconnectWatcher"; | ||
|
||
export const TonconnectWatcher = () => { | ||
// Watch for TonConnect requests | ||
useTonconnectWatcher(); | ||
return null; | ||
} |
Oops, something went wrong.