add to favorite actionsheet minor fix

This commit is contained in:
TrueZhuanjia
2025-06-07 12:42:23 +08:00
parent 782ac4c362
commit d9dbb2bcee
2 changed files with 18 additions and 17 deletions
@@ -1106,8 +1106,7 @@ const int FrontViewPositionNone = 0xff;
[menuController setMenuItems:@[item1, item2]];
UIView *targetView = [sender valueForKey:@"view"];
[menuController setTargetRect:targetView.bounds inView:targetView];
[menuController setMenuVisible:YES animated:YES];
[menuController showMenuFromView:targetView rect:targetView.bounds];
[self becomeFirstResponder];
}
@@ -667,6 +667,21 @@ BOOL isCustomResolution(CGSize res) {
else NSLog(@"hit test: not setting stack captured");
}
- (UIAlertController* )prepareAddToFavoriteActionSheet{
// actionsheet
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *addFavoriteAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Add to favorite"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self addSettingToFavorite:self->capturedStack];
// 在这里执行收藏逻辑
}];
[actionSheet addAction:addFavoriteAction];
return actionSheet;
}
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture {
CGPoint locationInParentStack = [gesture locationInView:parentStack];
CGPoint locationInRootView = [gesture locationInView:self.view.superview];
@@ -674,21 +689,8 @@ BOOL isCustomResolution(CGSize res) {
if (gesture.state == UIGestureRecognizerStateBegan) {
[self findCapturedStackByTouchLocation:locationInParentStack];
if(capturedStack == nil) return;
// actionsheet
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *addFavoriteAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Add to favorite"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self addSettingToFavorite:self->capturedStack];
// 在这里执行收藏逻辑
}];
[actionSheet addAction:addFavoriteAction];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
actionSheet.popoverPresentationController.sourceView = self.view;
actionSheet.popoverPresentationController.sourceRect = CGRectMake(locationInParentStack.x, locationInParentStack.y, 1, 1);
}
UIAlertController* actionSheet = [self prepareAddToFavoriteActionSheet];
actionSheet.popoverPresentationController.sourceView = capturedStack;
[self presentViewController:actionSheet animated:YES completion:nil];
}
}