mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import QuickActions from 'react-native-quick-actions';
|
|
import { Platform } from 'react-native';
|
|
import { formatBalance } from '../loc';
|
|
|
|
export default class DeviceQuickActions {
|
|
static shared = new DeviceQuickActions();
|
|
wallets;
|
|
|
|
static setWallets(wallets) {
|
|
DeviceQuickActions.shared.wallets = wallets.slice(0, 4);
|
|
}
|
|
|
|
static removeAllWallets() {
|
|
DeviceQuickActions.shared.wallets = undefined;
|
|
}
|
|
|
|
static setQuickActions() {
|
|
if (DeviceQuickActions.shared.wallets === undefined) {
|
|
return;
|
|
}
|
|
QuickActions.isSupported((error, _supported) => {
|
|
if (error === null) {
|
|
const shortcutItems = [];
|
|
for (const wallet of DeviceQuickActions.shared.wallets) {
|
|
shortcutItems.push({
|
|
type: 'Wallets', // Required
|
|
title: wallet.getLabel(), // Optional, if empty, `type` will be used instead
|
|
subtitle:
|
|
wallet.hideBalance || wallet.getBalance() <= 0
|
|
? ''
|
|
: formatBalance(Number(wallet.getBalance()), wallet.getPreferredBalanceUnit(), true),
|
|
userInfo: {
|
|
url: `bluewallet://wallet/${wallet.getID()}`, // Provide any custom data like deep linking URL
|
|
},
|
|
icon: Platform.select({ android: 'quickactions', ios: 'bookmark' }),
|
|
});
|
|
}
|
|
QuickActions.setShortcutItems(shortcutItems);
|
|
}
|
|
});
|
|
}
|
|
|
|
static clearShortcutItems() {
|
|
QuickActions.clearShortcutItems();
|
|
}
|
|
}
|