-
Notifications
You must be signed in to change notification settings - Fork 109
feat: [IOPID-3214] Offline wallet: startup timeout scenario #7282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2724e08
30cedec
9e45263
7d7f0c3
286f776
5b0a549
4253e7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,11 @@ | |
"contextualHelp": { | ||
"title": "Problemi di inizializzazione?" | ||
}, | ||
"offline_access_banner": { | ||
"title": "Ti servono i documenti?", | ||
"content": "Non attendere, sono sempre disponibili, anche se non hai connessione!", | ||
"action": "Vai ai documenti" | ||
}, | ||
"connection_lost": { | ||
"title": "Non hai una connessione a internet attiva", | ||
"description": "Controlla la tua connessione e riavvia l’app." | ||
|
@@ -5337,6 +5342,12 @@ | |
"footerAction": "Ricarica l'app IO" | ||
} | ||
}, | ||
"timeout": { | ||
"alert": { | ||
"content": " Hai bisogno di tornare alla versione completa di IO?", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
"action": "Ricarica l’app IO" | ||
} | ||
}, | ||
"back_online": { | ||
"alert": { | ||
"content": "Sei di nuovo online. Per usare tutti i servizi ", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* An ingress screen to choose the real first screen the user must navigate to. | ||
*/ | ||
import { | ||
Banner, | ||
ContentWrapper, | ||
H3, | ||
IOColors, | ||
|
@@ -18,6 +19,7 @@ import { | |
AnimatedPictogram, | ||
IOAnimatedPictograms | ||
} from "../ui/AnimatedPictogram"; | ||
import I18n from "../../i18n"; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
|
@@ -33,6 +35,7 @@ type LoadingScreenContentProps = WithTestID<{ | |
children?: ReactNode; | ||
headerVisible?: boolean; | ||
animatedPictogramSource?: IOAnimatedPictograms; | ||
banner?: { showBanner?: boolean; onPress: () => void }; | ||
}>; | ||
|
||
export const LoadingScreenContent = (props: LoadingScreenContentProps) => { | ||
|
@@ -42,7 +45,8 @@ export const LoadingScreenContent = (props: LoadingScreenContentProps) => { | |
children, | ||
headerVisible, | ||
testID, | ||
animatedPictogramSource | ||
animatedPictogramSource, | ||
banner = { showBanner: false } | ||
} = props; | ||
|
||
useEffect(() => { | ||
|
@@ -66,10 +70,10 @@ export const LoadingScreenContent = (props: LoadingScreenContentProps) => { | |
edges={headerVisible ? ["bottom"] : undefined} | ||
testID={testID} | ||
> | ||
<ContentWrapper> | ||
<ContentWrapper style={{ flex: 1 }}> | ||
<VStack | ||
space={SPACE_BETWEEN_SPINNER_AND_TEXT} | ||
style={{ alignItems: "center" }} | ||
style={{ alignItems: "center", flex: 1, justifyContent: "center" }} | ||
> | ||
<View | ||
accessible={false} | ||
|
@@ -93,9 +97,21 @@ export const LoadingScreenContent = (props: LoadingScreenContentProps) => { | |
> | ||
{contentTitle} | ||
</H3> | ||
{children} | ||
</VStack> | ||
</ContentWrapper> | ||
{children} | ||
<ContentWrapper style={{ marginBottom: 16 }}> | ||
{banner.showBanner && ( | ||
<Banner | ||
pictogramName="identityCheck" | ||
color="neutral" | ||
title={I18n.t("startup.offline_access_banner.title")} | ||
content={I18n.t("startup.offline_access_banner.content")} | ||
action={I18n.t("startup.offline_access_banner.action")} | ||
onPress={banner.onPress} | ||
/> | ||
)} | ||
Comment on lines
+103
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this screen is used app-wide, should we configure the banner externally instead of tying it to the startup version? This might give us more flexibility. What do you think? |
||
</ContentWrapper> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* An ingress screen to choose the real first screen the user must navigate to. | ||
*/ | ||
import { memo, useEffect, useRef, useState } from "react"; | ||
import { memo, useCallback, useEffect, useRef, useState } from "react"; | ||
import { Millisecond } from "@pagopa/ts-commons/lib/units"; | ||
import { AccessibilityInfo, View } from "react-native"; | ||
import I18n from "../../../i18n"; | ||
|
@@ -43,6 +43,7 @@ export const IngressScreen = () => { | |
|
||
const [showBlockingScreen, setShowBlockingScreen] = useState(false); | ||
const [contentTitle, setContentTitle] = useState(I18n.t("startup.title")); | ||
const [showBanner, setShowBanner] = useState(false); | ||
|
||
useEffect(() => { | ||
// Since the screen is shown for a very short time, | ||
|
@@ -66,6 +67,7 @@ export const IngressScreen = () => { | |
timeouts.push( | ||
setTimeout(() => { | ||
setContentTitle(I18n.t("startup.title2")); | ||
setShowBanner(true); | ||
timeouts.shift(); | ||
}, TIMEOUT_CHANGE_LABEL) | ||
); | ||
|
@@ -83,14 +85,9 @@ export const IngressScreen = () => { | |
}; | ||
}, [dispatch]); | ||
|
||
useEffect(() => { | ||
const visualizeOfflineWallet = | ||
isConnected === false && isOfflineAccessAvailable; | ||
|
||
if (visualizeOfflineWallet) { | ||
// This dispatch could be placed inside `onSuccess`, | ||
// but executing it here ensures the startup saga stops immediately. | ||
dispatch(setOfflineAccessReason(OfflineAccessReasonEnum.DEVICE_OFFLINE)); | ||
const navgateOnOfflineMiniApp = useCallback( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we've adopted React 19, should we avoid using |
||
(offlineReason: OfflineAccessReasonEnum) => { | ||
dispatch(setOfflineAccessReason(offlineReason)); | ||
dispatch( | ||
identificationRequest(false, false, undefined, undefined, { | ||
onSuccess: () => { | ||
|
@@ -101,8 +98,23 @@ export const IngressScreen = () => { | |
} | ||
}) | ||
); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
useEffect(() => { | ||
const visualizeOfflineWallet = | ||
isConnected === false && isOfflineAccessAvailable; | ||
|
||
if (visualizeOfflineWallet) { | ||
navgateOnOfflineMiniApp(OfflineAccessReasonEnum.DEVICE_OFFLINE); | ||
} | ||
}, [dispatch, isConnected, isOfflineAccessAvailable]); | ||
}, [ | ||
dispatch, | ||
isConnected, | ||
isOfflineAccessAvailable, | ||
navgateOnOfflineMiniApp | ||
]); | ||
|
||
if (isConnected === false && !isOfflineAccessAvailable) { | ||
return <IngressScreenNoInternetConnection />; | ||
|
@@ -123,6 +135,11 @@ export const IngressScreen = () => { | |
testID="ingress-screen-loader-id" | ||
contentTitle={contentTitle} | ||
animatedPictogramSource="waiting" | ||
banner={{ | ||
showBanner: isOfflineAccessAvailable && showBanner, | ||
onPress: () => | ||
navgateOnOfflineMiniApp(OfflineAccessReasonEnum.TIMEOUT) | ||
}} | ||
/> | ||
</> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have a trailing blank space? 🤔