Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 6fc7fe3

Browse files
committed
backdrop: uses semi-bold fonts
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent a27410b commit 6fc7fe3

File tree

4 files changed

+59
-51
lines changed

4 files changed

+59
-51
lines changed

TrollSpeed.xcodeproj/xcshareddata/xcschemes/TrollSpeed-Sandbox.xcscheme

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
buildConfiguration = "Debug"
3434
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3535
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36-
language = "es"
3736
launchStyle = "0"
3837
useCustomWorkingDirectory = "NO"
3938
ignoresPersistentStateOnLaunch = "NO"

sources/HUDBackdropLabel.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ - (void)setupAppearance
5353
[blurFilter setValue:@(50.0) forKey:@"inputRadius"]; // radius 50pt
5454
[blurFilter setValue:@YES forKey:@"inputNormalizeEdges"]; // do not use inputHardEdges
5555

56-
CAFilter *brightnessFilter = [CAFilter filterWithName:kCAFilterColorBrightness];
57-
[brightnessFilter setValue:@(-0.3) forKey:@"inputAmount"]; // -30%
58-
5956
CAFilter *contrastFilter = [CAFilter filterWithName:kCAFilterColorContrast];
6057
[contrastFilter setValue:@(500.0) forKey:@"inputAmount"]; // 500x
6158

59+
CAFilter *brightnessFilter = [CAFilter filterWithName:kCAFilterColorBrightness];
60+
[brightnessFilter setValue:@(-0.3) forKey:@"inputAmount"]; // -30%
61+
6262
CAFilter *saturateFilter = [CAFilter filterWithName:kCAFilterColorSaturate];
6363
[saturateFilter setValue:@(0.0) forKey:@"inputAmount"];
6464

@@ -71,7 +71,6 @@ - (void)setupAppearance
7171

7272
_backdropTextLayer = [CATextLayer layer];
7373
_backdropTextLayer.contentsScale = self.layer.contentsScale;
74-
_backdropTextLayer.allowsEdgeAntialiasing = NO;
7574
_backdropTextLayer.allowsFontSubpixelQuantization = YES;
7675
_backdropView.layer.mask = _backdropTextLayer;
7776

sources/HUDRootViewController.mm

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@
105105
#define INLINE_SEPARATOR "\t"
106106
#define IDLE_INTERVAL 3.0
107107

108-
static double FONT_SIZE = 8.0;
109-
static uint8_t DATAUNIT = 0;
110-
static uint8_t SHOW_UPLOAD_SPEED = 1;
111-
static uint8_t SHOW_DOWNLOAD_SPEED = 1;
112-
static uint8_t SHOW_DOWNLOAD_SPEED_FIRST = 1;
113-
static uint8_t SHOW_SECOND_SPEED_IN_NEW_LINE = 0;
114-
static const char *UPLOAD_PREFIX = "";
115-
static const char *DOWNLOAD_PREFIX = "";
108+
static double HUD_FONT_SIZE = 8.0;
109+
static UIFontWeight HUD_FONT_WEIGHT = UIFontWeightRegular;
110+
static CGFloat HUD_INACTIVE_OPACITY = 0.667;
111+
static uint8_t HUD_DATA_UNIT = 0;
112+
static uint8_t HUD_SHOW_UPLOAD_SPEED = 1;
113+
static uint8_t HUD_SHOW_DOWNLOAD_SPEED = 1;
114+
static uint8_t HUD_SHOW_DOWNLOAD_SPEED_FIRST = 1;
115+
static uint8_t HUD_SHOW_SECOND_SPEED_IN_NEW_LINE = 0;
116+
static const char *HUD_UPLOAD_PREFIX = "";
117+
static const char *HUD_DOWNLOAD_PREFIX = "";
116118

