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
1.5 KB
Raw Blame
// The device button of Spotify's own now playing bar, hidden on request.
//
// Tree (trees/test6.txt): the button row is a UIStackView holding Connect_EntryPointsImpl.ConnectStateView
// (the connected device) and .ConnectButtonView, each wrapped; hiding the wrapper closes the gap.
// The ConnectStateView under the title ("playing on ...") sits in InformationContainer and stays.
#import "Core/SGCore.h"
#import "NowPlayingBar.h"

// `marker` is a literal: SGClassNamed keeps its answers by the marker's address.
static BOOL insideClass(UIView *view, NSString *marker) {
    for (UIView *v = view; v; v = v.superview) if (SGClassNamed(v.class, marker)) return YES;
    return NO;
}

static void hideConnectButton(UIView *bar) {
    SGForEachView(bar, ^(UIView *v) {
        Class cls = v.class;
        if (!SGClassNamed(cls, @"ConnectButtonView") && !SGClassNamed(cls, @"ConnectStateView")) return;
        if (insideClass(v, @"InformationContainer")) return;
        UIView *item = v;
        while (item.superview && ![item.superview isKindOfClass:UIStackView.class]) item = item.superview;
        if (item.superview && !item.hidden) item.hidden = YES;
    });
}

%hook _TtC18NowPlaying_BarImpl27NowPlayingBarViewController
- (void)viewDidLayoutSubviews {
    %orig;
    hideConnectButton(((UIViewController *)self).view);
}
%end

%ctor {
    if (!SGNativeUI() || !SGHidden(SGHideBarConnect)) return;
    %init;
    SGRequireClasses(@[@"_TtC18NowPlaying_BarImpl27NowPlayingBarViewController"]);
}