Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
// What drives the native look's navbar: Spotify's tab bar composed on its layout passes (Navbar.x), and
// holding Home opens Mod Settings.
//
// Tree (trees/home.txt): NavigationUI_TabBarImpl.TabBarView > TabBarCompactView > UIStackView of
// ElementContentView<TabBarItemElement>, each with an SPTEncoreIconView and an SPTEncoreLabel.
#import "Core/SGCore.h"
#import "Navbar.h"
#import "Settings/SGPage.h"
#import "Shared/Navigation/TabItems.h"
@interface SGHomeHold : UILongPressGestureRecognizer
@end
@implementation SGHomeHold
+ (void)held:(SGHomeHold *)hold {
if (hold.state == UIGestureRecognizerStateBegan) SGOpenModSettings(hold.view);
}
@end
// On Spotify's own bar a hold that begins fails the item's tap recognizer, so Home is not tapped too.
static void holdHome(UIView *stockBar) {
UIView *home = SGRowIn(stockBar).arrangedSubviews.firstObject;
if (!home) return;
for (UIGestureRecognizer *recognizer in home.gestureRecognizers) {
if ([recognizer isKindOfClass:SGHomeHold.class]) return;
}
[home addGestureRecognizer:[[SGHomeHold alloc] initWithTarget:SGHomeHold.class action:@selector(held:)]];
}
%hook _TtC23NavigationUI_TabBarImpl10TabBarView
- (void)layoutSubviews {
%orig;
SGComposeTabBar((UIView *)self);
holdHome((UIView *)self);
SGLogTabBarRow((UIView *)self);
}
%end
// The bar's own pass runs before Spotify has filled the row; the items lay out as they arrive.
static void itemDidLayOut(UIView *item) {
UIView *bar = tabBarOf(item);
if (!bar) return;
SGComposeTabBar(bar);
holdHome(bar);
SGLogTabBarRow(bar);
}
%hook _TtC23NavigationUI_TabBarImpl21TabBarItemElementView
- (void)layoutSubviews {
%orig;
itemDidLayOut((UIView *)self);
}
%end
%hook _TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView
- (void)layoutSubviews {
%orig;
itemDidLayOut((UIView *)self);
}
%end
%ctor {
if (!SGNativeUI()) return;
%init;
SGRequireClasses(@[
@"_TtC23NavigationUI_TabBarImpl10TabBarView",
@"_TtC23NavigationUI_TabBarImpl21TabBarItemElementView",
@"_TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView",
]);
}