117119
typedef struct {
118120
uint64_t inputBytes;
@@ -123,7 +125,7 @@
123125
{
124126
if (isFocused)
125127
{
126-
if (0 == DATAUNIT)
128+
if (0 == HUD_DATA_UNIT)
127129
{
128130
if (bytes < KILOBYTES) return NSLocalizedString(@"0 KB", @"formattedSpeed");
129131
else if (bytes < MEGABYTES) return [NSString stringWithFormat:NSLocalizedString(@"%.0f KB", @"formattedSpeed"), (double)bytes / KILOBYTES];
@@ -139,7 +141,7 @@
139141
}
140142
}
141143
else {
142-
if (0 == DATAUNIT)
144+
if (0 == HUD_DATA_UNIT)
143145
{
144146
if (bytes < KILOBYTES) return NSLocalizedString(@"0 KB/s", @"formattedSpeed");
145147
else if (bytes < MEGABYTES) return [NSString stringWithFormat:NSLocalizedString(@"%.0f KB/s", @"formattedSpeed"), (double)bytes / KILOBYTES];
@@ -205,13 +207,13 @@ static UpDownBytes getUpDownBytes()
205207
@autoreleasepool
206208
{
207209
if (!attributedUploadPrefix)
208-
attributedUploadPrefix = [[NSAttributedString alloc] initWithString:[[NSString stringWithUTF8String:UPLOAD_PREFIX] stringByAppendingString:@" "] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:FONT_SIZE]}];
210+
attributedUploadPrefix = [[NSAttributedString alloc] initWithString:[[NSString stringWithUTF8String:HUD_UPLOAD_PREFIX] stringByAppendingString:@" "] attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:HUD_FONT_SIZE] }];
209211
if (!attributedDownloadPrefix)
210-
attributedDownloadPrefix = [[NSAttributedString alloc] initWithString:[[NSString stringWithUTF8String:DOWNLOAD_PREFIX] stringByAppendingString:@" "] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:FONT_SIZE]}];
212+
attributedDownloadPrefix = [[NSAttributedString alloc] initWithString:[[NSString stringWithUTF8String:HUD_DOWNLOAD_PREFIX] stringByAppendingString:@" "] attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:HUD_FONT_SIZE] }];
211213
if (!attributedInlineSeparator)
212-
attributedInlineSeparator = [[NSAttributedString alloc] initWithString:[NSString stringWithUTF8String:INLINE_SEPARATOR] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:FONT_SIZE]}];
214+
attributedInlineSeparator = [[NSAttributedString alloc] initWithString:[NSString stringWithUTF8String:INLINE_SEPARATOR] attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:HUD_FONT_SIZE] }];
213215
if (!attributedLineSeparator)
214-
attributedLineSeparator = [[NSAttributedString alloc] initWithString:@"\n" attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:FONT_SIZE]}];
216+
attributedLineSeparator = [[NSAttributedString alloc] initWithString:@"\n" attributes:@{ NSFontAttributeName: [UIFont boldSystemFontOfSize:HUD_FONT_SIZE] }];
215217

216218
NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc] init];
217219

@@ -248,49 +250,49 @@ static UpDownBytes getUpDownBytes()
248250
}
249251
else shouldUpdateSpeedLabel = YES;
250252

251-
if (DATAUNIT == 1)
253+
if (HUD_DATA_UNIT == 1)
252254
{
253255
upDiff *= BYTE_SIZE;
254256
downDiff *= BYTE_SIZE;
255257
}
256258

257-
if (SHOW_DOWNLOAD_SPEED_FIRST)
259+
if (HUD_SHOW_DOWNLOAD_SPEED_FIRST)
258260
{
259-
if (SHOW_DOWNLOAD_SPEED)
261+
if (HUD_SHOW_DOWNLOAD_SPEED)
260262
{
261263
[mutableString appendAttributedString:attributedDownloadPrefix];
262-
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(downDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:FONT_SIZE weight:UIFontWeightRegular] }]];
264+
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(downDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:HUD_FONT_SIZE weight:HUD_FONT_WEIGHT] }]];
263265
}
264266

