From f79ba70037ee224cc31fbb6ae1a1e8ae94741ef4 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Sat, 27 Sep 2025 21:04:14 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BC=98=E5=8C=96AWEElementStackView?= =?UTF-8?q?=E9=80=8F=E6=98=8E=E5=BA=A6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/DYYY.xm b/DYYY.xm index f3cabc87f..7c9705f2e 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -6392,19 +6392,20 @@ static Class TagViewClass = nil; }]; } return; - } else { - if (pureModeTimer) { - [pureModeTimer cancel]; - pureModeTimer = nil; - } - attempts = 0; - pureModeSet = NO; - %orig(alpha); } + // 清理纯净模式的残留状态 + if (pureModeTimer) { + [pureModeTimer cancel]; + pureModeTimer = nil; + } + attempts = 0; + pureModeSet = NO; + // 倍速和清屏按钮的状态控制 if (speedButton && isFloatSpeedButtonEnabled) { if (alpha == 0) { + dyyyCommentViewVisible = YES; } else if (alpha == 1) { dyyyCommentViewVisible = NO; } @@ -6412,19 +6413,21 @@ static Class TagViewClass = nil; updateClearButtonVisibility(); } - // 全局透明 + // 值守全局透明度 CGFloat finalAlpha = alpha; if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - float alphaValue; - - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd && alphaValue >= 0 && alphaValue <= 1) { - finalAlpha = alphaValue; + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + } } } - if (fabs(self.alpha - finalAlpha) > 0.01) { + // 统一应用透明度 + if (fabs(self.alpha - finalAlpha) >= 0.01) { %orig(finalAlpha); } } From a27ef09d9b5d20aefb714f8f64b2473fba1043d4 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Sat, 27 Sep 2025 22:03:56 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=9C=A8StackView=E4=B8=AD=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=85=A8=E5=B1=80=E9=80=8F=E6=98=8E=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 122 ++++++++++++++++++++++++-------------------------------- 1 file changed, 52 insertions(+), 70 deletions(-) diff --git a/DYYY.xm b/DYYY.xm index 7c9705f2e..f75771b52 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -5692,43 +5692,6 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; } %end -static NSArray *kStackViewClasses = @[ NSClassFromString(@"AWEElementStackView"), NSClassFromString(@"IESLiveStackView") ]; -static char kCachedStackViewsKey; - -void applyGlobalTransparency(id targetObject) { - if (!targetObject) { - return; - } - - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - float alphaValue; - if (![scanner scanFloat:&alphaValue] || !scanner.isAtEnd || alphaValue < 0 || alphaValue > 1) { - return; - } - - NSHashTable *cachedStackViews = objc_getAssociatedObject(targetObject, &kCachedStackViewsKey); - if (!cachedStackViews) { - cachedStackViews = [NSHashTable weakObjectsHashTable]; - objc_setAssociatedObject(targetObject, &kCachedStackViewsKey, cachedStackViews, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - - for (Class stackViewClass in kStackViewClasses) { - NSArray *foundViews = [DYYYUtils findAllSubviewsOfClass:stackViewClass inContainer:targetObject]; - for (UIView *view in foundViews) { - [cachedStackViews addObject:view]; - } - } - } - - if (cachedStackViews.count > 0) { - for (UIView *stackViews in cachedStackViews) { - if (stackViews.alpha > 0 && fabs(stackViews.alpha - alphaValue) > 0.01 && stackViews.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - stackViews.alpha = alphaValue; - } - } - } -} - %hook AFDPureModePageTapController - (void)onVideoPlayerViewDoubleClicked:(id)arg1 { @@ -5760,8 +5723,6 @@ void applyGlobalTransparency(id targetObject) { - (void)viewDidLayoutSubviews { %orig; - applyGlobalTransparency(self); - if (isFloatSpeedButtonEnabled) { BOOL hasRightStack = NO; Class stackClass = NSClassFromString(@"AWEElementStackView"); @@ -6312,36 +6273,6 @@ static void DYYYRemoveKeyboardObserver(void) { } %end -%hook AWELiveNewPreStreamViewController - -- (void)viewDidLayoutSubviews { - %orig; - - applyGlobalTransparency(self); -} - -%end - -%hook AWECommentInputViewController - -- (void)viewDidLayoutSubviews { - %orig; - - applyGlobalTransparency(self); -} - -%end - -%hook AWEAwemeDetailNaviBarContainerView - -- (void)layoutSubviews { - %orig; - - applyGlobalTransparency(self); -} - -%end - static Class GuideViewClass = nil; static Class MuteViewClass = nil; static Class TagViewClass = nil; @@ -6452,6 +6383,24 @@ static Class TagViewClass = nil; updateClearButtonVisibility(); } +- (void)didMoveToWindow { + %orig; + + if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + if (fabs(self.alpha - targetAlpha) > 0.01) { + self.alpha = targetAlpha; + } + } + } + } +} + - (void)layoutSubviews { %orig; @@ -6591,7 +6540,6 @@ static Class TagViewClass = nil; } - (void)setAlpha:(CGFloat)alpha { - %orig; if (speedButton && isFloatSpeedButtonEnabled) { if (alpha == 0) { dyyyCommentViewVisible = YES; @@ -6601,6 +6549,40 @@ static Class TagViewClass = nil; updateSpeedButtonVisibility(); updateClearButtonVisibility(); } + + CGFloat finalAlpha = alpha; + if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + } + } + } + + if (fabs(self.alpha - finalAlpha) >= 0.01) { + %orig(finalAlpha); + } +} + +- (void)didMoveToWindow { + %orig; + + if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + if (fabs(self.alpha - targetAlpha) > 0.01) { + self.alpha = targetAlpha; + } + } + } + } } - (void)layoutSubviews { From fda24c1e0ecc69587eb02fb8c0ac5fd4255a7060 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Sat, 27 Sep 2025 15:52:56 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=8A=8A=E5=85=A8=E5=B1=80=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=BA=A6=E5=BA=94=E7=94=A8=E5=88=B0"=E5=85=A8?= =?UTF-8?q?=E5=B1=8F=E8=A7=82=E7=9C=8B"=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/DYYY.xm b/DYYY.xm index f75771b52..0fe371287 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -6755,6 +6755,42 @@ static Class TagViewClass = nil; %hook AWELandscapeFeedEntryView +- (void)setAlpha:(CGFloat)alpha { + CGFloat finalAlpha = alpha; + if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + } + } + } + + if (fabs(self.alpha - finalAlpha) >= 0.01) { + %orig(finalAlpha); + } +} + +- (void)didMoveToWindow { + %orig; + + if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); + if (fabs(self.alpha - targetAlpha) > 0.01) { + self.alpha = targetAlpha; + } + } + } + } +} + - (void)layoutSubviews { %orig; if (DYYYGetBool(@"DYYYRemoveEntry")) { From f5d6be94b59df1568397e6f84bd098d961a174a3 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Sun, 28 Sep 2025 05:26:39 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BD=BF=E7=94=A8KVO=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=A8=E5=B1=80=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 169 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 103 insertions(+), 66 deletions(-) diff --git a/DYYY.xm b/DYYY.xm index 0fe371287..ec321d135 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -24,6 +24,23 @@ #import "DYYYUtils.h" static CGFloat DYYYCurrentTabHeight(void); +static const CGFloat kInvalidAlpha = -1.0; +static CGFloat gGlobalTransparency = kInvalidAlpha; +static NSString *const kDYYYGlobalTransparencyKey = @"DYYYGlobalTransparency"; +static NSString *const kDYYYGlobalTransparencyDidChangeNotification = @"DYYYGlobalTransparencyDidChangeNotification"; + +static void updateGlobalTransparencyCache() { + NSString *transparentValue = DYYYGetString(kDYYYGlobalTransparencyKey); + if (transparentValue.length > 0) { + float alphaValue; + NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; + if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { + gGlobalTransparency = MIN(MAX(alphaValue, 0.0), 1.0); + return; + } + } + gGlobalTransparency = kInvalidAlpha; +} static NSDictionary *DYYYTopTabTitleMapping(void) { static NSString *cachedRawValue = nil; @@ -5589,6 +5606,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; %end %hook UIView + - (id)initWithFrame:(CGRect)frame { UIView *view = %orig; if (hideButton && hideButton.isElementsHidden) { @@ -5610,6 +5628,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; } return view; } + - (void)layoutSubviews { %orig; @@ -5679,6 +5698,23 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; %orig(frame); } +%new +- (void)dyyy_applyGlobalTransparency { + if ([NSThread isMainThread]) { + if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { + if (gGlobalTransparency != kInvalidAlpha && fabs(self.alpha - gGlobalTransparency) >= 0.01) { + [UIView animateWithDuration:0.2 animations:^{ + self.alpha = gGlobalTransparency; + }]; + } + } + } else { + dispatch_async(dispatch_get_main_queue(), ^{ + [self dyyy_applyGlobalTransparency]; + }); + } +} + %end %hook AWEIMSkylightListView @@ -6177,6 +6213,7 @@ static id dyyyWindowKeyObserverToken = nil; static id dyyyDidBecomeActiveToken = nil; static id dyyyWillResignActiveToken = nil; static id dyyyKeyboardWillShowToken = nil; +static void *DYYYGlobalTransparencyContext = &DYYYGlobalTransparencyContext; static void DYYYRemoveAppLifecycleObservers(void) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; @@ -6202,10 +6239,18 @@ static void DYYYRemoveKeyboardObserver(void) { } %hook AppDelegate + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BOOL result = %orig; initTargetClassNames(); + updateGlobalTransparencyCache(); + + [[NSUserDefaults standardUserDefaults] addObserver:(NSObject *)self + forKeyPath:kDYYYGlobalTransparencyKey + options:NSKeyValueObservingOptionNew + context:DYYYGlobalTransparencyContext]; + BOOL isEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"DYYYEnableFloatClearButton"]; if (isEnabled) { if (hideButton) { @@ -6269,8 +6314,30 @@ static void DYYYRemoveKeyboardObserver(void) { - (void)dealloc { DYYYRemoveAppLifecycleObservers(); DYYYRemoveKeyboardObserver(); + @try { + [[NSUserDefaults standardUserDefaults] removeObserver:(NSObject *)self + forKeyPath:kDYYYGlobalTransparencyKey + context:DYYYGlobalTransparencyContext]; + } @catch (NSException *exception) { + NSLog(@"[DYYY] KVO removeObserver failed: %@", exception); + } %orig; } + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context { + if (context == DYYYGlobalTransparencyContext) { + dispatch_async(dispatch_get_main_queue(), ^{ + updateGlobalTransparencyCache(); + [[NSNotificationCenter defaultCenter] postNotificationName:kDYYYGlobalTransparencyDidChangeNotification object:nil]; + }); + } else { + %orig(keyPath, object, change, context); + } +} + %end static Class GuideViewClass = nil; @@ -6346,15 +6413,8 @@ static Class TagViewClass = nil; // 值守全局透明度 CGFloat finalAlpha = alpha; - if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - } - } + if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG && gGlobalTransparency != kInvalidAlpha) { + finalAlpha = gGlobalTransparency; } // 统一应用透明度 @@ -6385,22 +6445,19 @@ static Class TagViewClass = nil; - (void)didMoveToWindow { %orig; - - if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - if (fabs(self.alpha - targetAlpha) > 0.01) { - self.alpha = targetAlpha; - } - } - } + if (self.window) { + [self dyyy_applyGlobalTransparency]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dyyy_applyGlobalTransparency) name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; + } else { + [[NSNotificationCenter defaultCenter] removeObserver:self name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; } } +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + %orig; +} + - (void)layoutSubviews { %orig; @@ -6551,15 +6608,8 @@ static Class TagViewClass = nil; } CGFloat finalAlpha = alpha; - if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - } - } + if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG && gGlobalTransparency != kInvalidAlpha) { + finalAlpha = gGlobalTransparency; } if (fabs(self.alpha - finalAlpha) >= 0.01) { @@ -6569,22 +6619,19 @@ static Class TagViewClass = nil; - (void)didMoveToWindow { %orig; - - if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - if (fabs(self.alpha - targetAlpha) > 0.01) { - self.alpha = targetAlpha; - } - } - } + if (self.window) { + [self dyyy_applyGlobalTransparency]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dyyy_applyGlobalTransparency) name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; + } else { + [[NSNotificationCenter defaultCenter] removeObserver:self name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; } } +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + %orig; +} + - (void)layoutSubviews { %orig; @@ -6757,15 +6804,8 @@ static Class TagViewClass = nil; - (void)setAlpha:(CGFloat)alpha { CGFloat finalAlpha = alpha; - if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - finalAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - } - } + if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG && gGlobalTransparency != kInvalidAlpha) { + finalAlpha = gGlobalTransparency; } if (fabs(self.alpha - finalAlpha) >= 0.01) { @@ -6775,22 +6815,19 @@ static Class TagViewClass = nil; - (void)didMoveToWindow { %orig; - - if (self.window && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG) { - NSString *transparentValue = DYYYGetString(@"DYYYGlobalTransparency"); - if (transparentValue.length > 0) { - float alphaValue; - NSScanner *scanner = [NSScanner scannerWithString:transparentValue]; - if ([scanner scanFloat:&alphaValue] && scanner.isAtEnd) { - CGFloat targetAlpha = MIN(MAX(alphaValue, 0.0), 1.0); - if (fabs(self.alpha - targetAlpha) > 0.01) { - self.alpha = targetAlpha; - } - } - } + if (self.window) { + [self dyyy_applyGlobalTransparency]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dyyy_applyGlobalTransparency) name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; + } else { + [[NSNotificationCenter defaultCenter] removeObserver:self name:kDYYYGlobalTransparencyDidChangeNotification object:nil]; } } +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + %orig; +} + - (void)layoutSubviews { %orig; if (DYYYGetBool(@"DYYYRemoveEntry")) { From c0f4118c07c777fa2542252799635931fe1bf70a Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Sun, 28 Sep 2025 14:18:03 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=8A=8A=E5=85=A8=E5=B1=80=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=BA=A6=E5=BA=94=E7=94=A8=E5=88=B0=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DYYY.xm b/DYYY.xm index ec321d135..4087f1b40 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -1027,6 +1027,7 @@ static CGFloat rightLabelRightMargin = -1; [parentView addSubview:leftLabel]; [DYYYUtils applyColorSettingsToLabel:leftLabel colorHexString:labelColorHex]; + [leftLabel dyyy_applyGlobalTransparency]; } if (!showLeftRemainingTime && !showLeftCompleteTime) { @@ -1051,6 +1052,7 @@ static CGFloat rightLabelRightMargin = -1; [parentView addSubview:rightLabel]; [DYYYUtils applyColorSettingsToLabel:rightLabel colorHexString:labelColorHex]; + [rightLabel dyyy_applyGlobalTransparency]; } [self setNeedsLayout]; @@ -1457,7 +1459,7 @@ static NSString *const kDYYYLongPressCopyEnabledKey = @"DYYYLongPressCopyTextEna - (void)didMoveToWindow { %orig; - if (DYYYGetBool(@"DYYYEnableNotificationTransparency")) { + if (self.window && DYYYGetBool(@"DYYYEnableNotificationTransparency")) { [self setupBlurEffectForNotificationView]; } } From 0f6bf839421d90dba4b748dc77566b65d3e902d7 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Tue, 30 Sep 2025 14:41:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E6=8B=86=E5=88=86=E5=BA=95=E6=A0=8F=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AwemeHeaders.h | 25 +++-- DYYY.xm | 242 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 183 insertions(+), 84 deletions(-) diff --git a/AwemeHeaders.h b/AwemeHeaders.h index c1f0e6b18..db94c2215 100644 --- a/AwemeHeaders.h +++ b/AwemeHeaders.h @@ -7,9 +7,20 @@ #define DYYYGetInteger(key) [[NSUserDefaults standardUserDefaults] integerForKey:key] #define DYYYGetString(key) [[NSUserDefaults standardUserDefaults] stringForKey:key] #define DYYY_IGNORE_GLOBAL_ALPHA_TAG 114514 + typedef NS_ENUM(NSInteger, MediaType) { MediaTypeVideo, MediaTypeImage, MediaTypeAudio, MediaTypeHeic }; -static __weak UICollectionView *gFeedCV = nil; +// 调节模式&全局状态 +typedef NS_ENUM(NSUInteger, DYEdgeMode) { + DYEdgeModeNone = 0, + DYEdgeModeBrightness = 1, + DYEdgeModeVolume = 2, +}; + +@interface UIView (DYYYGlobalAlpha) +- (void)dyyy_applyGlobalTransparency; +@end + // 音量控制 @interface AVSystemController : NSObject + (instancetype)sharedAVSystemController; @@ -21,15 +32,6 @@ static __weak UICollectionView *gFeedCV = nil; + (instancetype)sharedInstance; - (void)presentHUDWithIcon:(NSString *)name level:(float)level; @end -// 调节模式&全局状态 -typedef NS_ENUM(NSUInteger, DYEdgeMode) { - DYEdgeModeNone = 0, - DYEdgeModeBrightness = 1, - DYEdgeModeVolume = 2, -}; -static DYEdgeMode gMode = DYEdgeModeNone; -static CGFloat gStartY = 0.0; -static CGFloat gStartVal = 0.0; @interface URLModel : NSObject @property(nonatomic, strong) NSArray *originURLList; @@ -351,6 +353,9 @@ static CGFloat gStartVal = 0.0; @interface AWENormalModeTabBar : UIView @property(nonatomic, assign, readonly) UITabBarController *yy_viewController; @property(retain, nonatomic) AWETabBarSkinContainerView *skinContainerView; +- (void)initializeOriginalTabBarHeight; +- (void)calculateTabBarHeight; +- (BOOL)applyTabBarHeight; @end @interface AWEPlayInteractionListenFeedView : UIView diff --git a/DYYY.xm b/DYYY.xm index 4087f1b40..24be94822 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -23,11 +23,19 @@ #import "DYYYToast.h" #import "DYYYUtils.h" -static CGFloat DYYYCurrentTabHeight(void); +static CGFloat gStartY = 0.0; +static CGFloat gStartVal = 0.0; +static DYEdgeMode gMode = DYEdgeModeNone; +static __weak UICollectionView *gFeedCV = nil; + static const CGFloat kInvalidAlpha = -1.0; +static const CGFloat kInvalidHeight = -1.0; static CGFloat gGlobalTransparency = kInvalidAlpha; +static CGFloat gCurrentTabBarHeight = kInvalidHeight; +static CGFloat originalTabBarHeight = kInvalidHeight; static NSString *const kDYYYGlobalTransparencyKey = @"DYYYGlobalTransparency"; static NSString *const kDYYYGlobalTransparencyDidChangeNotification = @"DYYYGlobalTransparencyDidChangeNotification"; +static NSString *const kDYYYTabBarHeightKey = @"DYYYTabBarHeight"; static void updateGlobalTransparencyCache() { NSString *transparentValue = DYYYGetString(kDYYYGlobalTransparencyKey); @@ -4314,11 +4322,10 @@ static CGFloat DYYYDesiredMTKViewShiftOffset(UIView *view) { if (viewWidth < screenWidth * 0.995f) { return 0.0f; } - CGFloat tabHeight = DYYYCurrentTabHeight(); - if (tabHeight <= 0.0f) { + if (gCurrentTabBarHeight <= 0.0f) { return 0.0f; } - return tabHeight * 0.5f; + return gCurrentTabBarHeight * 0.5f; } static void DYYYApplyMTKViewShiftIfNeeded(UIView *view) { @@ -4930,19 +4937,13 @@ static void DYYYApplyMTKViewShiftIfNeeded(UIView *view) { %end // 底栏高度 -static CGFloat tabHeight = 0; -static CGFloat originalTabHeight = 0; - -static CGFloat DYYYCurrentTabHeight(void) { return tabHeight; } - %hook AWENormalModeTabBar static Class barBackgroundClass = nil; static Class generalButtonClass = nil; static Class plusButtonClass = nil; static Class tabBarButtonClass = nil; -static NSString *const TabBarHeightKey = @"DYYYTabBarHeight"; -static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; +static void *DYYYTabBarHeightContext = &DYYYTabBarHeightContext; + (void)initialize { if (self == [%c(AWENormalModeTabBar) class]) { @@ -4953,70 +4954,139 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; } } +%new +- (void)initializeOriginalTabBarHeight { + if (originalTabBarHeight != kInvalidHeight) { + NSLog(@"[DYYY] initializeOriginalTabBarHeight: Skipped! originalTabBarHeight already initialized."); + return; + } + + UIWindow *targetWindow = self.window ?: [DYYYUtils getActiveWindow]; + if (self.frame.size.height >= 30) { + originalTabBarHeight = self.frame.size.height; + NSLog(@"[DYYY] initializeOriginalTabBarHeight: Success! originalTabBarHeight set to %.1f (from self.frame.size.height)", originalTabBarHeight); + } else if (targetWindow) { + CGFloat bottomInset = targetWindow.safeAreaInsets.bottom; + originalTabBarHeight = 49 + bottomInset; + NSLog(@"[DYYY] initializeOriginalTabBarHeight: Success! originalTabBarHeight set to %.1f (fallback calculation: 49.0 + %.1f)", originalTabBarHeight, bottomInset); + } else { + NSLog(@"[DYYY] initializeOriginalTabBarHeight: Failed! No window available."); + } +} + +%new +- (void)calculateTabBarHeight { + if (originalTabBarHeight == kInvalidHeight) { + NSLog(@"[DYYY] calculateTabBarHeight: Skipped! originalTabBarHeight not initialized yet."); + return; + } + + CGFloat newHeight = originalTabBarHeight; + NSString *tabBarHeightStr = [[NSUserDefaults standardUserDefaults] stringForKey:kDYYYTabBarHeightKey]; + + if (tabBarHeightStr.length > 0) { + float tabBarHeightValue; + NSScanner *scanner = [NSScanner scannerWithString:tabBarHeightStr]; + if ([scanner scanFloat:&tabBarHeightValue]) { + newHeight = MAX(tabBarHeightValue, 0.0); + } else { + NSLog(@"[DYYY] calculateTabBarHeight: Failed! Could not parse float value for key %@: '%@'", kDYYYTabBarHeightKey, tabBarHeightStr); + } + } + + if (fabs(gCurrentTabBarHeight - newHeight) > 0.1) { + NSLog(@"[DYYY] calculateTabBarHeight: Success! gCurrentTabBarHeight updated from %.1f to %.1f", gCurrentTabBarHeight, newHeight); + gCurrentTabBarHeight = newHeight; + } +} + +%new +- (BOOL)applyTabBarHeight { + if (gCurrentTabBarHeight == kInvalidHeight) { + NSLog(@"[DYYY] applyTabBarHeight: Skipped! gCurrentTabBarHeight not calculated yet."); + return NO; + } + + CGRect frame = self.frame; + if (fabs(frame.size.height - gCurrentTabBarHeight) < 0.1) { + NSLog(@"[DYYY] applyTabBarHeight: Skipped! Frame height already applied."); + return NO; + } + + if ([self respondsToSelector:@selector(setDesiredHeight:)]) { + ((void (*)(id, SEL, double))objc_msgSend)(self, @selector(setDesiredHeight:), gCurrentTabBarHeight); + } + + frame.size.height = gCurrentTabBarHeight; + if (self.superview) { + frame.origin.y = self.superview.bounds.size.height - gCurrentTabBarHeight; + } + self.frame = frame; + NSLog(@"[DYYY] applyTabBarHeight: Success! Frame height applied to %.1f", gCurrentTabBarHeight); + return YES; +} + - (instancetype)initWithFrame:(CGRect)frame { self = %orig; if (self) { - [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:TabBarHeightKey options:NSKeyValueObservingOptionNew context:TabBarHeightObservationContext]; + [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:kDYYYTabBarHeightKey options:NSKeyValueObservingOptionNew context:DYYYTabBarHeightContext]; } return self; } - (void)dealloc { @try { - [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:TabBarHeightKey context:TabBarHeightObservationContext]; + [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:kDYYYTabBarHeightKey context:DYYYTabBarHeightContext]; } @catch (NSException *exception) { NSLog(@"[DYYY] KVO removeObserver failed: %@", exception); } %orig; } -%new -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == TabBarHeightObservationContext) { +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context { + if (context == DYYYTabBarHeightContext) { + __weak __typeof(self) weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - [self setNeedsLayout]; + __strong __typeof(weakSelf) strongSelf = weakSelf; + if (strongSelf) { + NSLog(@"[DYYY] observeValueForKeyPath: %@ has new value: '%@'", kDYYYTabBarHeightKey, change[NSKeyValueChangeNewKey]); + if (originalTabBarHeight == kInvalidHeight) { + [strongSelf initializeOriginalTabBarHeight]; + } + [strongSelf calculateTabBarHeight]; + [strongSelf applyTabBarHeight]; + } }); } } +- (void)didMoveToWindow { + %orig; + if (self.window) { + [self initializeOriginalTabBarHeight]; + [self calculateTabBarHeight]; + } +} + - (void)layoutSubviews { %orig; - if (originalTabHeight == 0) { - NSString *sourceDescription = @""; - if (self.frame.size.height > 30) { - originalTabHeight = self.frame.size.height; - sourceDescription = [NSString stringWithFormat:@"from self.frame.size.height: %.1f", originalTabHeight]; - } else { - CGFloat bottomInset = (self.window ?: [DYYYUtils getActiveWindow]).safeAreaInsets.bottom; - originalTabHeight = 49 + bottomInset; - sourceDescription = [NSString stringWithFormat:@"by fallback calculation: 49.0 + %.1f", bottomInset]; - } - NSLog(@"[DYYY] Initialized originalTabHeight: %.1f (%@)", originalTabHeight, sourceDescription); + if (originalTabBarHeight == kInvalidHeight) { + NSLog(@"[DYYY] layoutSubviews: Fallback! originalTabBarHeight initialization triggered."); + [self initializeOriginalTabBarHeight]; } - CGFloat customHeight = DYYYGetFloat(@"DYYYTabBarHeight"); - tabHeight = (customHeight > 0) ? customHeight : originalTabHeight; + if (gCurrentTabBarHeight == kInvalidHeight) { + NSLog(@"[DYYY] layoutSubviews: Fallback! gCurrentTabBarHeight calculation triggered."); + [self calculateTabBarHeight]; + } - if (tabHeight <= 0) + if ([self applyTabBarHeight]) return; - if (fabs(self.frame.size.height - tabHeight) > 0.1) { - NSLog(@"[DYYY] Adjusting tabHeight to: %1f", tabHeight); - - if ([self respondsToSelector:@selector(setDesiredHeight:)]) { - ((void (*)(id, SEL, double))objc_msgSend)(self, @selector(setDesiredHeight:), tabHeight); - } - - CGRect frame = self.frame; - frame.size.height = tabHeight; - if (self.superview) { - frame.origin.y = self.superview.bounds.size.height - tabHeight; - } - self.frame = frame; - return; - } - BOOL hideShop = DYYYGetBool(@"DYYYHideShopButton"); BOOL hideMsg = DYYYGetBool(@"DYYYHideMessageButton"); BOOL hideFri = DYYYGetBool(@"DYYYHideFriendsButton"); @@ -5115,7 +5185,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; continue; } // 隐藏底栏背景 - if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabHeight > 0 && fabs(subview.frame.size.height - tabHeight) < 0.1)) { + if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabBarHeight > 0 && fabs(subview.frame.size.height - gCurrentTabBarHeight) < 0.1)) { subview.hidden = shouldHideBackgrounds; } // 隐藏细分割线 @@ -5188,7 +5258,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; continue; } // 隐藏底栏背景 - if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabHeight > 0 && fabs(subview.frame.size.height - tabHeight) < 0.1)) { + if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabBarHeight > 0 && fabs(subview.frame.size.height - gCurrentTabBarHeight) < 0.1)) { subview.hidden = shouldHideBackgrounds; } // 隐藏细分割线 @@ -5460,10 +5530,10 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; - (void)layoutSubviews { %orig; - if (DYYYGetBool(@"DYYYEnableFullScreen") && tabHeight > 0) { + if (DYYYGetBool(@"DYYYEnableFullScreen") && gCurrentTabBarHeight > 0) { for (UIView *subview in self.subviews) { CGRect frame = subview.frame; - frame.origin.y -= tabHeight; + frame.origin.y -= gCurrentTabBarHeight; subview.frame = frame; } } @@ -5479,7 +5549,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; return; } - CGAffineTransform newTransform = CGAffineTransformMakeTranslation(0, originalTabHeight - tabHeight); + CGAffineTransform newTransform = CGAffineTransformMakeTranslation(0, originalTabBarHeight - gCurrentTabBarHeight); if (!CGAffineTransformEqualToTransform(self.transform, newTransform)) { self.transform = newTransform; @@ -5635,7 +5705,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; %orig; if (DYYYGetBool(@"DYYYEnableFullScreen")) { - if (self.frame.size.height == originalTabHeight && originalTabHeight > 0) { + if (self.frame.size.height == originalTabBarHeight && originalTabBarHeight > 0) { UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView:self]; if ([vc isKindOfClass:NSClassFromString(@"AWEMixVideoPanelDetailTableViewController")] || [vc isKindOfClass:NSClassFromString(@"AWECommentInputViewController")] || [vc isKindOfClass:NSClassFromString(@"AWEAwemeDetailTableViewController")]) { @@ -5686,11 +5756,28 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; %orig(frame); return; } - CGRect superF = self.superview.frame; - if (CGRectGetHeight(superF) > 0 && CGRectGetHeight(frame) > 0 && CGRectGetHeight(frame) < CGRectGetHeight(superF)) { - CGFloat diff = CGRectGetHeight(superF) - CGRectGetHeight(frame); - if (fabs(diff - tabHeight) < 1.0) { - frame.size.height = CGRectGetHeight(superF); + + if (fabs(frame.origin.x) > 0.1 || fabs(frame.origin.y) > 0.1) { + %orig(frame); + return; + } + + UIView *superView = self.superview; + if (!superView) { + %orig(frame); + return; + } + + CGFloat superHeight = CGRectGetHeight(superView.bounds); + CGFloat frameHeight = CGRectGetHeight(frame); + CGFloat frameWidth = CGRectGetWidth(frame); + + if (superHeight > 0 && frameHeight > 0 && frameHeight < superHeight) { + CGFloat diff = superHeight - frameHeight; + BOOL isLandscapeFrame = (frameWidth > frameHeight); + + if (!isLandscapeFrame && fabs(diff - gCurrentTabBarHeight) < 1.0) { + frame.size.height = superHeight; } } @@ -5868,7 +5955,7 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; if (useFullHeight) { frame.size.height = superviewHeight; } else { - frame.size.height = superviewHeight - tabHeight; + frame.size.height = superviewHeight - gCurrentTabBarHeight; } if (fabs(frame.size.height - self.view.frame.size.height) > 0.5) { @@ -6045,11 +6132,11 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; CGRect frame = contentView.frame; CGFloat parentHeight = contentView.superview.frame.size.height; - if (frame.size.height == parentHeight - tabHeight) { + if (frame.size.height == parentHeight - gCurrentTabBarHeight) { frame.size.height = parentHeight; contentView.frame = frame; - } else if (frame.size.height == parentHeight - (tabHeight * 2)) { - frame.size.height = parentHeight - tabHeight; + } else if (frame.size.height == parentHeight - (gCurrentTabBarHeight * 2)) { + frame.size.height = parentHeight - gCurrentTabBarHeight; contentView.frame = frame; } } @@ -6110,14 +6197,14 @@ static void *TabBarHeightObservationContext = &TabBarHeightObservationContext; CGRect frame = self.frame; frame.size.height = self.superview.frame.size.height; self.frame = frame; - } else if (tabHeight > 0) { + } else if (gCurrentTabBarHeight > 0) { UIWindow *keyWindow = [DYYYUtils getActiveWindow]; if (keyWindow && keyWindow.safeAreaInsets.bottom == 0) { return; } CGRect frame = self.frame; - frame.size.height = self.superview.frame.size.height - tabHeight; + frame.size.height = self.superview.frame.size.height - gCurrentTabBarHeight; self.frame = frame; } } @@ -6478,9 +6565,9 @@ static Class TagViewClass = nil; CGFloat targetHeight, tx, ty = 0; UIWindow *keyWindow = [DYYYUtils getActiveWindow]; if (keyWindow && keyWindow.safeAreaInsets.bottom == 0) { - targetHeight = tabHeight - originalTabHeight; + targetHeight = gCurrentTabBarHeight - originalTabBarHeight; } else { - targetHeight = tabHeight; + targetHeight = gCurrentTabBarHeight; } if ([DYYYUtils containsSubviewOfClass:GuideViewClass inContainer:self]) { @@ -6652,9 +6739,9 @@ static Class TagViewClass = nil; CGFloat targetHeight, tx, ty = 0; UIWindow *keyWindow = [DYYYUtils getActiveWindow]; if (keyWindow && keyWindow.safeAreaInsets.bottom == 0) { - targetHeight = tabHeight - originalTabHeight; + targetHeight = gCurrentTabBarHeight - originalTabBarHeight; } else { - targetHeight = tabHeight; + targetHeight = gCurrentTabBarHeight; } if ([DYYYUtils containsSubviewOfClass:GuideViewClass inContainer:self]) { @@ -6724,7 +6811,7 @@ static Class TagViewClass = nil; CGRect frame = subview.frame; if (DYYYGetBool(@"DYYYEnableFullScreen")) { - frame.size.height = subview.superview.frame.size.height - tabHeight; + frame.size.height = subview.superview.frame.size.height - gCurrentTabBarHeight; subview.frame = frame; } } @@ -6744,7 +6831,7 @@ static Class TagViewClass = nil; if (isWorkImage) { // 修复作者主页作品图片上移问题 CGRect frame = subview.frame; - frame.origin.y += tabHeight; + frame.origin.y += gCurrentTabBarHeight; subview.frame = frame; } } @@ -6785,7 +6872,7 @@ static Class TagViewClass = nil; - (void)setCenter:(CGPoint)center { UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView:self]; if ([vc isKindOfClass:NSClassFromString(@"AWEFeedPlayControlImpl.PureModePageCellViewController")] && DYYYGetBool(@"DYYYEnableFullScreen")) { - center.y -= tabHeight; + center.y -= gCurrentTabBarHeight; } %orig(center); } @@ -6803,6 +6890,13 @@ static Class TagViewClass = nil; %end %hook AWELandscapeFeedEntryView +- (void)setCenter:(CGPoint)center { + if (DYYYGetBool(@"DYYYEnableFullScreen")) { + center.y += gCurrentTabBarHeight * 0.5; + } + + %orig(center); +} - (void)setAlpha:(CGFloat)alpha { CGFloat finalAlpha = alpha; @@ -6874,8 +6968,8 @@ static Class TagViewClass = nil; - (void)setFrame:(CGRect)frame { if (DYYYGetBool(@"DYYYEnableFullScreen")) { - CGFloat targetY = frame.origin.y - tabHeight; - CGFloat screenHeightMinusGDiff = [UIScreen mainScreen].bounds.size.height - tabHeight; + CGFloat targetY = frame.origin.y - gCurrentTabBarHeight; + CGFloat screenHeightMinusGDiff = [UIScreen mainScreen].bounds.size.height - gCurrentTabBarHeight; CGFloat tolerance = 10.0; @@ -6921,7 +7015,7 @@ static Class TagViewClass = nil; } } if (target) { - target.hidden = ([(UIView *)self frame].size.height == tabHeight); + target.hidden = ([(UIView *)self frame].size.height == gCurrentTabBarHeight); } } } From e0e986e570e1a7c3457071063d7e3ec19628c939 Mon Sep 17 00:00:00 2001 From: PaTTeeL Date: Mon, 29 Sep 2025 18:59:50 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E5=BA=95=E6=A0=8F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8B=86=E5=88=86=E8=A7=86=E5=9B=BE=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E5=92=8C=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DYYY.xm | 64 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/DYYY.xm b/DYYY.xm index 24be94822..500190d49 100644 --- a/DYYY.xm +++ b/DYYY.xm @@ -5209,60 +5209,59 @@ static void *DYYYTabBarHeightContext = &DYYYTabBarHeightContext; - (void)setHidden:(BOOL)hidden { %orig(hidden); - // 禁用首页刷新功能 - if (DYYYGetBool(@"DYYYDisableHomeRefresh")) { - for (UIView *subview in self.subviews) { - if ([subview isKindOfClass:generalButtonClass]) { - AWENormalModeTabBarGeneralButton *button = (AWENormalModeTabBarGeneralButton *)subview; + BOOL disableHomeRefresh = DYYYGetBool(@"DYYYDisableHomeRefresh"); + BOOL enableFullScreen = DYYYGetBool(@"DYYYEnableFullScreen"); + BOOL hideBottomBg = DYYYGetBool(@"DYYYHideBottomBg"); + BOOL hideFriendsButton = DYYYGetBool(@"DYYYHideFriendsButton"); + + BOOL isHomeSelected = NO; + BOOL isFriendsSelected = NO; + + for (UIView *subview in self.subviews) { + if ([subview isKindOfClass:generalButtonClass]) { + AWENormalModeTabBarGeneralButton *button = (AWENormalModeTabBarGeneralButton *)subview; + + // 禁用首页刷新功能 + if (disableHomeRefresh && [button.accessibilityLabel isEqualToString:@"首页"]) { + button.userInteractionEnabled = (button.status != 2); + } + + // 检查当前选中的页 + if (enableFullScreen && button.status == 2) { if ([button.accessibilityLabel isEqualToString:@"首页"]) { - // status == 2 表示选中状态 - button.userInteractionEnabled = (button.status != 2); + isHomeSelected = YES; + } else if ([button.accessibilityLabel containsString:@"朋友"]) { + isFriendsSelected = YES; } } } } - // 背景和分隔线处理 - BOOL hideBottomBg = DYYYGetBool(@"DYYYHideBottomBg"); - BOOL enableFullScreen = DYYYGetBool(@"DYYYEnableFullScreen"); - if (hideBottomBg || enableFullScreen) { if (self.skinContainerView) { self.skinContainerView.hidden = YES; } - BOOL isHomeSelected = NO; - BOOL isFriendsSelected = NO; - - if (enableFullScreen && !hideBottomBg) { - for (UIView *subview in self.subviews) { - if ([subview isKindOfClass:generalButtonClass]) { - AWENormalModeTabBarGeneralButton *button = (AWENormalModeTabBarGeneralButton *)subview; - if (button.status == 2) { - if ([button.accessibilityLabel isEqualToString:@"首页"]) - isHomeSelected = YES; - else if ([button.accessibilityLabel containsString:@"朋友"]) - isFriendsSelected = YES; - } - } - } + BOOL shouldHideBackgrounds = NO; + if (hideBottomBg) { + shouldHideBackgrounds = YES; + } else if (enableFullScreen) { + shouldHideBackgrounds = isHomeSelected || (isFriendsSelected && !hideFriendsButton); } - BOOL hideFriendsButton = DYYYGetBool(@"DYYYHideFriendsButton"); - BOOL shouldHideBackgrounds = hideBottomBg || (enableFullScreen && (isHomeSelected || (isFriendsSelected && !hideFriendsButton))); - - // 单次遍历处理所有背景和分割线 + // 处理所有背景和分割线 for (UIView *subview in self.subviews) { + CGFloat subviewHeight = subview.frame.size.height; // 跳过底栏按钮 if ([subview isKindOfClass:generalButtonClass] || [subview isKindOfClass:plusButtonClass]) { continue; } // 隐藏底栏背景 - if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabBarHeight > 0 && fabs(subview.frame.size.height - gCurrentTabBarHeight) < 0.1)) { + if ([subview isKindOfClass:barBackgroundClass] || ([subview isMemberOfClass:[UIView class]] && originalTabBarHeight > 0 && fabs(subviewHeight - gCurrentTabBarHeight) < 0.1)) { subview.hidden = shouldHideBackgrounds; } // 隐藏细分割线 - if (subview.frame.size.height > 0 && subview.frame.size.height < 1 && subview.frame.size.width > 300) { + if (subviewHeight > 0 && subviewHeight < 1 && subview.frame.size.width > 300) { subview.hidden = enableFullScreen; } } @@ -5270,7 +5269,6 @@ static void *DYYYTabBarHeightContext = &DYYYTabBarHeightContext; if (self.skinContainerView) { self.skinContainerView.hidden = NO; } - for (UIView *subview in self.subviews) { if ([subview isKindOfClass:barBackgroundClass] || [subview isMemberOfClass:[UIView class]]) { subview.hidden = NO;