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

Pay Card area #91

Merged
merged 7 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[ISSUES-81-90]: Small frontend improvements
  • Loading branch information
Danswar committed Jun 22, 2024
commit b80489618eb69150d61b7bfcd3825e5f958c3e93
20 changes: 10 additions & 10 deletions Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ const WalletsRoot = () => {
<WalletsStack.Screen name="WalletTransactions" component={WalletHome} options={WalletHome.navigationOptions(theme)} />
<WalletsStack.Screen name="WalletAsset" component={Asset} options={Asset.navigationOptions(theme)} />
<WalletsStack.Screen name="AddLightning" component={AddLightning} options={AddLightning.navigationOptions(theme)} />
<AddWalletStack.Screen
name="WalletsAddMultisig"
component={WalletsAddMultisig}
options={WalletsAddMultisig.navigationOptions(theme)}
/>
<AddWalletStack.Screen
name="WalletsAddMultisigStep2"
component={WalletsAddMultisigStep2}
options={WalletsAddMultisigStep2.navigationOptions(theme)}
/>
<WalletsStack.Screen name="LdkOpenChannel" component={LdkOpenChannel} options={LdkOpenChannel.navigationOptions(theme)} />
<WalletsStack.Screen name="LdkInfo" component={LdkInfo} options={LdkInfo.navigationOptions(theme)} />
<WalletsStack.Screen name="WalletDetails" component={WalletDetails} options={WalletDetails.navigationOptions(theme)} />
Expand Down Expand Up @@ -204,16 +214,6 @@ const AddWalletRoot = () => {
/>
<AddWalletStack.Screen name="PleaseBackupLdk" component={PleaseBackupLdk} options={PleaseBackupLdk.navigationOptions(theme)} />
<AddWalletStack.Screen name="ProvideEntropy" component={ProvideEntropy} options={ProvideEntropy.navigationOptions(theme)} />
<AddWalletStack.Screen
name="WalletsAddMultisig"
component={WalletsAddMultisig}
options={WalletsAddMultisig.navigationOptions(theme)}
/>
<AddWalletStack.Screen
name="WalletsAddMultisigStep2"
component={WalletsAddMultisigStep2}
options={WalletsAddMultisigStep2.navigationOptions(theme)}
/>
<AddWalletStack.Screen
name="WalletsAddMultisigHelp"
component={WalletsAddMultisigHelp}
Expand Down
12 changes: 3 additions & 9 deletions api/dfx/contexts/session.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,9 @@ export function DfxSessionContextProvider(props: PropsWithChildren<any>): JSX.El
!isProcessing &&
connect(wallets.filter((w: any) => w.type !== MultisigHDWallet.type).map((w: any) => w.getID()))
.then(() => setIsInitialized(true))
.catch(e =>
Alert.alert('Something went wrong', e.message?.toString(), [
{
text: loc._.ok,
onPress: () => { },
style: 'default',
},
]),
);
.catch(e => {
console.error('DFX session init error: ', e.message?.toString());
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wallets]);

Expand Down
14 changes: 9 additions & 5 deletions blue_modules/BlueElectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ const hardcodedPeers = [
{ host: 'electrum1.bluewallet.io', ssl: '443' },
{ host: 'electrum.acinq.co', ssl: '50002' },
{ host: 'electrum.bitaroo.net', ssl: '50002' },
{ host: 'VPS.hsmiths.com', tcp: '50001', ssl: '50002' },
{ host: 'helicarrier.bauerj.eu', tcp: '50001', ssl: '50002' },
{ host: 'node.xbt.eu', tcp: '50001', ssl: '50002' },
{ host: 'electrumx.not.fyi', tcp: '50001', ssl: '50002' },
{ host: 'kirsche.emzy.de', tcp: '50001', ssl: '50002' },
];

/** @type {ElectrumClient} */
Expand Down Expand Up @@ -147,6 +152,7 @@ async function connectMain() {
const ver = await mainClient.initElectrum({ client: 'bluewallet', version: '1.4' });
if (ver && ver[0]) {
console.log('connected to ', ver);
connectionAttempt = 0;
serverName = ver[0];
mainConnected = true;
wasConnectedAtLeastOnce = true;
Expand Down Expand Up @@ -188,13 +194,11 @@ async function connectMain() {
console.log('retry');
connectionAttempt = connectionAttempt + 1;
mainClient.close && mainClient.close();
if (connectionAttempt >= 5) {
presentNetworkErrorAlert(usingPeer);
} else {
console.log('reconnection attempt #', connectionAttempt);
await new Promise(resolve => setTimeout(resolve, 500)); // sleep
// quadratic backoff: 1st retry 100ms, 2nd 400ms, 3rd 900ms, 4th 1.6secs, 5th 2.5secs, 6th 3.6secs ...
await new Promise(resolve => setTimeout(resolve, 100 * connectionAttempt * connectionAttempt));
if (connectionAttempt > 30) connectionAttempt = 0; // speedup again after 2min
return connectMain();
}
}
}

Expand Down
1 change: 1 addition & 0 deletions loc/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
"add_lndhub_signature": "DFX signature",
"add_lndhub_url": "LNDHub admin URL",
"add_lndhub_instructions": "How to use your own LNDHub",
"add_lndhub_DFXswiss_not_available": "This service will be available soon",
"add_placeholder": "my first wallet",
"add_title": "Create Wallet",
"add_wallet_name": "Name",
Expand Down
7 changes: 3 additions & 4 deletions screen/receive/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ const ReceiveDetails = () => {

const renderReceiveDetails = () => {
return (
<KeyboardAvoidingView
enabled={!Platform.isPad}
behavior="position"
>
<ScrollView contentInsetAdjustmentBehavior="automatic">
<KeyboardAvoidingView enabled={!Platform.isPad} behavior="position" keyboardVerticalOffset={50}>
<View style={styles.scrollBody}>
<QRCodeComponent value={bip21encoded} />
<BlueCopyTextToClipboard text={isCustom ? bip21encoded : address} textStyle={{ marginVertical: 24 }} />
Expand Down Expand Up @@ -297,6 +295,7 @@ const ReceiveDetails = () => {
</View>
<BlueDismissKeyboardInputAccessory />
</KeyboardAvoidingView>
</ScrollView>
);
};

Expand Down
14 changes: 10 additions & 4 deletions screen/wallets/addMultisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Icon } from 'react-native-elements';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { SafeAreaView } from 'react-native-safe-area-context';

import { BlueButton, BlueListItem, BlueSpacing20 } from '../../BlueComponents';
import { BlueButton, BlueListItem, BlueSpacing20, SecondButton } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import BottomModal from '../../components/BottomModal';
import { MultisigHDWallet } from '../../class';
Expand Down Expand Up @@ -69,6 +69,8 @@ const WalletsAddMultisig = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const onBack = () => navigate('WalletTransactions');

const onLetsStartPress = async () => {
setIsLoading(true);
await new Promise(resolve => setTimeout(resolve, 100));
Expand Down Expand Up @@ -235,6 +237,8 @@ const WalletsAddMultisig = () => {
onPress={onLetsStartPress}
isLoading={isLoading}
/>
<BlueSpacing20 />
<SecondButton title={loc._.cancel} onPress={onBack} />
</View>
{renderModal()}
</SafeAreaView>
Expand Down Expand Up @@ -335,8 +339,10 @@ WalletsAddMultisig.getCurrentFormatReadable = f => {
}
};

WalletsAddMultisig.navigationOptions = navigationStyle({
headerTitle: null,
});
WalletsAddMultisig.navigationOptions = navigationStyle({}, opts => ({
...opts,
headerTitle: loc.wallets.multi_sig_wallet_label,
gestureEnabled: false,
}));

export default WalletsAddMultisig;
16 changes: 9 additions & 7 deletions screen/wallets/addMultisigStep2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon } from 'react-native-elements';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';

import { BlueButton } from '../../BlueComponents';
import { BlueButton, BlueSpacing10 } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import { MultisigCosigner, MultisigHDWallet } from '../../class';
import loc from '../../loc';
Expand All @@ -13,6 +13,7 @@ import { BlueURDecoder, encodeUR } from '../../blue_modules/ur';
import QRCodeComponent from '../../components/QRCodeComponent';
import alert from '../../components/Alert';
import { Camera } from 'react-native-camera-kit';
import { ScrollView } from 'react-native-gesture-handler';
const createHash = require('create-hash');

const prompt = require('../../helpers/prompt');
Expand Down Expand Up @@ -43,7 +44,7 @@ const WalletsAddMultisigStep2 = () => {

const stylesHook = StyleSheet.create({
root: {
flex: 1,
flexGrow: 1,
justifyContent: 'space-between',
backgroundColor: colors.elevated,
},
Expand Down Expand Up @@ -101,7 +102,7 @@ const WalletsAddMultisigStep2 = () => {
await saveToDisk();
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
navigation.dangerouslyGetParent().goBack();
navigation.navigate('WalletTransactions')
};

const getPath = () => {
Expand Down Expand Up @@ -357,7 +358,7 @@ const WalletsAddMultisigStep2 = () => {
};

return (
<View style={[styles.root, stylesHook.root]}>
<ScrollView contentContainerStyle={[styles.root, stylesHook.root]}>
<View>
<FlatList
contentContainerStyle={styles.keyCircleContainer}
Expand All @@ -374,8 +375,9 @@ const WalletsAddMultisigStep2 = () => {
</View>
<View style={styles.buttonContainer}>
<BlueButton isLoading={isLoading} title={loc.multisig.create} onPress={onCreate} disabled={cosigners.length !== n} />
{Platform.OS === 'ios' && (<BlueSpacing10 />)}
</View>
</View>
</ScrollView>
);
};

Expand All @@ -394,7 +396,7 @@ const styles = StyleSheet.create({
},
cameraContainer: {
position: 'relative',
height: '40%',
flexGrow: 1
},
camera: {
flex: 1,
Expand All @@ -408,7 +410,7 @@ const styles = StyleSheet.create({
});

WalletsAddMultisigStep2.navigationOptions = navigationStyle({
headerTitle: null,
headerTitle: loc.wallets.multi_sig_wallet_label,
gestureEnabled: false,
swipeEnabled: false,
});
Expand Down
26 changes: 23 additions & 3 deletions screen/wallets/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
View,
I18nManager,
useWindowDimensions,
TouchableOpacity,
} from 'react-native';
import { Icon } from 'react-native-elements';
import { useRoute, useNavigation, useTheme, useFocusEffect } from '@react-navigation/native';
Expand Down Expand Up @@ -654,15 +655,30 @@ const Asset = ({ navigation }) => {

export default Asset;

Asset.navigationOptions = navigationStyle({
Asset.navigationOptions = navigationStyle({}, (options, { navigation, route }) => ({
...options,
headerStyle: {
backgroundColor: 'transparent',
borderBottomWidth: 0,
elevation: 0,
// shadowRadius: 0,
shadowOffset: { height: 0, width: 0 },
},
});
headerRight: () => (
<TouchableOpacity
accessibilityRole="button"
testID="Settings"
style={styles.walletDetails}
onPress={() => {
route?.params?.walletID &&
navigation.navigate('Settings', {
walletID: route?.params?.walletID,
});
}}
>
<Icon name="more-horiz" type="material" size={22} color="#FFFFFF" />
</TouchableOpacity>
),
}));

Asset.propTypes = {
navigation: PropTypes.shape(),
Expand Down Expand Up @@ -714,4 +730,8 @@ const styles = StyleSheet.create({
padding: 5,
alignItems: 'center',
},
walletDetails:{
paddingLeft: 12,
paddingVertical:12
}
});
2 changes: 1 addition & 1 deletion screen/wallets/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const WalletDetails = () => {
}

const deleteCurrentWallet = () => {
dispatch(StackActions.pop());
navigate('WalletTransactions');
deleteWallet(wallet);
saveToDisk();
};
Expand Down
46 changes: 42 additions & 4 deletions screen/wallets/dfx/add-lightning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
BlueFormInput,
BlueSpacing10,
BlueSpacing20,
BlueSpacing40,
BlueSpacingAuto,
BlueText,
SafeBlueArea,
Expand All @@ -31,6 +32,7 @@ const AddLightning = () => {
const { addAndSaveWallet } = useContext(BlueStorageContext);

const [isLoading, setIsLoading] = useState(false);
const [useDFXswiss, setUseDFXswiss] = useState(false);
const [useCustom, setUseCustom] = useState(false);
const [customAddress, setCustomAddress] = useState<string>();
const [signature, setSignature] = useState<string>();
Expand Down Expand Up @@ -98,11 +100,33 @@ const AddLightning = () => {
<SafeBlueArea>
<ScrollView contentContainerStyle={styles.scrollableContainer}>
<View style={styles.contentContainer}>
<SelectButton active={!useCustom} onPress={() => setUseCustom(false)}>
<SelectButton
active={!useCustom && !useDFXswiss}
onPress={() => {
setUseCustom(false);
setUseDFXswiss(false);
}}
>
<BlueText>lightning.space</BlueText>
</SelectButton>
<BlueSpacing10 />
<SelectButton active={useCustom} onPress={() => setUseCustom(true)}>
<SelectButton
active={useDFXswiss}
onPress={() => {
setUseDFXswiss(true);
setUseCustom(false);
}}
>
<BlueText>DFX.swiss</BlueText>
</SelectButton>
<BlueSpacing10 />
<SelectButton
active={useCustom}
onPress={() => {
setUseCustom(true);
setUseDFXswiss(false);
}}
>
<BlueText>{loc.wallets.add_lndhub_custom}</BlueText>
</SelectButton>

Expand Down Expand Up @@ -136,11 +160,19 @@ const AddLightning = () => {
/>
</>
)}

{useDFXswiss && (
<>
<View style={styles.contentContainer}>
<BlueSpacing40 />
<BlueSpacing40 />
<BlueText style={styles.notAvailable}>{loc.wallets.add_lndhub_DFXswiss_not_available}</BlueText>
</View>
</>
)}
<BlueSpacingAuto />

<Text style={styles.disclaimer}>{loc.wallets.add_lndhub_disclaimer}</Text>
<BlueButton title={loc._.continue} onPress={onCreate} disabled={useCustom && !dataValid} isLoading={isLoading} />
<BlueButton title={loc._.continue} onPress={onCreate} disabled={(useCustom && !dataValid) || useDFXswiss} isLoading={isLoading} />
<BlueSpacing20 />
{/* @ts-ignore component in JS */}
<SecondButton title={loc._.cancel} onPress={onBack} />
Expand Down Expand Up @@ -170,6 +202,12 @@ const styles = StyleSheet.create({
color: '#9aa0aa',
textAlign: 'center',
},
notAvailable: {
margin: 40,
textAlign: 'center',
fontWeight: 'bold',
fontSize: 18,
},
});

AddLightning.navigationOptions = navigationStyle({}, opts => ({
Expand Down
Loading