Merge pull request #2181 from BlueWallet/successreuse

REF: Reuse Success screen
This commit is contained in:
GLaDOS 2020-11-25 14:25:32 +00:00 committed by GitHub
commit ed27ca799c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 33 deletions

View file

@ -143,6 +143,14 @@ const WalletsRoot = () => (
<WalletsStack.Screen name="Broadcast" component={Broadcast} options={Broadcast.navigationOptions} />
<WalletsStack.Screen name="LnurlPay" component={LnurlPay} options={LnurlPay.navigationOptions} />
<WalletsStack.Screen name="LnurlPaySuccess" component={LnurlPaySuccess} options={LnurlPaySuccess.navigationOptions} />
<WalletsStack.Screen
name="Success"
component={Success}
options={{
headerShown: false,
gestureEnabled: false,
}}
/>
</WalletsStack.Navigator>
);

View file

@ -9,9 +9,13 @@ import loc from '../../loc';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
const Success = () => {
const pop = () => {
dangerouslyGetParent().pop();
};
const { colors } = useTheme();
const { dangerouslyGetParent } = useNavigation();
const { amount = 0, fee = 0, amountUnit = BitcoinUnit.BTC, invoiceDescription = '' } = useRoute().params;
const { amount = 0, fee = 0, amountUnit = BitcoinUnit.BTC, invoiceDescription = '', onDonePressed = pop } = useRoute().params;
const animationRef = useRef();
const stylesHook = StyleSheet.create({
root: {
@ -29,9 +33,6 @@ const Success = () => {
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const pop = () => {
dangerouslyGetParent().pop();
};
useEffect(() => {
animationRef.current.reset();
@ -84,7 +85,7 @@ const Success = () => {
/>
</View>
<View style={styles.buttonContainer}>
<BlueButton onPress={pop} title={loc.send.success_done} />
<BlueButton onPress={onDonePressed} title={loc.send.success_done} />
</View>
</SafeAreaView>
);

View file

@ -14,7 +14,6 @@ import {
BlueText,
BlueSpacing,
BlueNavigationStyle,
BlueBigCheckmark,
} from '../../BlueComponents';
import { BlueCurrentTheme } from '../../components/themes';
import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class';
@ -101,7 +100,6 @@ export default class CPFP extends Component {
await BlueElectrum.waitTillConnected();
const result = await this.state.wallet.broadcastTx(this.state.txhex);
if (result) {
this.setState({ stage: 3, isLoading: false });
this.onSuccessBroadcast();
} else {
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
@ -119,6 +117,7 @@ export default class CPFP extends Component {
onSuccessBroadcast() {
this.context.txMetadata[this.state.newTxid] = { memo: 'Child pays for parent (CPFP)' };
Notifications.majorTomToGroundControl([], [], [this.state.newTxid]);
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
}
async componentDidMount() {
@ -203,20 +202,6 @@ export default class CPFP extends Component {
);
}
renderStage3() {
return (
<SafeBlueArea style={styles.doneWrap}>
<BlueCard style={styles.center}>
<View style={styles.doneCard} />
</BlueCard>
<BlueBigCheckmark style={styles.blueBigCheckmark} />
<BlueCard>
<BlueButton onPress={() => this.props.navigation.popToTop()} title={loc.send.success_done} />
</BlueCard>
</SafeBlueArea>
);
}
render() {
if (this.state.isLoading) {
return (
@ -226,10 +211,6 @@ export default class CPFP extends Component {
);
}
if (this.state.stage === 3) {
return this.renderStage3();
}
if (this.state.stage === 2) {
return this.renderStage2();
}

View file

@ -65,6 +65,7 @@ export default class RBFBumpFee extends CPFP {
if (this.context.txMetadata[this.state.txid]) {
this.context.txMetadata[this.state.newTxid] = this.context.txMetadata[this.state.txid];
}
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
}
render() {
@ -76,10 +77,6 @@ export default class RBFBumpFee extends CPFP {
);
}
if (this.state.stage === 3) {
return this.renderStage3();
}
if (this.state.stage === 2) {
return this.renderStage2();
}

View file

@ -75,6 +75,7 @@ export default class RBFCancel extends CPFP {
} else {
this.context.txMetadata[this.state.newTxid].memo = 'Cancelled transaction';
}
this.props.navigation.navigate('Success', { onDonePressed: () => this.props.navigation.popToTop(), amount: undefined });
}
render() {
@ -86,10 +87,6 @@ export default class RBFCancel extends CPFP {
);
}
if (this.state.stage === 3) {
return this.renderStage3();
}
if (this.state.stage === 2) {
return this.renderStage2();
}