2019-11-03 01:25:55 +01:00
|
|
|
import QuickActions from 'react-native-quick-actions';
|
|
|
|
import { Platform } from 'react-native';
|
|
|
|
|
|
|
|
export default class DeviceQuickActions {
|
|
|
|
static shared = new DeviceQuickActions();
|
|
|
|
wallets;
|
|
|
|
|
|
|
|
static setWallets(wallets) {
|
2019-11-28 17:27:46 +01:00
|
|
|
DeviceQuickActions.shared.wallets = wallets.slice(0, 4);
|
2019-11-03 01:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static removeAllWallets() {
|
|
|
|
DeviceQuickActions.shared.wallets = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static setQuickActions() {
|
|
|
|
if (DeviceQuickActions.shared.wallets === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-12 05:24:06 +01:00
|
|
|
QuickActions.isSupported((error, _supported) => {
|
|
|
|
if (error === null) {
|
2019-11-03 01:25:55 +01:00
|
|
|
let shortcutItems = [];
|
|
|
|
const loc = require('../loc/');
|
|
|
|
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
|
|
|
|
? ''
|
|
|
|
: loc.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();
|
|
|
|
}
|
|
|
|
}
|