Skip to content

Commit

Permalink
[HBPackageNameHeaderCell] Design tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed May 28, 2023
1 parent 3060611 commit dab73cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
27 changes: 17 additions & 10 deletions prefs/HBPackageNameHeaderCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
@import CepheiUI;

static CGFloat const kHBPackageNameTableCellCondensedFontSize = 25.f;
static CGFloat const kHBPackageNameTableCellHeaderFontSize = 42.f;
static CGFloat const kHBPackageNameTableCellSubtitleFontSize = 18.f;
static CGFloat const kHBPackageNameTableCellSubtitleFontSize = 15.f;

@implementation HBPackageNameHeaderCell {
BOOL _condensed;
Expand Down Expand Up @@ -82,7 +81,7 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
}

if (_subtitleColor == nil) {
_subtitleColor = _hasGradient ? [UIColor colorWithWhite:235.f / 255.f alpha:0.7f] : [[UIColor labelColor] colorWithAlphaComponent:0.68f];
_subtitleColor = _hasGradient ? [UIColor colorWithWhite:235.f / 255.f alpha:0.7f] : [UIColor secondaryLabelColor];
}

#if !CEPHEI_EMBEDDED
Expand Down Expand Up @@ -124,7 +123,7 @@ - (void)layoutSubviews {
#pragma mark - PSHeaderFooterView

- (CGFloat)preferredHeightForWidth:(CGFloat)width {
CGFloat height = _condensed ? 74.f : 94.f;
CGFloat height = 72.f;

if (_showAuthor) {
height += 26.f;
Expand Down Expand Up @@ -153,23 +152,31 @@ - (void)updateData {
NSString *version = _showVersion ? [NSString stringWithFormat:_condensed ? @" %@" : [@"\n" stringByAppendingString:LOCALIZE(@"HEADER_VERSION", @"PackageNameHeaderCell", @"The subheading containing the package version.")], _version] : @"";
NSString *author = _showAuthor ? [NSString stringWithFormat:[@"\n" stringByAppendingString:LOCALIZE(@"HEADER_AUTHOR", @"PackageNameHeaderCell", @"The subheading containing the package author.")], cleanedAuthor] : @"";

UIFontDescriptor *systemTitleFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleTitle1];
UIFontDescriptor *systemTitleFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleLargeTitle];
UIFontDescriptor *systemTitleSemiboldFontDescriptor = [systemTitleFontDescriptor fontDescriptorByAddingAttributes:@{
UIFontDescriptorTraitsAttribute: @{
UIFontWeightTrait: @(UIFontWeightSemibold)
}
}];
UIFontDescriptor *systemTitle2FontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleTitle2];
UIFontDescriptor *systemSubtitleFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleSubheadline];
UIFontDescriptor *systemSubtitleFontDescriptor = [[UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleSubheadline] fontDescriptorByAddingAttributes:@{
UIFontDescriptorTraitsAttribute: @{
UIFontWeightTrait: @(UIFontWeightMedium)
}
}];

// Use the specified font names, with either the font sizes we want, or the sizes the user wants,
// whichever is larger
UIFont *headerFont = [UIFont fontWithDescriptor:systemTitleFontDescriptor size:MAX(systemTitleFontDescriptor.pointSize * 1.7f, kHBPackageNameTableCellHeaderFontSize)];
UIFont *subtitleFont = [UIFont systemFontOfSize:MAX(systemSubtitleFontDescriptor.pointSize * 1.1f, kHBPackageNameTableCellSubtitleFontSize)];
UIFont *condensedFont = [UIFont systemFontOfSize:MAX(systemTitle2FontDescriptor.pointSize * 1.1f, kHBPackageNameTableCellCondensedFontSize)];
UIFont *headerFont = [UIFont fontWithDescriptor:systemTitleSemiboldFontDescriptor size:systemTitleSemiboldFontDescriptor.pointSize * 1.15f];
UIFont *subtitleFont = [UIFont systemFontOfSize:MAX(systemSubtitleFontDescriptor.pointSize, kHBPackageNameTableCellSubtitleFontSize)];
UIFont *condensedFont = [UIFont fontWithDescriptor:systemTitleSemiboldFontDescriptor size:MAX(systemTitle2FontDescriptor.pointSize * 1.1f, kHBPackageNameTableCellCondensedFontSize)];
UIFont *condensedLightFont = [UIFont fontWithDescriptor:systemTitleFontDescriptor size:condensedFont.pointSize];

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@%@%@", icon, name, version, author] attributes:@{
NSKernAttributeName: [NSNull null], // This *enables* kerning, interestingly
}];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = _condensed ? 4.f : 2.f;
paragraphStyle.alignment = NSTextAlignmentCenter;

NSUInteger location = 0, length = 0;
Expand Down
8 changes: 0 additions & 8 deletions prefs/Resources/DemoAbout.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
<string>ws.hbang.common</string>
<key>packageNameOverride</key>
<string>Cephei</string>
<key>titleColor</key>
<string>#ffffff</string>
<key>subtitleColor</key>
<string>#aaaaaa</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
</dict>
<dict>
<key>big</key>
Expand Down
4 changes: 0 additions & 4 deletions prefs/Resources/DemoRoot.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
<string>ws.hbang.common</string>
<key>packageNameOverride</key>
<string>Cephei</string>
<key>titleColor</key>
<string>#ffffff</string>
<key>subtitleColor</key>
<string>#aaaaaa</string>
<key>footerText</key>
<string>This is a demo of Cephei features. Refer to https://hbang.github.io/libcephei/ for further details.</string>
</dict>
Expand Down

0 comments on commit dab73cd

Please sign in to comment.