diff --git a/components/Alert.ts b/components/Alert.ts index 4a4e284fc..2c45650bf 100644 --- a/components/Alert.ts +++ b/components/Alert.ts @@ -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; diff --git a/screen/settings/electrumSettings.js b/screen/settings/electrumSettings.js index 7939a44b3..de9d2c359 100644 --- a/screen/settings/electrumSettings.js +++ b/screen/settings/electrumSettings.js @@ -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 }); }); diff --git a/screen/transactions/CPFP.js b/screen/transactions/CPFP.js index d05fe9ca2..1c01526c1 100644 --- a/screen/transactions/CPFP.js +++ b/screen/transactions/CPFP.js @@ -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 }); } }); }; diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 066fb65a0..7ffa456cd 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -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); }