Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Split tabs sets chosen tabs apart at the right end of the bar
My-Name-Is-Jeff06d5f8b9402f
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 2d4a18ac..d25863f9 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -143,7 +143,9 @@ Shared:as the picture of a local file whose metadata names none. A cover picked in Edit info wins.The model and the LRC reading are checked on the Mac against harness/local-files/, the row andthe editor in the simulator against its sim/- Navigation/ the page transition fix (PageTransition.x) and opening a spotify: link (Links.x)+ Navigation/ the page transition fix (PageTransition.x), opening a spotify: link (Links.x), and either look's+ Add a Tab sheet (AddTabSheet.m) with the icons a tab can wear, Encore's glyphs or SF Symbols+ (TabIcons.m). The sheet runs in the simulator in harness/addtab/Player/ the player's open and close announced (PlayerEvents.x), what the player is doing read throughone hook for every feature that wants it (PlayerState.x), the lock screen widget's flags, and in themore button's menu Speed and pitch: both done to Spotify's audio by Apple's time and pitch unit, put@@ -435,7 +437,10 @@ registers in `Core/SGFlagForce.h`. A change shows after Spotify restarts.The tab editor on the Navbar page is the exception and applies as soon as the bar lays out again. It lists the tabs in the orderthe bar shows them: drag to reorder, tap to hide or show, and Add a tab puts a page of Spotify's or-any `spotify:` link on the bar with one of Encore's own glyphs. Spotify's own tabs are kept by the+any `spotify:` link on the bar. It is a sheet: a name, a link picked from Spotify's pages or pasted (one+Spotify's router cannot open is refused there), and an icon picked from Encore's glyphs or the SF Symbols,+searchable. Split tabs sets chosen tabs apart at the right end of the bar: after a gap in the native look,+on a glass bar of their own in the redesign, like Search in the Music app. Spotify's own tabs are kept by thename under their icon, so they can be hidden but never removed, and switching the app's languagestarts the order over. A tab of the mod's own opens its link through Spotify's link dispatcher, so itnever lights up as the tab you are on. Hide labels, on the same page, leaves the glass bar with itsdiff --git a/harness/tabbar/README.md b/harness/tabbar/README.mdindex 9a1c4dc6..50789e55 100644--- a/harness/tabbar/README.md+++ b/harness/tabbar/README.md@@ -36,6 +36,11 @@ logged in window points, with the gap between the bottom of the now playing cardglass bar's platter (8 pt is the redesign's own, on a Face ID phone with nothing under the bar), andhalf way through a slide what the screen shows of the message bar, the tab bar and the now playing bar:+`split` after the first word makes Search a split tab (stubs.m answers `SGRTabIsApart` for it), so it+stands on a glass bar of its own, and the platters of both bars are logged. `pick` picks Search at 2 s and+Home at 4 s through the system bar's delegate, the mock tab repainting its label white as Spotify's does,+and logs which bar selects what after each: `xcrun simctl launch <udid> com.vojta.tabbarharness pick split`.+xcrun simctl spawn <udid> log show --last 1m --style compact --predicate 'eventMessage CONTAINS "[harness]" OR eventMessage CONTAINS "tab bar:"'`jam` plays a Jam: a strip under the class name of Spotify's (a SwiftUI hosting view ofdiff --git a/harness/tabbar/main.m b/harness/tabbar/main.mindex 66d52f81..571dc2f6 100644--- a/harness/tabbar/main.m+++ b/harness/tabbar/main.m@@ -179,8 +179,19 @@ static __weak UIView *sgJamStrip;- (UIView *)tabBarView { return self.bar; }- (void)setSelectedViewController:(UIViewController *)controller {}+// A tap on a mock item does what Spotify's does to the bar: its label goes white and the others grey.++ (void)tapped:(UITapGestureRecognizer *)tap {+ for (UIView *item in tap.view.superview.subviews) {+ for (UIView *sub in item.subviews) {+ if ([sub isKindOfClass:UILabel.class]) ((UILabel *)sub).textColor = item == tap.view ? UIColor.whiteColor : [UIColor colorWithWhite:0xB3 / 255.0 alpha:1];+ }+ }+ for (UIView *v = tap.view; v; v = v.superview) [v setNeedsLayout];+}+static UIView *item(Class cls, NSString *title, NSString *symbol, BOOL active) {UIView *item = [cls new];+ [item addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:_TtC23NavigationUI_TabBarImpl19TabBarContainerImpl.class action:@selector(tapped:)]];UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:symbol]];icon.tintColor = UIColor.whiteColor;icon.contentMode = UIViewContentModeScaleAspectFit;@@ -382,6 +393,32 @@ static UITabBar *systemBarIn(UIView *root) {return nil;}+static NSArray<UITabBar *> *systemBarsIn(UIView *root) {+ NSMutableArray<UITabBar *> *bars = [NSMutableArray array];+ if ([root isKindOfClass:UITabBar.class]) [bars addObject:(UITabBar *)root];+ else for (UIView *sub in root.subviews) [bars addObjectsFromArray:systemBarsIn(sub)];+ return bars;+}++// A tab picked on whichever system bar shows it, the calls a finger ends in.+static void pick(SGHarnessChrome *chrome, NSString *title) {+ for (UITabBar *bar in systemBarsIn(chrome.tabs.bar)) {+ for (UITabBarItem *item in bar.items) {+ if (![item.title isEqualToString:title]) continue;+ bar.selectedItem = item;+ [bar.delegate tabBar:bar didSelectItem:item];+ }+ }+}++static void reportSelection(SGHarnessChrome *chrome, NSString *moment) {+ NSMutableString *out = [NSMutableString stringWithFormat:@"[harness] %@ selection", moment];+ for (UITabBar *bar in systemBarsIn(chrome.tabs.bar)) {+ [out appendFormat:@" | bar%@ %@: %@", bar.hidden ? @" (hidden)" : @"", [bar.items valueForKey:@"title"], bar.selectedItem.title ?: @"none"];+ }+ NSLog(@"%@", [out stringByReplacingOccurrencesOfString:@"\n" withString:@" "]);+}+static void report(SGHarnessChrome *chrome, NSString *moment) {UIWindow *window = chrome.view.window;UIView *stock = chrome.tabs.bar;@@ -409,6 +446,18 @@ static void report(SGHarnessChrome *chrome, NSString *moment) {}UIView *strip = sgJamStrip;if (strip.window) NSLog(@"[harness] %@ strip %@", moment, NSStringFromCGRect([strip convertRect:strip.bounds toView:window]));+ // Every glass platter on the bar: with `split`, the main bar's and the split bar's.+ NSMutableString *platters = [NSMutableString stringWithFormat:@"[harness] %@ platters", moment];+ NSMutableArray<UIView *> *found = [NSMutableArray array];+ NSMutableArray<UIView *> *walk = [NSMutableArray arrayWithObject:stock];+ while (walk.count) {+ UIView *v = walk.firstObject;+ [walk removeObjectAtIndex:0];+ if ([NSStringFromClass(v.class) hasSuffix:@"PlatterView"]) [found addObject:v];+ else [walk addObjectsFromArray:v.subviews];+ }+ for (UIView *v in found) [platters appendFormat:@" %@ %@", NSStringFromClass(v.class), NSStringFromCGRect([v convertRect:v.bounds toView:window])];+ NSLog(@"%@", platters);}#pragma mark - the app@@ -454,6 +503,13 @@ static void after(double seconds, dispatch_block_t block) {after(4.5, ^{ report(chrome, @"left the jam"); });}if ([mode isEqualToString:@"away"]) [chrome setBanner:YES animated:NO];+ // `pick`: Search picked at 2 s and Home at 4 s, which bar selects what logged after each.+ if ([mode isEqualToString:@"pick"]) {+ after(2.0, ^{ pick(chrome, @"Search"); });+ after(3.0, ^{ reportSelection(chrome, @"after Search"); });+ after(4.0, ^{ pick(chrome, @"Home"); });+ after(5.0, ^{ reportSelection(chrome, @"after Home"); });+ }after(0.5, ^{UITableView *list = (UITableView *)chrome.tabs.childViewControllers.firstObject.view;[list scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:29 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];diff --git a/harness/tabbar/stubs.m b/harness/tabbar/stubs.mindex 9a139547..c328a7fd 100644--- a/harness/tabbar/stubs.m+++ b/harness/tabbar/stubs.m@@ -11,5 +11,14 @@ __weak UIView *sgr_albumRoot = nil;__weak UIView *sgr_artistRoot = nil;void SGRComposeTabBar(UIView *tabBar) {}++// With `split` among the launch words, Search is a split tab, which TabBar.x stands on a bar of its own.+BOOL SGRTabIsApart(UIView *item) {+ if (![NSProcessInfo.processInfo.arguments containsObject:@"split"]) return NO;+ for (UIView *sub in item.subviews) {+ if ([sub isKindOfClass:UILabel.class] && [((UILabel *)sub).text isEqualToString:@"Search"]) return YES;+ }+ return NO;+}void SGRLogTabBarRow(UIView *tabBar) {}void SGOpenModSettings(UIView *source) {}diff --git a/tweak/Sources/Native/Navbar/Navbar.h b/tweak/Sources/Native/Navbar/Navbar.hindex e839abd7..c393ad22 100644--- a/tweak/Sources/Native/Navbar/Navbar.h+++ b/tweak/Sources/Native/Navbar/Navbar.h@@ -13,6 +13,9 @@ extern NSString *const SGNavbarIconSet; // NSString, SGTabIconSetSymbols when thextern NSString *const SGNavbarHidden; // NSNumberNSArray<NSDictionary *> *SGNavbarLayout(void);void SGSetNavbarLayout(NSArray<NSDictionary *> *layout);+// The tabs set apart at the trailing end of the bar (Split tabs), by their entries' identities.+NSArray<NSString *> *SGNavbarSplit(void);+void SGSetNavbarSplit(NSArray<NSString *> *split);// Spotify's own tabs in Spotify's order, as Navbar.x last saw them on the bar.NSArray<NSString *> *SGNavbarStock(void);void SGSetNavbarStock(NSArray<NSString *> *stock);diff --git a/tweak/Sources/Native/Navbar/Navbar.x b/tweak/Sources/Native/Navbar/Navbar.xindex 3fcc0477..cda157e8 100644--- a/tweak/Sources/Native/Navbar/Navbar.x+++ b/tweak/Sources/Native/Navbar/Navbar.x@@ -24,6 +24,8 @@ static const CGFloat kIconTop = 12.5;static const CGFloat kLabelTop = 35;static const CGFloat kLabelHeight = 14;static char kCustomKey, kOrderKey;+// Between the main group and the split tabs (Split tabs), when both have something on the bar.+static const CGFloat kSplitGap = 10;// Where Spotify's own items keep their icon and label, read off one of them every pass, so an item of// the mod's own sits on the same line as its neighbours.@@ -37,6 +39,8 @@ static UIFont *sg_tabFont;// Spotify's own tabs in Spotify's order, from the first layout pass of this launch, before// anything below has moved them.static NSMutableArray<NSString *> *sg_stockOrder;+// How many tabs at the end of the row are split off from the rest, 0 for one group.+static NSUInteger sg_apartCount;static UIColor *itemColor(void) { return [UIColor colorWithWhite:0xB3 / 255.0 alpha:1]; }@@ -169,6 +173,8 @@ void SGComposeTabBar(UIView *tabBar) {NSMutableArray<UIView *> *wanted = [NSMutableArray array];NSMutableSet<NSString *> *placed = [NSMutableSet set];NSMutableSet<NSString *> *keep = [NSMutableSet set];+ NSSet<NSString *> *split = SGEnabled(SGKeyNavbar) ? [NSSet setWithArray:SGNavbarSplit()] : nil;+ NSMutableSet<UIView *> *apart = [NSMutableSet set];if (SGEnabled(SGKeyNavbar)) {for (NSDictionary *entry in SGNavbarLayout()) {@@ -183,9 +189,11 @@ void SGComposeTabBar(UIView *tabBar) {else custom[ident] = item = [[SGTabItemView alloc] initWithEntry:entry];[keep addObject:ident];[wanted addObject:item];+ if ([split containsObject:ident]) [apart addObject:item];} else if (stockViews[ident]) {stockViews[ident].hidden = hidden;[wanted addObject:stockViews[ident]];+ if ([split containsObject:ident]) [apart addObject:stockViews[ident]];}}}@@ -196,6 +204,7 @@ void SGComposeTabBar(UIView *tabBar) {if (!item || [wanted containsObject:item]) continue;item.hidden = NO;[wanted addObject:item];+ if ([split containsObject:ident]) [apart addObject:item];}for (NSString *ident in custom.allKeys) {if ([keep containsObject:ident]) continue;@@ -213,10 +222,18 @@ void SGComposeTabBar(UIView *tabBar) {for (UIView *item in wanted) {if ([item isKindOfClass:SGTabItemView.class] && item.superview != stack) [stack addArrangedSubview:item];}- NSMutableArray<UIView *> *order = [NSMutableArray array];- for (UIView *item in wanted) if (!item.hidden && item.superview == stack) [order addObject:item];+ // Split tabs go to the end, each group in the list's order. With nothing left in the main group they+ // are the bar's one group.+ NSMutableArray<UIView *> *order = [NSMutableArray array], *trailing = [NSMutableArray array];+ for (UIView *item in wanted) {+ if (item.hidden || item.superview != stack) continue;+ [([apart containsObject:item] ? trailing : order) addObject:item];+ }+ NSUInteger apartCount = order.count ? trailing.count : 0;+ [order addObjectsFromArray:trailing];sg_row = stack;- if (![order isEqualToArray:objc_getAssociatedObject(stack, &kOrderKey)]) {+ if (![order isEqualToArray:objc_getAssociatedObject(stack, &kOrderKey)] || apartCount != sg_apartCount) {+ sg_apartCount = apartCount;objc_setAssociatedObject(stack, &kOrderKey, order, OBJC_ASSOCIATION_RETAIN_NONATOMIC);[stack setNeedsLayout];}@@ -231,16 +248,19 @@ static void centreContents(UIView *item) {});}-// Equal slots across the bar, in the order composed above. The frames go on after the stack's-// own pass, so Spotify's own widths never decide whether a fifth item fits.+// Equal slots across the bar, in the order composed above, the split tabs' after a gap. The frames go on+// after the stack's own pass, so Spotify's own widths never decide whether a fifth item fits.static void placeRow(UIStackView *stack) {NSArray<UIView *> *order = objc_getAssociatedObject(stack, &kOrderKey);UIView *bar = sg_navbarRoot;if (!order.count || !bar) return;- CGFloat width = bar.bounds.size.width / order.count;+ CGFloat gap = sg_apartCount ? kSplitGap : 0;+ CGFloat width = (bar.bounds.size.width - gap) / order.count;CGFloat height = stack.bounds.size.height;+ NSUInteger firstApart = order.count - sg_apartCount;[order enumerateObjectsUsingBlock:^(UIView *item, NSUInteger i, BOOL *stop) {- CGFloat x = [bar convertPoint:CGPointMake(i * width, 0) toView:stack].x;+ CGFloat left = i * width + (i >= firstApart ? gap : 0);+ CGFloat x = [bar convertPoint:CGPointMake(left, 0) toView:stack].x;CGRect frame = CGRectMake(x, 0, width, height);if (!CGAffineTransformIsIdentity(item.transform)) item.transform = CGAffineTransformIdentity;if (!CGRectEqualToRect(item.frame, frame)) item.frame = frame;diff --git a/tweak/Sources/Native/Navbar/NavbarLayout.m b/tweak/Sources/Native/Navbar/NavbarLayout.mindex a3cf249f..71bad609 100644--- a/tweak/Sources/Native/Navbar/NavbarLayout.m+++ b/tweak/Sources/Native/Navbar/NavbarLayout.m@@ -10,6 +10,7 @@ NSString *const SGNavbarHidden = @"hidden";static NSString *const kNavbarLayout = @"spotifyglass.navbar.layout";static NSString *const kNavbarStock = @"spotifyglass.navbar.stock";+static NSString *const kNavbarSplit = @"spotifyglass.navbar.split";// Only property list types go in, so a corrupt read cannot be anything but an array of dictionaries.static NSArray *listOfKind(NSString *key, Class kind) {@@ -26,6 +27,14 @@ void SGSetNavbarLayout(NSArray<NSDictionary *> *layout) {[NSUserDefaults.standardUserDefaults setObject:layout ?: @[] forKey:kNavbarLayout];}+NSArray<NSString *> *SGNavbarSplit(void) {+ return listOfKind(kNavbarSplit, NSString.class);+}++void SGSetNavbarSplit(NSArray<NSString *> *split) {+ [NSUserDefaults.standardUserDefaults setObject:split ?: @[] forKey:kNavbarSplit];+}+NSArray<NSString *> *SGNavbarStock(void) {return listOfKind(kNavbarStock, NSString.class);}diff --git a/tweak/Sources/Native/Navbar/NavbarSettings.m b/tweak/Sources/Native/Navbar/NavbarSettings.mindex 4ae1f085..404830e2 100644--- a/tweak/Sources/Native/Navbar/NavbarSettings.m+++ b/tweak/Sources/Native/Navbar/NavbarSettings.m@@ -58,10 +58,88 @@ static void appendTab(NSDictionary *tab) {SGRefreshTabBar();}+// Split tabs: a switch per tab of the bar, on to set it apart at the trailing end.+@interface SGSplitTabsPage : SGPage+@end++@implementation SGSplitTabsPage {+ NSArray<NSDictionary *> *_entries;+ NSMutableSet<NSString *> *_split;+ UIView *_intro;+}++- (instancetype)init {+ if (!(self = [super initWithStyle:UITableViewStyleInsetGrouped])) return nil;+ self.title = @"Split Tabs";+ return self;+}++- (void)viewDidLoad {+ [super viewDidLoad];+ _intro = SGNote(@"Tabs switched on here sit apart from the others at the right end of the bar, the way the Music "+ "app sets Search apart. Hidden tabs stay hidden.");+ self.tableView.tableHeaderView = _intro;+ _entries = navbarEntries();+ _split = [NSMutableSet setWithArray:SGNavbarSplit()];+}++- (void)viewWillLayoutSubviews {+ [super viewWillLayoutSubviews];+ SGFitNote(self.tableView, _intro, 24, 0);+}++- (void)viewDidLayoutSubviews {+ [super viewDidLayoutSubviews];+ SGInsetForBars(self.tableView);+}++- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {+ return (NSInteger)_entries.count;+}++- (UIView *)tableView:(UITableView *)table viewForHeaderInSection:(NSInteger)section {+ return SGSectionHeader(table, @"Tabs");+}++- (CGFloat)tableView:(UITableView *)table heightForHeaderInSection:(NSInteger)section {+ return SGSectionHeaderHeight;+}++- (CGFloat)tableView:(UITableView *)table heightForFooterInSection:(NSInteger)section {+ return CGFLOAT_MIN;+}++- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {+ UITableViewCell *cell = SGDequeueCell(table, @"split");+ NSDictionary *entry = _entries[(NSUInteger)path.row];+ BOOL apart = [_split containsObject:entry[SGNavbarID]];+ NSString *where = [entry[SGNavbarHidden] boolValue] ? @"Hidden" : apart ? @"Apart, on the right" : @"With the others";+ SGFillCell(cell, entry[SGNavbarTitle], where, nil, nil);+ UISwitch *toggle = [UISwitch new];+ toggle.onTintColor = SGGreen();+ toggle.on = apart;+ toggle.tag = path.row;+ [toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];+ cell.accessoryView = toggle;+ return cell;+}++- (void)toggled:(UISwitch *)toggle {+ NSString *ident = _entries[(NSUInteger)toggle.tag][SGNavbarID];+ if (toggle.on) [_split addObject:ident];+ else [_split removeObject:ident];+ SGSetNavbarSplit(_split.allObjects);+ SGRefreshTabBar();+ [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:toggle.tag inSection:0]] withRowAnimation:UITableViewRowAnimationNone];+}++@end+typedef NS_ENUM(NSInteger, SGNavbarSection) {SGNavbarSectionSwitch,SGNavbarSectionTabs,SGNavbarSectionAdd,+ SGNavbarSectionSplit,SGNavbarSectionReset,SGNavbarSectionCount,};@@ -109,6 +187,9 @@ typedef NS_ENUM(NSInteger, SGNavbarSection) {- (void)save {SGSetNavbarLayout(_entries);+ // A split tab swiped away leaves the split list with it.+ NSArray *idents = [_entries valueForKey:SGNavbarID];+ SGSetNavbarSplit([SGNavbarSplit() filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF IN %@", idents]]);SGRefreshTabBar();}@@ -162,6 +243,11 @@ typedef NS_ENUM(NSInteger, SGNavbarSection) {SGFillCell(cell, @"Add a tab…", nil, nil, @"plus");cell.selectionStyle = UITableViewCellSelectionStyleDefault;break;+ case SGNavbarSectionSplit:+ SGFillCell(cell, @"Split tabs", @"Place chosen tabs apart on the right", nil, @"rectangle.split.2x1");+ cell.accessoryView = SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);+ cell.selectionStyle = UITableViewCellSelectionStyleDefault;+ break;default:SGFillCell(cell, @"Use Spotify's order", nil, nil, @"arrow.uturn.backward");cell.selectionStyle = UITableViewCellSelectionStyleDefault;@@ -215,6 +301,8 @@ typedef NS_ENUM(NSInteger, SGNavbarSection) {appendTab(tab);[weakSelf reload];});+ } else if (path.section == SGNavbarSectionSplit) {+ [self.navigationController pushViewController:[SGSplitTabsPage new] animated:YES];} else if (path.section == SGNavbarSectionReset) {[self reset];}@@ -227,11 +315,12 @@ typedef NS_ENUM(NSInteger, SGNavbarSection) {- (void)reset {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Use Spotify's order"- message:@"Every tab of Spotify's comes back where Spotify put it, and the tabs you added go."+ message:@"Every tab of Spotify's comes back where Spotify put it, the tabs you added go, and no tab is split apart."preferredStyle:UIAlertControllerStyleAlert];[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];[alert addAction:[UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {SGSetNavbarLayout(@[]);+ SGSetNavbarSplit(@[]);SGRefreshTabBar();self->_entries = navbarEntries();[self.tableView reloadData];diff --git a/tweak/Sources/Redesigned/Navbar/Navbar.h b/tweak/Sources/Redesigned/Navbar/Navbar.hindex d12bb80e..9d50d439 100644--- a/tweak/Sources/Redesigned/Navbar/Navbar.h+++ b/tweak/Sources/Redesigned/Navbar/Navbar.h@@ -16,6 +16,9 @@ extern NSString *const SGRNavbarIconSet; // NSString, SGTabIconSetSymbols when textern NSString *const SGRNavbarHidden; // NSNumberNSArray<NSDictionary *> *SGRNavbarLayout(void);void SGRSetNavbarLayout(NSArray<NSDictionary *> *layout);+// The tabs set apart at the trailing end of the bar (Split tabs), by their entries' identities.+NSArray<NSString *> *SGRNavbarSplit(void);+void SGRSetNavbarSplit(NSArray<NSString *> *split);// Spotify's own tabs in Spotify's order, as Navbar.x last saw them on the bar.NSArray<NSString *> *SGRNavbarStock(void);void SGRSetNavbarStock(NSArray<NSString *> *stock);@@ -29,6 +32,8 @@ void SGRComposeTabBar(UIView *tabBar);void SGRLogTabBarRow(UIView *tabBar);// Lays the bar out again after the Navbar page changes something, so it does not wait for a touch.void SGRRefreshTabBar(void);+// Whether a tab of the composed row is one of the split tabs at its trailing end, for TabBar.x's second bar.+BOOL SGRTabIsApart(UIView *item);UIViewController *SGRNavbarSettingsPage(void); // the tab editor, in Mod SettingsUIViewController *SGRNavbarEditorPage(void); // the tab editor alone, for the welcome tourdiff --git a/tweak/Sources/Redesigned/Navbar/Navbar.x b/tweak/Sources/Redesigned/Navbar/Navbar.xindex ca8d7432..2d260fa9 100644--- a/tweak/Sources/Redesigned/Navbar/Navbar.x+++ b/tweak/Sources/Redesigned/Navbar/Navbar.x@@ -24,7 +24,9 @@ static const CGFloat kIconSize = 24;static const CGFloat kIconTop = 12.5;static const CGFloat kLabelTop = 35;static const CGFloat kLabelHeight = 14;-static char kCustomKey, kOrderKey;+static char kCustomKey, kOrderKey, kApartKey;+// Between the main group and the split tabs (Split tabs), when both have something on the bar.+static const CGFloat kSplitGap = 10;// Where Spotify's own items keep their icon and label, read off one of them every pass, so an item of// the mod's own sits on the same line as its neighbours.@@ -38,6 +40,8 @@ static UIFont *sg_tabFont;// Spotify's own tabs in Spotify's order, from the first layout pass of this launch, before// anything below has moved them.static NSMutableArray<NSString *> *sg_stockOrder;+// How many tabs at the end of the row are split off from the rest, 0 for one group.+static NSUInteger sg_apartCount;static UIColor *itemColor(void) { return [UIColor colorWithWhite:0xB3 / 255.0 alpha:1]; }@@ -177,6 +181,8 @@ void SGRComposeTabBar(UIView *tabBar) {NSMutableArray<UIView *> *wanted = [NSMutableArray array];NSMutableSet<NSString *> *placed = [NSMutableSet set];NSMutableSet<NSString *> *keep = [NSMutableSet set];+ NSSet<NSString *> *split = SGEnabled(SGRKeyNavbar) ? [NSSet setWithArray:SGRNavbarSplit()] : nil;+ NSMutableSet<UIView *> *apart = [NSMutableSet set];if (SGEnabled(SGRKeyNavbar)) {for (NSDictionary *entry in SGRNavbarLayout()) {@@ -191,9 +197,11 @@ void SGRComposeTabBar(UIView *tabBar) {else custom[ident] = item = [[SGRTabItemView alloc] initWithEntry:entry];[keep addObject:ident];[wanted addObject:item];+ if ([split containsObject:ident]) [apart addObject:item];} else if (stockViews[ident]) {stockViews[ident].hidden = hidden;[wanted addObject:stockViews[ident]];+ if ([split containsObject:ident]) [apart addObject:stockViews[ident]];}}}@@ -204,6 +212,7 @@ void SGRComposeTabBar(UIView *tabBar) {if (!item || [wanted containsObject:item]) continue;item.hidden = NO;[wanted addObject:item];+ if ([split containsObject:ident]) [apart addObject:item];}for (NSString *ident in custom.allKeys) {if ([keep containsObject:ident]) continue;@@ -221,10 +230,21 @@ void SGRComposeTabBar(UIView *tabBar) {for (UIView *item in wanted) {if ([item isKindOfClass:SGRTabItemView.class] && item.superview != stack) [stack addArrangedSubview:item];}- NSMutableArray<UIView *> *order = [NSMutableArray array];- for (UIView *item in wanted) if (!item.hidden && item.superview == stack) [order addObject:item];+ // Split tabs go to the end, each group in the list's order. With nothing left in the main group they+ // are the bar's one group.+ NSMutableArray<UIView *> *order = [NSMutableArray array], *trailing = [NSMutableArray array];+ for (UIView *item in wanted) {+ if (item.hidden || item.superview != stack) continue;+ [([apart containsObject:item] ? trailing : order) addObject:item];+ }+ NSUInteger apartCount = order.count ? trailing.count : 0;+ [order addObjectsFromArray:trailing];+ [order enumerateObjectsUsingBlock:^(UIView *item, NSUInteger i, BOOL *stop) {+ objc_setAssociatedObject(item, &kApartKey, i + apartCount >= order.count ? @YES : nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }];sg_row = stack;- if (![order isEqualToArray:objc_getAssociatedObject(stack, &kOrderKey)]) {+ if (![order isEqualToArray:objc_getAssociatedObject(stack, &kOrderKey)] || apartCount != sg_apartCount) {+ sg_apartCount = apartCount;objc_setAssociatedObject(stack, &kOrderKey, order, OBJC_ASSOCIATION_RETAIN_NONATOMIC);[stack setNeedsLayout];}@@ -239,16 +259,19 @@ static void centreContents(UIView *item) {});}-// Equal slots across the bar, in the order composed above. The frames go on after the stack's-// own pass, so Spotify's own widths never decide whether a fifth item fits.+// Equal slots across the bar, in the order composed above, the split tabs' after a gap. The frames go on+// after the stack's own pass, so Spotify's own widths never decide whether a fifth item fits.static void placeRow(UIStackView *stack) {NSArray<UIView *> *order = objc_getAssociatedObject(stack, &kOrderKey);UIView *bar = sg_navbarRoot;if (!order.count || !bar) return;- CGFloat width = bar.bounds.size.width / order.count;+ CGFloat gap = sg_apartCount ? kSplitGap : 0;+ CGFloat width = (bar.bounds.size.width - gap) / order.count;CGFloat height = stack.bounds.size.height;+ NSUInteger firstApart = order.count - sg_apartCount;[order enumerateObjectsUsingBlock:^(UIView *item, NSUInteger i, BOOL *stop) {- CGFloat x = [bar convertPoint:CGPointMake(i * width, 0) toView:stack].x;+ CGFloat left = i * width + (i >= firstApart ? gap : 0);+ CGFloat x = [bar convertPoint:CGPointMake(left, 0) toView:stack].x;CGRect frame = CGRectMake(x, 0, width, height);if (!CGAffineTransformIsIdentity(item.transform)) item.transform = CGAffineTransformIdentity;if (!CGRectEqualToRect(item.frame, frame)) item.frame = frame;@@ -302,6 +325,10 @@ static CGFloat slotCentreX(UIView *view) {}%end+BOOL SGRTabIsApart(UIView *item) {+ return objc_getAssociatedObject(item, &kApartKey) != nil;+}+void SGRRefreshTabBar(void) {[sg_navbarRoot setNeedsLayout];}diff --git a/tweak/Sources/Redesigned/Navbar/NavbarLayout.m b/tweak/Sources/Redesigned/Navbar/NavbarLayout.mindex f7de2503..4f3ca038 100644--- a/tweak/Sources/Redesigned/Navbar/NavbarLayout.m+++ b/tweak/Sources/Redesigned/Navbar/NavbarLayout.m@@ -11,6 +11,7 @@ NSString *const SGRNavbarHidden = @"hidden";static NSString *const kNavbarLayout = @"spotifyglass.redesign.navbar.layout";static NSString *const kNavbarStock = @"spotifyglass.redesign.navbar.stock";+static NSString *const kNavbarSplit = @"spotifyglass.redesign.navbar.split";// Only property list types go in, so a corrupt read cannot be anything but an array of dictionaries.static NSArray *listOfKind(NSString *key, Class kind) {@@ -27,6 +28,14 @@ void SGRSetNavbarLayout(NSArray<NSDictionary *> *layout) {[NSUserDefaults.standardUserDefaults setObject:layout ?: @[] forKey:kNavbarLayout];}+NSArray<NSString *> *SGRNavbarSplit(void) {+ return listOfKind(kNavbarSplit, NSString.class);+}++void SGRSetNavbarSplit(NSArray<NSString *> *split) {+ [NSUserDefaults.standardUserDefaults setObject:split ?: @[] forKey:kNavbarSplit];+}+NSArray<NSString *> *SGRNavbarStock(void) {return listOfKind(kNavbarStock, NSString.class);}diff --git a/tweak/Sources/Redesigned/Navbar/NavbarSettings.m b/tweak/Sources/Redesigned/Navbar/NavbarSettings.mindex 99b7dd96..ad63e19e 100644--- a/tweak/Sources/Redesigned/Navbar/NavbarSettings.m+++ b/tweak/Sources/Redesigned/Navbar/NavbarSettings.m@@ -61,10 +61,88 @@ static void appendTab(NSDictionary *tab) {SGRRefreshTabBar();}+// Split tabs: a switch per tab of the bar, on to set it apart at the trailing end.+@interface SGRSplitTabsPage : SGPage+@end++@implementation SGRSplitTabsPage {+ NSArray<NSDictionary *> *_entries;+ NSMutableSet<NSString *> *_split;+ UIView *_intro;+}++- (instancetype)init {+ if (!(self = [super initWithStyle:UITableViewStyleInsetGrouped])) return nil;+ self.title = @"Split Tabs";+ return self;+}++- (void)viewDidLoad {+ [super viewDidLoad];+ _intro = SGNote(@"Tabs switched on here sit apart from the others at the right end of the bar, the way the Music "+ "app sets Search apart. Hidden tabs stay hidden.");+ self.tableView.tableHeaderView = _intro;+ _entries = navbarEntries();+ _split = [NSMutableSet setWithArray:SGRNavbarSplit()];+}++- (void)viewWillLayoutSubviews {+ [super viewWillLayoutSubviews];+ SGFitNote(self.tableView, _intro, 24, 0);+}++- (void)viewDidLayoutSubviews {+ [super viewDidLayoutSubviews];+ SGInsetForBars(self.tableView);+}++- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {+ return (NSInteger)_entries.count;+}++- (UIView *)tableView:(UITableView *)table viewForHeaderInSection:(NSInteger)section {+ return SGSectionHeader(table, @"Tabs");+}++- (CGFloat)tableView:(UITableView *)table heightForHeaderInSection:(NSInteger)section {+ return SGSectionHeaderHeight;+}++- (CGFloat)tableView:(UITableView *)table heightForFooterInSection:(NSInteger)section {+ return CGFLOAT_MIN;+}++- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {+ UITableViewCell *cell = SGDequeueCell(table, @"split");+ NSDictionary *entry = _entries[(NSUInteger)path.row];+ BOOL apart = [_split containsObject:entry[SGRNavbarID]];+ NSString *where = [entry[SGRNavbarHidden] boolValue] ? @"Hidden" : apart ? @"Apart, on the right" : @"With the others";+ SGFillCell(cell, entry[SGRNavbarTitle], where, nil, nil);+ UISwitch *toggle = [UISwitch new];+ toggle.onTintColor = SGGreen();+ toggle.on = apart;+ toggle.tag = path.row;+ [toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];+ cell.accessoryView = toggle;+ return cell;+}++- (void)toggled:(UISwitch *)toggle {+ NSString *ident = _entries[(NSUInteger)toggle.tag][SGRNavbarID];+ if (toggle.on) [_split addObject:ident];+ else [_split removeObject:ident];+ SGRSetNavbarSplit(_split.allObjects);+ SGRRefreshTabBar();+ [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:toggle.tag inSection:0]] withRowAnimation:UITableViewRowAnimationNone];+}++@end+typedef NS_ENUM(NSInteger, SGRNavbarSection) {SGRNavbarSectionSwitch,SGRNavbarSectionTabs,SGRNavbarSectionAdd,+ SGRNavbarSectionSplit,SGRNavbarSectionReset,SGRNavbarSectionCount,};@@ -112,6 +190,9 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {- (void)save {SGRSetNavbarLayout(_entries);+ // A split tab swiped away leaves the split list with it.+ NSArray *idents = [_entries valueForKey:SGRNavbarID];+ SGRSetNavbarSplit([SGRNavbarSplit() filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF IN %@", idents]]);SGRRefreshTabBar();}@@ -168,6 +249,11 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {SGFillCell(cell, @"Add a tab…", nil, nil, @"plus");cell.selectionStyle = UITableViewCellSelectionStyleDefault;break;+ case SGRNavbarSectionSplit:+ SGFillCell(cell, @"Split tabs", @"Place chosen tabs apart on the right", nil, @"rectangle.split.2x1");+ cell.accessoryView = SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);+ cell.selectionStyle = UITableViewCellSelectionStyleDefault;+ break;default:SGFillCell(cell, @"Use Spotify's order", nil, nil, @"arrow.uturn.backward");cell.selectionStyle = UITableViewCellSelectionStyleDefault;@@ -221,6 +307,8 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {appendTab(tab);[weakSelf reload];});+ } else if (path.section == SGRNavbarSectionSplit) {+ [self.navigationController pushViewController:[SGRSplitTabsPage new] animated:YES];} else if (path.section == SGRNavbarSectionReset) {[self reset];}@@ -233,11 +321,12 @@ typedef NS_ENUM(NSInteger, SGRNavbarSection) {- (void)reset {UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Use Spotify's order"- message:@"Every tab of Spotify's comes back where Spotify put it, and the tabs you added go."+ message:@"Every tab of Spotify's comes back where Spotify put it, the tabs you added go, and no tab is split apart."preferredStyle:UIAlertControllerStyleAlert];[alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];[alert addAction:[UIAlertAction actionWithTitle:@"Reset" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {SGRSetNavbarLayout(@[]);+ SGRSetNavbarSplit(@[]);SGRRefreshTabBar();self->_entries = navbarEntries();[self.tableView reloadData];diff --git a/tweak/Sources/Redesigned/Navbar/TabBar.x b/tweak/Sources/Redesigned/Navbar/TabBar.xindex bc999d08..9e4d4544 100644--- a/tweak/Sources/Redesigned/Navbar/TabBar.x+++ b/tweak/Sources/Redesigned/Navbar/TabBar.x@@ -17,7 +17,7 @@#import "Headers/SPTEncoreIconView.h"#import <objc/message.h>-static char kBarKey, kHostKey;+static char kBarKey, kApartBarKey, kHostKey;static __weak UIView *sg_stockBar;static CGFloat sg_room, sg_glassHeight; // see "room for the glass bar"@@ -26,6 +26,8 @@ static CGFloat sg_room, sg_glassHeight; // see "room for the glass bar"@property (nonatomic, copy) NSArray<UIView *> *sources;@property (nonatomic, weak) UILongPressGestureRecognizer *hold;@property (nonatomic) BOOL holding;+// The other bar, when the split tabs have one of their own: a tab picked on one bar clears the other's.+@property (nonatomic, weak) SGRSystemTabBar *partner;@endstatic void syncBar(UIView *stockBar);@@ -186,6 +188,7 @@ static void forwardTap(UIView *item) {if (index == NSNotFound || index >= self.sources.count) return;// Home tapped while on Home pops Spotify's stack, which would take Mod Settings straight off it.if (!self.holding) forwardTap(self.sources[index]);+ self.partner.selectedItem = nil;// Spotify repaints its labels a moment later; a tap it did not take snaps the selection back.UIView *stockBar = self.stockBar;dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{@@ -332,43 +335,25 @@ static void makeRoom(UIViewController *container) {SGLog(@"tab bar: %.0f pt of room made under Spotify's bar for the glass bar's %.0f, over an inset of %.0f", room, height, inset);}-static void syncBar(UIView *stockBar) {- sg_stockBar = stockBar;-- SGRSystemTabBar *bar = objc_getAssociatedObject(stockBar, &kBarKey);- if (!bar) {- bar = [[SGRSystemTabBar alloc] initWithFrame:stockBar.bounds];- // UIKit draws the glass in the appearance the bar inherits, and the bar is outside the navigation- // stacks Spotify makes dark itself (-[SPNavigationController viewDidLoad] while +[SPTLiquidGlass- // isEnabled]), so a phone in light mode had it light over Spotify's black. Spotify is dark whatever- // the system is, and so is the bar.- bar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;- bar.delegate = bar;- bar.stockBar = stockBar;- UILongPressGestureRecognizer *hold = [[UILongPressGestureRecognizer alloc] initWithTarget:bar action:@selector(held:)];- hold.delegate = bar;- [bar addGestureRecognizer:hold];- bar.hold = hold;- objc_setAssociatedObject(stockBar, &kBarKey, bar, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- SGRTabBarHost *host = [SGRTabBarHost new];- [host addSubview:bar];- objc_setAssociatedObject(stockBar, &kHostKey, host, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }+static SGRSystemTabBar *makeBar(UIView *stockBar) {+ SGRSystemTabBar *bar = [[SGRSystemTabBar alloc] initWithFrame:stockBar.bounds];+ // UIKit draws the glass in the appearance the bar inherits, and the bar is outside the navigation+ // stacks Spotify makes dark itself (-[SPNavigationController viewDidLoad] while +[SPTLiquidGlass+ // isEnabled]), so a phone in light mode had it light over Spotify's black. Spotify is dark whatever+ // the system is, and so is the bar.+ bar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;+ bar.delegate = bar;+ bar.stockBar = stockBar;+ UILongPressGestureRecognizer *hold = [[UILongPressGestureRecognizer alloc] initWithTarget:bar action:@selector(held:)];+ hold.delegate = bar;+ [bar addGestureRecognizer:hold];+ bar.hold = hold;+ return bar;+}++// One bar's share of the tabs: its items, their glyphs and titles. YES while a glyph is still missing.+static BOOL fillBar(SGRSystemTabBar *bar, NSArray<UIView *> *sources, BOOL hideLabels) {bar.tintColor = SGRAccent();- UIView *host = objc_getAssociatedObject(stockBar, &kHostKey);-- for (UIView *sub in stockBar.subviews) {- if (sub == host) continue;- sub.alpha = 0;- sub.userInteractionEnabled = NO;- }- stockBar.superview.layer.backgroundColor = NULL;-- NSArray<UIView *> *sources = tabItems(stockBar);- if (!sources.count) return;- // An item with no title is drawn by UIKit as its glyph alone, centred, on a bar of the same height.- BOOL hideLabels = SGHidden(SGRKeyNavbarHideLabels);-if (![sources isEqualToArray:bar.sources]) {NSMutableArray<UITabBarItem *> *items = [NSMutableArray array];for (UIView *source in sources) [items addObject:[[UITabBarItem alloc] initWithTitle:hideLabels ? nil : labelIn(source).text image:nil tag:items.count]];@@ -386,7 +371,6 @@ static void syncBar(UIView *stockBar) {SGLogLong(@"navbar", out);}- UITabBarItem *selected = nil;BOOL missing = NO;for (NSUInteger i = 0; i < sources.count; i++) {UITabBarItem *item = bar.items[i];@@ -395,9 +379,74 @@ static void syncBar(UIView *stockBar) {missing |= !item.image || !item.selectedImage;NSString *title = hideLabels ? nil : labelIn(sources[i]).text;if (hideLabels ? item.title != nil : title.length && ![title isEqualToString:item.title]) item.title = title;- if (!selected && isActive(sources[i])) selected = item;}- if (selected && bar.selectedItem != selected) bar.selectedItem = selected;+ return missing;+}++// The bar holding the tab Spotify paints as selected selects it, and the other one lets go. With no tab+// painted (a tab of the mod's own, a repaint still to come) both keep what they have.+static void selectActive(SGRSystemTabBar *bar, UIView *active) {+ NSUInteger index = active ? [bar.sources indexOfObject:active] : NSNotFound;+ UITabBarItem *item = index == NSNotFound ? nil : bar.items[index];+ if (active && bar.selectedItem != item) bar.selectedItem = item;+}++// Split tabs stand on a glass bar of their own at the trailing end, the way the Music app sets Search+// apart. A standalone UITabBar has no way to set an item apart (iOS 27 SDK: only UITabBarController's+// UISearchTab does), so it is a second bar. UIKit draws each bar's platter 21 pt in from its sides+// (harness/tabbar, iPhone 17 Pro, iOS 27: a 72 pt bar got a 30 pt platter at x 21), so a split bar is+// a 62 pt platter, a circle as tall as the bar's, per tab plus those insets, and the main bar runs under+// its leading inset to leave 12 pt of glassless gap between the two platters.+static const CGFloat kPlatterInset = 21, kApartItemWidth = 62, kPlatterGap = 12;++static void syncBar(UIView *stockBar) {+ sg_stockBar = stockBar;++ SGRSystemTabBar *bar = objc_getAssociatedObject(stockBar, &kBarKey);+ if (!bar) {+ bar = makeBar(stockBar);+ objc_setAssociatedObject(stockBar, &kBarKey, bar, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ SGRTabBarHost *host = [SGRTabBarHost new];+ [host addSubview:bar];+ objc_setAssociatedObject(stockBar, &kHostKey, host, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ UIView *host = objc_getAssociatedObject(stockBar, &kHostKey);++ for (UIView *sub in stockBar.subviews) {+ if (sub == host) continue;+ sub.alpha = 0;+ sub.userInteractionEnabled = NO;+ }+ stockBar.superview.layer.backgroundColor = NULL;++ NSArray<UIView *> *sources = tabItems(stockBar);+ if (!sources.count) return;+ // An item with no title is drawn by UIKit as its glyph alone, centred, on a bar of the same height.+ BOOL hideLabels = SGHidden(SGRKeyNavbarHideLabels);++ NSMutableArray<UIView *> *main = [NSMutableArray array], *apart = [NSMutableArray array];+ for (UIView *source in sources) [(SGRTabIsApart(source) ? apart : main) addObject:source];+ if (!main.count) {+ main = [sources mutableCopy];+ [apart removeAllObjects];+ }+ SGRSystemTabBar *apartBar = objc_getAssociatedObject(stockBar, &kApartBarKey);+ if (apart.count && !apartBar) {+ apartBar = makeBar(stockBar);+ objc_setAssociatedObject(stockBar, &kApartBarKey, apartBar, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ apartBar.partner = bar;+ bar.partner = apartBar;+ [host addSubview:apartBar];+ }+ apartBar.hidden = !apart.count;+ if (!apart.count) apartBar.sources = nil;++ BOOL missing = fillBar(bar, main, hideLabels);+ if (apart.count) missing |= fillBar(apartBar, apart, hideLabels);+ UIView *active = nil;+ for (UIView *source in sources) if (!active && isActive(source)) active = source;+ selectActive(bar, active);+ if (apart.count) selectActive(apartBar, active);// An icon view Spotify has not built yet is looked for again shortly, not on the next touch.static NSUInteger retries;if (missing && retries++ < 40) {@@ -411,7 +460,14 @@ static void syncBar(UIView *stockBar) {CGFloat height = MAX(bounds.size.height, glassHeight(bar, stockBar));CGRect frame = CGRectMake(0, CGRectGetMaxY(bounds) - height, width, height);if (!CGRectEqualToRect(host.frame, frame)) host.frame = frame;- if (!CGRectEqualToRect(bar.frame, host.bounds)) bar.frame = host.bounds;+ CGRect mainFrame = host.bounds, apartFrame = CGRectZero;+ if (apart.count) {+ CGFloat apartWidth = MIN(width / 2, apart.count * kApartItemWidth + 2 * kPlatterInset);+ CGRectDivide(host.bounds, &apartFrame, &mainFrame, apartWidth, CGRectMaxXEdge);+ mainFrame.size.width += 2 * kPlatterInset - kPlatterGap;+ }+ if (!CGRectEqualToRect(bar.frame, mainFrame)) bar.frame = mainFrame;+ if (apart.count && !CGRectEqualToRect(apartBar.frame, apartFrame)) apartBar.frame = apartFrame;if (host.superview != stockBar) [stockBar addSubview:host];else if (stockBar.subviews.lastObject != host) [stockBar bringSubviewToFront:host];logBarOnce(bar);