From dfaa4005bb8ae1ab9cad8b020ebe1f68dec3f6eb Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Sat, 7 Jun 2025 21:28:40 +0800 Subject: [PATCH] - newUI ios12 compatibility - settings wighet them color - minor tweaks --- Limelight/Base.lproj/iPad.storyboard | 78 ++++++++++--------- Limelight/HostCardView.m | 46 ++++++----- .../Input/CustomOSC/OSCProfilesManager.m | 4 +- Limelight/Input/StreamView.m | 2 +- Limelight/MenuSectionView.m | 25 +++--- Limelight/ThemeManager.h | 1 + Limelight/ThemeManager.m | 38 ++++++++- Limelight/UIAppView.m | 2 +- Limelight/UIComputerView.m | 2 +- .../LayoutOnScreenControlsViewController.m | 2 +- .../OSCProfilesTableViewController.m | 2 +- .../ViewControllers/MainFrameViewController.m | 23 ++++-- .../ViewControllers/SWRevealViewController.m | 22 +++--- .../ViewControllers/SettingsViewController.m | 29 ++++--- .../StreamFrameViewController.m | 2 +- 15 files changed, 170 insertions(+), 108 deletions(-) diff --git a/Limelight/Base.lproj/iPad.storyboard b/Limelight/Base.lproj/iPad.storyboard index c5ef800e..f8661fac 100644 --- a/Limelight/Base.lproj/iPad.storyboard +++ b/Limelight/Base.lproj/iPad.storyboard @@ -2,7 +2,6 @@ - @@ -73,7 +72,7 @@ - + @@ -84,6 +83,8 @@ + + @@ -112,8 +113,8 @@ - - + + @@ -132,7 +133,7 @@ - + @@ -157,7 +158,7 @@ - + @@ -180,8 +181,7 @@ - - + @@ -202,7 +202,7 @@ - + @@ -223,7 +223,7 @@ - + @@ -244,7 +244,7 @@ - + @@ -265,7 +265,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -316,7 +316,7 @@ ICAgICAgICAgICAgICA - + @@ -339,8 +339,8 @@ ICAgICAgICAgICAgICA - - + + @@ -364,7 +364,7 @@ ICAgICAgICAgICAgICA - + @@ -388,7 +388,7 @@ ICAgICAgICAgICAgICA - + @@ -413,7 +413,7 @@ ICAgICAgICAgICAgICA - + @@ -434,7 +434,7 @@ ICAgICAgICAgICAgICA - + @@ -457,7 +457,7 @@ ICAgICAgICAgICAgICA - + @@ -480,7 +480,7 @@ ICAgICAgICAgICAgICA - + @@ -503,7 +503,7 @@ ICAgICAgICAgICAgICA - + @@ -526,7 +526,7 @@ ICAgICAgICAgICAgICA - + @@ -551,7 +551,7 @@ ICAgICAgICAgICAgICA - + @@ -574,7 +574,7 @@ ICAgICAgICAgICAgICA - + @@ -597,7 +597,7 @@ ICAgICAgICAgICAgICA - + @@ -620,7 +620,7 @@ ICAgICAgICAgICAgICA - + @@ -643,7 +643,7 @@ ICAgICAgICAgICAgICA - + @@ -666,7 +666,7 @@ ICAgICAgICAgICAgICA - + @@ -690,7 +690,7 @@ ICAgICAgICAgICAgICA - + @@ -713,7 +713,7 @@ ICAgICAgICAgICAgICA - + @@ -736,7 +736,7 @@ ICAgICAgICAgICAgICA - + @@ -760,7 +760,7 @@ ICAgICAgICAgICAgICA - + @@ -1267,14 +1267,20 @@ ICAgICAgICAgICAgICA + + + - + - + + + + diff --git a/Limelight/HostCardView.m b/Limelight/HostCardView.m index cffe7c0b..24d8d7f1 100644 --- a/Limelight/HostCardView.m +++ b/Limelight/HostCardView.m @@ -187,7 +187,7 @@ static const float REFRESH_CYCLE = 2.0f; self.hostIconView = [[UIImageView alloc] init]; self.hostIconView.translatesAutoresizingMaskIntoConstraints = NO; self.hostIconView.contentMode = UIViewContentModeScaleAspectFit; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { self.hostIconView.image = [UIImage systemImageNamed:@"display"]; } else { self.hostIconView.image = [UIImage imageNamed:@"Computer"]; @@ -208,6 +208,10 @@ static const float REFRESH_CYCLE = 2.0f; // [self.iconImageView layoutIfNeeded]; //spinner + bool oldiOS = false; + if (@available(iOS 13.0, *)){} + else oldiOS = true; + _hostSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; _hostSpinner.userInteractionEnabled = NO; _hostSpinner.translatesAutoresizingMaskIntoConstraints = NO; @@ -215,7 +219,7 @@ static const float REFRESH_CYCLE = 2.0f; [self.iconBackgroundView addSubview:_hostSpinner]; [NSLayoutConstraint activateConstraints:@[ [_hostSpinner.centerXAnchor constraintEqualToAnchor:self.iconBackgroundView.centerXAnchor constant:0], - [_hostSpinner.centerYAnchor constraintEqualToAnchor:self.iconBackgroundView.centerYAnchor constant:computerIconMonitorCenterYOffset], + [_hostSpinner.centerYAnchor constraintEqualToAnchor:self.iconBackgroundView.centerYAnchor constant:oldiOS ? -5.5*_sizeFactor : computerIconMonitorCenterYOffset], ]]; _hostSpinner.transform = CGAffineTransformMakeScale(_sizeFactor, _sizeFactor); [_hostSpinner stopAnimating]; @@ -225,10 +229,11 @@ static const float REFRESH_CYCLE = 2.0f; // lockIcon lockIconView =[[UIImageView alloc] init]; lockIconView.translatesAutoresizingMaskIntoConstraints = NO; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { lockIconView.image = [UIImage systemImageNamed:@"lock.fill"]; } else { - // lockIconView.image = [UIImage imageNamed:@"Computer"]; + lockIconView.image = [UIImage imageNamed:@"LockedOverlayIcon"]; + computerIconMonitorCenterYOffset = -5 * _sizeFactor; } lockIconView.tintColor = [UIColor whiteColor]; [self.iconBackgroundView insertSubview:lockIconView aboveSubview:_iconBackgroundView]; @@ -308,7 +313,7 @@ static const float REFRESH_CYCLE = 2.0f; self.launchButton.tintColor = [UIColor whiteColor]; [self.launchButton addTarget:self action:@selector(launchButtonTapped) forControlEvents:UIControlEventPrimaryActionTriggered]; [self addSubview:self.launchButton]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:self.launchButton.frame.size.height*_sizeFactor]; [self.launchButton setImage:[UIImage systemImageNamed:@"play.fill" withConfiguration:config] forState:UIControlStateNormal]; @@ -329,12 +334,12 @@ 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 appPrimaryColorWithAlpha]; + self.pairButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; self.pairButton.layer.cornerRadius = 10; [self.pairButton setTitle:[LocalizationHelper localizedStringForKey:@" Pair with PIN"] forState:UIControlStateNormal]; [self.pairButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme self.pairButton.titleLabel.font = [UIFont boldSystemFontOfSize:16*_sizeFactor]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:self.pairButton.frame.size.height/3.5*_sizeFactor weight:UIImageSymbolWeightBold]; UIImage *templateImage = [UIImage systemImageNamed:@"lock.open.fill" withConfiguration:config]; UIImage *coloredImage = [templateImage imageWithTintColor:defaultBlue renderingMode:UIImageRenderingModeAlwaysOriginal]; @@ -342,7 +347,7 @@ static const float REFRESH_CYCLE = 2.0f; } else { // Fallback on earlier versions } - self.pairButton.backgroundColor = [ThemeManager appPrimaryColorWithAlpha]; + self.pairButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; [self.pairButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme [self.pairButton addTarget:self action:@selector(pairButtonTapped) forControlEvents:UIControlEventPrimaryActionTriggered]; @@ -363,7 +368,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 appPrimaryColorWithAlpha]; + self.wakeupButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; self.wakeupButton.layer.cornerRadius = 10; [self.wakeupButton setTitle:[LocalizationHelper localizedStringForKey:@" Wake-on-LAN"] forState:UIControlStateNormal]; [self.wakeupButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme @@ -475,7 +480,7 @@ static const float REFRESH_CYCLE = 2.0f; - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { [super traitCollectionDidChange:previousTraitCollection]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { if ([self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]) { [self updateTheme:self.traitCollection.userInterfaceStyle]; } @@ -507,6 +512,7 @@ static const float REFRESH_CYCLE = 2.0f; _statusLabel.textColor = defaultGreen; _statusLabel.text = @"Online"; self.statusIcon.image = [[UIImage imageNamed:@"wifi_green"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + self.statusIcon.hidden = NO; _hostIconView.tintColor = [UIColor whiteColor]; _appButton.titleLabel.font = [UIFont systemFontOfSize:16*_sizeFactor]; if(host.pairState == PairStatePaired){ @@ -520,13 +526,12 @@ static const float REFRESH_CYCLE = 2.0f; _launchButton.hidden = NO; _pairButton.hidden = YES; _wakeupButton.hidden = YES; - + [_appButton setTitleColor:defaultBlue forState:UIControlStateNormal]; // theme - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:self.launchButton.frame.size.height/4*_sizeFactor]; [self.launchButton setImage:[UIImage systemImageNamed:@"play.fill" withConfiguration:config] forState:UIControlStateNormal]; } else { - // Fallback on earlier versions } _launchButton.backgroundColor = defaultBlue; [_launchButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; // theme @@ -547,10 +552,10 @@ static const float REFRESH_CYCLE = 2.0f; _statusLabel.textColor = [ThemeManager textColorGray]; _statusLabel.text = @"Offline"; _statusIcon.tintColor = [ThemeManager textColorGray]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { _statusIcon.image = [UIImage systemImageNamed:@"exclamationmark.triangle.fill"]; } else { - // Fallback on earlier versions + self.statusIcon.hidden = YES; } _hostIconView.tintColor = [ThemeManager lowProfileGray]; lockIconView.hidden = YES; @@ -559,7 +564,7 @@ static const float REFRESH_CYCLE = 2.0f; _pairButton.hidden = YES; _wakeupButton.hidden = NO; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:self.wakeupButton.frame.size.height/3.2*_sizeFactor weight:UIImageSymbolWeightBold]; UIImage *templateImage = [UIImage systemImageNamed:@"power" withConfiguration:config]; UIImage *coloredImage = [templateImage imageWithTintColor:defaultBlue renderingMode:UIImageRenderingModeAlwaysOriginal]; @@ -567,9 +572,8 @@ static const float REFRESH_CYCLE = 2.0f; } else { // Fallback on earlier versions } - self.wakeupButton.backgroundColor = [ThemeManager appPrimaryColorWithAlpha]; + self.wakeupButton.backgroundColor = [ThemeManager textTintColorWithAlpha]; [self.wakeupButton setTitleColor:defaultBlue forState:UIControlStateNormal]; - break; case StateUnknown: _hostSpinner.color = [UIColor whiteColor]; @@ -579,10 +583,10 @@ static const float REFRESH_CYCLE = 2.0f; _statusLabel.textColor = [ThemeManager textColorGray]; _statusLabel.text = @"Detecting..."; _statusIcon.tintColor = [ThemeManager textColorGray]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { _statusIcon.image = [UIImage systemImageNamed:@"antenna.radiowaves.left.and.right"]; } else { - // Fallback on earlier versions + self.statusIcon.hidden = YES; } // _hostIconView.tintColor = [UIColor lowProfileGray]; _hostIconView.tintColor = defaultBlue; @@ -593,7 +597,7 @@ static const float REFRESH_CYCLE = 2.0f; _wakeupButton.hidden = NO; [_wakeupButton setTitleColor:[ThemeManager textColorGray] forState:UIControlStateNormal]; // theme - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:self.wakeupButton.frame.size.height/3.2*_sizeFactor weight:UIImageSymbolWeightBold]; UIImage *templateImage = [UIImage systemImageNamed:@"power" withConfiguration:config]; UIImage *coloredImage = [templateImage imageWithTintColor:[ThemeManager textColorGray] renderingMode:UIImageRenderingModeAlwaysOriginal]; diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.m b/Limelight/Input/CustomOSC/OSCProfilesManager.m index 2d0c42d4..69b218a1 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.m +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.m @@ -161,7 +161,7 @@ static CGRect streamViewBounds; if (fileData && !error) { // 3. 成功读取 NSSet *classes = [NSSet setWithObjects: [NSMutableData class], [NSMutableArray class], nil]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { // 在 iOS 13 及以上使用 unarchivedObjectOfClasses profilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:fileData error:&error]; } else { @@ -402,7 +402,7 @@ static CGRect streamViewBounds; - (OnScreenButtonState *)unarchiveButtonStateEncoded:(NSData *)data { OnScreenButtonState* buttonState; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { // 在 iOS 13 及以上使用 unarchivedObjectOfClasses buttonState = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObjects:[NSString class], [OnScreenButtonState class], nil] fromData:data diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 37fe3df2..c4d1b05f 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -1032,7 +1032,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; #endif - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { // Disable the 3 finger tap gestures that trigger the copy/paste/undo toolbar on iOS 13+ return gestureRecognizer.name == nil || ![gestureRecognizer.name hasPrefix:@"kbProductivity."]; } diff --git a/Limelight/MenuSectionView.m b/Limelight/MenuSectionView.m index 13aebda4..619d569d 100644 --- a/Limelight/MenuSectionView.m +++ b/Limelight/MenuSectionView.m @@ -83,11 +83,11 @@ // 切换按钮 _toggleButton = [UIButton buttonWithType:UIButtonTypeSystem]; _toggleArea = [UIButton buttonWithType:UIButtonTypeSystem]; - if (@available(iOS 13.0, *) && false) { - UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:_headerViewHeight*0.31 weight:UIImageSymbolWeightMedium]; + if (@available(iOS 13.0, *)) { + UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:_headerViewHeight*0.31 weight:UIImageSymbolWeightBold]; [_toggleButton setImage:[UIImage systemImageNamed:@"chevron.left" withConfiguration:config] forState:UIControlStateNormal]; } else { - [_toggleButton setTitle:@"<" forState:UIControlStateNormal]; + // [_toggleButton setTitle:@"<" forState:UIControlStateNormal]; } [_toggleButton addTarget:self action:@selector(toggleFold) forControlEvents:UIControlEventTouchUpInside]; [_toggleArea addTarget:self action:@selector(toggleFold) forControlEvents:UIControlEventTouchUpInside]; @@ -140,11 +140,18 @@ ]]; // 标题约束 - [NSLayoutConstraint activateConstraints:@[ - [_titleLabel.leadingAnchor constraintEqualToAnchor:_iconImageView.trailingAnchor constant:8], - [_titleLabel.centerYAnchor constraintEqualToAnchor:_headerView.centerYAnchor], - [_titleLabel.trailingAnchor constraintEqualToAnchor:_toggleButton.leadingAnchor constant:-8] - ]]; + if(@available(iOS 13.0, *)){ + [NSLayoutConstraint activateConstraints:@[ + [_titleLabel.leadingAnchor constraintEqualToAnchor:_iconImageView.trailingAnchor constant:8], + [_titleLabel.centerYAnchor constraintEqualToAnchor:_headerView.centerYAnchor], + [_titleLabel.trailingAnchor constraintEqualToAnchor:_toggleButton.leadingAnchor constant:-8] + ]]; + } + else [NSLayoutConstraint activateConstraints:@[ + [_titleLabel.leadingAnchor constraintEqualToAnchor:_headerView.leadingAnchor constant:0], + [_titleLabel.centerYAnchor constraintEqualToAnchor:_headerView.centerYAnchor], + [_titleLabel.trailingAnchor constraintEqualToAnchor:_toggleButton.leadingAnchor constant:-8] + ]]; // 切换按钮约束 [NSLayoutConstraint activateConstraints:@[ @@ -192,7 +199,7 @@ #pragma mark - Public Methods - (void)setSectionIcon:(UIImage *)icon { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithWeight:UIImageSymbolWeightSemibold]; _iconImageView.image = [icon imageWithConfiguration:config]; diff --git a/Limelight/ThemeManager.h b/Limelight/ThemeManager.h index d80608ef..58fded68 100644 --- a/Limelight/ThemeManager.h +++ b/Limelight/ThemeManager.h @@ -20,6 +20,7 @@ + (UIColor *)textColor; + (UIColor *)textColorGray; + (UIColor *)lowProfileGray; ++ (UIColor *)textTintColorWithAlpha; @end diff --git a/Limelight/ThemeManager.m b/Limelight/ThemeManager.m index 12023c11..95004ff7 100644 --- a/Limelight/ThemeManager.m +++ b/Limelight/ThemeManager.m @@ -14,7 +14,7 @@ static UIUserInterfaceStyle _privateUserInterfaceStyle = UIUserInterfaceStyleUns static UIUserInterfaceStyle _userInterfaceStyle; + (UIColor *)getUIStyle{ - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UITraitCollection *traitCollection = [UIScreen mainScreen].traitCollection; if(_privateUserInterfaceStyle == UIUserInterfaceStyleUnspecified) { _userInterfaceStyle = traitCollection.userInterfaceStyle; @@ -97,11 +97,43 @@ static UIUserInterfaceStyle _userInterfaceStyle; } + (UIColor *)appSecondaryColor { - return [UIColor colorWithRed:0.0 green:0.319 blue:0.64 alpha:1.0]; // 可换其他常用色 + // return [UIColor colorWithRed:0.0 green:0.319 blue:0.64 alpha:1.0]; // 可换其他常用色 + UIColor* originalColor = [ThemeManager appPrimaryColor]; + + UIColor *grayColor = [UIColor grayColor]; + CGFloat mixRatio = 0.3; // 混合比例,0.0 到 1.0 + + CGFloat r1, g1, b1, a1; + CGFloat r2, g2, b2, a2; + + [originalColor getRed:&r1 green:&g1 blue:&b1 alpha:&a1]; + [grayColor getRed:&r2 green:&g2 blue:&b2 alpha:&a2]; + + CGFloat r = r1 * (1 - mixRatio) + r2 * mixRatio; + CGFloat g = g1 * (1 - mixRatio) + g2 * mixRatio; + CGFloat b = b1 * (1 - mixRatio) + b2 * mixRatio; + CGFloat a = a1 * (1 - mixRatio) + a2 * mixRatio; + + UIColor *tonedColor = [UIColor colorWithRed:r green:g blue:b alpha:a]; + + return tonedColor; // 可换其他常用色 } + (UIColor *)appPrimaryColorWithAlpha { - return [[ThemeManager appPrimaryColor] colorWithAlphaComponent:0.24]; // #0A84FF + [ThemeManager getUIStyle]; + switch (self.userInterfaceStyle) { + case UIUserInterfaceStyleLight: + return [[ThemeManager appPrimaryColor] colorWithAlphaComponent:0.24]; // #0A84FF + break; + case UIUserInterfaceStyleDark: + default: + return [[ThemeManager appPrimaryColor] colorWithAlphaComponent:0.5]; + break; + } +} + ++ (UIColor *)textTintColorWithAlpha{ + return [[ThemeManager appPrimaryColor] colorWithAlphaComponent:0.24]; } + (UIColor *)textColorGray{ diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index 4fc69281..3b966571 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -49,7 +49,7 @@ static UIImage* noImage; // Use UIContextMenuInteraction on iOS 13.0+ and a standard UILongPressGestureRecognizer // for tvOS devices and iOS prior to 13.0. #if !TARGET_OS_TV - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self]; [self addInteraction:rightClickInteraction]; } diff --git a/Limelight/UIComputerView.m b/Limelight/UIComputerView.m index 6c0975c5..e3f26ef5 100644 --- a/Limelight/UIComputerView.m +++ b/Limelight/UIComputerView.m @@ -127,7 +127,7 @@ static const int LABEL_DY = 20; // Use UIContextMenuInteraction on iOS 13.0+ and a standard UILongPressGestureRecognizer // for tvOS devices and iOS prior to 13.0. #if !TARGET_OS_TV - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIContextMenuInteraction* rightClickInteraction = [[UIContextMenuInteraction alloc] initWithDelegate:self]; [self addInteraction:rightClickInteraction]; } diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m index 93a7d27a..51973718 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m @@ -738,7 +738,7 @@ // Set the label's frame with the calculated x-position self.currentProfileLabel.frame = CGRectMake(profileLabelXPosition, self.currentProfileLabel.frame.origin.y, self.currentProfileLabel.frame.size.width, self.currentProfileLabel.frame.size.height); self.currentProfileLabel.hidden = NO; // Show Current Profile display - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { self.currentProfileLabel.textAlignment = NSTextAlignmentNatural; self.currentProfileLabel.numberOfLines = 2; } else { diff --git a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m index e05eba69..431f175d 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m @@ -268,7 +268,7 @@ didPickDocumentsAtURLs:(NSArray *)urls { NSMutableArray *profilesEncoded; // 解码原始的NSArray对象,得到包含编码对象的数组 error = nil; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { // 在 iOS 13 及以上使用 unarchivedObjectOfClasses profilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:fileData error:&error]; } else { diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 2977bc3b..095999e1 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -136,7 +136,7 @@ static NSMutableSet* hostList; - (void)updateTitle { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { navBarAppearanceScroll.titleTextAttributes = navBarAppearanceStandard.titleTextAttributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:20 weight:UIFontWeightMedium], NSForegroundColorAttributeName: [ThemeManager textColor] // 可选,设置标题颜色 @@ -151,7 +151,7 @@ static NSMutableSet* hostList; self.title = [LocalizationHelper localizedStringForKey: @"Searching for PCs on your network..."] ; } else { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { navBarAppearanceScroll.titleTextAttributes = navBarAppearanceStandard.titleTextAttributes = @{ NSFontAttributeName: [UIFont systemFontOfSize:24 weight:UIFontWeightSemibold], NSForegroundColorAttributeName: [ThemeManager textColor] // 可选,设置标题颜色 @@ -165,10 +165,10 @@ static NSMutableSet* hostList; self.title = [LocalizationHelper localizedStringForKey: @"Hosts" ]; //self.title = nil; } - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [self applyNavBarAppearance]; } else { - // Fallback on earlier versions + self.navigationController.navigationBar.backgroundColor = [ThemeManager appBackgroundColor]; } } @@ -365,6 +365,8 @@ static NSMutableSet* hostList; self.hostCollectionVC.view.hidden = YES; self.collectionView.hidden = NO; self.collectionView.backgroundColor = [ThemeManager appBackgroundColor]; + //self.view.backgroundColor = [ThemeManager appBackgroundColor]; + [self attachWaterMark]; self.navigationItem.rightBarButtonItems = @[_upButton]; self.revealViewController.mainFrameIsInHostView = false; @@ -1280,7 +1282,7 @@ static NSMutableSet* hostList; // 设置图标(SF Symbol) - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:17 weight:UIImageSymbolWeightMedium]; UIImage *image = [UIImage systemImageNamed:@"plus.circle" withConfiguration:config]; [button setImage:image forState:UIControlStateNormal]; @@ -1320,7 +1322,7 @@ static NSMutableSet* hostList; button.clipsToBounds = YES; // 设置图标(SF Symbol) - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:buttonHeight*0.85 weight:UIImageSymbolWeightRegular]; UIImage *image = [UIImage systemImageNamed:@"questionmark.circle" withConfiguration:config]; [button setImage:image forState:UIControlStateNormal]; @@ -1380,7 +1382,7 @@ static NSMutableSet* hostList; } - (void)setupNavBar{ - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { navBarAppearanceStandard = [[UINavigationBarAppearance alloc] init]; [navBarAppearanceStandard configureWithOpaqueBackground]; // 不透明 navBarAppearanceStandard.backgroundColor =[ThemeManager appBackgroundColor];; // 设置你需要的背景色 @@ -1406,6 +1408,9 @@ static NSMutableSet* hostList; //appearance. [self applyNavBarAppearance]; } + else { + self.navigationController.navigationBar.backgroundColor = [ThemeManager appBackgroundColor]; + } self->_addHostButton = [self createAddHostButton]; self->_helpButton = [self createHelpButton]; @@ -1419,7 +1424,7 @@ static NSMutableSet* hostList; [_settingsButton setTarget:self.revealViewController]; [_settingsButton setAction:@selector(revealToggle:)]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [_settingsButton setTitle:nil]; UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23 weight:UIImageSymbolWeightMedium ]; UIImage *image = [[UIImage systemImageNamed:@"sidebar.left" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; @@ -1767,6 +1772,8 @@ static NSMutableSet* hostList; // view, so we won't get a return to active notification // for that which would normally fire beginForegroundRefresh. self.view.backgroundColor = [ThemeManager appBackgroundColor]; + self.hostCollectionVC.view.backgroundColor = [ThemeManager appBackgroundColor]; + self.collectionView.backgroundColor = [ThemeManager appBackgroundColor]; [self.view addSubview:self.collectionView]; [self initHostCollection]; diff --git a/Limelight/ViewControllers/SWRevealViewController.m b/Limelight/ViewControllers/SWRevealViewController.m index b3bf90f0..38c2c137 100755 --- a/Limelight/ViewControllers/SWRevealViewController.m +++ b/Limelight/ViewControllers/SWRevealViewController.m @@ -911,7 +911,7 @@ const int FrontViewPositionNone = 0xff; _dockedNavBar.translatesAutoresizingMaskIntoConstraints = NO; _dockedNavBar.userInteractionEnabled = YES; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UINavigationBarAppearance *navBarAppearanceStandard = [[UINavigationBarAppearance alloc] init]; [navBarAppearanceStandard configureWithOpaqueBackground]; // 不透明 navBarAppearanceStandard.backgroundColor =[ThemeManager appBackgroundColor];; // 设置你需要的背景色 @@ -924,7 +924,8 @@ const int FrontViewPositionNone = 0xff; _dockedNavBar.standardAppearance = navBarAppearanceStandard; _dockedNavBar.scrollEdgeAppearance = navBarAppearanceStandard; } else { - _dockedNavBar.backgroundColor = [ThemeManager appBackgroundColor]; + _dockedNavBar.backgroundColor = [UIColor clearColor]; + _dockedNavBar.barTintColor = [[ThemeManager appBackgroundColor] colorWithAlphaComponent:0.1]; } @@ -939,7 +940,6 @@ const int FrontViewPositionNone = 0xff; // navItem.rightBarButtonItem = _disconnectButton; [_dockedNavBar setItems:@[_navItem]]; - _dockedNavBar.barTintColor = [UIColor darkGrayColor]; _dockedNavBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]}; [_contentView.rearNavView addSubview:_dockedNavBar]; @@ -961,14 +961,14 @@ const int FrontViewPositionNone = 0xff; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init]; [backButton setTarget:self]; [backButton setAction:@selector(foldRearView)]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [backButton setTitle:nil]; UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23 weight:UIImageSymbolWeightMedium ]; UIImage *image = [[UIImage systemImageNamed:@"sidebar.left" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; [backButton setImage:image]; backButton.imageInsets = UIEdgeInsetsMake(20, 10, 0, 0); } else { - [backButton setTitle:[LocalizationHelper localizedStringForKey:@"Back"]]; + [backButton setTitle:[LocalizationHelper localizedStringForKey:@"Collapse"]]; } _navItem.leftBarButtonItem = backButton; } @@ -979,7 +979,7 @@ const int FrontViewPositionNone = 0xff; _disconnectButton = [[UIBarButtonItem alloc] init]; [_disconnectButton setTarget:self]; [_disconnectButton setAction:@selector(disconnectRemoteSession)]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [_disconnectButton setTitle:nil]; UIImage *image = [[UIImage imageNamed:@"disconnect.svg" ] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; @@ -1002,7 +1002,7 @@ const int FrontViewPositionNone = 0xff; if(!_moreButton) _moreButton = [[UIBarButtonItem alloc] init]; //[moreButton setAction:@selector(moreButtonTapped:)]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [_moreButton setTitle:nil]; UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:23 weight:UIImageSymbolWeightMedium ]; UIImage *image = [[UIImage systemImageNamed:@"ellipsis.circle" withConfiguration:config] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; @@ -1039,7 +1039,7 @@ const int FrontViewPositionNone = 0xff; - (void)removeSettingItemSelected{ - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { // UIAction* action1 = [self getAllSettingMenuAction]; UIAction* action1 = [self getDoneRemoveSettingAction]; if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[action1]]; @@ -1051,7 +1051,7 @@ const int FrontViewPositionNone = 0xff; } - (void)doneRemoveSettingItemSelected{ - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIAction* action1 = [self getAllSettingMenuAction]; UIAction* action2 = [self getRemoveSettingItemAction]; if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[action1, action2]]; @@ -1146,7 +1146,7 @@ const int FrontViewPositionNone = 0xff; } - (void)favoriteSettingSelected { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIAction* action1 = [self getAllSettingMenuAction]; UIAction* action2 = [self getRemoveSettingItemAction]; if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[action1, action2]]; @@ -1157,7 +1157,7 @@ const int FrontViewPositionNone = 0xff; } - (void)allSettingSelected { - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIAction* action1 = [self getFavoriteMenuAction]; if (@available(iOS 14.0, *)) _moreButton.menu = [UIMenu menuWithTitle:@"" children:@[action1]]; } diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index d6bd746e..d0987028 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -387,7 +387,7 @@ BOOL isCustomResolution(CGSize res) { parentStack.translatesAutoresizingMaskIntoConstraints = NO; [self.scrollView addSubview:parentStack]; [NSLayoutConstraint activateConstraints:@[ - [parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: [self getStandardNavBarHeight] + 13], + [parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: [self getStandardNavBarHeight]], [parentStack.bottomAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.bottomAnchor constant:-20], [parentStack.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor constant: 0], //mark: settingMenuLayout [parentStack.widthAnchor constraintEqualToAnchor:self.view.widthAnchor constant:-20] // section width adjusted here //mark: settingMenuLayout @@ -404,7 +404,7 @@ BOOL isCustomResolution(CGSize res) { - (void)layoutSections{ MenuSectionView *videoSection = [[MenuSectionView alloc] init]; videoSection.sectionTitle = [LocalizationHelper localizedStringForKey:@"Video"]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [videoSection setSectionIcon:[UIImage systemImageNamed:@"airplayvideo"]]; } else [videoSection setSectionIcon:nil]; @@ -417,7 +417,7 @@ BOOL isCustomResolution(CGSize res) { MenuSectionView *gesturesSection = [[MenuSectionView alloc] init]; gesturesSection.sectionTitle = [LocalizationHelper localizedStringForKey:@"Gestures"]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [gesturesSection setSectionIcon:[UIImage systemImageNamed:@"hand.draw"]]; } else [gesturesSection setSectionIcon:nil]; @@ -775,7 +775,7 @@ BOOL isCustomResolution(CGSize res) { - (void)attachRemoveButtonForStack:(UIStackView* )stack{ UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:16 weight:UIImageSymbolWeightMedium]; [button setImage:[UIImage systemImageNamed:@"minus.circle" withConfiguration:config] forState:UIControlStateNormal]; } else { @@ -795,12 +795,15 @@ BOOL isCustomResolution(CGSize res) { } - (void)attachInfoTagForStack:(UIStackView* )stack{ + bool usingTextButton = false; UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem]; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:13.5 weight:UIImageSymbolWeightBold]; [button setImage:[UIImage systemImageNamed:@"info.circle" withConfiguration:config] forState:UIControlStateNormal]; } else { - [button setTitle:@"i" forState:UIControlStateNormal]; + usingTextButton = true; + [button setTitle:@"info" forState:UIControlStateNormal]; + button.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold]; } button.accessibilityIdentifier = @"infoButton"; button.translatesAutoresizingMaskIntoConstraints = NO; @@ -811,7 +814,7 @@ BOOL isCustomResolution(CGSize res) { [stack addSubview:button]; [NSLayoutConstraint activateConstraints:@[ [button.trailingAnchor constraintEqualToAnchor:stack.trailingAnchor constant:-4], - [button.topAnchor constraintEqualToAnchor:stack.topAnchor], + [button.topAnchor constraintEqualToAnchor:stack.topAnchor constant: usingTextButton ? -2 : 0], ]]; } @@ -1729,7 +1732,7 @@ BOOL isCustomResolution(CGSize res) { for (UIView *subview in view.subviews) { if ([subview isKindOfClass:[UILabel class]]) { UILabel *label = (UILabel *)subview; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { label.layer.filters = nil; label.textColor = [ThemeManager textColor]; } else { @@ -1744,7 +1747,7 @@ BOOL isCustomResolution(CGSize res) { for (UIView *subview in view.subviews) { if ([subview isKindOfClass:[UISegmentedControl class]]) { UISegmentedControl *selector = (UISegmentedControl *)subview; - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { selector.selectedSegmentTintColor = [ThemeManager appSecondaryColor]; } else { // Fallback on earlier versions @@ -1768,9 +1771,11 @@ BOOL isCustomResolution(CGSize res) { - (void)updateTheme{ self.view.backgroundColor = [ThemeManager appBackgroundColor]; - [self updateThemeForLabels:self.view]; - [self updateThemeForSelectors:self.view]; - [self updateThemeForSliders:self.view]; + if (@available(iOS 13.0, *)) { + [self updateThemeForLabels:self.view]; + [self updateThemeForSelectors:self.view]; + [self updateThemeForSliders:self.view]; + } } diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index d704d951..d0584613 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -555,7 +555,7 @@ #if TARGET_OS_TV [_overlayView setFont:[UIFont systemFontOfSize:24]]; #else - if (@available(iOS 13.0, *) && false) { + if (@available(iOS 13.0, *)) { [_overlayView setFont:[UIFont monospacedSystemFontOfSize:12 weight:UIFontWeightRegular]]; } else { [_overlayView setFont:[UIFont systemFontOfSize:12]];// Fallback on earlier versions