From b2521de84e6520e3456994e1e6eba6a1b83296f8 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Thu, 12 Mar 2026 16:15:52 +0800 Subject: [PATCH 1/3] refactor themeManager --- VoidLink/HostCardView.m | 50 +++---- VoidLink/Input/PressureCurve.swift | 2 +- VoidLink/MenuSectionView.m | 10 +- VoidLink/ThemeManager.swift | 128 +++++++++++------- VoidLink/UIAppView.m | 4 +- VoidLink/Utility/GenericUtils.swift | 13 ++ .../HostCollectionViewController.m | 2 +- .../ViewControllers/MainFrameViewController.m | 44 +++--- .../ViewControllers/SWRevealViewController.m | 30 ++-- .../ViewControllers/SettingsViewController.m | 38 ++++-- .../StreamFrameViewController.m | 6 +- 11 files changed, 189 insertions(+), 138 deletions(-) diff --git a/VoidLink/HostCardView.m b/VoidLink/HostCardView.m index f02ba211..39dfcd4a 100644 --- a/VoidLink/HostCardView.m +++ b/VoidLink/HostCardView.m @@ -62,7 +62,7 @@ static const float REFRESH_CYCLE = 2.0f; computerIconMonitorCenterYOffset = [self isIPhone] ? -2.75*_sizeFactor : -3.2*_sizeFactor; iconAndButtonSpacing = 37*_sizeFactor; buttonHeight = 39*_sizeFactor; - defaultBlue = [ThemeManager appPrimaryColor]; + defaultBlue = ThemeManager.appPrimaryColor; defaultGreen = [UIColor colorWithRed:52.0/255.0 green:199.0/255.0 blue:89.0/255.0 alpha:1.0]; // self.userIterfaceStyle = UIUserInterfaceStyleLight @@ -165,7 +165,7 @@ static const float REFRESH_CYCLE = 2.0f; - (void)setupUI { self.userInteractionEnabled = YES; - self.backgroundColor = [ThemeManager widgetBackgroundColor]; // theme + self.backgroundColor = ThemeManager.widgetBackgroundColor; // theme self.cardContentpadding = 13 * _sizeFactor; self.clipsToBounds = YES; self.translatesAutoresizingMaskIntoConstraints = NO; @@ -296,7 +296,7 @@ static const float REFRESH_CYCLE = 2.0f; self.appButton.translatesAutoresizingMaskIntoConstraints = NO; self.appButton.frame = CGRectMake(20, 200, 150, buttonHeight); [self.appButton setTitle:[LocalizationHelper localizedStringForKey:@"Applications"] forState:UIControlStateNormal]; - [self.appButton setTitleColor:[ThemeManager textColorGray] forState:UIControlStateNormal]; //theme + [self.appButton setTitleColor:ThemeManager.textColorGray forState:UIControlStateNormal]; //theme self.appButton.titleLabel.font = [UIFont systemFontOfSize:buttonLabelFontSize]; [self.appButton addTarget:self action:@selector(appButtonTapped) forControlEvents:UIControlEventPrimaryActionTriggered]; [self addSubview:self.appButton]; @@ -343,7 +343,7 @@ static const float REFRESH_CYCLE = 2.0f; self.pairButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.pairButton.translatesAutoresizingMaskIntoConstraints = NO; self.pairButton.frame = CGRectMake(0, 0, 150, 50); - self.pairButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; + self.pairButton.backgroundColor = ThemeManager.textTintColorWithAlpha; self.pairButton.layer.cornerRadius = 2*(uint16_t)(cardWidth*0.0377/2); [self.pairButton setTitle:[LocalizationHelper localizedStringForKey:@" Pair with PIN"] forState:UIControlStateNormal]; [self.pairButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme @@ -356,7 +356,7 @@ static const float REFRESH_CYCLE = 2.0f; } else { // Fallback on earlier versions } - self.pairButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; + self.pairButton.backgroundColor = ThemeManager.textTintColorWithAlpha; [self.pairButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme [self.pairButton addTarget:self action:@selector(pairButtonTapped) forControlEvents:UIControlEventPrimaryActionTriggered]; @@ -377,7 +377,7 @@ static const float REFRESH_CYCLE = 2.0f; self.wakeupButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.wakeupButton.translatesAutoresizingMaskIntoConstraints = NO; self.wakeupButton.frame = CGRectMake(0, 0, 150, 50); - self.wakeupButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; + self.wakeupButton.backgroundColor = ThemeManager.textTintColorWithAlpha; self.wakeupButton.layer.cornerRadius = 2*(uint16_t)(cardWidth*0.0377/2); [self.wakeupButton setTitle:[LocalizationHelper localizedStringForKey:@" Wake-on-LAN"] forState:UIControlStateNormal]; [self.wakeupButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme @@ -472,10 +472,10 @@ static const float REFRESH_CYCLE = 2.0f; - (void)updateTheme { - self.backgroundColor = [ThemeManager widgetBackgroundColor]; - _hostNameLabel.textColor = [ThemeManager textColor]; - [_appButton setTitleColor:[ThemeManager appPrimaryColor] forState:UIControlStateNormal]; - _separatorLine.backgroundColor = [ThemeManager separatorColor]; + self.backgroundColor = ThemeManager.widgetBackgroundColor; + _hostNameLabel.textColor = ThemeManager.textColor; + [_appButton setTitleColor:ThemeManager.appPrimaryColor forState:UIControlStateNormal]; + _separatorLine.backgroundColor = ThemeManager.separatorColor; backgroundLayer.hidden = NO; [self updateBackgroundLayerTheme]; @@ -560,7 +560,7 @@ static const float REFRESH_CYCLE = 2.0f; [_launchButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; // theme } else { - _iconBackgroundView.backgroundColor = [ThemeManager appPrimaryColorWithAlpha]; + _iconBackgroundView.backgroundColor = ThemeManager.appPrimaryColorWithAlpha; UIColor* iconColor = [[UIColor whiteColor] colorWithAlphaComponent:[self isDarkTheme] ? 0.63 : 1]; _hostIconView.tintColor = iconColor; lockIconView.tintColor = iconColor; @@ -574,18 +574,18 @@ static const float REFRESH_CYCLE = 2.0f; case StateOffline: [_hostSpinner stopAnimating]; // _iconBackgroundView.backgroundColor = _userIterfaceStyle == UIUserInterfaceStyleDark ? [UIColor appBackgroundColorDark] : [UIColor appBackgroundColorLight]; - _iconBackgroundView.backgroundColor = [ThemeManager offlineHostIconBackgroundColor]; - _statusLabel.textColor = [ThemeManager textColorGray]; + _iconBackgroundView.backgroundColor = ThemeManager.offlineHostIconBackgroundColor; + _statusLabel.textColor = ThemeManager.textColorGray; _statusLabel.text = [LocalizationHelper localizedStringForKey: @"Offline"]; - _statusIcon.tintColor = [ThemeManager textColorGray]; + _statusIcon.tintColor = ThemeManager.textColorGray; if (@available(iOS 13.0, *)) { _statusIcon.image = [UIImage systemImageNamed:@"exclamationmark.triangle.fill"]; } else { self.statusIcon.hidden = YES; } - _hostIconView.tintColor = [ThemeManager lowProfileGray]; - lockIconView.tintColor = [ThemeManager lowProfileGray]; + _hostIconView.tintColor = ThemeManager.lowProfileGray; + lockIconView.tintColor = ThemeManager.lowProfileGray; lockIconView.hidden = hostPaired; _appButton.hidden = YES; _launchButton.hidden = YES; @@ -595,24 +595,24 @@ static const float REFRESH_CYCLE = 2.0f; if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:buttonHeight/3.45 weight:UIImageSymbolWeightBold]; UIImage *templateImage = [UIImage systemImageNamed:@"power" withConfiguration:config]; - UIImage *coloredImage = [templateImage imageWithTintColor:hasValidMac ? defaultBlue : [ThemeManager textColorGray] renderingMode:UIImageRenderingModeAlwaysOriginal]; + UIImage *coloredImage = [templateImage imageWithTintColor:hasValidMac ? defaultBlue : ThemeManager.textColorGray renderingMode:UIImageRenderingModeAlwaysOriginal]; [self.wakeupButton setImage:coloredImage forState:UIControlStateNormal]; } else { // Fallback on earlier versions } - self.wakeupButton.backgroundColor = hasValidMac ? [ThemeManager textTintColorWithAlpha] : [[ThemeManager textColorGray] colorWithAlphaComponent:0.2]; - [self.wakeupButton setTitleColor: hasValidMac ? defaultBlue : [ThemeManager textColorGray] forState:UIControlStateNormal]; + self.wakeupButton.backgroundColor = hasValidMac ? ThemeManager.textTintColorWithAlpha : [ThemeManager.textColorGray colorWithAlphaComponent:0.2]; + [self.wakeupButton setTitleColor: hasValidMac ? defaultBlue : ThemeManager.textColorGray forState:UIControlStateNormal]; break; case StateUnknown: _hostSpinner.color = [UIColor whiteColor]; [_hostSpinner startAnimating]; // _iconBackgroundView.backgroundColor = _userIterfaceStyle == UIUserInterfaceStyleDark ? [UIColor appBackgroundColorDark] : [UIColor appBackgroundColorLight]; - _iconBackgroundView.backgroundColor = [ThemeManager appPrimaryColorWithAlpha]; - _statusLabel.textColor = [ThemeManager textColorGray]; + _iconBackgroundView.backgroundColor = ThemeManager.appPrimaryColorWithAlpha; + _statusLabel.textColor = ThemeManager.textColorGray; _statusLabel.text = [LocalizationHelper localizedStringForKey: @"Detecting..."]; - _statusIcon.tintColor = [ThemeManager textColorGray]; + _statusIcon.tintColor = ThemeManager.textColorGray; if (@available(iOS 13.0, *)) { _statusIcon.image = [UIImage systemImageNamed:@"antenna.radiowaves.left.and.right"]; } else { @@ -629,13 +629,13 @@ static const float REFRESH_CYCLE = 2.0f; if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:buttonHeight/3.45 weight:UIImageSymbolWeightBold]; UIImage *templateImage = [UIImage systemImageNamed:@"power" withConfiguration:config]; - UIImage *coloredImage = [templateImage imageWithTintColor:hasValidMac ? defaultBlue : [ThemeManager textColorGray] renderingMode:UIImageRenderingModeAlwaysOriginal]; + UIImage *coloredImage = [templateImage imageWithTintColor:hasValidMac ? defaultBlue : ThemeManager.textColorGray renderingMode:UIImageRenderingModeAlwaysOriginal]; [self.wakeupButton setImage:coloredImage forState:UIControlStateNormal]; } else { // Fallback on earlier versions } - self.wakeupButton.backgroundColor = hasValidMac ? [ThemeManager textTintColorWithAlpha] : [[ThemeManager textColorGray] colorWithAlphaComponent:0.2]; - [self.wakeupButton setTitleColor: hasValidMac ? defaultBlue : [ThemeManager textColorGray] forState:UIControlStateNormal]; + self.wakeupButton.backgroundColor = hasValidMac ? ThemeManager.textTintColorWithAlpha : [ThemeManager.textColorGray colorWithAlphaComponent:0.2]; + [self.wakeupButton setTitleColor: hasValidMac ? defaultBlue : ThemeManager.textColorGray forState:UIControlStateNormal]; break; default:break; } diff --git a/VoidLink/Input/PressureCurve.swift b/VoidLink/Input/PressureCurve.swift index e7aa3ebe..f73608ec 100644 --- a/VoidLink/Input/PressureCurve.swift +++ b/VoidLink/Input/PressureCurve.swift @@ -507,7 +507,7 @@ class PressureCurveViewController: UIViewController { container.layer.cornerRadius = 12 container.layer.masksToBounds = true container.layer.borderWidth = 2 - container.layer.borderColor = ThemeManager.separatorColor().cgColor + container.layer.borderColor = ThemeManager.separatorColor.cgColor container.addSubview(curveView) self.loadPersistedCurve() self.curveView.showGraph = true diff --git a/VoidLink/MenuSectionView.m b/VoidLink/MenuSectionView.m index 36134b9c..3d803394 100644 --- a/VoidLink/MenuSectionView.m +++ b/VoidLink/MenuSectionView.m @@ -78,7 +78,7 @@ static BOOL overridePersistedFoldState = YES; _iconImageView = [[UIImageView alloc] init]; _iconImageView.contentMode = UIViewContentModeScaleAspectFit; _iconImageView.translatesAutoresizingMaskIntoConstraints = NO; - _iconImageView.tintColor = [ThemeManager textColor]; + _iconImageView.tintColor = ThemeManager.textColor; [_headerView addSubview:_iconImageView]; // 标题标签 @@ -86,7 +86,7 @@ static BOOL overridePersistedFoldState = YES; _titleLabel.text = _sectionTitle; _titleLabel.accessibilityIdentifier = @"menuSectionTitleLabel"; _titleLabel.font = [UIFont systemFontOfSize:19.5 weight:UIFontWeightMedium]; - _titleLabel.textColor = [ThemeManager textColor]; + _titleLabel.textColor = ThemeManager.textColor; _titleLabel.textAlignment = NSTextAlignmentLeft; _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; [_headerView addSubview:_titleLabel]; @@ -118,7 +118,7 @@ static BOOL overridePersistedFoldState = YES; // 分隔线 _separatorLine = [[UIView alloc] init]; - _separatorLine.backgroundColor = [ThemeManager separatorColor]; + _separatorLine.backgroundColor = ThemeManager.separatorColor; _separatorLine.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:_separatorLine]; @@ -216,7 +216,7 @@ static BOOL overridePersistedFoldState = YES; } else { _iconImageView.image = icon; } - _iconImageView.tintColor = [ThemeManager textColor]; + _iconImageView.tintColor = ThemeManager.textColor; _iconImageView.hidden = (icon == nil); // 图标约束 @@ -242,7 +242,7 @@ static BOOL overridePersistedFoldState = YES; } else { _iconImageView.image = icon; } - _iconImageView.tintColor = [ThemeManager textColor]; + _iconImageView.tintColor = ThemeManager.textColor; _iconImageView.hidden = (icon == nil); // 图标约束 diff --git a/VoidLink/ThemeManager.swift b/VoidLink/ThemeManager.swift index a1357b25..442e3f67 100644 --- a/VoidLink/ThemeManager.swift +++ b/VoidLink/ThemeManager.swift @@ -11,12 +11,12 @@ import UIKit @objcMembers class ThemeManager: NSObject { - + static let ThemeDidChangeNotification = "ThemeDidChangeNotification" - + private static var _privateUserInterfaceStyle: UIUserInterfaceStyle = .unspecified private static var _userInterfaceStyle: UIUserInterfaceStyle = .unspecified - + @objc class func setPublicUIStyle() -> UIColor { if #available(iOS 13.0, *) { let traitCollection = UIScreen.main.traitCollection @@ -28,30 +28,30 @@ class ThemeManager: NSObject { } return UIColor.clear } - + @objc class func userInterfaceStyle() -> UIUserInterfaceStyle { _ = setPublicUIStyle() return _userInterfaceStyle } - + @objc class func setUserInterfaceStyle(_ style: UIUserInterfaceStyle) { _privateUserInterfaceStyle = style - + if _userInterfaceStyle == style { return } - + _ = setPublicUIStyle() - + NotificationCenter.default.post( name: Notification.Name(ThemeDidChangeNotification), object: nil ) } - - @objc class func menuBackgroundColor() -> UIColor { + + @objc static var menuBackgroundColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor( @@ -60,7 +60,7 @@ class ThemeManager: NSObject { blue: 247.0/255.0, alpha: 1 ) - + default: if #available(iOS 13.0, *) { let darkTraits = UITraitCollection(userInterfaceStyle: .dark) @@ -76,9 +76,9 @@ class ThemeManager: NSObject { } } - @objc class func hostViewBackgroundColor() -> UIColor { + @objc static var hostViewBackgroundColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor( @@ -87,7 +87,7 @@ class ThemeManager: NSObject { blue: 247.0/255.0, alpha: 1 ) - + default: if #available(iOS 13.0, *) { let darkTraits = UITraitCollection(userInterfaceStyle: .dark) @@ -98,9 +98,9 @@ class ThemeManager: NSObject { } } - @objc class func offlineHostIconBackgroundColor() -> UIColor { + @objc static var offlineHostIconBackgroundColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor( @@ -109,7 +109,7 @@ class ThemeManager: NSObject { blue: 247.0/255.0, alpha: 1 ) - + default: return UIColor( red: 17.0/255.0, @@ -119,10 +119,10 @@ class ThemeManager: NSObject { ) } } - - @objc class func widgetBackgroundColor() -> UIColor { + + @objc static var widgetBackgroundColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor.white @@ -141,10 +141,10 @@ class ThemeManager: NSObject { } } } - - @objc class func separatorColor() -> UIColor { + + @objc static var separatorColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: if #available(iOS 13.0, *) { @@ -166,9 +166,9 @@ class ThemeManager: NSObject { } } - @objc class func hostCardSeparatorColor() -> UIColor { + @objc static var hostCardSeparatorColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor(white: 0.1, alpha: 0.28) @@ -176,10 +176,10 @@ class ThemeManager: NSObject { return UIColor(white: 0.28, alpha: 1) } } - - @objc class func textColor() -> UIColor { + + @objc static var textColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: return UIColor.black @@ -188,9 +188,9 @@ class ThemeManager: NSObject { } } - @objc class func sectionLabelTextColor() -> UIColor { + @objc static var sectionLabelTextColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { case .light: if #available(iOS 13.0, *) { @@ -208,8 +208,8 @@ class ThemeManager: NSObject { } } } - - @objc class func appPrimaryColor() -> UIColor { + + @objc static var appPrimaryColor: UIColor { return UIColor( red: 0.0, green: 0.48, @@ -217,43 +217,43 @@ class ThemeManager: NSObject { alpha: 1.0 ) // #0A84FF } - - @objc class func appSecondaryColor() -> UIColor { - - let originalColor = appPrimaryColor() + + @objc static var appSecondaryColor: UIColor { + + let originalColor = appPrimaryColor let grayColor = UIColor.gray let mixRatio: CGFloat = 0.3 - + var r1: CGFloat = 0 var g1: CGFloat = 0 var b1: CGFloat = 0 var a1: CGFloat = 0 - + var r2: CGFloat = 0 var g2: CGFloat = 0 var b2: CGFloat = 0 var a2: CGFloat = 0 - + originalColor.getRed(&r1, green: &g1, blue: &b1, alpha: &a1) grayColor.getRed(&r2, green: &g2, blue: &b2, alpha: &a2) - + let r = r1 * (1 - mixRatio) + r2 * mixRatio let g = g1 * (1 - mixRatio) + g2 * mixRatio let b = b1 * (1 - mixRatio) + b2 * mixRatio let a = a1 * (1 - mixRatio) + a2 * mixRatio - + return UIColor(red: r, green: g, blue: b, alpha: a) } - - @objc class func appPrimaryColorWithAlpha() -> UIColor { - return appPrimaryColor().withAlphaComponent(0.24) + + @objc static var appPrimaryColorWithAlpha: UIColor { + return appPrimaryColor.withAlphaComponent(0.24) } - - @objc class func textTintColorWithAlpha() -> UIColor { - return appPrimaryColor().withAlphaComponent(0.24) + + @objc static var textTintColorWithAlpha: UIColor { + return appPrimaryColor.withAlphaComponent(0.24) } - - @objc class func textColorGray() -> UIColor { + + @objc static var textColorGray: UIColor { return UIColor( red: 0.55, green: 0.55, @@ -261,8 +261,8 @@ class ThemeManager: NSObject { alpha: 0.95 ) } - - @objc class func lowProfileGray() -> UIColor { + + @objc static var lowProfileGray: UIColor { return UIColor( red: 0.65, green: 0.65, @@ -270,4 +270,28 @@ class ThemeManager: NSObject { alpha: 0.4 ) } + + @available(iOS 26.0, *) + @objc static var liquidGlassSwitchOffTint: UIColor { + switch userInterfaceStyle() { + case .light: + return UIColor.systemFill + default: + return UIColor.clear + } + } + + @objc static var liquidGlassSliderMaxTrackTint: UIColor { + if #available(iOS 13.0, *) { + switch userInterfaceStyle() { + case .light: + return UIColor.tertiarySystemFill + default: + return UIColor.tertiarySystemFill + } + } + else { + return UIColor.black + } + } } diff --git a/VoidLink/UIAppView.m b/VoidLink/UIAppView.m index 7dfea223..28d67799 100644 --- a/VoidLink/UIAppView.m +++ b/VoidLink/UIAppView.m @@ -178,7 +178,7 @@ static UIImage* noImage; if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23]; UIImageView* playIcon = [[UIImageView alloc] initWithImage:[[UIImage systemImageNamed:@"play.circle.fill" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]]; - //playIcon.tintColor = [[ThemeManager widgetBackgroundColor] colorWithAlphaComponent:0.85]; + //playIcon.tintColor = [ThemeManager.widgetBackgroundColor colorWithAlphaComponent:0.85]; playIcon.tintColor = [[UIColor blackColor] colorWithAlphaComponent:0.55]; _appOverlay = playIcon; @@ -202,7 +202,7 @@ static UIImage* noImage; UIImage* appIconImage = [[UIImage imageNamed:@"icon-pc-app"] imageWithConfiguration:config]; UIImageView* appIcon = [[UIImageView alloc] initWithImage:[appIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]]; - //layIcon.tintColor = [[ThemeManager widgetBackgroundColor] colorWithAlphaComponent:0.85]; + //layIcon.tintColor = [ThemeManager.widgetBackgroundColor colorWithAlphaComponent:0.85]; appIcon.tintColor = [[UIColor blackColor] colorWithAlphaComponent:0.5]; _appOverlay = appIcon; diff --git a/VoidLink/Utility/GenericUtils.swift b/VoidLink/Utility/GenericUtils.swift index c2aa747a..754592a2 100644 --- a/VoidLink/Utility/GenericUtils.swift +++ b/VoidLink/Utility/GenericUtils.swift @@ -88,4 +88,17 @@ import Foundation @objc static var dockedNavBarTopAnchorOffset: CGFloat { return liquidGlassEnabled ? 10 : 0 } + + @available(iOS 26.0, *) + @objc static func applyOffTintColor(_ view: UIView) { + let name = String(describing: type(of: view)) + if name.contains("UISwitchModernVisualElement") { + view.backgroundColor = ThemeManager.liquidGlassSwitchOffTint + view.layer.cornerRadius = view.bounds.height/2 + view.clipsToBounds = true + } + for sub in view.subviews { + applyOffTintColor(sub) + } + } } diff --git a/VoidLink/ViewControllers/HostCollectionViewController.m b/VoidLink/ViewControllers/HostCollectionViewController.m index 68f07fcc..c5d50dfd 100644 --- a/VoidLink/ViewControllers/HostCollectionViewController.m +++ b/VoidLink/ViewControllers/HostCollectionViewController.m @@ -104,7 +104,7 @@ static const CGFloat cellOffsetY = 20; } - (void)updateTheme { - self.collectionView.backgroundColor = [ThemeManager hostViewBackgroundColor]; + self.collectionView.backgroundColor = ThemeManager.hostViewBackgroundColor; for (HostCell *cell in [self.collectionView visibleCells]) { [cell.cardView updateTheme]; } diff --git a/VoidLink/ViewControllers/MainFrameViewController.m b/VoidLink/ViewControllers/MainFrameViewController.m index 39fb16a1..9f363bf0 100644 --- a/VoidLink/ViewControllers/MainFrameViewController.m +++ b/VoidLink/ViewControllers/MainFrameViewController.m @@ -151,7 +151,7 @@ static NSMutableSet* hostList; UINavigationBarAppearance* appearance = navBarAppearanceStandard; NSDictionary* titleTextAttributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:20 weight:UIFontWeightMedium], - NSForegroundColorAttributeName: [ThemeManager textColor] // 可选,设置标题颜色 + NSForegroundColorAttributeName: ThemeManager.textColor // 可选,设置标题颜色 }; appearance.titleTextAttributes = titleTextAttributes; navBarAppearanceStandard = appearance; @@ -170,7 +170,7 @@ static NSMutableSet* hostList; UINavigationBarAppearance* appearance = navBarAppearanceStandard; NSDictionary* titleTextAttributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:20 weight:UIFontWeightMedium], - NSForegroundColorAttributeName: [ThemeManager textColor] // 可选,设置标题颜色 + NSForegroundColorAttributeName: ThemeManager.textColor // 可选,设置标题颜色 }; appearance.titleTextAttributes = titleTextAttributes; navBarAppearanceStandard = appearance; @@ -178,7 +178,7 @@ static NSMutableSet* hostList; /* self.navigationController.navigationBar.titleTextAttributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:24 weight:UIFontWeightSemibold], - NSForegroundColorAttributeName: [ThemeManager textColor] // 可选,设置标题颜色 + NSForegroundColorAttributeName: ThemeManager.textColor // 可选,设置标题颜色 };*/ self.title = [LocalizationHelper localizedStringForKey: @"Hosts" ]; //self.title = nil; @@ -380,7 +380,7 @@ static NSMutableSet* hostList; // [self.view bringSubviewToFront:self.collectionView]; self.hostCollectionVC.view.hidden = YES; self.collectionView.hidden = NO; - self.collectionView.backgroundColor = [ThemeManager hostViewBackgroundColor]; + self.collectionView.backgroundColor = ThemeManager.hostViewBackgroundColor; //self.view.backgroundColor = [ThemeManager appBackgroundColor]; // [self.collectionView setContentOffset:CGPointZero animated:NO]; @@ -1395,7 +1395,7 @@ static NSMutableSet* hostList; CGFloat buttonHeight = 30; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.backgroundColor = liquidGlassEnabled ? [ThemeManager appPrimaryColor] : [ThemeManager appPrimaryColor]; // #0A85FF + button.backgroundColor = liquidGlassEnabled ? ThemeManager.appPrimaryColor : ThemeManager.appPrimaryColor; // #0A85FF button.layer.cornerRadius = buttonHeight/2; button.clipsToBounds = !liquidGlassEnabled; @@ -1420,13 +1420,13 @@ static NSMutableSet* hostList; button.titleLabel.font = [UIFont systemFontOfSize:liquidGlassEnabled ? 16 : 16 weight:UIFontWeightMedium]; // 文字颜色设置为 tintColor 控制 if(liquidGlassEnabled) button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0.9, 0); - button.tintColor = liquidGlassEnabled ? [ThemeManager appPrimaryColor] : UIColor.whiteColor; + button.tintColor = liquidGlassEnabled ? ThemeManager.appPrimaryColor : UIColor.whiteColor; [button setTitleColor:button.tintColor forState:UIControlStateNormal]; // button.tintColor = UIColor.whiteColor; // [button setTitleColor:button.tintColor forState:UIControlStateNormal]; // 设置按下时的 tintColor(变灰或淡) - UIColor *highlightColor = [ThemeManager textColorGray]; + UIColor *highlightColor = ThemeManager.textColorGray; [button setTitleColor:highlightColor forState:UIControlStateHighlighted]; button.adjustsImageWhenHighlighted = YES; // 图标自动变淡 @@ -1465,7 +1465,7 @@ static NSMutableSet* hostList; button.titleLabel.font = [UIFont systemFontOfSize:buttonHeight*0.6 weight:UIFontWeightMedium]; // 文字颜色设置为 tintColor 控制 - button.tintColor = [ThemeManager appPrimaryColor]; + button.tintColor = ThemeManager.appPrimaryColor; [button setTitleColor:button.tintColor forState:UIControlStateNormal]; button.frame = CGRectMake(0, 0, buttonHeight*1.3, buttonHeight*1.05); @@ -1497,7 +1497,7 @@ static NSMutableSet* hostList; else{ self.navigationController.navigationBar.backgroundColor = [UIColor clearColor]; // old ios depend on this, do not remove self.navigationController.navigationBar.barTintColor = [UIColor clearColor]; // ios 14 depend on this, do not remove - self.navigationController.navigationBar.barTintColor = [ThemeManager hostViewBackgroundColor]; // ios 14 depend on this, do not remove + self.navigationController.navigationBar.barTintColor = ThemeManager.hostViewBackgroundColor; // ios 14 depend on this, do not remove } } @@ -1505,10 +1505,10 @@ static NSMutableSet* hostList; if (@available(iOS 13.0, *)) { UINavigationBarAppearance* appearance = [[UINavigationBarAppearance alloc] init]; [appearance configureWithOpaqueBackground]; - appearance.backgroundColor = [ThemeManager hostViewBackgroundColor]; + appearance.backgroundColor = ThemeManager.hostViewBackgroundColor; appearance.shadowColor = nil; NSDictionary* titleTextAttributes = @{ - NSForegroundColorAttributeName: [ThemeManager textColor] + NSForegroundColorAttributeName: ThemeManager.textColor }; appearance.titleTextAttributes = titleTextAttributes; appearance.shadowColor = [UIColor clearColor]; @@ -1543,7 +1543,7 @@ static NSMutableSet* hostList; _settingsButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.55) : UIEdgeInsetsMake(10, 10, 0, 0); if(GenericUtils.liquidGlassEnabled){ // if(@available(iOS 26.0, *)) _settingsButton.hidesSharedBackground = YES; - _settingsButton.tintColor = [ThemeManager appPrimaryColor]; + _settingsButton.tintColor = ThemeManager.appPrimaryColor; } } else { [_settingsButton setTitle:[LocalizationHelper localizedStringForKey:@"Settings"]]; @@ -1572,29 +1572,29 @@ static NSMutableSet* hostList; } - (void)updateTheme { - self.view.backgroundColor = [ThemeManager hostViewBackgroundColor]; - self.hostCollectionVC.view.backgroundColor = [ThemeManager hostViewBackgroundColor]; - self.collectionView.backgroundColor = [ThemeManager hostViewBackgroundColor]; + self.view.backgroundColor = ThemeManager.hostViewBackgroundColor; + self.hostCollectionVC.view.backgroundColor = ThemeManager.hostViewBackgroundColor; + self.collectionView.backgroundColor = ThemeManager.hostViewBackgroundColor; if (@available(iOS 13.0, *)) { UINavigationBarAppearance* appearance = navBarAppearanceStandard; - appearance.backgroundColor = [ThemeManager hostViewBackgroundColor]; + appearance.backgroundColor = ThemeManager.hostViewBackgroundColor; NSDictionary* titleTextAttributes = @{ - NSForegroundColorAttributeName: [ThemeManager textColor] + NSForegroundColorAttributeName: ThemeManager.textColor }; appearance.titleTextAttributes = titleTextAttributes; navBarAppearanceStandard = appearance; } - _settingsButton.tintColor = [ThemeManager appPrimaryColor]; - _upButton.tintColor = [ThemeManager appPrimaryColor]; - ((UIButton*)_addHostButton.customView).backgroundColor = GenericUtils.liquidGlassEnabled ? UIColor.clearColor : [ThemeManager appPrimaryColor]; - ((UIButton*)_helpButton.customView).tintColor = [ThemeManager appPrimaryColor]; + _settingsButton.tintColor = ThemeManager.appPrimaryColor; + _upButton.tintColor = ThemeManager.appPrimaryColor; + ((UIButton*)_addHostButton.customView).backgroundColor = GenericUtils.liquidGlassEnabled ? UIColor.clearColor : ThemeManager.appPrimaryColor; + ((UIButton*)_helpButton.customView).tintColor = ThemeManager.appPrimaryColor; [self applyNavBarAppearance]; [self updateTitle]; if (hostViewTitleLabel) { - hostViewTitleLabel.textColor = [ThemeManager textColor]; + hostViewTitleLabel.textColor = ThemeManager.textColor; } [self.hostCollectionVC updateTheme]; } diff --git a/VoidLink/ViewControllers/SWRevealViewController.m b/VoidLink/ViewControllers/SWRevealViewController.m index c52707cb..45a65bf0 100755 --- a/VoidLink/ViewControllers/SWRevealViewController.m +++ b/VoidLink/ViewControllers/SWRevealViewController.m @@ -147,7 +147,7 @@ static CGFloat scaledValue( CGFloat v1, CGFloat min2, CGFloat max2, CGFloat min1 _rearNavView.translatesAutoresizingMaskIntoConstraints = NO; _safeAreaPadding.translatesAutoresizingMaskIntoConstraints = NO; // _rearNavView.backgroundColor = [UIColor lightGrayColor]; // 设置背景色以便查看 - _safeAreaPadding.backgroundColor = [ThemeManager menuBackgroundColor]; + _safeAreaPadding.backgroundColor = ThemeManager.menuBackgroundColor; // NSLog(@"_c.rearViewRevealWidth: %f", _c.rearViewRevealWidth); // _rearNavView.frame = CGRectMake(0, 0, _c.rearViewRevealWidth, 100); @@ -838,21 +838,21 @@ const int FrontViewPositionNone = 0xff; } - (void)updateTheme { - _contentView.backgroundColor = [ThemeManager menuBackgroundColor]; - _contentView.rearNavView.backgroundColor = [ThemeManager menuBackgroundColor]; - _contentView.safeAreaPadding.backgroundColor = [ThemeManager menuBackgroundColor]; - _separatorLine.backgroundColor = [ThemeManager separatorColor]; + _contentView.backgroundColor = ThemeManager.menuBackgroundColor; + _contentView.rearNavView.backgroundColor = ThemeManager.menuBackgroundColor; + _contentView.safeAreaPadding.backgroundColor = ThemeManager.menuBackgroundColor; + _separatorLine.backgroundColor = ThemeManager.separatorColor; if (@available(iOS 13.0, *)) { UINavigationBarAppearance *navBarAppearanceStandard = _dockedNavBar.standardAppearance; - navBarAppearanceStandard.backgroundColor = [ThemeManager menuBackgroundColor]; + navBarAppearanceStandard.backgroundColor = ThemeManager.menuBackgroundColor; navBarAppearanceStandard.titleTextAttributes = @{ - NSForegroundColorAttributeName: [ThemeManager textColor] + NSForegroundColorAttributeName: ThemeManager.textColor }; _dockedNavBar.standardAppearance = navBarAppearanceStandard; _dockedNavBar.scrollEdgeAppearance = navBarAppearanceStandard; } else { - _dockedNavBar.barTintColor = [ThemeManager menuBackgroundColor]; + _dockedNavBar.barTintColor = ThemeManager.menuBackgroundColor; } } @@ -921,7 +921,7 @@ const int FrontViewPositionNone = 0xff; // 分隔线 _separatorLine = [[UIView alloc] init]; _separatorLine.accessibilityIdentifier = @"menuSeparator"; - _separatorLine.backgroundColor = [ThemeManager separatorColor]; + _separatorLine.backgroundColor = ThemeManager.separatorColor; _separatorLine.translatesAutoresizingMaskIntoConstraints = NO; [_contentView.frontView addSubview:_separatorLine]; _separatorLine.hidden = YES; @@ -955,10 +955,10 @@ const int FrontViewPositionNone = 0xff; if (@available(iOS 13.0, *)) { UINavigationBarAppearance *navBarAppearanceStandard = [[UINavigationBarAppearance alloc] init]; [navBarAppearanceStandard configureWithOpaqueBackground]; // 不透明 - navBarAppearanceStandard.backgroundColor =[ThemeManager menuBackgroundColor];; // 设置你需要的背景色 + navBarAppearanceStandard.backgroundColor =ThemeManager.menuBackgroundColor;; // 设置你需要的背景色 navBarAppearanceStandard.shadowColor = nil; // 去掉底部分割线(可选) navBarAppearanceStandard.titleTextAttributes = @{ - NSForegroundColorAttributeName: [ThemeManager textColor] + NSForegroundColorAttributeName: ThemeManager.textColor }; navBarAppearanceStandard.shadowColor = [UIColor clearColor]; navBarAppearanceStandard.backgroundImage = nil; @@ -967,7 +967,7 @@ const int FrontViewPositionNone = 0xff; _dockedNavBar.shadowImage = nil; } else { _dockedNavBar.barTintColor = [UIColor clearColor]; - _dockedNavBar.barTintColor = [ThemeManager menuBackgroundColor]; + _dockedNavBar.barTintColor = ThemeManager.menuBackgroundColor; _dockedNavBar.shadowImage = [UIImage new]; // remove bottom line for navbar } @@ -1015,7 +1015,7 @@ const int FrontViewPositionNone = 0xff; backButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.55) : UIEdgeInsetsMake(20, 10, 0, 0); if(GenericUtils.liquidGlassEnabled){ // if(@available(iOS 26.0, *)) backButton.hidesSharedBackground = YES; - backButton.tintColor = [ThemeManager appPrimaryColor]; + backButton.tintColor = ThemeManager.appPrimaryColor; } } else { [backButton setTitle:[LocalizationHelper localizedStringForKey:@"Collapse"]]; @@ -1042,7 +1042,7 @@ const int FrontViewPositionNone = 0xff; [_disconnectButton setImage:image]; if(GenericUtils.liquidGlassEnabled) _disconnectButton.imageInsets = UIEdgeInsetsMake(5, 5, 5, 5); - _disconnectButton.tintColor = [ThemeManager appPrimaryColor]; + _disconnectButton.tintColor = ThemeManager.appPrimaryColor; } else { [_disconnectButton setTitle:[LocalizationHelper localizedStringForKey:@"Disconnect"]]; } @@ -1066,7 +1066,7 @@ const int FrontViewPositionNone = 0xff; UIImage *image = [[UIImage systemImageNamed:@"ellipsis.circle" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [_moreButton setImage:image]; _moreButton.imageInsets = GenericUtils.liquidGlassEnabled ? UIEdgeInsetsMake(0, 0, 0, 0.75) : UIEdgeInsetsMake(20, 0, 0, -10); - if(GenericUtils.liquidGlassEnabled) _moreButton.tintColor = [ThemeManager appPrimaryColor]; + if(GenericUtils.liquidGlassEnabled) _moreButton.tintColor = ThemeManager.appPrimaryColor; } else { [_moreButton setTitle:[LocalizationHelper localizedStringForKey:@"Options"]]; } diff --git a/VoidLink/ViewControllers/SettingsViewController.m b/VoidLink/ViewControllers/SettingsViewController.m index 54e2b509..dc253838 100644 --- a/VoidLink/ViewControllers/SettingsViewController.m +++ b/VoidLink/ViewControllers/SettingsViewController.m @@ -54,7 +54,7 @@ MenuSectionView *otherSection; MenuSectionView *experimentalSection; NSMutableSet* hiddenStacks; - + GCController *capturedController; } @@ -750,7 +750,7 @@ BOOL isCustomResolution(int resolutionSelected) { label.textAlignment = NSTextAlignmentCenter; // label.adjustsFontSizeToFitWidth = YES; label.accessibilityIdentifier = @"dynamicLabel"; - label.textColor = [ThemeManager appPrimaryColor]; + label.textColor = ThemeManager.appPrimaryColor; label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; label.translatesAutoresizingMaskIntoConstraints = NO; [stack addSubview:label]; @@ -1120,7 +1120,7 @@ BOOL isCustomResolution(int resolutionSelected) { view.layer.cornerRadius = 6; view.layer.masksToBounds = YES; view.clipsToBounds = YES; - view.backgroundColor = [ThemeManager appPrimaryColorWithAlpha]; + view.backgroundColor = ThemeManager.appPrimaryColorWithAlpha; } completion:^(BOOL finished){ if(completion) completion(); }]; @@ -1324,7 +1324,7 @@ BOOL isCustomResolution(int resolutionSelected) { } button.accessibilityIdentifier = @"infoButton"; button.translatesAutoresizingMaskIntoConstraints = NO; - button.tintColor = [ThemeManager appPrimaryColor]; + button.tintColor = ThemeManager.appPrimaryColor; [button addTarget:self action:@selector(infoButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; @@ -3333,7 +3333,7 @@ BOOL isCustomResolution(int resolutionSelected) { if (@available(iOS 13.0, *)) { label.layer.filters = nil; label.textColor = [UIColor clearColor]; - label.textColor = [ThemeManager textColor]; + label.textColor = ThemeManager.textColor; } else { UIView *view = label; bool isPartOfSelector = false; @@ -3357,9 +3357,9 @@ BOOL isCustomResolution(int resolutionSelected) { UISegmentedControl *selector = (UISegmentedControl *)subview; if (@available(iOS 13.0, *)) { selector.selectedSegmentTintColor = [UIColor clearColor]; - selector.selectedSegmentTintColor = [ThemeManager appSecondaryColor]; + selector.selectedSegmentTintColor = ThemeManager.appSecondaryColor; } else { - selector.tintColor = [ThemeManager appSecondaryColor]; + selector.tintColor = ThemeManager.appSecondaryColor; } } [self updateThemeForSelectors:subview]; @@ -3371,21 +3371,34 @@ BOOL isCustomResolution(int resolutionSelected) { if ([subview isKindOfClass:[UISlider class]]) { UISlider *slider = (UISlider *)subview; slider.tintColor = [UIColor clearColor]; - slider.tintColor = [ThemeManager appSecondaryColor]; + slider.tintColor = ThemeManager.appSecondaryColor; + if(GenericUtils.liquidGlassEnabled) slider.maximumTrackTintColor = ThemeManager.liquidGlassSliderMaxTrackTint; } [self updateThemeForSliders:subview]; } } +- (void)updateThemeForSwitches:(UIView *)view { + if (@available(iOS 26.0, *)) { + for (UIView *subview in view.subviews) { + if ([subview isKindOfClass:[UISwitch class]]) { + UISwitch *uiSwitch = (UISwitch *)subview; + [GenericUtils applyOffTintColor:uiSwitch]; + } + [self updateThemeForSwitches:subview]; + } + } +} + - (void)updateThemeForMenuSections:(UIView *)view { for (UIView *subview in view.subviews) { if ([subview isKindOfClass:[MenuSectionView class]]) { MenuSectionView *section = (MenuSectionView *)subview; - section.titleLabel.textColor = [ThemeManager sectionLabelTextColor]; + section.titleLabel.textColor = ThemeManager.sectionLabelTextColor; section.iconImageView.tintColor = [UIColor clearColor]; - section.iconImageView.tintColor = [ThemeManager sectionLabelTextColor]; + section.iconImageView.tintColor = ThemeManager.sectionLabelTextColor; section.separatorLine.backgroundColor = [UIColor clearColor]; - section.separatorLine.backgroundColor = [ThemeManager separatorColor]; + section.separatorLine.backgroundColor = ThemeManager.separatorColor; } [self updateThemeForMenuSections:subview]; } @@ -3393,11 +3406,12 @@ BOOL isCustomResolution(int resolutionSelected) { - (void)updateTheme{ self.view.backgroundColor = [UIColor clearColor]; - self.view.backgroundColor = [ThemeManager menuBackgroundColor]; + self.view.backgroundColor = ThemeManager.menuBackgroundColor; [self updateThemeForMenuSections:self.view]; [self updateThemeForLabels:self.view]; [self updateThemeForSelectors:self.view]; [self updateThemeForSliders:self.view]; + if(GenericUtils.liquidGlassEnabled) [self updateThemeForSwitches:self.view]; } - (void) frameQueueSizeSliderMoved:(UISlider* )sender { diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index 6b866fb5..9e7d5abc 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -585,9 +585,9 @@ } - (void)updateTheme { - self.view.backgroundColor = [ThemeManager menuBackgroundColor]; - _stageLabel.textColor = [[ThemeManager textColor] colorWithAlphaComponent:0.9]; - _spinner.color = [ThemeManager textColor]; + self.view.backgroundColor = ThemeManager.menuBackgroundColor; + _stageLabel.textColor = [ThemeManager.textColor colorWithAlphaComponent:0.9]; + _spinner.color = ThemeManager.textColor; } - (void)viewDidLoad From ed8bf5af9e80e570fa6383bc9e88c2f154ac17df Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Thu, 12 Mar 2026 16:45:50 +0800 Subject: [PATCH 2/3] deal with separator color --- VoidLink/HostCardView.m | 2 +- VoidLink/ThemeManager.swift | 55 +++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/VoidLink/HostCardView.m b/VoidLink/HostCardView.m index 39dfcd4a..85235946 100644 --- a/VoidLink/HostCardView.m +++ b/VoidLink/HostCardView.m @@ -475,7 +475,7 @@ static const float REFRESH_CYCLE = 2.0f; self.backgroundColor = ThemeManager.widgetBackgroundColor; _hostNameLabel.textColor = ThemeManager.textColor; [_appButton setTitleColor:ThemeManager.appPrimaryColor forState:UIControlStateNormal]; - _separatorLine.backgroundColor = ThemeManager.separatorColor; + _separatorLine.backgroundColor = ThemeManager.hostCardSeparatorColor; backgroundLayer.hidden = NO; [self updateBackgroundLayerTheme]; diff --git a/VoidLink/ThemeManager.swift b/VoidLink/ThemeManager.swift index 442e3f67..f4479d0b 100644 --- a/VoidLink/ThemeManager.swift +++ b/VoidLink/ThemeManager.swift @@ -144,7 +144,49 @@ class ThemeManager: NSObject { @objc static var separatorColor: UIColor { _ = setPublicUIStyle() - + switch userInterfaceStyle() { + case .light: + if #available(iOS 13.0, *) { + let lightTraits = UITraitCollection(userInterfaceStyle: .light) + return GenericUtils.liquidGlassEnabled ? legacySepratorColor : UIColor.separator.resolvedColor(with: lightTraits) + } else { + return UIColor( + red: 214.0/255.0, + green: 214.0/255.0, + blue: 218.0/255.0, + alpha: 1 + ) + } + default: + if #available(iOS 13.0, *) { + let darkTraits = UITraitCollection(userInterfaceStyle: .dark) + return GenericUtils.liquidGlassEnabled ? legacySepratorColor : UIColor.separator.resolvedColor(with: darkTraits) + } else {return UIColor(white: 0.28, alpha: 1)} + } + } + + @objc static var legacySepratorColor: UIColor { + _ = setPublicUIStyle() + switch userInterfaceStyle() { + case .light: + return UIColor( + red: 0.23529411764705882, + green: 0.23529411764705882, + blue: 0.2627450980392157, + alpha: 0.29 + ) + default: + return UIColor( + red: 0.32941176470588235, + green: 0.32941176470588235, + blue: 0.34509803921568627, + alpha: 0.6 + ) + } + } + + @objc static var hostCardSeparatorColor: UIColor { + _ = setPublicUIStyle() switch userInterfaceStyle() { case .light: if #available(iOS 13.0, *) { @@ -166,17 +208,6 @@ class ThemeManager: NSObject { } } - @objc static var hostCardSeparatorColor: UIColor { - _ = setPublicUIStyle() - - switch userInterfaceStyle() { - case .light: - return UIColor(white: 0.1, alpha: 0.28) - default: - return UIColor(white: 0.28, alpha: 1) - } - } - @objc static var textColor: UIColor { _ = setPublicUIStyle() From f8badd51c5adbdacf4c562a46ff51b46b8a6cb07 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Thu, 12 Mar 2026 18:10:39 +0800 Subject: [PATCH 3/3] deal with osw profile selector table navigation bar --- VoidLink/Base.lproj/iPad.storyboard | 5 +++-- VoidLink/Input/StreamView.m | 5 +++++ .../OSCProfilesTableViewController.m | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/VoidLink/Base.lproj/iPad.storyboard b/VoidLink/Base.lproj/iPad.storyboard index 2aae85ee..97b827ae 100644 --- a/VoidLink/Base.lproj/iPad.storyboard +++ b/VoidLink/Base.lproj/iPad.storyboard @@ -3171,7 +3171,7 @@ - + @@ -3221,12 +3221,13 @@ + - + diff --git a/VoidLink/Input/StreamView.m b/VoidLink/Input/StreamView.m index 90f597c8..f88a3316 100644 --- a/VoidLink/Input/StreamView.m +++ b/VoidLink/Input/StreamView.m @@ -373,6 +373,11 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; [customToolbarView setItems:[NSArray arrayWithObjects:doneBarButton, windowsBarButton, escapeBarButton, tabBarButton, shiftBarButton, controlBarButton, altBarButton, deleteBarButton, flexibleSpace, nil]]; + if (@available(iOS 26.0, *)) { + for(UIBarButtonItem *button in customToolbarView.items){ + button.hidesSharedBackground = true; + } + } keyInputField.inputAccessoryView = customToolbarView; } #endif diff --git a/VoidLink/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m b/VoidLink/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m index 8b186332..4206468c 100644 --- a/VoidLink/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m +++ b/VoidLink/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m @@ -20,9 +20,11 @@ const double NAV_BAR_HEIGHT = 50; @interface OSCProfilesTableViewController () +@property (weak, nonatomic) IBOutlet UINavigationItem *profileTableViewNavigationItem; @end + @implementation OSCProfilesTableViewController { OSCProfilesManager *profilesManager; } @@ -70,6 +72,11 @@ const double NAV_BAR_HEIGHT = 50; self.profileTableViewNavigationBar.layer.masksToBounds = true; // 使圆角生效 self.profileTableViewNavigationBar.layer.mask = maskLayer; + if (GenericUtils.liquidGlassEnabled) { + if (@available(iOS 13.0, *)) { + self.profileTableViewNavigationBar.layer.backgroundColor = UIColor.systemFillColor.CGColor; + } + } self.tableView.layer.cornerRadius = 15; // 设置圆角半径 self.tableView.layer.masksToBounds = true; // 使圆角生效 @@ -101,6 +108,17 @@ const double NAV_BAR_HEIGHT = 50; tap.delegate = (id)self; [self.view addGestureRecognizer:tap]; + + if(GenericUtils.liquidGlassEnabled){ + if (@available(iOS 26.0, *)) { + for(UIBarButtonItem* button in self.profileTableViewNavigationItem.leftBarButtonItems){ + button.hidesSharedBackground = true; + } + for(UIBarButtonItem* button in self.profileTableViewNavigationItem.rightBarButtonItems){ + button.hidesSharedBackground = true; + } + } + } } - (void)dismissSelf {