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

Commit f6ef133

Browse files
committed
feature: add repo link
1 parent 2f038f1 commit f6ef133

File tree

5 files changed

+51
-12
lines changed

5 files changed

+51
-12
lines changed

MainApplication.mm

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#include <CoreGraphics/CoreGraphics.h>
12
#include <Foundation/Foundation.h>
2-
#include <MacTypes.h>
33
#import <notify.h>
44
#import <UIKit/UIKit.h>
55
#import "TrollSpeed-Swift.h"
@@ -236,6 +236,10 @@ - (void)loadView
236236
[_authorLabel.bottomAnchor constraintEqualToAnchor:_settingsButton.topAnchor constant:-20],
237237
]];
238238

239+
UITapGestureRecognizer *authorTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAuthorLabel:)];
240+
[_authorLabel setUserInteractionEnabled:YES];
241+
[_authorLabel addGestureRecognizer:authorTapGesture];
242+
239243
[self reloadMainButtonState];
240244
}
241245

@@ -408,14 +412,47 @@ - (void)setUsesRotation:(BOOL)usesRotation
408412
- (void)reloadMainButtonState
409413
{
410414
_isHUDActive = IsHUDEnabled();
415+
416+
static NSAttributedString *hintAttributedString = nil;
417+
static NSAttributedString *githubAttributedString = nil;
418+
static dispatch_once_t onceToken;
419+
dispatch_once(&onceToken, ^{
420+
NSDictionary *defaultAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: [UIFont systemFontOfSize:14]};
421+
422+
NSString *hintText = NSLocalizedString(@"You can quit this app now.\nThe HUD will persist on your screen.", nil);
423+
hintAttributedString = [[NSAttributedString alloc] initWithString:hintText attributes:defaultAttributes];
424+
425+
NSTextAttachment *githubIcon = [NSTextAttachment textAttachmentWithImage:[UIImage imageNamed:@"github-mark-white"]];
426+
[githubIcon setBounds:CGRectMake(0, 0, 14, 14)];
427+
428+
NSAttributedString *githubIconText = [NSAttributedString attributedStringWithAttachment:githubIcon];
429+
NSMutableAttributedString *githubIconTextFull = [[NSMutableAttributedString alloc] initWithAttributedString:githubIconText];
430+
[githubIconTextFull appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:defaultAttributes]];
431+
432+
NSString *githubText = NSLocalizedString(@"Made with ♥ by @Lessica and @jmpews", nil);
433+
NSMutableAttributedString *githubAttributedText = [[NSMutableAttributedString alloc] initWithString:githubText attributes:defaultAttributes];
434+
435+
// replace all "@" with github icon
436+
NSRange atRange = [githubAttributedText.string rangeOfString:@"@"];
437+
while (atRange.location != NSNotFound) {
438+
[githubAttributedText replaceCharactersInRange:atRange withAttributedString:githubIconTextFull];
439+
atRange = [githubAttributedText.string rangeOfString:@"@"];
440+
}
441+
442+
githubAttributedString = githubAttributedText;
443+
});
444+
411445
[UIView transitionWithView:self.backgroundView duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
412446
[_mainButton setTitle:(_isHUDActive ? NSLocalizedString(@"Exit HUD", nil) : NSLocalizedString(@"Open HUD", nil)) forState:UIControlStateNormal];
413-
[_authorLabel setText:(_isHUDActive ? NSLocalizedString(@"You can quit this app now.\nThe HUD will persist on your screen.", nil) : NSLocalizedString(@"Made with ♥ by @i_82 and @jmpews", nil))];
447+
[_authorLabel setAttributedText:(_isHUDActive ? hintAttributedString : githubAttributedString)];
414448
} completion:nil];
415449
}
416450

417451
- (void)presentTopCenterMostHints
418452
{
453+
if (!_isHUDActive) {
454+
return;
455+
}
419456
[_authorLabel setText:NSLocalizedString(@"Tap that button on the center again,\nto toggle ON/OFF “Dynamic Island” mode.", nil)];
420457
}
421458

@@ -450,6 +487,16 @@ - (void)tapView:(UITapGestureRecognizer *)sender
450487
os_log_debug(OS_LOG_DEFAULT, "- [RootViewController tapView:%{public}@]: %{public}@", sender, NSStringFromCGPoint([sender locationInView:self.backgroundView]));
451488
}
452489

490+
- (void)tapAuthorLabel:(UITapGestureRecognizer *)sender
491+
{
492+
if (_isHUDActive) {
493+
return;
494+
}
495+
NSString *repoURLString = @"https://github.com/Lessica/TrollSpeed";
496+
NSURL *repoURL = [NSURL URLWithString:repoURLString];
497+
[[UIApplication sharedApplication] openURL:repoURL options:@{} completionHandler:nil];
498+
}
499+
453500
- (void)tapTopLeftButton:(UIButton *)sender
454501
{
455502
os_log_debug(OS_LOG_DEFAULT, "- [RootViewController tapTopLeftButton:%{public}@]", sender);
12 Bytes
Binary file not shown.
4.72 KB
Loading
Binary file not shown.

layout/Library/LaunchDaemons/ch.xxtou.hudapp.plist

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
<true/>
99
<key>Label</key>
1010
<string>ch.xxtou.hudapp</string>
11-
<key>MachServices</key>
12-
<dict>
13-
<key>ch.xxtou.hudapp.springboard.launched</key>
14-
<dict>
15-
<key>ResetAtClose</key>
16-
<true/>
17-
</dict>
18-
</dict>
1911
<key>POSIXSpawnType</key>
2012
<string>Interactive</string>
2113
<key>ProgramArguments</key>
@@ -24,9 +16,9 @@
2416
<string>-hud</string>
2517
</array>
2618
<key>RunAtLoad</key>
27-
<false/>
19+
<true/>
2820
<key>ThrottleInterval</key>
29-
<integer>1</integer>
21+
<integer>5</integer>
3022
<key>UserName</key>
3123
<string>mobile</string>
3224
</dict>

0 commit comments

Comments
 (0)