Skip to content

Commit

Permalink
refactor: routes
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarkhanzadian committed Sep 23, 2024
1 parent a5b7e40 commit 3ea94d1
Show file tree
Hide file tree
Showing 44 changed files with 368 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ function HeaderBottom() {
tabs={[
{
onPress() {
router.navigate(AppRoutes.WalletAllAssets);
router.navigate(AppRoutes.AllAssets);
},
title: t`All assets`,
isActive: pathname === AppRoutes.WalletAllAssets,
isActive: pathname === AppRoutes.AllAssets,
},
{
onPress() {
router.navigate(AppRoutes.WalletTokens);
router.navigate(AppRoutes.Tokens);
},
title: t`Tokens`,
isActive: pathname === AppRoutes.WalletTokens,
isActive: pathname === AppRoutes.Tokens,
},
{
onPress() {
router.navigate(AppRoutes.WalletCollectibles);
router.navigate(AppRoutes.Collectibles);
},
title: t`Collectibles`,
isActive: pathname === AppRoutes.WalletCollectibles,
isActive: pathname === AppRoutes.Collectibles,
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function SwapScreen() {
<View style={styles.container}>
<Text>{t`Collectibles 🖼️`}</Text>
<TouchableOpacity
onPress={() => router.navigate(AppRoutes.WalletBrowser)}
onPress={() => router.navigate(AppRoutes.Browser)}
p="4"
bg="ink.background-primary"
borderRadius="sm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function StackLayout() {
);
}

function NavigationWalletSettings(title: string = t`Settings`) {
function WalletNavigationSettings(title: string = t`Settings`) {
return (
<SimpleHeader
insets={insets}
Expand Down Expand Up @@ -99,7 +99,7 @@ export default function StackLayout() {
<Stack.Screen name="receive" options={{ header: () => NavigationHeader }} />
<Stack.Screen name="swap" options={{ header: () => NavigationHeader }} />
<Stack.Screen name="browser" options={{ headerShown: false }} />
<Stack.Screen name="home" options={{ header: () => NavigationHeaderHome }} />
<Stack.Screen name="index" options={{ header: () => NavigationHeaderHome }} />
<Stack.Screen name="create-new-wallet" options={{ header: () => NavigationBackSimple }} />
<Stack.Screen name="recover-wallet" options={{ header: () => NavigationBackSimple }} />
<Stack.Screen name="secure-your-wallet" options={{ header: () => NavigationBackSimple }} />
Expand All @@ -125,29 +125,29 @@ export default function StackLayout() {
options={{ header: () => NavigationSettings(t`Help`) }}
/>
<Stack.Screen
name="wallet-settings/index"
options={{ header: () => NavigationWalletSettings() }}
name="settings/wallet/index"
options={{ header: () => WalletNavigationSettings() }}
/>
<Stack.Screen
name="wallet-settings/hidden-accounts"
options={{ header: () => NavigationWalletSettings() }}
name="settings/wallet/hidden-accounts"
options={{ header: () => WalletNavigationSettings() }}
/>
<Stack.Screen
name="wallet-settings/configure/[wallet]/[account]/index"
options={{ header: props => NavigationWalletSettings(props.options.title) }}
name="settings/wallet/configure/[wallet]/[account]/index"
options={{ header: props => WalletNavigationSettings(props.options.title) }}
/>
<Stack.Screen
name="wallet-settings/configure/[wallet]/[account]/choose-avatar"
name="settings/wallet/configure/[wallet]/[account]/choose-avatar"
options={{ header: () => NavigationBackSimple }}
/>
<Stack.Screen
name="wallet-settings/configure/[wallet]/index"
name="settings/wallet/configure/[wallet]/index"
options={{
header: props => NavigationWalletSettings(props.options.title),
header: props => WalletNavigationSettings(props.options.title),
}}
/>
<Stack.Screen
name="wallet-settings/configure/[wallet]/view-secret-key"
name="settings/wallet/configure/[wallet]/view-secret-key"
options={{ header: () => NavigationBackSimple }}
/>
<Stack.Screen
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export default function DeveloperConsoleScreen() {
/>
<PressableListItem
title={t`Wallet management`}
onPress={() => router.navigate(AppRoutes.WalletDeveloperConsoleWalletManager)}
onPress={() => router.navigate(AppRoutes.DeveloperConsoleWalletManager)}
/>
<PressableListItem
title={t`Bitcoin Scrach Pad`}
onPress={() => router.navigate(AppRoutes.WalletDeveloperBitcoinScratchPad)}
onPress={() => router.navigate(AppRoutes.DeveloperBitcoinScratchPad)}
/>
<PressableListItem
title={t`getAddresses`}
Expand Down
10 changes: 3 additions & 7 deletions apps/mobile/src/app/(home)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { AppRoutes } from '@/routes';
import { Redirect } from 'expo-router';
import { Home } from '@/components/home/home';

export default function Home() {
if (!process.env.EXPO_PUBLIC_SECRET_KEY) {
throw new Error('You need to set EXPO_PUBLIC_SECRET_KEY');
}
return <Redirect href={AppRoutes.WalletHome} />;
export default function HomeScreen() {
return <Home />;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function SettingsScreen() {
subtitle={t`Add, configure and remove`}
Icon={WalletIcon}
onPress={() => {
router.navigate(AppRoutes.WalletWalletsSettings);
router.navigate(AppRoutes.SettingsWallet);
}}
/>
<Divider />
Expand All @@ -52,39 +52,39 @@ export default function SettingsScreen() {
subtitle={t`Theme, bitcoin unit and more`}
Icon={SunIcon}
onPress={() => {
router.navigate(AppRoutes.WalletSettingsDisplay);
router.navigate(AppRoutes.SettingsDisplay);
}}
/>
<Cell
title={t`Security`}
subtitle={t`Analytics and app authentication`}
Icon={ShieldIcon}
onPress={() => {
router.navigate(AppRoutes.WalletSettingsSecurity);
router.navigate(AppRoutes.SettingsSecurity);
}}
/>
<Cell
title={t`Networks`}
subtitle={t`Mainnet, testnet or signet`}
Icon={GlobeTiltedIcon}
onPress={() => {
router.navigate(AppRoutes.WalletSettingsNetworks);
router.navigate(AppRoutes.SettingsNetworks);
}}
/>
<Cell
title={t`Notifications`}
subtitle={t`Push and email notifications`}
Icon={BellIcon}
onPress={() => {
router.navigate(AppRoutes.WalletSettingsNotifications);
router.navigate(AppRoutes.SettingsNotifications);
}}
/>
<Cell
title={t`Help`}
subtitle={t`Support, guides and articles`}
Icon={SupportIcon}
onPress={() => {
router.navigate(AppRoutes.WalletSettingsHelp);
router.navigate(AppRoutes.SettingsHelp);
}}
/>
<Accordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function ConfigureAccount({ fingerprint, accountIndex, account }: ConfigureAccou
Icon={HeadIcon}
onPress={() => {
router.navigate({
pathname: AppRoutes.WalletWalletsSettingsConfigureAccountAvatar,
pathname: AppRoutes.SettingsWalletConfigureAccountAvatar,
params: { wallet: fingerprint, account: accountIndex },
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function ConfigureWallet({ wallet }: ConfigureWalletProps) {
Icon={Eye1ClosedIcon}
onPress={() => {
router.navigate({
pathname: AppRoutes.WalletWalletsSettingsConfigureViewSecretKey,
pathname: AppRoutes.SettingsWalletConfigureViewSecretKey,
params: { fingerprint: wallet.fingerprint },
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function SettingsScreen() {
subtitle={t`${hiddenAccountsLength} hidden accounts`}
Icon={Eye1ClosedIcon}
onPress={() => {
router.navigate(AppRoutes.WalletWalletsSettingsHiddenAccounts);
router.navigate(AppRoutes.SettingsWalletHiddenAccounts);
}}
/>
<Cell
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions apps/mobile/src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const unstable_settings = { initialRouteName: '/' };
initiateI18n();

export default function RootLayout() {
if (!process.env.EXPO_PUBLIC_SECRET_KEY) {
throw new Error('You need to set EXPO_PUBLIC_SECRET_KEY');
}

void SplashScreen.hideAsync();

return (
Expand Down
5 changes: 0 additions & 5 deletions apps/mobile/src/app/wallet/home.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions apps/mobile/src/components/action-bar/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,21 @@ export const ActionBarContainer = forwardRef<ActionBarMethods>((_, ref) => {
ref={ref}
left={
<ActionBarButton
onPress={() => router.navigate(AppRoutes.WalletSend)}
onPress={() => router.navigate(AppRoutes.Send)}
icon={<PaperPlaneIcon />}
label={t`Send`}
/>
}
center={
<ActionBarButton
onPress={() => router.navigate(AppRoutes.WalletReceive)}
onPress={() => router.navigate(AppRoutes.Receive)}
icon={<InboxIcon />}
label={t`Receive`}
/>
}
right={
<ActionBarButton
onPress={() => router.navigate(AppRoutes.WalletSwap)}
onPress={() => router.navigate(AppRoutes.Swap)}
icon={<ArrowsRepeatLeftRightIcon />}
label={t`Swap`}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/components/add-wallet/add-wallet-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export function AddWalletSheet({ addWalletSheetRef }: AddWalletSheetBaseProps) {
const router = useRouter();
const [optionData, setOptionData] = useState<OptionData | null>(null);
const createWallet = useCallback(() => {
router.navigate(AppRoutes.WalletCreateNewWallet);
router.navigate(AppRoutes.CreateNewWallet);
addWalletSheetRef.current?.close();
}, [addWalletSheetRef, router]);

const restoreWallet = useCallback(() => {
router.navigate(AppRoutes.WalletRecoverWallet);
router.navigate(AppRoutes.RecoverWallet);
addWalletSheetRef.current?.close();
}, [addWalletSheetRef, router]);

Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/components/headers/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export function OptionsHeader() {

return (
<Box flexDirection="row">
<TouchableOpacity p="3" onPress={() => router.navigate(AppRoutes.WalletSettings)}>
<TouchableOpacity p="3" onPress={() => router.navigate(AppRoutes.Settings)}>
<SettingsGearIcon />
</TouchableOpacity>
<TouchableOpacity p="3" onPress={() => router.navigate(AppRoutes.WalletDeveloperConsole)}>
<TouchableOpacity p="3" onPress={() => router.navigate(AppRoutes.DeveloperConsole)}>
<TerminalIcon />
</TouchableOpacity>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/src/components/wallet-settings/wallet-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function WalletCard({ fingerprint, variant, name }: WalletCardProps) {
<TouchableOpacity
onPress={() => {
router.navigate({
pathname: AppRoutes.WalletWalletsSettingsConfigureWallet,
pathname: AppRoutes.SettingsWalletConfigureWallet,
params: { fingerprint },
});
}}
Expand All @@ -82,7 +82,7 @@ export function WalletCard({ fingerprint, variant, name }: WalletCardProps) {
name={account.name}
onPress={() => {
router.navigate({
pathname: AppRoutes.WalletWalletsSettingsConfigureAccount,
pathname: AppRoutes.SettingsWalletConfigureAccount,
params: { fingerprint, account: account.accountIndex },
});
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function AccountsWidget({ accounts, wallets }: AccountsWidgetProps) {
))}

{hasAccounts ? (
<ImportWalletCard onPress={() => router.navigate(AppRoutes.WalletRecoverWallet)} />
<ImportWalletCard onPress={() => router.navigate(AppRoutes.RecoverWallet)} />
) : (
<CreateWalletCard onPress={() => addWalletSheetRef.current?.present()} />
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/features/account-selector-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function AccountSelectorSheet({ sheetRef }: { sheetRef: RefObject<SheetRe
const { fingerprint, accountIndex } = destructAccountIdentifer(accountId);
sheetRef.current?.close();
router.navigate({
pathname: AppRoutes.WalletWalletsSettingsConfigureAccount,
pathname: AppRoutes.SettingsWalletConfigureAccount,
params: { fingerprint, account: accountIndex },
});
},
Expand Down
8 changes: 4 additions & 4 deletions apps/mobile/src/hooks/create-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useCreateWallet() {
changeWalletSecurityLevel(biometrics ? 'secure' : 'insecure');
const { mnemonic, passphrase } = await tempMnemonicStore.getTemporaryMnemonic();
if (mnemonic) {
router.navigate(AppRoutes.WalletGeneratingWallet);
router.navigate(AppRoutes.GeneratingWallet);
await nextAnimationFrame();
try {
await keyStore.restoreWalletFromMnemonic({
Expand All @@ -25,7 +25,7 @@ export function useCreateWallet() {
passphrase: passphrase ?? undefined,
});
toastContext.displayToast({ type: 'success', title: t`Wallet added successfully` });
router.navigate(AppRoutes.WalletHome);
router.navigate(AppRoutes.Home);
} catch (e) {
if (keychainErrorHandlers.isKeyExistsError(e)) {
toastContext.displayToast({ type: 'info', title: t`Wallet already exists` });
Expand All @@ -41,7 +41,7 @@ export function useCreateWallet() {
async function navigateAndCreateWallet() {
switch (walletSecurityLevel) {
case 'undefined':
router.navigate(AppRoutes.WalletSecureYourWallet);
router.navigate(AppRoutes.SecureYourWallet);
return;
case 'secure':
await createWallet({ biometrics: true });
Expand All @@ -54,7 +54,7 @@ export function useCreateWallet() {
console.warn(
"walletSecurityLevel is undefined. That shouldn't happen in a newly created store"
);
router.navigate(AppRoutes.WalletSecureYourWallet);
router.navigate(AppRoutes.SecureYourWallet);
}
}

Expand Down
Loading

0 comments on commit 3ea94d1

Please sign in to comment.