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

Customise Card Header View #637

Open
majidsaleem105 opened this issue Dec 27, 2021 · 6 comments
Open

Customise Card Header View #637

majidsaleem105 opened this issue Dec 27, 2021 · 6 comments

Comments

@majidsaleem105
Copy link

Hello everyone,

I want to call different custom functions by clicking on:

  • The Title of the card
  • The disclosure icon of the card

Please consider the attached screenshot. I want to call different custom functions when a user clicks on the "Bell Icon" (Disclosure Image) or the Task Title.

Please note, I'm using Custom Task View Controller defined by @gavirawson-apple on #401

sample-screenshot

Thanks,

  • Majid S.
@majidsaleem105
Copy link
Author

Hello @gavirawson-apple, @erik-apple,
Any idea to achieve the goal?

@grawson
Copy link

grawson commented Feb 8, 2022

Hi @majidsaleem105. You can try accessing the UI element directly and setting up tap gestures. From within your view controller, something along the lines of:

taskView.headerView.titleLabel.addGestureRecognizer(someTapGesture)

@majidsaleem105
Copy link
Author

Hi @grawson,

I've tried as you suggested but it didn't work. I guess this is because the HeaderView click event triggers first. I tried to remove the UserInteraction from HeaderView, but it also didn't work.

I tried it in the OCKGridTaskViewSynchronizer class under the makeView function.

  • instructionsView.headerView.isUserInteractionEnabled = false

I also tried it from the dailyPageViewController function like

  • newTaskCard.taskView.headerView.isUserInteractionEnabled = false

It didn't work either way. I think it may work if we could remove the UserIntraction from the HeaderView and then add the GestureRecognizer.

Can you please guide me on how I can remove UserInteration from the HeaderView?

Thanks,
Majid S.

@grawson
Copy link

grawson commented Feb 24, 2022

The tap gesture in the header is set up on a private property of the view. Getting around that and producing the setup you mention will take some crafting. But given this particular view described is more custom, have you considered creating your own view + view controller? You can piece together the smaller view components provided in CareKit (OCKHeaderView, etc) and follow the guide here for setting up view synchronization with the store.

@majidsaleem105
Copy link
Author

Hi @grawson,

Thanks for your advice. I've managed to build the functionality the way you suggested. I used Collection Content View Circles to bring up the further task details and Header View to call my custom functions.

Thanks,

  • Majid S.

@grawson
Copy link

grawson commented Mar 11, 2022

Glad to hear it!

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

No branches or pull requests

2 participants