-
Notifications
You must be signed in to change notification settings - Fork 30
feat(iOS): Add checkbox list #366
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
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # android/src/main/java/com/swmansion/enriched/utils/EnrichedSpanState.kt # apps/example/src/App.tsx # apps/example/src/components/Toolbar.tsx
# Conflicts: # android/src/main/java/com/swmansion/enriched/utils/Utils.kt
exploIF
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well 🚀
| blockTap.textView = textView; | ||
| blockTap.input = self; | ||
| blockTap.cancelsTouchesInView = YES; | ||
| blockTap.delaysTouchesBegan = YES; | ||
| blockTap.delaysTouchesEnded = YES; | ||
|
|
||
| for (UIGestureRecognizer *gr in textView.gestureRecognizers) { | ||
| [gr requireGestureRecognizerToFail:blockTap]; | ||
| } | ||
| [textView addGestureRecognizer:blockTap]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these could be done in some custom init on the TextBlockTapGestureRecognizer; one that would take input and of course the action, assign the input to a property, ran the initWithTarget base class method and then did all these operations. I think it would be much more clear.
| [textView addGestureRecognizer:blockTap]; | ||
| } | ||
|
|
||
| - (void)onTextBlockTap:(TextBlockTapGestureRecognizer *)gr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this method somewhere lower; I think it should be in the same place as traitCollectionDidChange method - so in the section of delegate methods and likewise.
| } | ||
| } | ||
|
|
||
| textView.selectedRange = NSMakeRange(endOfLineIndex, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add some comment describing why this seleciton fix is needed and what case was happening without it.
| // Draw Checkmark | ||
| UIBezierPath *checkPath = [UIBezierPath bezierPath]; | ||
| CGFloat startX = insetRect.origin.x + insetRect.size.width * 0.25; | ||
| CGFloat startY = insetRect.origin.y + insetRect.size.height * 0.5; | ||
| CGFloat midX = insetRect.origin.x + insetRect.size.width * 0.45; | ||
| CGFloat midY = insetRect.origin.y + insetRect.size.height * 0.65; | ||
| CGFloat endX = insetRect.origin.x + insetRect.size.width * 0.75; | ||
| CGFloat endY = insetRect.origin.y + insetRect.size.height * 0.35; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart, but crazy at the same time to manually draw a checmark 😮
| leading:YES | ||
| trailing:NO]; | ||
| fixedHtml = [self stringByAddingNewlinesToTag:@"<li>" | ||
| fixedHtml = [self stringByAddingNewlinesToTag:@"<li" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so I'm not sure about this one. It's there to specifically add newlines after all <li>. If we remove the >, it will start adding newlines in the middle of li tag content. I think we should rather separately do it for:
<li><li checked>
You can test it out by inputting a html like this;
<html><ul data-type=\"checkbox\"><li checked>something</li></ul></html>
to setHtml and I think there will be something wrong with newlines.
| return self; | ||
| } | ||
|
|
||
| - (void)applyStyle:(NSRange)range { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment why it's a no-op.
Summary
Fixes: #248
Add support for checkbox list.
Test Plan
Play with checkbox list in example app.
Screenshots / Videos
Screen.Recording.2026-01-16.at.12.11.44.mov
Compatibility