This commit is contained in:
Marcos Rodriguez Velez 2024-07-04 21:00:22 -04:00
parent 2d06c4e661
commit 574b6a3b41
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
4 changed files with 15 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import { Alert as RNAlert } from 'react-native';
import { Alert as RNAlert, Platform } from 'react-native';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
import { ToastAndroid } from 'react-native/types';
import loc from '../loc';
export enum AlertType {
@ -21,7 +22,14 @@ const presentAlert = ({
if (hapticFeedback) {
triggerHapticFeedback(hapticFeedback);
}
if (Platform.OS !== 'android') {
type = AlertType.Alert;
}
switch (type) {
case AlertType.Toast:
ToastAndroid.showWithGravity(message, ToastAndroid.LONG, ToastAndroid.BOTTOM);
break;
default:
RNAlert.alert(title ?? loc.alert.default, message);
break;

View File

@ -28,7 +28,7 @@ import {
BlueText,
} from '../../BlueComponents';
import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
import presentAlert from '../../components/Alert';
import presentAlert, { AlertType } from '../../components/Alert';
import Button from '../../components/Button';
import ListItem from '../../components/ListItem';
import { BlueCurrentTheme } from '../../components/themes';
@ -205,7 +205,7 @@ export default class ElectrumSettings extends Component {
}
} catch (error) {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ message: error });
presentAlert({ message: error, type: AlertType.Toast });
}
this.setState({ isLoading: false });
});

View File

@ -18,7 +18,7 @@ import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/h
import Notifications from '../../blue_modules/notifications';
import { BlueCard, BlueSpacing, BlueSpacing20, BlueText } from '../../BlueComponents';
import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class';
import presentAlert from '../../components/Alert';
import presentAlert, { AlertType } from '../../components/Alert';
import Button from '../../components/Button';
import navigationStyle from '../../components/navigationStyle';
import SafeArea from '../../components/SafeArea';
@ -101,7 +101,7 @@ export default class CPFP extends Component {
} catch (error) {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
this.setState({ isLoading: false });
presentAlert({ message: error.message });
presentAlert({ message: error.message, type: AlertType.Toast });
}
});
};

View File

@ -26,7 +26,7 @@ import * as fs from '../../blue_modules/fs';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet, WatchOnlyWallet } from '../../class';
import WalletGradient from '../../class/wallet-gradient';
import presentAlert from '../../components/Alert';
import presentAlert, { AlertType } from '../../components/Alert';
import { FButton, FContainer } from '../../components/FloatButtons';
import LNNodeBar from '../../components/LNNodeBar';
import navigationStyle from '../../components/navigationStyle';
@ -241,7 +241,7 @@ const WalletTransactions = ({ navigation }) => {
console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
} catch (err) {
noErr = false;
presentAlert({ message: err.message });
presentAlert({ message: err.message, type: AlertType.Toast });
setIsLoading(false);
setTimeElapsed(prev => prev + 1);
}