Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context menu for events ? #248

Open
al314 opened this issue Mar 20, 2020 · 5 comments
Open

Context menu for events ? #248

al314 opened this issue Mar 20, 2020 · 5 comments
Labels

Comments

@al314
Copy link

al314 commented Mar 20, 2020

Hello,

Could CalendarKit be able to present a context menu at the event by e.g. using dayViewDidLongPressEventView or some other hook ?
( I tried, but when I was selecting the event the y position changed and it looked weird since the frame seemed detached from the scrollview. I.e. the event that I was selecting for context menu was not anymore returned back into the scroll panel. )

Basically I would need to open a context menu for each and every separate event by long tapping the event.
Thanks for any help

@richardtop
Copy link
Owner

Please, provide a mockup of the design you're trying to achieve and a code sample you've used.
In particular, I'm interested in the code you've put in the dayViewDidLongPressEventView hook.

@richardtop richardtop added the bug label Mar 21, 2020
@al314
Copy link
Author

al314 commented Mar 21, 2020

Here is the mockup of what I try to achieve:
Screenshot 2020-03-21 at 11 27 19

while adding something like this into the dayViewDidLongPressEventView nothing happens when I add the similar to the dayView the mentioned event displacement happens.

I used your ExampleController as base to extend it with UIContextMenuInteractionDelegate, further I modified the below:

override func dayView(dayView: DayView, didLongPressTimelineAt date: Date) {   
     print("Did long press timeline at date dayView\(date)"). 
      ...
     event.endDate = datePeriod.end!
     // new code:
     view.addSubview(dayView)
     let interaction = UIContextMenuInteraction(delegate: self)
     dayView.addInteraction(interaction)
}

After all a step-by-step view of what happens with the current code.

  1. starts up fine, everything is good here

Screenshot 2020-03-21 at 12 05 41

  1. long press one of the events (red) in attempt to open the context menu. At this point the event "jumps" off to another layer where it can't be scrolled, it's stuck at the bottom of the screen. (if I were to press an event closer to the bottom of the timeline, it completely disappears, and cannot be interacted with anymore.)

Screenshot 2020-03-21 at 12 06 02

  1. a preview of how the red event doesn't move in spite of scrolling.

Screenshot 2020-03-21 at 12 06 16

Screenshot 2020-03-21 at 12 06 22

  1. After the event bugging out to the bottom of the screen it is possible to open a context menu from this particular event. None of the other events can open a context menu at this point, unless long pressing them, to which they also either "jump" off the canvas. (movement in only Y-axis)

Screenshot 2020-03-21 at 12 06 43

@richardtop
Copy link
Owner

richardtop commented Mar 21, 2020

Thank you for the detailed report. This is clearly a bug. I'll try to fix it asap.

Btw, what is this line for:

     // new code:
     view.addSubview(dayView)

I think, it's wrong. As a CalendarKit user when working with the default CalendarViewController, you shouldn't add DayView to any of the view hierarchy.

@al314
Copy link
Author

al314 commented May 18, 2020

Hello,

I have run into a similar issue once again, while trying to open a completely new view from

dayViewDidSelectEventView

        override func dayViewDidSelectEventView(_ eventView: EventView) {
        guard let descriptor = eventView.descriptor as? Event else {
            return
        }
                   let SwifUIview = ViewToBeOpenedByTappingOnEvent()
                   let vc = UIHostingController(rootView: SwifUIview)
                   guard let vcview = vc.view else { debugPrint("guard failed"); return }
                   view.addSubview(vcview)
                    }
        }

This is my code, I am aware there has been another problem with opening a new view from this function, which to my knowledge was in UIKit. However i'm trying to open a SwiftUI view from this, and it doesn't seem to be working. it does enter the view struct, and runs the code, but doesn't present it. (although i'm hosting it as a UIKit ViewController in the UIHostingControllermethod.
Appreciate any help you can provide.

PS.

If i might ask. i'd like to inquire about the progress on how to open a context menu as conversed previously. i still haven't found any plausible way of implementing it.

Many thanks.

@richardtop
Copy link
Owner

Hi,

  1. I guess, you need to present the controller itself, not the view. Otherwise, the view controller lifecycle is interrupted, which prevents the view from showing up correctly.
  2. No progress on this issue. Feel free to fix it yourself and submit a pull request, I'd be very happy to accept your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants