issue 12 : fix subscription back navigation #55
5
app.json
5
app.json
|
|
@ -5,7 +5,10 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/images/icon.png",
|
"icon": "./assets/images/icon.png",
|
||||||
"scheme": "myapp",
|
"scheme": [
|
||||||
|
"myapp",
|
||||||
|
"acupedia"
|
||||||
|
],
|
||||||
"userInterfaceStyle": "automatic",
|
"userInterfaceStyle": "automatic",
|
||||||
"ios": {
|
"ios": {
|
||||||
"bundleIdentifier": "com.renownent.mobile.acupedia",
|
"bundleIdentifier": "com.renownent.mobile.acupedia",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
|
BackHandler,
|
||||||
Linking,
|
Linking,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
|
@ -81,6 +82,30 @@ export default function SubscriptionScreen() {
|
||||||
}, [accessToken, refreshAccess]),
|
}, [accessToken, refreshAccess]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleBack = useCallback(() => {
|
||||||
|
if (unlocked) {
|
||||||
|
router.replace("/modules");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (router.canGoBack()) {
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.replace("/modules");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, [unlocked]);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
const onBackPress = () => handleBack();
|
||||||
|
const subscription = BackHandler.addEventListener(
|
||||||
|
"hardwareBackPress",
|
||||||
|
onBackPress
|
||||||
|
);
|
||||||
|
return () => subscription.remove();
|
||||||
|
}, [handleBack])
|
||||||
|
);
|
||||||
|
|
||||||
const showAlert = (alertTitle: string, message: string, onConfirm?: () => void) => {
|
const showAlert = (alertTitle: string, message: string, onConfirm?: () => void) => {
|
||||||
if (Platform.OS === "web") {
|
if (Platform.OS === "web") {
|
||||||
alert(`${alertTitle}\n\n${message}`);
|
alert(`${alertTitle}\n\n${message}`);
|
||||||
|
|
@ -132,9 +157,11 @@ export default function SubscriptionScreen() {
|
||||||
<SafeAreaView style={styles.safeArea} edges={["top", "bottom", "left", "right"]}>
|
<SafeAreaView style={styles.safeArea} edges={["top", "bottom", "left", "right"]}>
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => router.back()}
|
onPress={handleBack}
|
||||||
style={styles.backButton}
|
style={styles.backButton}
|
||||||
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel="Go back"
|
||||||
>
|
>
|
||||||
<Ionicons name="chevron-back" size={24} color={Colors.textPrimary} />
|
<Ionicons name="chevron-back" size={24} color={Colors.textPrimary} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue