Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: add home gradient options
Vojtěch Škopek133bf155edaa
diff --git a/README.md b/README.mdindex 4e049da5..d4443c95 100644--- a/README.md+++ b/README.md@@ -35,7 +35,7 @@ jailbreak. Every piece sits behind its own switch in Settings → Mod Settings.- Spotify's own Liquid Glass, every flag of it on at once- Glass now playing bar, player header, search field and lyrics card-- Pure black AMOLED, and a Home gradient+- Pure black AMOLED, and a Home gradient in any of eight colours- A tab bar you reorder, hide and add any `spotify:` link to- Queue as a bottom sheet, swipe a row to play next- Like and dislike back on the lock screen widget, animated artwork on itdiff --git a/docs/tweaks.md b/docs/tweaks.mdindex 2200f4f5..9460bd22 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -44,7 +44,7 @@ app:A hook reads its switch when it runs (`SGEnabled`, `SGHidden`, `SGFlag` from Core/SGPrefs.h), so achange shows after Spotify restarts; Navbar is the exception and applies as soon as the bar lays-out again. The root page in `Settings/SGModSettings.x` lists every feature's page by hand.+out again, as are the Home gradient's colour, strength and height, but not the switch that turns it on. The root page in `Settings/SGModSettings.x` lists every feature's page by hand.## Make targets@@ -59,8 +59,9 @@ out again. The root page in `Settings/SGModSettings.x` lists every feature's pag## Mod SettingsSettings → Mod Settings lists its pages without a description each, so the list reads as a list: UI-Tweaks (tab bar, search field, Spotify's own glass, AMOLED), Home & Library (a gradient background,-hide sections of the Home tab, Spotify's home and library flags), Playlist (hide the cover, the+Tweaks (tab bar, search field, Spotify's own glass, AMOLED), Home & Library (a Gradient page: the wash behind the top of+Home in one of eight colours, at three strengths and four heights; then hide sections of the Home+tab and Spotify's home and library flags), Playlist (hide the cover, theheader's text and buttons, the curation pills), Now Playing (glass, Spotify's player flags, hidebuttons and cards of the full screen player, and a Lyrics page under it), Lock screen widget,Playback (speed, queue, the player and the now playing bar), Ads & nags (every switch forces a flagdiff --git a/tweak/Sources/Core/SGPrefs.h b/tweak/Sources/Core/SGPrefs.hindex 0dec37d8..37688086 100644--- a/tweak/Sources/Core/SGPrefs.h+++ b/tweak/Sources/Core/SGPrefs.h@@ -7,6 +7,11 @@ BOOL SGEnabled(NSString *key); // an unset switch is onBOOL SGHidden(NSString *key); // an unset switch is offvoid SGSetEnabled(NSString *key, BOOL on);+// A setting picked from a list, stored as the index into it; the choice rows of+// Settings/SGModPage.h write these.+NSInteger SGInt(NSString *key, NSInteger fallback);+void SGSetInt(NSString *key, NSInteger value);+// Overrides of Spotify's remote-config flags, stored under SGFlagOverridePrefix + flag key;// nil keeps Spotify's value. Features/Flags reads them, the All flags page and flag rows write them.extern NSString *const SGFlagOverridePrefix;diff --git a/tweak/Sources/Core/SGPrefs.m b/tweak/Sources/Core/SGPrefs.mindex 706a1400..bcd6051b 100644--- a/tweak/Sources/Core/SGPrefs.m+++ b/tweak/Sources/Core/SGPrefs.m@@ -17,6 +17,15 @@ void SGSetEnabled(NSString *key, BOOL on) {[NSUserDefaults.standardUserDefaults setBool:on forKey:key];}+NSInteger SGInt(NSString *key, NSInteger fallback) {+ id value = [NSUserDefaults.standardUserDefaults objectForKey:key];+ return value ? [value integerValue] : fallback;+}++void SGSetInt(NSString *key, NSInteger value) {+ [NSUserDefaults.standardUserDefaults setInteger:value forKey:key];+}+NSString *const SGFlagOverridePrefix = @"spotifyglass.flag.";id SGFlagOverride(NSString *key) {diff --git a/tweak/Sources/Features/Home/Home.h b/tweak/Sources/Features/Home/Home.hindex a2a5474f..3487a977 100644--- a/tweak/Sources/Features/Home/Home.h+++ b/tweak/Sources/Features/Home/Home.h@@ -1,6 +1,25 @@-// Home: the gradient behind the top of the page (HomeGradient.x), off until it is asked for.+// Home: the gradient behind the top of the page (HomeGradient.x), off until it is asked for, and+// the settings that shape it (HomeGradientChoices.m, the Gradient page in HomeSettings.m).#import <UIKit/UIKit.h>#define SGKeyHomeGradient @"spotifyglass.homeGradient"+// Every setting the gradient is shaped by. One entry per setting in HomeGradientChoices.m holds the+// names the Gradient page offers, the key it is stored under and the one it falls back to, so a+// name and what it does cannot drift apart.+typedef NS_ENUM(NSInteger, SGHomeChoice) {+ SGHomeChoiceTint, // which colour it fades+ SGHomeChoiceStrength, // how far up or down that colour is taken+ SGHomeChoiceHeight, // how far down the page it reaches+ SGHomeChoiceCount,+};++NSArray<NSString *> *SGHomeChoiceNames(SGHomeChoice choice);+NSString *SGHomeChoiceKey(SGHomeChoice choice);+NSInteger SGHomeChoiceDefault(SGHomeChoice choice);+// The index set for `choice`: its own default while nothing is set, or while what is set is a name+// this build no longer offers.+NSInteger SGHomeChoiceValue(SGHomeChoice choice);+UIViewController *SGHomeSettingsPage(void);+UIViewController *SGHomeGradientPage(void);diff --git a/tweak/Sources/Features/Home/HomeGradient.x b/tweak/Sources/Features/Home/HomeGradient.xindex 4866fed6..63a255c1 100644--- a/tweak/Sources/Features/Home/HomeGradient.x+++ b/tweak/Sources/Features/Home/HomeGradient.x@@ -1,9 +1,13 @@-// Home gradient: a green wash behind the top of the Home tab, strongest under the avatar and the-// pills and out by the second shelf, like the gradient Spotify's own Home used to have. The wash-// is a layer inside the page's scroll view, under its content, so it scrolls away with the-// shelves; the base grey the page and the shelves paint over it goes clear in Appearance/Repaint.x, and+// Home gradient: a wash behind the top of the Home tab, strongest under the avatar and the pills+// and out by the second shelf, like the gradient Spotify's own Home used to have. The wash is a+// layer inside the page's scroll view, under its content, so it scrolls away with the shelves; the+// base grey the page and the shelves paint over it goes clear in Appearance/Repaint.x, and// Spotify's own scrim behind the header goes with it, since it would only mute the colour.//+// Which colour it fades, how strong it is and how far down it reaches come from the choice tables+// in HomeGradientChoices.m, read on every layout pass, so all three apply without restarting+// Spotify. The switch itself is read once, in the %ctor, and still needs a restart.+//// Tree (trees/home.txt): FunkisViewController.view holds the page, a 402x112 wrapper around// LiquidGlass.GradientView (the scrim under the avatar and the pills) and HomeHeaderView. Four// views down, EvoLoadableResourceViewController.view holds the one@@ -13,24 +17,76 @@#import "Core/SGCore.h"#import "Home.h"-// Sampled off the design: #0B4110 at the top of the screen, level behind the header, gone by 390pt.-static UIColor *tint(void) { return [UIColor colorWithRed:0x0B / 255.0 green:0x41 / 255.0 blue:0x10 / 255.0 alpha:1]; }-static const CGFloat kFadeHeight = 390;+// Colour level behind the header before it starts to go, and colour above the content as well, for+// the rubber band of an overscroll to pull down into.static const CGFloat kLevelHeight = 52;-// Colour above the content as well, for the rubber band of an overscroll to pull down into.static const CGFloat kOverscroll = 600;+// Each table is indexed by the choice of the same name in HomeGradientChoices.m and is as long as+// that list of names.+//+// Sampled off the design: #0B4110 at the top of the screen, level behind the header, gone by 390pt,+// which is Medium at Medium. The other seven colours are that one taken around the wheel.+static const uint32_t kTints[] = {0x0B4110, 0x0B4138, 0x0B2B41, 0x160B41, 0x330B41, 0x410B2E, 0x410B10, 0x412A0B};+static const CGFloat kStrengths[] = {0.62, 1.0, 1.45};+// 0 stands for the whole screen, which is only known once the page has been laid out.+static const CGFloat kHeights[] = {260, 390, 560, 0};++#define SGCount(table) (sizeof(table) / sizeof((table)[0]))+static char kGradientKey, kStrippedKey;+static NSUInteger clamp(NSInteger index, NSUInteger count) {+ if (index < 0) return 0;+ return (NSUInteger)index >= count ? count - 1 : (NSUInteger)index;+}++static UIColor *unpacked(uint32_t rgb) {+ return [UIColor colorWithRed:((rgb >> 16) & 0xFF) / 255.0+ green:((rgb >> 8) & 0xFF) / 255.0+ blue:(rgb & 0xFF) / 255.0+ alpha:1];+}++// Strength is the colour itself taken up or down rather than its alpha, so that Subtle stays as+// saturated as Bold instead of washing out into the page behind it.+static uint32_t strengthened(uint32_t rgb, CGFloat factor) {+ uint32_t out = 0;+ for (int shift = 16; shift >= 0; shift -= 8) {+ uint32_t channel = (uint32_t)round(MIN(255.0, ((rgb >> shift) & 0xFF) * factor));+ out |= channel << shift;+ }+ return out;+}+// A view of its own, so the wash follows the page's layout passes instead of animating itself// through CoreAnimation whenever the inset changes.@interface SGHomeGradientView : UIView+- (void)paintColor:(uint32_t)color span:(CGFloat)span;@end-@implementation SGHomeGradientView+@implementation SGHomeGradientView {+ uint32_t _color;+ CGFloat _span;+}++ (Class)layerClass {return CAGradientLayer.class;}++// The page lays out on every scroll, so a pass that changes neither the colour nor how far it+// reaches leaves the layer alone.+- (void)paintColor:(uint32_t)color span:(CGFloat)span {+ if (color == _color && span == _span) return;+ _color = color;+ _span = span;+ UIColor *tint = unpacked(color);+ CGFloat total = kOverscroll + span;+ CAGradientLayer *gradient = (CAGradientLayer *)self.layer;+ gradient.colors = @[(id)tint.CGColor, (id)tint.CGColor, (id)[tint colorWithAlphaComponent:0].CGColor];+ gradient.locations = @[@0, @((kOverscroll + kLevelHeight) / total), @1];+}+@end// The shelves and the shortcuts grid are lists of their own, each painting the base surface over@@ -52,10 +108,6 @@ static SGHomeGradientView *gradientIn(UIScrollView *list) {if (!view) {view = [SGHomeGradientView new];view.userInteractionEnabled = NO;- CGFloat height = kOverscroll + kFadeHeight;- CAGradientLayer *gradient = (CAGradientLayer *)view.layer;- gradient.colors = @[(id)tint().CGColor, (id)tint().CGColor, (id)[tint() colorWithAlphaComponent:0].CGColor];- gradient.locations = @[@0, @((kOverscroll + kLevelHeight) / height), @1];// A list puts its cells in at index 0, so that its scroll indicators stay on top of them;// the subview order alone would push the wash over the content. Depth settles it instead.view.layer.zPosition = -1;@@ -72,9 +124,16 @@ static void layoutGradient(UIScrollView *list) {SGHomeGradientView *view = gradientIn(list);if (sg_homeRoot != list) sg_homeRoot = list;stripCells(list);++ CGFloat height = kHeights[clamp(SGHomeChoiceValue(SGHomeChoiceHeight), SGCount(kHeights))];+ CGFloat span = height > 0 ? height : list.bounds.size.height;+ uint32_t color = strengthened(kTints[clamp(SGHomeChoiceValue(SGHomeChoiceTint), SGCount(kTints))],+ kStrengths[clamp(SGHomeChoiceValue(SGHomeChoiceStrength), SGCount(kStrengths))]);+CGRect frame = CGRectMake(0, -kOverscroll - list.adjustedContentInset.top,- list.bounds.size.width, kOverscroll + kFadeHeight);+ list.bounds.size.width, kOverscroll + span);if (!CGRectEqualToRect(view.frame, frame)) view.frame = frame;+ [view paintColor:color span:span];}// The one collection view of the page; the shelves are collection views nested inside it.diff --git a/tweak/Sources/Features/Home/HomeGradientChoices.m b/tweak/Sources/Features/Home/HomeGradientChoices.mnew file mode 100644index 00000000..e837aec2--- /dev/null+++ b/tweak/Sources/Features/Home/HomeGradientChoices.m@@ -0,0 +1,52 @@+// What the Gradient page offers and what the hooks read back, one entry per setting: the names, the+// key it is stored under and the index it falls back to. HomeGradient.x carries the numbers behind+// the names, in the same order as the names themselves.+#import "Core/SGCore.h"+#import "Home.h"++static NSDictionary *choiceDef(SGHomeChoice choice) {+ static NSDictionary<NSNumber *, NSDictionary *> *table;+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ table = @{+ // Eight rotations of the green the wash was born as, at the same depth and saturation+ // around the wheel, so each of them sits behind white text the way the green does.+ @(SGHomeChoiceTint): @{+ @"key": @"spotifyglass.homeGradientTint",+ @"default": @0,+ @"names": @[@"Spotify green", @"Teal", @"Blue", @"Indigo", @"Purple", @"Pink",+ @"Red", @"Amber"],+ },+ @(SGHomeChoiceStrength): @{+ @"key": @"spotifyglass.homeGradientStrength",+ @"default": @1,+ @"names": @[@"Subtle", @"Medium", @"Bold"],+ },+ @(SGHomeChoiceHeight): @{+ @"key": @"spotifyglass.homeGradientHeight",+ @"default": @1,+ @"names": @[@"Short", @"Medium", @"Tall", @"The whole screen"],+ },+ };+ });+ return table[@(choice)] ?: table[@(SGHomeChoiceTint)];+}++NSArray<NSString *> *SGHomeChoiceNames(SGHomeChoice choice) {+ return choiceDef(choice)[@"names"];+}++NSString *SGHomeChoiceKey(SGHomeChoice choice) {+ return choiceDef(choice)[@"key"];+}++NSInteger SGHomeChoiceDefault(SGHomeChoice choice) {+ return [choiceDef(choice)[@"default"] integerValue];+}++NSInteger SGHomeChoiceValue(SGHomeChoice choice) {+ NSDictionary *def = choiceDef(choice);+ NSInteger fallback = [def[@"default"] integerValue];+ NSInteger index = SGInt(def[@"key"], fallback);+ return index >= 0 && index < (NSInteger)[def[@"names"] count] ? index : fallback;+}diff --git a/tweak/Sources/Features/Home/HomeSettings.m b/tweak/Sources/Features/Home/HomeSettings.mindex 98f43c38..62e84c4c 100644--- a/tweak/Sources/Features/Home/HomeSettings.m+++ b/tweak/Sources/Features/Home/HomeSettings.m@@ -1,12 +1,36 @@+#import "Core/SGCore.h"#import "Settings/SGModPage.h"#import "Home.h"#import "Features/Declutter/Declutter.h"+static SGModRow *choiceRow(NSString *title, NSString *subtitle, SGHomeChoice choice) {+ return SGChoiceRow(title, subtitle, SGHomeChoiceKey(choice), SGHomeChoiceNames(choice),+ SGHomeChoiceDefault(choice));+}++UIViewController *SGHomeGradientPage(void) {+ return [[SGModPage alloc] initWithTitle:@"Gradient"+ intro:@"A wash behind the top of Home, under the avatar and the pills, fading into the page by the second shelf. Turning it on or off applies after you restart Spotify; the colour, the strength and the height take effect straight away."+ sections:@[+ SGSection(@"Gradient", @[+ SGOptionRow(@"Show", @"Off leaves Home the way Spotify draws it", SGKeyHomeGradient),+ choiceRow(@"Colour", nil, SGHomeChoiceTint),+ choiceRow(@"Strength", @"How much of that colour reaches the top of the screen", SGHomeChoiceStrength),+ choiceRow(@"Height", @"How far down the page it reaches before the page takes over", SGHomeChoiceHeight),+ ]),+ ] footer:nil];+}+UIViewController *SGHomeSettingsPage(void) {+ // The row reads its own state out, so the section says which colour is set without being opened.+ SGModRow *gradient = SGPageRow(@"Gradient", ^UIViewController *{ return SGHomeGradientPage(); });+ gradient.value = ^NSString *{+ if (!SGFlag(SGKeyHomeGradient, NO)) return @"Off";+ return SGHomeChoiceNames(SGHomeChoiceTint)[(NSUInteger)SGHomeChoiceValue(SGHomeChoiceTint)];+ };+return [[SGModPage alloc] initWithTitle:@"Home & Library" intro:SGRestartNote sections:@[- SGSection(@"Background", @[- SGOptionRow(@"Gradient", @"A green wash behind the top of the page, fading into the background", SGKeyHomeGradient),- ]),+ SGSection(@"Background", @[gradient]),SGSection(@"Hide", @[SGHideRow(@"Filter pills", @"Music and Podcasts next to your avatar", SGHideHomePills),SGHideRow(@"Shortcuts grid", @"The tiles at the top", SGHideHomeShortcuts),diff --git a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.mindex 1ddb71a7..e1539a8b 100644--- a/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m+++ b/tweak/Sources/Features/NowPlaying/NowPlayingSettings.m@@ -33,9 +33,7 @@ UIViewController *SGNowPlayingSettingsPage(void) {SGFlagRow(@"Expand the sticky header on tap", @"ios-feature-nowplaying.expand_sticky_header_on_tap"),SGFlagRow(@"Redesigned header with context menu", @"ios-feature-nowplaying.new_redesign_header_with_context_menu_enabled"),SGFlagRow(@"Video in the mini player", @"ios-feature-nowplaying.video_in_miniplayer"),- ]),- SGSection(@"Turn off", @[- SGKillRow(@"Canvas", @"ios-feature-canvas.canvas_enabled"),+ SGKillRow(@"Disable Canvas", @"ios-feature-canvas.canvas_enabled"),]),SGSection(@"Hide buttons", @[SGHideRow(@"Shuffle", @"Left of the playback controls", SGHideShuffle),diff --git a/tweak/Sources/Settings/SGModPage.h b/tweak/Sources/Settings/SGModPage.hindex 79776a1f..89002357 100644--- a/tweak/Sources/Settings/SGModPage.h+++ b/tweak/Sources/Settings/SGModPage.h@@ -4,8 +4,9 @@// A row is a switch when it has a key and a link to another page when it has a page. A flag row// switches one of Spotify's remote-config flags: on forces it (off for a forceOff row, which is how// a flag Spotify ships on is turned off), the switch off leaves Spotify's own value. A row-// with a value reads one out on the right and is asked again while the page is open; a row with an-// action runs it when tapped.+// with a value reads one out on the right and is asked again while the page is open; a page row+// with a value reads it out too, next to the chevron, and is asked when the page appears. A row+// with an action runs it when tapped.@interface SGModRow : NSObject@property (nonatomic, copy) NSString *title;@property (nonatomic, copy) NSString *subtitle;@@ -46,6 +47,9 @@ SGModRow *SGActionRow(NSString *title, NSString *subtitle, void (^action)(void))// Red, with a warning symbol: something is wrong and tapping the row says what to do about it.SGModRow *SGWarningRow(NSString *title, NSString *subtitle, void (^action)(void));SGModRow *SGPageRow(NSString *title, UIViewController *(^page)(void));+// A setting picked from a list of names, stored under `key` as the index into it: the row reads the+// name of the current one out and opens a list of them, a checkmark against that one.+SGModRow *SGChoiceRow(NSString *title, NSString *subtitle, NSString *key, NSArray<NSString *> *choices, NSInteger fallback);SGModRow *SGLinkRow(NSString *title, NSString *subtitle, NSString *url);SGModRow *SGStatActionRow(NSString *title, NSString *subtitle, NSString *(^value)(void), void (^action)(void));SGModSection *SGSection(NSString *title, NSArray<SGModRow *> *rows);diff --git a/tweak/Sources/Settings/SGModPage.m b/tweak/Sources/Settings/SGModPage.mindex 6f826f63..839f6274 100644--- a/tweak/Sources/Settings/SGModPage.m+++ b/tweak/Sources/Settings/SGModPage.m@@ -87,6 +87,90 @@ SGModRow *SGPageRow(NSString *title, UIViewController *(^page)(void)) {return row;}+// The list a choice row opens: the names it was given, a green checkmark against the one set.+// Picking one writes the index and goes back, where the row it came from reads the new name out+// and the page it sits on rebuilds around it.+@interface SGChoicePage : SGPage+- (instancetype)initWithTitle:(NSString *)title key:(NSString *)key choices:(NSArray<NSString *> *)choices fallback:(NSInteger)fallback;+@end++@implementation SGChoicePage {+ NSString *_key;+ NSArray<NSString *> *_choices;+ NSInteger _fallback;+}++- (instancetype)initWithTitle:(NSString *)title key:(NSString *)key choices:(NSArray<NSString *> *)choices fallback:(NSInteger)fallback {+ if (!(self = [super initWithStyle:UITableViewStyleGrouped])) return nil;+ self.title = title;+ _key = key;+ _choices = choices;+ _fallback = fallback;+ return self;+}++- (void)viewDidLoad {+ [super viewDidLoad];+ self.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;+ self.tableView.backgroundColor = SGPageBackground();+ self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;+ self.tableView.sectionHeaderTopPadding = 0;+}++- (void)viewDidLayoutSubviews {+ [super viewDidLayoutSubviews];+ SGInsetForBars(self.tableView);+}++- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {+ return (NSInteger)_choices.count;+}++- (CGFloat)tableView:(UITableView *)table heightForHeaderInSection:(NSInteger)section {+ return CGFLOAT_MIN;+}++- (CGFloat)tableView:(UITableView *)table heightForFooterInSection:(NSInteger)section {+ return CGFLOAT_MIN;+}++- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {+ UITableViewCell *cell = SGDequeueCell(table, @"choice");+ SGFillCell(cell, _choices[(NSUInteger)path.row], nil, nil, nil);+ cell.selectionStyle = UITableViewCellSelectionStyleDefault;+ if (path.row == SGInt(_key, _fallback)) {+ UIImageView *tick = SGSymbolView(@"checkmark", 13, UIImageSymbolWeightSemibold, 16);+ tick.tintColor = SGGreen();+ cell.accessoryView = tick;+ }+ return cell;+}++- (void)tableView:(UITableView *)table didSelectRowAtIndexPath:(NSIndexPath *)path {+ [table deselectRowAtIndexPath:path animated:NO];+ SGSetInt(_key, path.row);+ [table reloadData];+ [self.navigationController popViewControllerAnimated:YES];+}++@end++// No key on the row: the key lives in the blocks, so the page draws the row as the link it is+// rather than as a switch.+SGModRow *SGChoiceRow(NSString *title, NSString *subtitle, NSString *key, NSArray<NSString *> *choices, NSInteger fallback) {+ SGModRow *row = [SGModRow new];+ row.title = title;+ row.subtitle = subtitle;+ row.value = ^NSString *{+ NSInteger index = SGInt(key, fallback);+ return index >= 0 && index < (NSInteger)choices.count ? choices[(NSUInteger)index] : choices.firstObject;+ };+ row.page = ^UIViewController *{+ return [[SGChoicePage alloc] initWithTitle:title key:key choices:choices fallback:fallback];+ };+ return row;+}+SGModRow *SGLinkRow(NSString *title, NSString *subtitle, NSString *url) {return SGActionRow(title, subtitle, ^{ SGOpenURL(url); });}@@ -109,6 +193,24 @@ SGModSection *SGSection(NSString *title, NSArray<SGModRow *> *rows) {return s;}+// What a page row carrying a value shows on the right: the value, then the chevron, the same+// distance apart as Spotify's own rows keep them.+static UIView *valueAndChevron(NSString *text) {+ UILabel *label = [UILabel new];+ label.font = SGTitleFont();+ label.textColor = SGGrey();+ label.text = text;+ [label sizeToFit];+ UIImageView *chevron = SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);+ CGFloat height = MAX(label.bounds.size.height, chevron.bounds.size.height);+ UIView *box = [[UIView alloc] initWithFrame:CGRectMake(0, 0, label.bounds.size.width + 6 + chevron.bounds.size.width, height)];+ label.center = CGPointMake(label.bounds.size.width / 2, height / 2);+ chevron.center = CGPointMake(box.bounds.size.width - chevron.bounds.size.width / 2, height / 2);+ [box addSubview:label];+ [box addSubview:chevron];+ return box;+}+// On means the row's own override is in place; anything else, including the opposite override// somebody set from the All flags page, reads as off.static BOOL flagRowOn(SGModRow *row) {@@ -136,7 +238,9 @@ static BOOL flagRowLocked(SGModRow *row) {_sections = sections;_intro = intro ? SGNote(intro) : nil;_footer = footer ? SGNote(footer) : nil;- for (SGModSection *s in sections) for (SGModRow *row in s.rows) _live |= row.value != nil;+ // A page row reads its value out when the page appears rather than on the ticker, so only the+ // rows whose numbers climb on their own keep one running.+ for (SGModSection *s in sections) for (SGModRow *row in s.rows) _live |= row.value && !row.page;return self;}@@ -163,8 +267,10 @@ static BOOL flagRowLocked(SGModRow *row) {- (void)viewWillAppear:(BOOL)animated {[super viewWillAppear:animated];- if (!_live) return;+ // Reloaded whether or not anything ticks: a choice row is showing whatever was picked on the+ // page it opened, which is gone by the time this one comes back.[self.tableView reloadData];+ if (!_live) return;// The counters climb while the page is open; the labels are written straight into the cells so// that a reload never lands under a switch being dragged._ticker = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(readValues) userInfo:nil repeats:YES];@@ -180,7 +286,7 @@ static BOOL flagRowLocked(SGModRow *row) {for (UITableViewCell *cell in self.tableView.visibleCells) {SGModRow *row = [self rowAt:[self.tableView indexPathForCell:cell]];UILabel *label = (UILabel *)cell.accessoryView;- if (!row.value || ![label isKindOfClass:UILabel.class]) continue;+ if (!row.value || row.page || ![label isKindOfClass:UILabel.class]) continue;label.text = row.value();[label sizeToFit];[cell setNeedsLayout];@@ -232,7 +338,7 @@ static BOOL flagRowLocked(SGModRow *row) {[toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];cell.accessoryView = toggle;} else if (row.page) {- cell.accessoryView = SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);+ cell.accessoryView = row.value ? valueAndChevron(row.value()) : SGSymbolView(@"chevron.right", 13, UIImageSymbolWeightSemibold, 16);cell.selectionStyle = UITableViewCellSelectionStyleDefault;} else if (row.value) {UILabel *label = [UILabel new];