Open qubyedev opened 2 years ago
No, there is no currently support for such a functionality. I've marked it as an enhancement.
If you wish to implement it yourself, please add the following API to the DayView:
func eventViewFor(eventDescriptor: EventDescriptor) -> EventView {
/// Ask a lower layer for the EventView:
/// DayView -> TimelinePager -> Timeline -> Implement the algorithm on the Timeline class
}
Hi @richardtop , after checking it, i dont really get it.
After implement the func in TimelineView.shift
, how can I use it from viewcontroller?
Hi, yes, you'll need to propagate the the call from the DayViewController
to the TimelineView
.
So, add this functionality to the DayViewController
first, then it should call the DayView
(you can even use the same method signature). The DayView
should call TimelinePagerView
and it in turn should call the TimelineView
thru the TimelineContainer
.
Then you just return the result back up the chain.
Please, submit a pull request to the library, I'm interested in having this functionality integrated.
Hi @richardtop , thanks a lot!! It did work 🥳🥳🥳
I'd like to submit a pull request, but I fork this project from last Octobor and I have modified a lot. So I will find time to fork again and add just this func then submit.
Thank you again, you save my day!
I've looked at your implementation, I see a few issues:
EventDescriptor
is required to be an Object type, i.e. have an identity semanticEventDescriptor
you're passing to the other properties of the EventDescriptor
stored in the EventView
.This might not always work.
I suggest you changing the code to the following:
===
operatorEventDescriptor
conform to Equatable
and use the equality operator to find the associated EventView
.Why the 1st way is preferred? Because the EventDescriptor
is meant to have a direct relationship to the EventView
. i.e. a single descriptor is attached to a single view. I think, it's even possible to add a view
property onto a descriptor, to be set by the library when a view has been attached.
So, the descriptor is not a value type but actually a direct reference used & edited by the library.
I just tried to modify the code like in below and it always return nil, did I get it wrong?
func eventViewFor(eventDescriptor: EventDescriptor) -> EventView?{
// for eventView in eventViews{
// if eventView.descriptor?.startDate == eventDescriptor.startDate &&
// eventView.descriptor?.endDate == eventDescriptor.endDate &&
// eventView.descriptor?.titleText === eventDescriptor.titleText &&
// eventView.descriptor?.timeText == eventDescriptor.timeText {
// return eventView
// }
// }
for eventView in eventViews{
if eventView.descriptor === eventDescriptor{
return eventView
}
}
return nil
}
No, the code is OK. but are you returning the same descriptor as you've used in the eventsForDate
method? It not only has to be the same model, but actually the same instance you've passed in that method.
Hi,
I'd like to know is there anyway to get specific eventview without any gesture such as tap or longpress?
The scerino will be I get a data from server, then i want to find the event match the data, and show a popover with the eventview's source rect. So the whole workaround will not have any user interaction.