-
Notifications
You must be signed in to change notification settings - Fork 3
/
quickActions.js
46 lines (41 loc) · 1.45 KB
/
quickActions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import QuickActions from 'react-native-quick-actions';
import { Platform } from 'react-native';
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) {
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();
}
}