Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

fix: the volume slider keeps its thumbless style when MPVolumeView makes a new slider

My-Name-Is-Jeff9c5bf8c4b7bd
diff --git a/tweak/Sources/Redesigned/Player/PlayerVolume.m b/tweak/Sources/Redesigned/Player/PlayerVolume.m
index 53466495..d05ff8fd 100644
--- a/tweak/Sources/Redesigned/Player/PlayerVolume.m
+++ b/tweak/Sources/Redesigned/Player/PlayerVolume.m
@@ -19,13 +19,34 @@ static const CGFloat kGlyphsHalf = 14;
// The slider draws its track this far above its own middle (6.5px measured on the phone), so the glyphs go up with it.
static const CGFloat kTrackAbove = 2;
+// iOS 26's thumbless slider is the one the progress bar above and the Music app's volume use: it grows under the finger
+// and drags from anywhere on the track. MPVolumeView makes its slider when it lays out and may make another later, so
+// the style goes on after each of its layouts.
+@interface SGRVolumeView : MPVolumeView
+@end
+
+@implementation SGRVolumeView
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ if (@available(iOS 26.0, *)) {
+ for (UISlider *slider in self.subviews) {
+ if (![slider isKindOfClass:UISlider.class] || slider.sliderStyle == UISliderStyleThumbless) continue;
+ slider.sliderStyle = UISliderStyleThumbless;
+ slider.minimumTrackTintColor = UIColor.whiteColor;
+ slider.maximumTrackTintColor = [UIColor colorWithWhite:1 alpha:0.22];
+ }
+ }
+}
+
+@end
+
@interface SGRVolumeRow : UIView
@end
@implementation SGRVolumeRow {
MPVolumeView *_volume;
UIImageView *_quiet, *_loud;
- BOOL _styled;
}
static UIImage *trackImage(UIColor *color) {
@@ -47,14 +68,6 @@ static UIImage *thumbImage(void) {
}];
}
-// MPVolumeView's slider, the one view of it that is a UISlider.
-static UISlider *sliderIn(UIView *view) {
- for (UIView *sub in view.subviews) {
- if ([sub isKindOfClass:UISlider.class]) return (UISlider *)sub;
- }
- return nil;
-}
-
static UIImageView *glyph(NSString *symbol) {
UIImageSymbolConfiguration *configuration = [UIImageSymbolConfiguration configurationWithPointSize:kGlyphSize weight:UIImageSymbolWeightSemibold];
UIImageView *view = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:symbol withConfiguration:configuration]];
@@ -66,11 +79,17 @@ static UIImageView *glyph(NSString *symbol) {
- (instancetype)initWithFrame:(CGRect)frame {
if (!(self = [super initWithFrame:frame])) return nil;
- _volume = [MPVolumeView new];
+ _volume = [SGRVolumeView new];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_volume.showsRouteButton = NO;
#pragma clang diagnostic pop
+ if (@available(iOS 26.0, *)) {
+ } else {
+ [_volume setMinimumVolumeSliderImage:trackImage(UIColor.whiteColor) forState:UIControlStateNormal];
+ [_volume setMaximumVolumeSliderImage:trackImage([UIColor colorWithWhite:1 alpha:0.22]) forState:UIControlStateNormal];
+ [_volume setVolumeThumbImage:thumbImage() forState:UIControlStateNormal];
+ }
_quiet = glyph(@"speaker.fill");
_loud = glyph(@"speaker.wave.3.fill");
[self addSubview:_quiet];
@@ -79,28 +98,8 @@ static UIImageView *glyph(NSString *symbol) {
return self;
}
-// iOS 26's thumbless slider is the one the progress bar above and the Music app's volume use: it grows under the finger
-// and drags from anywhere on the track. Older systems keep a drawn track and thumb. MPVolumeView makes its slider when it
-// first lays out, so the style goes on then.
-- (void)styleSlider {
- UISlider *slider = sliderIn(_volume);
- if (_styled || !slider) return;
- _styled = YES;
- if (@available(iOS 26.0, *)) {
- slider.sliderStyle = UISliderStyleThumbless;
- slider.minimumTrackTintColor = UIColor.whiteColor;
- slider.maximumTrackTintColor = [UIColor colorWithWhite:1 alpha:0.22];
- return;
- }
- [_volume setMinimumVolumeSliderImage:trackImage(UIColor.whiteColor) forState:UIControlStateNormal];
- [_volume setMaximumVolumeSliderImage:trackImage([UIColor colorWithWhite:1 alpha:0.22]) forState:UIControlStateNormal];
- [_volume setVolumeThumbImage:thumbImage() forState:UIControlStateNormal];
-}
-
- (void)layoutSubviews {
[super layoutSubviews];
- [_volume layoutIfNeeded];
- [self styleSlider];
CGRect bounds = self.bounds;
CGFloat side = kRowHeight, middle = CGRectGetMidY(bounds), glyphs = middle - kTrackAbove;
_quiet.frame = CGRectMake(0, glyphs - side / 2, side / 2 + kGlyphSize / 2, side);