mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
Merge pull request #6668 from BlueWallet/close
REF: navigationStyle default close position
This commit is contained in:
commit
6151f736ca
24 changed files with 103 additions and 132 deletions
|
@ -14,6 +14,12 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
enum CloseButtonPosition {
|
||||||
|
None = 'None',
|
||||||
|
Left = 'Left',
|
||||||
|
Right = 'Right',
|
||||||
|
}
|
||||||
|
|
||||||
type OptionsFormatter = (
|
type OptionsFormatter = (
|
||||||
options: NativeStackNavigationOptions,
|
options: NativeStackNavigationOptions,
|
||||||
deps: { theme: Theme; navigation: any; route: any },
|
deps: { theme: Theme; navigation: any; route: any },
|
||||||
|
@ -21,34 +27,63 @@ type OptionsFormatter = (
|
||||||
|
|
||||||
export type NavigationOptionsGetter = (theme: Theme) => (deps: { navigation: any; route: any }) => NativeStackNavigationOptions;
|
export type NavigationOptionsGetter = (theme: Theme) => (deps: { navigation: any; route: any }) => NativeStackNavigationOptions;
|
||||||
|
|
||||||
|
const getCloseButtonPosition = (
|
||||||
|
closeButtonPosition: CloseButtonPosition | undefined,
|
||||||
|
isFirstRouteInStack: boolean,
|
||||||
|
isModal: boolean,
|
||||||
|
): CloseButtonPosition => {
|
||||||
|
if (closeButtonPosition !== undefined) {
|
||||||
|
return closeButtonPosition;
|
||||||
|
}
|
||||||
|
if (isFirstRouteInStack && isModal) {
|
||||||
|
return CloseButtonPosition.Right;
|
||||||
|
}
|
||||||
|
return CloseButtonPosition.None;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getHandleCloseAction = (
|
||||||
|
onCloseButtonPressed: ((args: { navigation: any; route: any }) => void) | undefined,
|
||||||
|
navigation: any,
|
||||||
|
route: any,
|
||||||
|
) => {
|
||||||
|
if (onCloseButtonPressed) {
|
||||||
|
return () => onCloseButtonPressed({ navigation, route });
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
Keyboard.dismiss();
|
||||||
|
navigation.goBack(null);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const navigationStyle = (
|
const navigationStyle = (
|
||||||
{
|
{
|
||||||
closeButtonFunc,
|
closeButtonPosition,
|
||||||
|
onCloseButtonPressed,
|
||||||
headerBackVisible = true,
|
headerBackVisible = true,
|
||||||
...opts
|
...opts
|
||||||
}: NativeStackNavigationOptions & {
|
}: NativeStackNavigationOptions & {
|
||||||
closeButton?: boolean;
|
closeButtonPosition?: CloseButtonPosition;
|
||||||
closeButtonFunc?: (deps: { navigation: any; route: any }) => React.ReactElement | void;
|
onCloseButtonPressed?: (deps: { navigation: any; route: any }) => void;
|
||||||
},
|
},
|
||||||
formatter?: OptionsFormatter,
|
formatter?: OptionsFormatter,
|
||||||
): NavigationOptionsGetter => {
|
): NavigationOptionsGetter => {
|
||||||
return theme =>
|
return theme =>
|
||||||
({ navigation, route }) => {
|
({ navigation, route }) => {
|
||||||
// Determine if the current screen is the first one in the stack using the updated method
|
|
||||||
const isFirstRouteInStack = navigation.getState().index === 0;
|
const isFirstRouteInStack = navigation.getState().index === 0;
|
||||||
|
const isModal = route.params?.presentation !== 'card';
|
||||||
|
|
||||||
// Default closeButton to true if the current screen is the first one in the stack
|
const closeButton = getCloseButtonPosition(closeButtonPosition, isFirstRouteInStack, isModal);
|
||||||
const closeButton = opts.closeButton !== undefined ? opts.closeButton : isFirstRouteInStack;
|
const handleClose = getHandleCloseAction(onCloseButtonPressed, navigation, route);
|
||||||
|
|
||||||
let headerRight;
|
let headerRight;
|
||||||
let headerLeft;
|
let headerLeft;
|
||||||
if (closeButton) {
|
|
||||||
const handleClose = closeButtonFunc
|
if (!headerBackVisible) {
|
||||||
? () => closeButtonFunc({ navigation, route })
|
headerLeft = () => <></>;
|
||||||
: () => {
|
opts.headerLeft = headerLeft;
|
||||||
Keyboard.dismiss();
|
}
|
||||||
navigation.goBack(null);
|
|
||||||
};
|
if (closeButton === CloseButtonPosition.Right) {
|
||||||
headerRight = () => (
|
headerRight = () => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
|
@ -60,22 +95,30 @@ const navigationStyle = (
|
||||||
<Image source={theme.closeImage} />
|
<Image source={theme.closeImage} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
} else if (closeButton === CloseButtonPosition.Left) {
|
||||||
|
headerLeft = () => (
|
||||||
|
<TouchableOpacity
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel={loc._.close}
|
||||||
|
style={styles.button}
|
||||||
|
onPress={handleClose}
|
||||||
|
testID="NavigationCloseButton"
|
||||||
|
>
|
||||||
|
<Image source={theme.closeImage} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!headerBackVisible) {
|
|
||||||
headerLeft = () => <></>;
|
|
||||||
opts.headerLeft = headerLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: NativeStackNavigationOptions = {
|
let options: NativeStackNavigationOptions = {
|
||||||
headerShadowVisible: false,
|
headerShadowVisible: false,
|
||||||
headerTitleStyle: {
|
headerTitleStyle: {
|
||||||
fontWeight: '600',
|
fontWeight: '600',
|
||||||
color: theme.colors.foregroundColor,
|
color: theme.colors.foregroundColor,
|
||||||
},
|
},
|
||||||
headerRight,
|
|
||||||
headerBackTitleVisible: false,
|
headerBackTitleVisible: false,
|
||||||
headerTintColor: theme.colors.foregroundColor,
|
headerTintColor: theme.colors.foregroundColor,
|
||||||
|
headerRight,
|
||||||
|
headerLeft,
|
||||||
...opts,
|
...opts,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,38 +131,4 @@ const navigationStyle = (
|
||||||
};
|
};
|
||||||
|
|
||||||
export default navigationStyle;
|
export default navigationStyle;
|
||||||
|
export { CloseButtonPosition };
|
||||||
export const navigationStyleTx = (opts: NativeStackNavigationOptions, formatter: OptionsFormatter): NavigationOptionsGetter => {
|
|
||||||
return theme =>
|
|
||||||
({ navigation, route }) => {
|
|
||||||
let options: NativeStackNavigationOptions = {
|
|
||||||
headerTitleStyle: {
|
|
||||||
fontWeight: '600',
|
|
||||||
color: theme.colors.foregroundColor,
|
|
||||||
},
|
|
||||||
// headerBackTitle: null,
|
|
||||||
headerBackTitleVisible: false,
|
|
||||||
headerTintColor: theme.colors.foregroundColor,
|
|
||||||
headerLeft: () => (
|
|
||||||
<TouchableOpacity
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel={loc._.close}
|
|
||||||
style={styles.button}
|
|
||||||
onPress={() => {
|
|
||||||
Keyboard.dismiss();
|
|
||||||
navigation.goBack(null);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Image source={theme.closeImage} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
),
|
|
||||||
...opts,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (formatter) {
|
|
||||||
options = formatter(options, { theme, navigation, route });
|
|
||||||
}
|
|
||||||
|
|
||||||
return options;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ const AddWalletStack = () => {
|
||||||
name="AddWallet"
|
name="AddWallet"
|
||||||
component={AddComponent}
|
component={AddComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
title: loc.wallets.add_title,
|
title: loc.wallets.add_title,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import navigationStyle, { navigationStyleTx } from '../components/navigationStyle';
|
import navigationStyle from '../components/navigationStyle';
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
import { AztecoRedeemComponent, SelectWalletComponent } from './LazyLoadAztecoRedeemStack';
|
import { AztecoRedeemComponent, SelectWalletComponent } from './LazyLoadAztecoRedeemStack';
|
||||||
|
@ -16,11 +15,10 @@ const AztecoRedeemStackRoot = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="AztecoRedeem"
|
name="AztecoRedeem"
|
||||||
component={AztecoRedeemComponent}
|
component={AztecoRedeemComponent}
|
||||||
options={navigationStyleTx({}, options => ({
|
options={navigationStyle({
|
||||||
...options,
|
|
||||||
title: loc.azteco.title,
|
title: loc.azteco.title,
|
||||||
statusBarStyle: 'auto',
|
statusBarStyle: 'auto',
|
||||||
}))(theme)}
|
})(theme)}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="SelectWallet"
|
name="SelectWallet"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { Icon } from 'react-native-elements';
|
||||||
|
|
||||||
import { isDesktop } from '../blue_modules/environment';
|
import { isDesktop } from '../blue_modules/environment';
|
||||||
import HeaderRightButton from '../components/HeaderRightButton';
|
import HeaderRightButton from '../components/HeaderRightButton';
|
||||||
import navigationStyle from '../components/navigationStyle';
|
import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle';
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
import { useExtendedNavigation } from '../hooks/useExtendedNavigation';
|
import { useExtendedNavigation } from '../hooks/useExtendedNavigation';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
|
@ -31,13 +31,7 @@ import LdkViewLogs from '../screen/wallets/ldkViewLogs';
|
||||||
import SelectWallet from '../screen/wallets/selectWallet';
|
import SelectWallet from '../screen/wallets/selectWallet';
|
||||||
import WalletTransactions from '../screen/wallets/transactions';
|
import WalletTransactions from '../screen/wallets/transactions';
|
||||||
import WalletsList from '../screen/wallets/WalletsList';
|
import WalletsList from '../screen/wallets/WalletsList';
|
||||||
import {
|
import { NavigationDefaultOptions, NavigationFormModalOptions, StatusBarLightOptions, DetailViewStack } from './index'; // Importing the navigator
|
||||||
NavigationDefaultOptions,
|
|
||||||
NavigationDefaultOptionsForDesktop,
|
|
||||||
NavigationFormModalOptions,
|
|
||||||
StatusBarLightOptions,
|
|
||||||
DetailViewStack,
|
|
||||||
} from './index'; // Importing the navigator
|
|
||||||
import AddWalletStack from './AddWalletStack';
|
import AddWalletStack from './AddWalletStack';
|
||||||
import AztecoRedeemStackRoot from './AztecoRedeemStack';
|
import AztecoRedeemStackRoot from './AztecoRedeemStack';
|
||||||
import ExportMultisigCoordinationSetupStackRoot from './ExportMultisigCoordinationSetupStack';
|
import ExportMultisigCoordinationSetupStackRoot from './ExportMultisigCoordinationSetupStack';
|
||||||
|
@ -72,16 +66,11 @@ import SignVerifyStackRoot from './SignVerifyStack';
|
||||||
import ViewEditMultisigCosignersStackRoot from './ViewEditMultisigCosignersStack';
|
import ViewEditMultisigCosignersStackRoot from './ViewEditMultisigCosignersStack';
|
||||||
import WalletExportStack from './WalletExportStack';
|
import WalletExportStack from './WalletExportStack';
|
||||||
import WalletXpubStackRoot from './WalletXpubStack';
|
import WalletXpubStackRoot from './WalletXpubStack';
|
||||||
import { StackActions } from '@react-navigation/native';
|
|
||||||
|
|
||||||
const DetailViewStackScreensStack = () => {
|
const DetailViewStackScreensStack = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigation = useExtendedNavigation();
|
const navigation = useExtendedNavigation();
|
||||||
|
|
||||||
const popToTop = () => {
|
|
||||||
navigation.dispatch(StackActions.popToTop());
|
|
||||||
};
|
|
||||||
|
|
||||||
const SaveButton = useMemo(() => <HeaderRightButton testID="SaveButton" disabled={true} title={loc.wallets.details_save} />, []);
|
const SaveButton = useMemo(() => <HeaderRightButton testID="SaveButton" disabled={true} title={loc.wallets.details_save} />, []);
|
||||||
const DetailButton = useMemo(() => <HeaderRightButton testID="DetailButton" disabled={true} title={loc.send.create_details} />, []);
|
const DetailButton = useMemo(() => <HeaderRightButton testID="DetailButton" disabled={true} title={loc.send.create_details} />, []);
|
||||||
|
|
||||||
|
@ -129,10 +118,9 @@ const DetailViewStackScreensStack = () => {
|
||||||
title: loc.lnd.new_channel,
|
title: loc.lnd.new_channel,
|
||||||
headerLargeTitle: true,
|
headerLargeTitle: true,
|
||||||
statusBarStyle: 'auto',
|
statusBarStyle: 'auto',
|
||||||
closeButton: true,
|
closeButtonPosition: CloseButtonPosition.Right,
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
gestureEnabled: false,
|
gestureEnabled: false,
|
||||||
closeButtonFunc: popToTop,
|
|
||||||
})(theme)}
|
})(theme)}
|
||||||
/>
|
/>
|
||||||
<DetailViewStack.Screen name="LdkInfo" component={LdkInfo} options={LdkInfo.navigationOptions(theme)} />
|
<DetailViewStack.Screen name="LdkInfo" component={LdkInfo} options={LdkInfo.navigationOptions(theme)} />
|
||||||
|
@ -217,8 +205,7 @@ const DetailViewStackScreensStack = () => {
|
||||||
component={LnurlPay}
|
component={LnurlPay}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
title: '',
|
title: '',
|
||||||
closeButton: true,
|
closeButtonPosition: CloseButtonPosition.Right,
|
||||||
closeButtonFunc: popToTop,
|
|
||||||
})(theme)}
|
})(theme)}
|
||||||
/>
|
/>
|
||||||
<DetailViewStack.Screen
|
<DetailViewStack.Screen
|
||||||
|
@ -226,10 +213,9 @@ const DetailViewStackScreensStack = () => {
|
||||||
component={LnurlPaySuccess}
|
component={LnurlPaySuccess}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
title: '',
|
title: '',
|
||||||
closeButton: true,
|
closeButtonPosition: CloseButtonPosition.Right,
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
gestureEnabled: false,
|
gestureEnabled: false,
|
||||||
closeButtonFunc: popToTop,
|
|
||||||
})(theme)}
|
})(theme)}
|
||||||
/>
|
/>
|
||||||
<DetailViewStack.Screen name="LnurlAuth" component={LnurlAuth} options={LnurlAuth.navigationOptions(theme)} />
|
<DetailViewStack.Screen name="LnurlAuth" component={LnurlAuth} options={LnurlAuth.navigationOptions(theme)} />
|
||||||
|
@ -251,7 +237,7 @@ const DetailViewStackScreensStack = () => {
|
||||||
<DetailViewStack.Screen
|
<DetailViewStack.Screen
|
||||||
name="SendDetailsRoot"
|
name="SendDetailsRoot"
|
||||||
component={SendDetailsStack}
|
component={SendDetailsStack}
|
||||||
options={isDesktop ? NavigationDefaultOptionsForDesktop : NavigationDefaultOptions}
|
options={navigationStyle({ headerShown: false, presentation: isDesktop ? 'fullScreenModal' : 'modal' })(theme)}
|
||||||
/>
|
/>
|
||||||
<DetailViewStack.Screen name="LNDCreateInvoiceRoot" component={LNDCreateInvoiceRoot} options={NavigationDefaultOptions} />
|
<DetailViewStack.Screen name="LNDCreateInvoiceRoot" component={LNDCreateInvoiceRoot} options={NavigationDefaultOptions} />
|
||||||
<DetailViewStack.Screen name="ScanLndInvoiceRoot" component={ScanLndInvoiceRoot} options={NavigationDefaultOptions} />
|
<DetailViewStack.Screen name="ScanLndInvoiceRoot" component={ScanLndInvoiceRoot} options={NavigationDefaultOptions} />
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import navigationStyle from '../components/navigationStyle';
|
import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle';
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
import { ExportMultisigCoordinationSetupComponent } from './LazyLoadExportMultisigCoordinationSetupStack';
|
import { ExportMultisigCoordinationSetupComponent } from './LazyLoadExportMultisigCoordinationSetupStack';
|
||||||
|
@ -17,7 +16,7 @@ const ExportMultisigCoordinationSetupStackRoot = () => {
|
||||||
name="ExportMultisigCoordinationSetup"
|
name="ExportMultisigCoordinationSetup"
|
||||||
component={ExportMultisigCoordinationSetupComponent}
|
component={ExportMultisigCoordinationSetupComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
closeButton: true,
|
closeButtonPosition: CloseButtonPosition.Right,
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
statusBarStyle: 'light',
|
statusBarStyle: 'light',
|
||||||
title: loc.multisig.export_coordination_setup,
|
title: loc.multisig.export_coordination_setup,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle';
|
||||||
import navigationStyle from '../components/navigationStyle';
|
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
import {
|
import {
|
||||||
|
@ -24,7 +23,7 @@ const LNDCreateInvoiceRoot = () => {
|
||||||
component={LNDCreateInvoiceComponent}
|
component={LNDCreateInvoiceComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
title: loc.receive.header,
|
title: loc.receive.header,
|
||||||
closeButton: true,
|
closeButtonPosition: CloseButtonPosition.Right,
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
statusBarStyle: 'light',
|
statusBarStyle: 'light',
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -33,12 +33,12 @@ const PaymentCodeStackRoot = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="PaymentCode"
|
name="PaymentCode"
|
||||||
component={PaymentCodeComponent}
|
component={PaymentCodeComponent}
|
||||||
options={navigationStyle({ title: loc.bip47.payment_code, closeButton: true })(theme)}
|
options={navigationStyle({ title: loc.bip47.payment_code })(theme)}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="PaymentCodesList"
|
name="PaymentCodesList"
|
||||||
component={PaymentCodesListComponent}
|
component={PaymentCodesListComponent}
|
||||||
options={navigationStyle({ title: loc.bip47.contacts, closeButton: true })(theme)}
|
options={navigationStyle({ title: loc.bip47.contacts })(theme)}
|
||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,9 +16,7 @@ const ReceiveDetailsStackRoot = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="ReceiveDetails"
|
name="ReceiveDetails"
|
||||||
component={ReceiveDetailsComponent}
|
component={ReceiveDetailsComponent}
|
||||||
options={navigationStyle({ closeButton: true, headerBackVisible: false, title: loc.receive.header, statusBarStyle: 'light' })(
|
options={navigationStyle({ headerBackVisible: false, title: loc.receive.header, statusBarStyle: 'light' })(theme)}
|
||||||
theme,
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,7 +19,6 @@ const ReorderWalletsStackRoot = () => {
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
headerLargeTitle: true,
|
headerLargeTitle: true,
|
||||||
closeButton: true,
|
|
||||||
|
|
||||||
headerTitle: loc.wallets.reorder_title,
|
headerTitle: loc.wallets.reorder_title,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -21,7 +21,7 @@ const ScanLndInvoiceRoot = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="ScanLndInvoice"
|
name="ScanLndInvoice"
|
||||||
component={ScanLndInvoiceComponent}
|
component={ScanLndInvoiceComponent}
|
||||||
options={navigationStyle({ closeButton: true, headerBackVisible: false, title: loc.send.header, statusBarStyle: 'light' })(theme)}
|
options={navigationStyle({ headerBackVisible: false, title: loc.send.header, statusBarStyle: 'light' })(theme)}
|
||||||
initialParams={{ uri: undefined, walletID: undefined, invoice: undefined }}
|
initialParams={{ uri: undefined, walletID: undefined, invoice: undefined }}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
|
@ -39,7 +39,6 @@ const ScanLndInvoiceRoot = () => {
|
||||||
component={LnurlPayComponent}
|
component={LnurlPayComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
title: '',
|
title: '',
|
||||||
closeButton: true,
|
|
||||||
})(theme)}
|
})(theme)}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
|
@ -47,7 +46,6 @@ const ScanLndInvoiceRoot = () => {
|
||||||
component={LnurlPaySuccessComponent}
|
component={LnurlPaySuccessComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
title: '',
|
title: '',
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
gestureEnabled: false,
|
gestureEnabled: false,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import navigationStyle, { navigationStyleTx } from '../components/navigationStyle';
|
import navigationStyle, { CloseButtonPosition } from '../components/navigationStyle';
|
||||||
import { useTheme } from '../components/themes';
|
import { useTheme } from '../components/themes';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
import {
|
import {
|
||||||
|
@ -32,11 +31,11 @@ const SendDetailsStack = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="SendDetails"
|
name="SendDetails"
|
||||||
component={SendDetailsComponent}
|
component={SendDetailsComponent}
|
||||||
options={navigationStyleTx({}, options => ({
|
options={navigationStyle({
|
||||||
...options,
|
|
||||||
title: loc.send.header,
|
title: loc.send.header,
|
||||||
statusBarStyle: 'light',
|
statusBarStyle: 'light',
|
||||||
}))(theme)}
|
closeButtonPosition: CloseButtonPosition.Left,
|
||||||
|
})(theme)}
|
||||||
initialParams={{ isEditable: true }} // Correctly typed now
|
initialParams={{ isEditable: true }} // Correctly typed now
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
|
|
|
@ -16,9 +16,7 @@ const SignVerifyStackRoot = () => {
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="SignVerify"
|
name="SignVerify"
|
||||||
component={SignVerifyComponent}
|
component={SignVerifyComponent}
|
||||||
options={navigationStyle({ closeButton: true, headerBackVisible: false, statusBarStyle: 'light', title: loc.addresses.sign_title })(
|
options={navigationStyle({ headerBackVisible: false, statusBarStyle: 'light', title: loc.addresses.sign_title })(theme)}
|
||||||
theme,
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,7 +23,6 @@ const ViewEditMultisigCosignersStackRoot = () => {
|
||||||
name="ViewEditMultisigCosigners"
|
name="ViewEditMultisigCosigners"
|
||||||
component={ViewEditMultisigCosignersComponent}
|
component={ViewEditMultisigCosignersComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
title: loc.multisig.manage_keys,
|
title: loc.multisig.manage_keys,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -21,7 +21,6 @@ const WalletExportStack = () => {
|
||||||
name="WalletExport"
|
name="WalletExport"
|
||||||
component={WalletExportComponent}
|
component={WalletExportComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
title: loc.wallets.export_title,
|
title: loc.wallets.export_title,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -17,7 +17,6 @@ const WalletXpubStackRoot = () => {
|
||||||
name="WalletXpub"
|
name="WalletXpub"
|
||||||
component={WalletXpubComponent}
|
component={WalletXpubComponent}
|
||||||
options={navigationStyle({
|
options={navigationStyle({
|
||||||
closeButton: true,
|
|
||||||
headerBackVisible: false,
|
headerBackVisible: false,
|
||||||
headerTitle: loc.wallets.xpub_title,
|
headerTitle: loc.wallets.xpub_title,
|
||||||
})(theme)}
|
})(theme)}
|
||||||
|
|
|
@ -18,7 +18,6 @@ export const NavigationFormModalOptions: NativeStackNavigationOptions = {
|
||||||
headerShown: false,
|
headerShown: false,
|
||||||
presentation: 'formSheet',
|
presentation: 'formSheet',
|
||||||
};
|
};
|
||||||
export const NavigationDefaultOptionsForDesktop: NativeStackNavigationOptions = { headerShown: false, presentation: 'fullScreenModal' };
|
|
||||||
export const StatusBarLightOptions: NativeStackNavigationOptions = { statusBarStyle: 'light' };
|
export const StatusBarLightOptions: NativeStackNavigationOptions = { statusBarStyle: 'light' };
|
||||||
|
|
||||||
const DetailViewStack = createNativeStackNavigator<DetailViewStackParamList>();
|
const DetailViewStack = createNativeStackNavigator<DetailViewStackParamList>();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { useNavigation } from '@react-navigation/native';
|
|
||||||
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
||||||
import React, { useReducer } from 'react';
|
import React, { useReducer } from 'react';
|
||||||
import { ScrollView } from 'react-native';
|
import { ScrollView } from 'react-native';
|
||||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
|
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
|
||||||
|
@ -9,6 +7,7 @@ import Button from '../components/Button';
|
||||||
import prompt from '../helpers/prompt';
|
import prompt from '../helpers/prompt';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
import { useStorage } from '../hooks/context/useStorage';
|
import { useStorage } from '../hooks/context/useStorage';
|
||||||
|
import { popToTop } from '../NavigationService';
|
||||||
|
|
||||||
// Action Types
|
// Action Types
|
||||||
const SET_LOADING = 'SET_LOADING';
|
const SET_LOADING = 'SET_LOADING';
|
||||||
|
@ -39,7 +38,6 @@ function reducer(state: State, action: Action): State {
|
||||||
const PlausibleDeniability: React.FC = () => {
|
const PlausibleDeniability: React.FC = () => {
|
||||||
const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useStorage();
|
const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useStorage();
|
||||||
const [state, dispatch] = useReducer(reducer, initialState);
|
const [state, dispatch] = useReducer(reducer, initialState);
|
||||||
const navigation = useNavigation<NativeStackNavigationProp<Record<string, object | undefined>>>();
|
|
||||||
|
|
||||||
const handleOnCreateFakeStorageButtonPressed = async () => {
|
const handleOnCreateFakeStorageButtonPressed = async () => {
|
||||||
dispatch({ type: SET_LOADING, payload: true });
|
dispatch({ type: SET_LOADING, payload: true });
|
||||||
|
@ -66,7 +64,7 @@ const PlausibleDeniability: React.FC = () => {
|
||||||
resetWallets();
|
resetWallets();
|
||||||
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
||||||
presentAlert({ message: loc.plausibledeniability.success });
|
presentAlert({ message: loc.plausibledeniability.success });
|
||||||
navigation.popToTop();
|
popToTop();
|
||||||
} catch {
|
} catch {
|
||||||
dispatch({ type: SET_LOADING, payload: false });
|
dispatch({ type: SET_LOADING, payload: false });
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,4 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
LnurlAuth.navigationOptions = navigationStyle({
|
LnurlAuth.navigationOptions = navigationStyle({
|
||||||
title: '',
|
title: '',
|
||||||
closeButton: true,
|
|
||||||
closeButtonFunc: ({ navigation }) => navigation.getParent().popToTop(),
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
import React, { Component } from 'react';
|
||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
|
||||||
import { Image, Linking, ScrollView, StyleSheet, View } from 'react-native';
|
import { Image, Linking, ScrollView, StyleSheet, View } from 'react-native';
|
||||||
|
|
||||||
import { BlueButtonLink, BlueCard, BlueLoading, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents';
|
import { BlueButtonLink, BlueCard, BlueLoading, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents';
|
||||||
import Lnurl from '../../class/lnurl';
|
import Lnurl from '../../class/lnurl';
|
||||||
import Button from '../../components/Button';
|
import Button from '../../components/Button';
|
||||||
import SafeArea from '../../components/SafeArea';
|
import SafeArea from '../../components/SafeArea';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { SuccessView } from '../send/success';
|
import { SuccessView } from '../send/success';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
export default class LnurlPaySuccess extends Component {
|
export default class LnurlPaySuccess extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -119,7 +119,7 @@ export default class LnurlPaySuccess extends Component {
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.props.navigation.getParent().popToTop();
|
popToTop();
|
||||||
}}
|
}}
|
||||||
title={loc.send.success_done}
|
title={loc.send.success_done}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import React, { useCallback, useEffect, useReducer } from 'react';
|
import React, { useCallback, useEffect, useReducer } from 'react';
|
||||||
import { Alert, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
|
import { Alert, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
|
||||||
import { StackActions } from '@react-navigation/native';
|
|
||||||
|
|
||||||
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
||||||
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
|
import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents';
|
||||||
import presentAlert from '../../components/Alert';
|
import presentAlert from '../../components/Alert';
|
||||||
|
@ -12,6 +10,7 @@ import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
enum ActionType {
|
enum ActionType {
|
||||||
SetLoading = 'SET_LOADING',
|
SetLoading = 'SET_LOADING',
|
||||||
|
@ -58,7 +57,7 @@ const EncryptStorage = () => {
|
||||||
const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useStorage();
|
const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useStorage();
|
||||||
const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType } = useBiometrics();
|
const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType } = useBiometrics();
|
||||||
const [state, dispatch] = useReducer(reducer, initialState);
|
const [state, dispatch] = useReducer(reducer, initialState);
|
||||||
const { navigate, dispatch: navigationDispatch } = useExtendedNavigation();
|
const { navigate } = useExtendedNavigation();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
const styleHooks = StyleSheet.create({
|
const styleHooks = StyleSheet.create({
|
||||||
|
@ -84,10 +83,6 @@ const EncryptStorage = () => {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const popToTop = () => {
|
|
||||||
navigationDispatch(StackActions.popToTop());
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDecryptStorage = async () => {
|
const handleDecryptStorage = async () => {
|
||||||
dispatch({ type: ActionType.SetCurrentLoadingSwitch, payload: 'decrypt' });
|
dispatch({ type: ActionType.SetCurrentLoadingSwitch, payload: 'decrypt' });
|
||||||
const password = await prompt(loc.settings.password, loc._.storage_is_encrypted).catch(() => {
|
const password = await prompt(loc.settings.password, loc._.storage_is_encrypted).catch(() => {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import SafeArea from '../../components/SafeArea';
|
||||||
import { BlueCurrentTheme } from '../../components/themes';
|
import { BlueCurrentTheme } from '../../components/themes';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { StorageContext } from '../../components/Context/StorageProvider';
|
import { StorageContext } from '../../components/Context/StorageProvider';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
|
@ -108,7 +109,7 @@ export default class CPFP extends Component {
|
||||||
this.context.txMetadata[this.state.newTxid] = { memo: 'Child pays for parent (CPFP)' };
|
this.context.txMetadata[this.state.newTxid] = { memo: 'Child pays for parent (CPFP)' };
|
||||||
Notifications.majorTomToGroundControl([], [], [this.state.newTxid]);
|
Notifications.majorTomToGroundControl([], [], [this.state.newTxid]);
|
||||||
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
||||||
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
|
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import SafeArea from '../../components/SafeArea';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import CPFP from './CPFP';
|
import CPFP from './CPFP';
|
||||||
import { StorageContext } from '../../components/Context/StorageProvider';
|
import { StorageContext } from '../../components/Context/StorageProvider';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
|
@ -68,7 +69,7 @@ export default class RBFBumpFee extends CPFP {
|
||||||
this.context.txMetadata[this.state.newTxid] = this.context.txMetadata[this.state.txid];
|
this.context.txMetadata[this.state.newTxid] = this.context.txMetadata[this.state.txid];
|
||||||
}
|
}
|
||||||
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
||||||
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
|
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -108,7 +109,6 @@ export default class RBFBumpFee extends CPFP {
|
||||||
|
|
||||||
RBFBumpFee.propTypes = {
|
RBFBumpFee.propTypes = {
|
||||||
navigation: PropTypes.shape({
|
navigation: PropTypes.shape({
|
||||||
popToTop: PropTypes.func,
|
|
||||||
navigate: PropTypes.func,
|
navigate: PropTypes.func,
|
||||||
state: PropTypes.shape({
|
state: PropTypes.shape({
|
||||||
params: PropTypes.shape({
|
params: PropTypes.shape({
|
||||||
|
|
|
@ -9,6 +9,7 @@ import SafeArea from '../../components/SafeArea';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import CPFP from './CPFP';
|
import CPFP from './CPFP';
|
||||||
import { StorageContext } from '../../components/Context/StorageProvider';
|
import { StorageContext } from '../../components/Context/StorageProvider';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
export default class RBFCancel extends CPFP {
|
export default class RBFCancel extends CPFP {
|
||||||
static contextType = StorageContext;
|
static contextType = StorageContext;
|
||||||
|
@ -71,7 +72,7 @@ export default class RBFCancel extends CPFP {
|
||||||
this.context.txMetadata[this.state.newTxid].memo = 'Cancelled transaction';
|
this.context.txMetadata[this.state.newTxid].memo = 'Cancelled transaction';
|
||||||
}
|
}
|
||||||
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
this.context.sleep(4000).then(() => this.context.fetchAndSaveWalletTransactions(this.state.wallet.getID()));
|
||||||
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
|
this.props.navigation.navigate('Success', { onDonePressed: () => popToTop(), amount: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -111,7 +112,6 @@ export default class RBFCancel extends CPFP {
|
||||||
|
|
||||||
RBFCancel.propTypes = {
|
RBFCancel.propTypes = {
|
||||||
navigation: PropTypes.shape({
|
navigation: PropTypes.shape({
|
||||||
popToTop: PropTypes.func,
|
|
||||||
navigate: PropTypes.func,
|
navigate: PropTypes.func,
|
||||||
state: PropTypes.shape({
|
state: PropTypes.shape({
|
||||||
params: PropTypes.shape({
|
params: PropTypes.shape({
|
||||||
|
|
|
@ -47,6 +47,7 @@ import loc, { formatBalanceWithoutSuffix } from '../../loc';
|
||||||
import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
|
import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
|
||||||
import { useSettings } from '../../hooks/context/useSettings';
|
import { useSettings } from '../../hooks/context/useSettings';
|
||||||
import { useStorage } from '../../hooks/context/useStorage';
|
import { useStorage } from '../../hooks/context/useStorage';
|
||||||
|
import { popToTop } from '../../NavigationService';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
scrollViewContent: {
|
scrollViewContent: {
|
||||||
|
@ -119,7 +120,7 @@ const WalletDetails = () => {
|
||||||
const { isAdvancedModeEnabled } = useSettings();
|
const { isAdvancedModeEnabled } = useSettings();
|
||||||
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
|
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
|
||||||
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
|
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
|
||||||
const { goBack, setOptions, popToTop, navigate } = useExtendedNavigation();
|
const { goBack, setOptions, navigate } = useExtendedNavigation();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const [masterFingerprint, setMasterFingerprint] = useState();
|
const [masterFingerprint, setMasterFingerprint] = useState();
|
||||||
const walletTransactionsLength = useMemo(() => wallet.getTransactions().length, [wallet]);
|
const walletTransactionsLength = useMemo(() => wallet.getTransactions().length, [wallet]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue