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

Store originalFont for CEVRK1Label to make updateAppearance idempotent #148

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ORK1Kit/ORK1Kit/Common/CEVRK1Label.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
@interface CEVRK1Label: UILabel

- (NSString * _Nullable)rawText;
- (UIFont * _Nullable)originalFont;

@end
10 changes: 10 additions & 0 deletions ORK1Kit/ORK1Kit/Common/CEVRK1Label.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,27 @@

@implementation CEVRK1Label {
NSString *_rawText;
UIFont *_originalFont;
}

- (void)setText:(NSString * _Nullable)text {
_rawText = text;
[self updateAppearance];
}

- (void)setFont:(UIFont *)font {
_originalFont = font;
[super setFont:font];
}

- (NSString * _Nullable)rawText {
return _rawText;
}

- (UIFont *)originalFont {
return _originalFont;
}

- (void)updateAppearance {
// overridden in subclasses
}
Expand Down
1 change: 1 addition & 0 deletions ORK1Kit/ORK1Kit/Common/CEVRK1Theme.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ - (void)updateAppearanceForLabel:(CEVRK1Label *)label ofType:(CEVRK1DisplayTextT
break;
}
NSMutableDictionary *attributes = [self textAttributesForView:label];
attributes[NSFontAttributeName] = label.originalFont;
[self combineIntoAttributes:attributes textStyle:textStyle];
label.attributedText = [[NSAttributedString alloc] initWithMarkdownRepresentation:[label rawText] attributes:attributes];
}
Expand Down
Loading