Skip to content
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

Drawer component optimizations #794

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
576 changes: 372 additions & 204 deletions app/LoadedApp/LoadedApp.tsx

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions components/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import 'moment/locale/ru';
import { useMagicModal } from 'react-native-magic-modal';

type AboutProps = {
goBack: () => void;
};
const About: React.FunctionComponent<AboutProps> = () => {
const About: React.FunctionComponent<AboutProps> = ({ goBack }) => {
const context = useContext(ContextAppLoaded);
const { info, translate, language } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
moment.locale(language);
const { hide } = useMagicModal();

Expand All @@ -47,7 +48,7 @@ const About: React.FunctionComponent<AboutProps> = () => {
noSyncingStatus={true}
noDrawMenu={true}
noPrivacy={true}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
style={{ maxHeight: '90%' }}
Expand Down
15 changes: 5 additions & 10 deletions components/AddressBook/AddressBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ import { useMagicModal } from 'react-native-magic-modal';

type AddressBookProps = {
setAddressBook: (ab: AddressBookFileClass[]) => void;
goBack: () => void;
};

const AddressBook: React.FunctionComponent<AddressBookProps> = ({ setAddressBook }) => {
const AddressBook: React.FunctionComponent<AddressBookProps> = ({ setAddressBook, goBack }) => {
const context = useContext(ContextAppLoaded);
const {
translate,
language,
addressBook,
addressBookCurrentAddress,
zenniesDonationAddress,
} = context;
const { colors } = useTheme() as ThemeType;
const { translate, language, addressBook, addressBookCurrentAddress, zenniesDonationAddress } = context;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(language);

Expand Down Expand Up @@ -163,7 +158,7 @@ const AddressBook: React.FunctionComponent<AddressBookProps> = ({ setAddressBook
noSyncingStatus={true}
noDrawMenu={true}
noPrivacy={true}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
ref={scrollViewRef}
Expand Down
16 changes: 6 additions & 10 deletions components/Insight/Insight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ const getPercent = (percent: number) => {

type InsightProps = {
setPrivacyOption: (value: boolean) => Promise<void>;
goBack: () => void;
};

const Insight: React.FunctionComponent<InsightProps> = ({ setPrivacyOption }) => {
const Insight: React.FunctionComponent<InsightProps> = ({ setPrivacyOption, goBack }) => {
const context = useContext(ContextAppLoaded);
const { info, translate, privacy, addLastSnackbar, language } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(language);

Expand Down Expand Up @@ -170,12 +171,7 @@ const Insight: React.FunctionComponent<InsightProps> = ({ setPrivacyOption }) =>
flexWrap: 'wrap',
}}>
{item.address !== 'fee' && (
<AddressItem
address={item.address}
oneLine={true}
onlyContact={true}
withIcon={true}
/>
<AddressItem address={item.address} oneLine={true} onlyContact={true} withIcon={true} />
)}
{!expandAddress[index] && !!item.address && (
<RegText>
Expand Down Expand Up @@ -230,7 +226,7 @@ const Insight: React.FunctionComponent<InsightProps> = ({ setPrivacyOption }) =>
{item?.value}
</SvgText>
),
[]
[],
);

//console.log('render insight');
Expand All @@ -252,7 +248,7 @@ const Insight: React.FunctionComponent<InsightProps> = ({ setPrivacyOption }) =>
noDrawMenu={true}
setPrivacyOption={setPrivacyOption}
addLastSnackbar={addLastSnackbar}
closeScreen={hide}
closeScreen={goBack}
/>

<View style={{ width: '100%', flexDirection: 'row', marginTop: 10 }}>
Expand Down
4 changes: 3 additions & 1 deletion components/Messages/MessagesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type MessagesModalProps = {
toast: boolean,
sameServerChainName: boolean,
) => Promise<void>;
goBack: () => void;
};

const MessagesModal: React.FunctionComponent<MessagesModalProps> = ({
Expand All @@ -34,6 +35,7 @@ const MessagesModal: React.FunctionComponent<MessagesModalProps> = ({
scrollToBottom,
sendTransaction,
setServerOption,
goBack,
}) => {
const context = useContext(ContextAppLoaded);
const { language } = context;
Expand All @@ -49,7 +51,7 @@ const MessagesModal: React.FunctionComponent<MessagesModalProps> = ({
scrollToBottom={scrollToBottom}
sendTransaction={sendTransaction}
setServerOption={setServerOption}
closeModal={hide}
closeModal={goBack}
noDrawMenu={true}
/>
);
Expand Down
13 changes: 8 additions & 5 deletions components/Pools/Pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import { useMagicModal } from 'react-native-magic-modal';

type PoolsProps = {
setPrivacyOption: (value: boolean) => Promise<void>;
goBack: () => void;
};

const Pools: React.FunctionComponent<PoolsProps> = ({ setPrivacyOption }) => {
const Pools: React.FunctionComponent<PoolsProps> = ({ setPrivacyOption, goBack }) => {
const context = useContext(ContextAppLoaded);
const { totalBalance, info, translate, privacy, addLastSnackbar, somePending, language, shieldingAmount } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
const [orchardPool, setOrchardPool] = useState<boolean>(false);
const [saplingPool, setSaplingPool] = useState<boolean>(false);
Expand Down Expand Up @@ -70,7 +71,7 @@ const Pools: React.FunctionComponent<PoolsProps> = ({ setPrivacyOption }) => {
noDrawMenu={true}
setPrivacyOption={setPrivacyOption}
addLastSnackbar={addLastSnackbar}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
style={{ maxHeight: '90%' }}
Expand Down Expand Up @@ -113,7 +114,8 @@ const Pools: React.FunctionComponent<PoolsProps> = ({ setPrivacyOption }) => {
size={18}
currencyName={info.currencyName}
color={
totalBalance.spendableOrchard > 0 && totalBalance.spendableOrchard === totalBalance.orchardBal
totalBalance.spendableOrchard > 0 &&
totalBalance.spendableOrchard === totalBalance.orchardBal
? colors.primary
: 'red'
}
Expand Down Expand Up @@ -156,7 +158,8 @@ const Pools: React.FunctionComponent<PoolsProps> = ({ setPrivacyOption }) => {
size={18}
currencyName={info.currencyName}
color={
totalBalance.spendablePrivate > 0 && totalBalance.spendablePrivate === totalBalance.privateBal
totalBalance.spendablePrivate > 0 &&
totalBalance.spendablePrivate === totalBalance.privateBal
? colors.syncing
: 'red'
}
Expand Down
13 changes: 9 additions & 4 deletions components/Rescan/Rescan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import { useMagicModal } from 'react-native-magic-modal';

type RescanProps = {
doRescan: () => void;
goBack: () => void;
};

const Rescan: React.FunctionComponent<RescanProps> = ({ doRescan }) => {
const Rescan: React.FunctionComponent<RescanProps> = ({ doRescan, goBack }) => {
const context = useContext(ContextAppLoaded);
const { wallet, translate, netInfo, addLastSnackbar, language, selectServer } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(language);

Expand Down Expand Up @@ -57,7 +58,7 @@ const Rescan: React.FunctionComponent<RescanProps> = ({ doRescan }) => {
noSyncingStatus={true}
noDrawMenu={true}
noPrivacy={true}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
style={{ height: '80%', maxHeight: '80%' }}
Expand All @@ -78,7 +79,11 @@ const Rescan: React.FunctionComponent<RescanProps> = ({ doRescan }) => {
alignItems: 'center',
marginVertical: 5,
}}>
<Button type={ButtonTypeEnum.Primary} title={translate('rescan.button') as string} onPress={doRescanAndClose} />
<Button
type={ButtonTypeEnum.Primary}
title={translate('rescan.button') as string}
onPress={doRescanAndClose}
/>
</View>
</SafeAreaView>
</SafeAreaProvider>
Expand Down
6 changes: 4 additions & 2 deletions components/Seed/Seed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ type SeedProps = {
action: SeedActionEnum;
setPrivacyOption: (value: boolean) => Promise<void>;
keepAwake?: (v: boolean) => void;
goBack: () => void;
};
const Seed: React.FunctionComponent<SeedProps> = ({
onClickOK,
onClickCancel,
action,
setPrivacyOption,
keepAwake,
goBack,
}) => {
const contextLoaded = useContext(ContextAppLoaded);
const contextLoading = useContext(ContextAppLoading);
Expand Down Expand Up @@ -87,7 +89,7 @@ const Seed: React.FunctionComponent<SeedProps> = ({
language = contextLoaded.language;
}

const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
// when this screen is open from LoadingApp (new wallet)
// is using the standard modal from react-native
const { hide } = useMagicModal();
Expand Down Expand Up @@ -221,7 +223,7 @@ const Seed: React.FunctionComponent<SeedProps> = ({
mode={mode}
privacy={privacy}
receivedLegend={action === SeedActionEnum.view ? !basicFirstViewSeed : false}
closeScreen={onClickCancelHide}
closeScreen={goBack}
/>
<ScrollView
keyboardShouldPersistTaps="handled"
Expand Down
15 changes: 5 additions & 10 deletions components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/* eslint-disable react-native/no-inline-styles */
import React, { useContext, useEffect, useState } from 'react';
import {
View,
ScrollView,
TouchableOpacity,
TextInput,
Platform,
KeyboardAvoidingView,
} from 'react-native';
import { View, ScrollView, TouchableOpacity, TextInput, Platform, KeyboardAvoidingView } from 'react-native';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';

import { useTheme } from '@react-navigation/native';
Expand Down Expand Up @@ -66,6 +59,7 @@ type SettingsProps = {
setSelectServerOption: (value: string) => Promise<void>;
setRescanMenuOption: (value: boolean) => Promise<void>;
setRecoveryWalletInfoOnDeviceOption: (value: boolean) => Promise<void>;
goBack: () => void;
};

type Options = {
Expand All @@ -86,6 +80,7 @@ const Settings: React.FunctionComponent<SettingsProps> = ({
setSelectServerOption,
setRescanMenuOption,
setRecoveryWalletInfoOnDeviceOption,
goBack,
}) => {
const context = useContext(ContextAppLoaded);
const {
Expand Down Expand Up @@ -162,7 +157,7 @@ const Settings: React.FunctionComponent<SettingsProps> = ({
RECOVERYWALLETINFOONDEVICE = recoveryWalletInfoOnDevicesArray as Options[];
}

const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(languageContext);

Expand Down Expand Up @@ -553,7 +548,7 @@ const Settings: React.FunctionComponent<SettingsProps> = ({
noSyncingStatus={true}
noDrawMenu={true}
noPrivacy={true}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
keyboardShouldPersistTaps="handled"
Expand Down
7 changes: 4 additions & 3 deletions components/SyncReport/SyncReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import Utils from '../../app/utils';
import { useMagicModal } from 'react-native-magic-modal';

type SyncReportProps = {
goBack: () => void;
};

const SyncReport: React.FunctionComponent<SyncReportProps> = () => {
const SyncReport: React.FunctionComponent<SyncReportProps> = ({ goBack }) => {
const context = useContext(ContextAppLoaded);
const { syncingStatus, wallet, translate, background, language, netInfo } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(language);

Expand Down Expand Up @@ -229,7 +230,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = () => {
noSyncingStatus={true}
noDrawMenu={true}
noPrivacy={true}
closeScreen={hide}
closeScreen={goBack}
/>
<ScrollView
testID="syncreport.scroll-view"
Expand Down
22 changes: 18 additions & 4 deletions components/Ufvk/ShowUfvk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ type ShowUfvkProps = {
onClickCancel: () => void;
action: UfvkActionEnum;
setPrivacyOption: (value: boolean) => Promise<void>;
goBack: () => void;
};
const ShowUfvk: React.FunctionComponent<ShowUfvkProps> = ({ onClickOK, onClickCancel, action, setPrivacyOption }) => {
const ShowUfvk: React.FunctionComponent<ShowUfvkProps> = ({
onClickOK,
onClickCancel,
action,
setPrivacyOption,
goBack,
}) => {
const context = useContext(ContextAppLoaded);
const { translate, wallet, server, mode, addLastSnackbar, language } = context;
const { colors } = useTheme() as ThemeType;
const { colors } = useTheme() as ThemeType;
const { hide } = useMagicModal();
moment.locale(language);

Expand Down Expand Up @@ -107,7 +114,7 @@ const ShowUfvk: React.FunctionComponent<ShowUfvkProps> = ({ onClickOK, onClickCa
noDrawMenu={true}
setPrivacyOption={setPrivacyOption}
addLastSnackbar={addLastSnackbar}
closeScreen={onClickCancelHide}
closeScreen={goBack}
/>
<ScrollView
style={{ height: '80%', maxHeight: '80%' }}
Expand All @@ -124,7 +131,14 @@ const ShowUfvk: React.FunctionComponent<ShowUfvkProps> = ({ onClickOK, onClickCa

<View style={{ display: 'flex', flexDirection: 'column', marginTop: 0, alignItems: 'center' }}>
{!!wallet.ufvk && (
<SingleAddress address={wallet.ufvk} ufvk={true} index={0} total={1} prev={() => null} next={() => null} />
<SingleAddress
address={wallet.ufvk}
ufvk={true}
index={0}
total={1}
prev={() => null}
next={() => null}
/>
)}
{!wallet.ufvk && <ActivityIndicator size="large" color={colors.primary} />}
</View>
Expand Down
Loading