ADD: Add Wallet menu item

This commit is contained in:
Marcos Rodriguez Velez 2024-01-11 12:22:06 -04:00
parent d88cc931b6
commit 85c57de1c5
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
4 changed files with 41 additions and 8 deletions

9
App.js
View File

@ -84,6 +84,14 @@ const App = () => {
); );
}; };
const addWalletMenuAction = () => {
NavigationService.dispatch(
CommonActions.navigate({
name: 'AddWalletRoot',
}),
);
};
const onUserActivityOpen = data => { const onUserActivityOpen = data => {
switch (data.activityType) { switch (data.activityType) {
case HandoffComponent.activityTypes.ReceiveOnchain: case HandoffComponent.activityTypes.ReceiveOnchain:
@ -127,6 +135,7 @@ const App = () => {
*/ */
eventEmitter?.addListener('onNotificationReceived', onNotificationReceived); eventEmitter?.addListener('onNotificationReceived', onNotificationReceived);
eventEmitter?.addListener('openSettings', openSettings); eventEmitter?.addListener('openSettings', openSettings);
eventEmitter?.addListener('addWalletMenuAction', addWalletMenuAction);
eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen); eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen);
}; };

View File

@ -117,7 +117,7 @@
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
} }
- (void)openSettings { - (void)openSettings:(UIKeyCommand *)keyCommand {
[EventEmitter.sharedInstance openSettings]; [EventEmitter.sharedInstance openSettings];
} }
@ -126,13 +126,33 @@
[builder removeMenuForIdentifier:UIMenuServices]; [builder removeMenuForIdentifier:UIMenuServices];
[builder removeMenuForIdentifier:UIMenuFormat]; [builder removeMenuForIdentifier:UIMenuFormat];
[builder removeMenuForIdentifier:UIMenuToolbar]; [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");
} }

View File

@ -14,6 +14,7 @@
+ (EventEmitter *)sharedInstance; + (EventEmitter *)sharedInstance;
- (void)sendNotification:(NSDictionary *)userInfo; - (void)sendNotification:(NSDictionary *)userInfo;
- (void)openSettings; - (void)openSettings;
- (void)addWalletMenuAction;
- (void)sendUserActivity:(NSDictionary *)userInfo; - (void)sendUserActivity:(NSDictionary *)userInfo;
@end @end

View File

@ -32,7 +32,7 @@ RCT_EXPORT_MODULE();
} }
- (NSArray<NSString *> *)supportedEvents { - (NSArray<NSString *> *)supportedEvents {
return @[@"onNotificationReceived",@"openSettings",@"onUserActivityOpen"]; return @[@"onNotificationReceived",@"openSettings",@"onUserActivityOpen",@"addWalletMenuAction"];
} }
- (void)sendNotification:(NSDictionary *)userInfo - (void)sendNotification:(NSDictionary *)userInfo
@ -58,5 +58,8 @@ RCT_REMAP_METHOD(getMostRecentUserActivity, resolve: (RCTPromiseResolveBlock)res
[sharedInstance sendEventWithName:@"openSettings" body:nil]; [sharedInstance sendEventWithName:@"openSettings" body:nil];
} }
- (void)addWalletMenuAction {
[sharedInstance sendEventWithName:@"addWalletMenuAction" body:nil];
}
@end @end