Skip to content

Commit ceadca8

Browse files
committed
feat: personal hotspot
Signed-off-by: 82Flex <[email protected]>
1 parent 3d38cc2 commit ceadca8

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

Common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
@interface _UIStatusBarStyleAttributes : NSObject
4545
@property(nonatomic, readonly) long long style;
4646
@property(nonatomic, copy) UIColor *textColor;
47+
@property(nonatomic, copy) UIColor *imageTintColor;
4748
@end
4849

4950
@interface _UIStatusBarItemUpdate : NSObject
@@ -57,8 +58,7 @@
5758
@end
5859

5960
@interface _UIStatusBarWifiItem : _UIStatusBarItem
60-
@property(nonatomic, strong) NSNumber *smIsVPNEnabled;
61-
@property(nonatomic, strong) NSNumber *smDisplayValue;
61+
@property(nonatomic, strong) _UIStatusBarImageView *networkIconView;
6262
- (UIColor *)_fillColorForUpdate:(_UIStatusBarItemUpdate *)update entry:(_UIStatusBarDataWifiEntry *)entry;
6363
@end
6464

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export PACKAGE_VERSION := 1.4
1+
export PACKAGE_VERSION := 1.5
22

33
ifeq ($(THEOS_DEVICE_SIMULATOR),1)
44
TARGET := simulator:clang:latest:14.0

SingleVPN.x

+13-15
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,27 @@ static void ReloadPrefs() {
4343

4444
%hook _UIStatusBarWifiItem
4545

46-
%property (nonatomic, strong) NSNumber *smIsVPNEnabled;
47-
%property (nonatomic, strong) NSNumber *smDisplayValue;
48-
4946
- (id)applyUpdate:(_UIStatusBarItemUpdate *)update toDisplayItem:(_UIStatusBarDisplayItem *)displayItem {
5047
_isVPNEnabled = update.data.vpnEntry.enabled;
51-
long long displayValue = update.data.wifiEntry.displayValue;
5248

5349
id result = %orig;
54-
BOOL needsReload = NO;
5550

56-
if ([self.smIsVPNEnabled boolValue] != _isVPNEnabled) {
57-
self.smIsVPNEnabled = @(_isVPNEnabled);
58-
needsReload = YES;
59-
}
51+
UIColor *originalColor = update.styleAttributes.textColor;
52+
UIColor *newColor = nil;
6053

61-
if ([self.smDisplayValue longLongValue] != displayValue) {
62-
self.smDisplayValue = @(displayValue);
63-
needsReload = YES;
54+
BOOL decision = _isEnabledReversed ? !_isVPNEnabled : _isVPNEnabled;
55+
if (decision) {
56+
newColor = svpnColorWithTextColor(originalColor);
6457
}
6558

66-
if (needsReload) {
67-
for (_UIStatusBarDisplayItem *item in self.displayItems.allValues) {
68-
%orig(update, item);
59+
if (!newColor) { newColor = update.styleAttributes.imageTintColor ?: originalColor; }
60+
61+
for (_UIStatusBarDisplayItem *item in self.displayItems.allValues) {
62+
%orig(update, item);
63+
64+
if (item.view == self.networkIconView && [item.view isKindOfClass:%c(_UIStatusBarImageView)]) {
65+
_UIStatusBarImageView *imageView = (_UIStatusBarImageView *)item.view;
66+
[imageView setTintColor:newColor];
6967
}
7068
}
7169

0 commit comments

Comments
 (0)