265-
if (SHOW_UPLOAD_SPEED)
267+
if (HUD_SHOW_UPLOAD_SPEED)
266268
{
267269
if ([mutableString length] > 0)
268270
{
269-
if (SHOW_SECOND_SPEED_IN_NEW_LINE) [mutableString appendAttributedString:attributedLineSeparator];
271+
if (HUD_SHOW_SECOND_SPEED_IN_NEW_LINE) [mutableString appendAttributedString:attributedLineSeparator];
270272
else [mutableString appendAttributedString:attributedInlineSeparator];
271273
}
272274

273275
[mutableString appendAttributedString:attributedUploadPrefix];
274-
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(upDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:FONT_SIZE weight:UIFontWeightRegular] }]];
276+
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(upDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:HUD_FONT_SIZE weight:HUD_FONT_WEIGHT] }]];
275277
}
276278
}
277279
else
278280
{
279-
if (SHOW_UPLOAD_SPEED)
281+
if (HUD_SHOW_UPLOAD_SPEED)
280282
{
281283
[mutableString appendAttributedString:attributedUploadPrefix];
282-
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(upDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:FONT_SIZE weight:UIFontWeightRegular] }]];
284+
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(upDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:HUD_FONT_SIZE weight:HUD_FONT_WEIGHT] }]];
283285
}
284-
if (SHOW_DOWNLOAD_SPEED)
286+
if (HUD_SHOW_DOWNLOAD_SPEED)
285287
{
286288
if ([mutableString length] > 0)
287289
{
288-
if (SHOW_SECOND_SPEED_IN_NEW_LINE) [mutableString appendAttributedString:attributedLineSeparator];
290+
if (HUD_SHOW_SECOND_SPEED_IN_NEW_LINE) [mutableString appendAttributedString:attributedLineSeparator];
289291
else [mutableString appendAttributedString:attributedInlineSeparator];
290292
}
291293

292294
[mutableString appendAttributedString:attributedDownloadPrefix];
293-
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(downDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:FONT_SIZE weight:UIFontWeightRegular] }]];
295+
[mutableString appendAttributedString:[[NSAttributedString alloc] initWithString:formattedSpeed(downDiff, isFocused) attributes:@{ NSFontAttributeName: [UIFont monospacedDigitSystemFontOfSize:HUD_FONT_SIZE weight:HUD_FONT_WEIGHT] }]];
294296
}
295297
}
296298

@@ -406,14 +408,16 @@ - (void)reloadUserDefaults
406408
[_lockedView setImage:[UIImage systemImageNamed:@"lock.fill"]];
407409
}
408410

409-
DATAUNIT = usesBitrate;
410-
SHOW_UPLOAD_SPEED = !singleLineMode;
411-
SHOW_DOWNLOAD_SPEED_FIRST = isCentered;
412-
SHOW_SECOND_SPEED_IN_NEW_LINE = !isCentered;
413-
FONT_SIZE = (usesLargeFont ? 9.0 : 8.0);
411+
HUD_DATA_UNIT = usesBitrate;
412+
HUD_SHOW_UPLOAD_SPEED = !singleLineMode;
413+
HUD_SHOW_DOWNLOAD_SPEED_FIRST = isCentered;
414+
HUD_SHOW_SECOND_SPEED_IN_NEW_LINE = !isCentered;
415+
HUD_FONT_SIZE = (usesLargeFont ? 9.0 : 8.0);
416+
HUD_FONT_WEIGHT = (usesInvertedColor ? UIFontWeightSemibold : UIFontWeightRegular);
417+
HUD_INACTIVE_OPACITY = (usesInvertedColor ? 1.0 : 0.667);
414418

415-
UPLOAD_PREFIX = (usesArrowPrefixes ? "" : "");
416-
DOWNLOAD_PREFIX = (usesArrowPrefixes ? "" : "");
419+
HUD_UPLOAD_PREFIX = (usesArrowPrefixes ? "" : "");
420+
HUD_DOWNLOAD_PREFIX = (usesArrowPrefixes ? "" : "");
417421

418422
prevInputBytes = 0;
419423
prevOutputBytes = 0;
@@ -595,7 +599,7 @@ - (void)viewDidLoad
595599
_speedLabel.numberOfLines = 0;
596600
_speedLabel.textAlignment = NSTextAlignmentCenter;
597601
_speedLabel.textColor = [UIColor whiteColor];
598-
_speedLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
602+
_speedLabel.font = [UIFont systemFontOfSize:HUD_FONT_SIZE];
599603
_speedLabel.translatesAutoresizingMaskIntoConstraints = NO;
600604
[_speedLabel setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical];
601605
[_blurView.contentView addSubview:_speedLabel];
@@ -847,8 +851,9 @@ - (void)onFocus:(UIView *)view scaleFactor:(CGFloat)scaleFactor duration:(NSTime
847851

848852
view.alpha = 1.0;
849853
} completion:^(BOOL finished) {
850-
if (blurWhenDone)
854+
if (blurWhenDone) {
851855
[self performSelector:@selector(onBlur:) withObject:view afterDelay:IDLE_INTERVAL];
856+
}
852857
}];
853858
}
854859

@@ -868,7 +873,7 @@ - (void)onBlur:(UIView *)view duration:(NSTimeInterval)duration
868873

