mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
ADD: Add Wallet menu item
This commit is contained in:
parent
d88cc931b6
commit
85c57de1c5
9
App.js
9
App.js
@ -84,6 +84,14 @@ const App = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const addWalletMenuAction = () => {
|
||||
NavigationService.dispatch(
|
||||
CommonActions.navigate({
|
||||
name: 'AddWalletRoot',
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const onUserActivityOpen = data => {
|
||||
switch (data.activityType) {
|
||||
case HandoffComponent.activityTypes.ReceiveOnchain:
|
||||
@ -127,6 +135,7 @@ const App = () => {
|
||||
*/
|
||||
eventEmitter?.addListener('onNotificationReceived', onNotificationReceived);
|
||||
eventEmitter?.addListener('openSettings', openSettings);
|
||||
eventEmitter?.addListener('addWalletMenuAction', addWalletMenuAction);
|
||||
eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen);
|
||||
};
|
||||
|
||||
|
@ -117,7 +117,7 @@
|
||||
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
|
||||
}
|
||||
|
||||
- (void)openSettings {
|
||||
- (void)openSettings:(UIKeyCommand *)keyCommand {
|
||||
[EventEmitter.sharedInstance openSettings];
|
||||
}
|
||||
|
||||
@ -126,13 +126,33 @@
|
||||
[builder removeMenuForIdentifier:UIMenuServices];
|
||||
[builder removeMenuForIdentifier:UIMenuFormat];
|
||||
[builder removeMenuForIdentifier:UIMenuToolbar];
|
||||
[builder removeMenuForIdentifier:UIMenuFile];
|
||||
|
||||
UIKeyCommand *settingsCommand = [UIKeyCommand keyCommandWithInput:@"," modifierFlags:UIKeyModifierCommand action:@selector(openSettings)];
|
||||
[settingsCommand setTitle:@"Settings..."];
|
||||
UIMenu *settings = [UIMenu menuWithTitle:@"Settings..." image:nil identifier:@"openSettings" options:UIMenuOptionsDisplayInline children:@[settingsCommand]];
|
||||
|
||||
[builder insertSiblingMenu:settings afterMenuForIdentifier:UIMenuAbout];
|
||||
// Add Wallet action with Command + A shortcut
|
||||
UIKeyCommand *addWalletCommand = [UIKeyCommand keyCommandWithInput:@"A" modifierFlags:UIKeyModifierCommand action:@selector(addWalletAction:)];
|
||||
[addWalletCommand setTitle:@"Add Wallet"];
|
||||
UIMenu *addWalletMenu = [UIMenu menuWithTitle:@"" image:nil identifier:nil options:UIMenuOptionsDisplayInline children:@[addWalletCommand]];
|
||||
|
||||
|
||||
// Modify the existing File menu
|
||||
UIMenu *fileMenu = [builder menuForIdentifier:UIMenuFile];
|
||||
if (fileMenu) {
|
||||
// Replace the children of the File menu with the Add Wallet menu
|
||||
UIMenu *newFileMenu = [UIMenu menuWithTitle:fileMenu.title image:nil identifier:fileMenu.identifier options:fileMenu.options children:@[addWalletMenu]];
|
||||
[builder replaceMenuForIdentifier:UIMenuFile withMenu:newFileMenu];
|
||||
}
|
||||
// Existing settings menu
|
||||
UIKeyCommand *settingsCommand = [UIKeyCommand keyCommandWithInput:@"," modifierFlags:UIKeyModifierCommand action:@selector(openSettings)];
|
||||
[settingsCommand setTitle:@"Settings..."];
|
||||
UIMenu *settings = [UIMenu menuWithTitle:@"Settings..." image:nil identifier:nil options:UIMenuOptionsDisplayInline children:@[settingsCommand]];
|
||||
[builder insertSiblingMenu:settings afterMenuForIdentifier:UIMenuAbout];
|
||||
}
|
||||
|
||||
// Action for Add Wallet
|
||||
- (void)addWalletAction:(UIKeyCommand *)keyCommand {
|
||||
// Implement the functionality for adding a wallet
|
||||
[EventEmitter.sharedInstance addWalletMenuAction];
|
||||
|
||||
NSLog(@"Add Wallet action performed");
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
+ (EventEmitter *)sharedInstance;
|
||||
- (void)sendNotification:(NSDictionary *)userInfo;
|
||||
- (void)openSettings;
|
||||
- (void)addWalletMenuAction;
|
||||
- (void)sendUserActivity:(NSDictionary *)userInfo;
|
||||
|
||||
@end
|
||||
|
@ -32,7 +32,7 @@ RCT_EXPORT_MODULE();
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)supportedEvents {
|
||||
return @[@"onNotificationReceived",@"openSettings",@"onUserActivityOpen"];
|
||||
return @[@"onNotificationReceived",@"openSettings",@"onUserActivityOpen",@"addWalletMenuAction"];
|
||||
}
|
||||
|
||||
- (void)sendNotification:(NSDictionary *)userInfo
|
||||
@ -58,5 +58,8 @@ RCT_REMAP_METHOD(getMostRecentUserActivity, resolve: (RCTPromiseResolveBlock)res
|
||||
[sharedInstance sendEventWithName:@"openSettings" body:nil];
|
||||
}
|
||||
|
||||
- (void)addWalletMenuAction {
|
||||
[sharedInstance sendEventWithName:@"addWalletMenuAction" body:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user