Skip to content

Commit

Permalink
Support SwiftUI inherited font
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Oct 21, 2023
1 parent 03549cc commit fe64e62
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ inline __attribute__((always_inline)) LNPopupBarStyle _LNPopupResolveBarStyleFro

@property (nonatomic) BOOL _applySwiftUILayoutFixes;

@property (nonatomic, strong) UIFont* swiftuiInheritedFont;

@property (nonatomic, strong) UIView* swiftuiTitleContentView;

@property (nonatomic, strong) UIViewController* swiftuiImageController;
Expand Down
22 changes: 22 additions & 0 deletions LNPopupController/LNPopupController/Private/LNPopupBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,18 @@ - (void)setSwiftuiTitleContentView:(UIView *)swiftuiTitleContentView
[self _setNeedsTitleLayoutRemovingLabels:YES];
}

- (void)setSwiftuiInheritedFont:(UIFont *)swiftuiInheritedFont
{
if([_swiftuiInheritedFont isEqual:swiftuiInheritedFont])
{
return;
}

_swiftuiInheritedFont = swiftuiInheritedFont;

[self _setNeedsTitleLayoutRemovingLabels:YES];
}

- (void)setSwiftuiHiddenLeadingController:(UIViewController *)swiftuiHiddenLeadingController
{
if(_swiftuiHiddenLeadingController == swiftuiHiddenLeadingController)
Expand Down Expand Up @@ -1308,6 +1320,11 @@ - (void)_updateTitleInsetsForProminentBar:(UIEdgeInsets*)titleInsets
//DO NOT CHANGE NAME! Used by LNPopupUI
- (UIFont*)_titleFont
{
if(_swiftuiInheritedFont)
{
return _swiftuiInheritedFont;
}

CGFloat fontSize = 15;
UIFontWeight fontWeight = UIFontWeightMedium;
UIFontTextStyle textStyle = UIFontTextStyleBody;
Expand Down Expand Up @@ -1345,6 +1362,11 @@ - (UIColor*)_titleColor
//DO NOT CHANGE NAME! Used by LNPopupUI
- (UIFont*)_subtitleFont
{
if(_swiftuiInheritedFont)
{
return [UIFont fontWithDescriptor:_swiftuiInheritedFont.fontDescriptor size:_swiftuiInheritedFont.pointSize - 2.5];
}

CGFloat fontSize = 15;
UIFontWeight fontWeight = UIFontWeightRegular;
UIFontTextStyle textStyle = UIFontTextStyleBody;
Expand Down

0 comments on commit fe64e62

Please sign in to comment.