869874
[UIView animateWithDuration:duration delay:0.0 usingSpringWithDamping:1.0 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionBeginFromCurrentState animations:^{
870875
view.transform = CGAffineTransformIdentity;
871-
view.alpha = 0.667;
876+
view.alpha = HUD_INACTIVE_OPACITY;
872877
} completion:nil];
873878
}
874879

@@ -1048,7 +1053,7 @@ - (void)updateOrientation:(UIInterfaceOrientation)orientation animateWithDuratio
10481053
__weak typeof(self) weakSelf = self;
10491054
[UIView animateWithDuration:duration animations:^{
10501055
__strong typeof(weakSelf) strongSelf = weakSelf;
1051-
strongSelf->_contentView.alpha = strongSelf->_isFocused ? 1.0 : 0.667;
1056+
strongSelf->_contentView.alpha = strongSelf->_isFocused ? 1.0 : HUD_INACTIVE_OPACITY;
10521057
}];
10531058
}
10541059
else
@@ -1115,7 +1120,7 @@ - (void)viewWillTransitionToSize:(CGSize)size
11151120
[strongSelf onBlur:strongSelf->_contentView duration:0];
11161121

11171122
if (orientation == UIInterfaceOrientationPortrait) {
1118-
strongSelf->_contentView.alpha = strongSelf->_isFocused ? 1.0 : 0.667;
1123+
strongSelf->_contentView.alpha = strongSelf->_isFocused ? 1.0 : HUD_INACTIVE_OPACITY;
11191124
} else {
11201125
strongSelf->_contentView.alpha = 0.0;
11211126
}

sources/RootViewController.mm

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,19 @@ - (void)reloadMainButtonState
487487
static NSAttributedString *creditsAttributedString = nil;
488488
static dispatch_once_t onceToken;
489489
dispatch_once(&onceToken, ^{
490-
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
491-
paraStyle.lineHeightMultiple = 1.2;
492-
paraStyle.alignment = NSTextAlignmentCenter;
493-
494490
NSDictionary *defaultAttributes = @{
495491
NSForegroundColorAttributeName: [UIColor whiteColor],
496492
NSFontAttributeName: [UIFont systemFontOfSize:14],
497-
NSParagraphStyleAttributeName: paraStyle,
493+
};
494+
495+
NSMutableParagraphStyle *creditsParaStyle = [[NSMutableParagraphStyle alloc] init];
496+
creditsParaStyle.lineHeightMultiple = 1.2;
497+
creditsParaStyle.alignment = NSTextAlignmentCenter;
498+
499+
NSDictionary *creditsAttributes = @{
500+
NSForegroundColorAttributeName: [UIColor whiteColor],
501+
NSFontAttributeName: [UIFont systemFontOfSize:14],
502+
NSParagraphStyleAttributeName: creditsParaStyle,
498503
};
499504

500505
NSString *hintText = NSLocalizedString(@"You can quit this app now.\nThe HUD will persist on your screen.", nil);
@@ -508,14 +513,14 @@ - (void)reloadMainButtonState
508513

509514
NSAttributedString *githubIconText = [NSAttributedString attributedStringWithAttachment:githubIcon];
510515
NSMutableAttributedString *githubIconTextFull = [[NSMutableAttributedString alloc] initWithAttributedString:githubIconText];
511-
[githubIconTextFull appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:defaultAttributes]];
516+
[githubIconTextFull appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:creditsAttributes]];
512517

513518
NSAttributedString *i18nIconText = [NSAttributedString attributedStringWithAttachment:i18nIcon];
514519
NSMutableAttributedString *i18nIconTextFull = [[NSMutableAttributedString alloc] initWithAttributedString:i18nIconText];
515-
[i18nIconTextFull appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:defaultAttributes]];
520+
[i18nIconTextFull appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:creditsAttributes]];
516521

517522
NSString *creditsText = NSLocalizedString(@"Made with ♥ by @GITHUB@Lessica and @GITHUB@jmpews\nTranslation @TRANSLATION@", nil);
518-
NSMutableAttributedString *creditsAttributedText = [[NSMutableAttributedString alloc] initWithString:creditsText attributes:defaultAttributes];
523+
NSMutableAttributedString *creditsAttributedText = [[NSMutableAttributedString alloc] initWithString:creditsText attributes:creditsAttributes];
519524

520525
// replace all "@GITHUB@" with github icon
521526
NSRange atRange;

0 commit comments

Comments
 (0)