Demo app dark mode support and letterbox/stepper fix#241
Conversation
… also fixes the shifted stepper (liquid glass). One constraint was adjusted but the editor updated a bunch of stuff.
…ft+A. This also required switching to system colors in the color pallette, of which a few more were added and reordered for a full rainbow.
There was a problem hiding this comment.
Code Review
This pull request updates the example application to support modern iOS devices and dark mode by removing legacy launch images, updating the XIB layout, and adopting dynamic system colors. However, two issues were identified regarding dark mode compatibility: the math label retains a hardcoded white background in the XIB, which will cause text to become invisible (white-on-white) in dark mode. It is recommended to set the background color of the math label to clear/transparent both in the XIB and programmatically in the view controller.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| <rect key="frame" x="10" y="65" width="300" height="60"/> | ||
| <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
| <rect key="frame" x="10" y="65" width="373" height="60"/> | ||
| <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
There was a problem hiding this comment.
The mathLabel (jao-lN-IEn) has a hardcoded white background (#FFFFFF) in the XIB. In dark mode, since its text color is set to UIColor.labelColor (which becomes white), the text will be white on a white background, making the custom equation completely invisible. Changing the background color to a transparent/clear color resolves this issue and allows the parent view's dynamic background to show through.
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
There was a problem hiding this comment.
I added a commit where I changed it to clear.
| // For night mode compatibility we use .labelColor | ||
| self.mathLabel.textColor = UIColor.labelColor; |
There was a problem hiding this comment.
To ensure that the custom equation label (self.mathLabel) is fully compatible with dark mode, we should also programmatically set its background color to clear. This acts as a safe fallback in case the XIB's background color is not updated, preventing white-on-white text invisibility in dark mode.
// For night mode compatibility we use .labelColor
self.mathLabel.textColor = UIColor.labelColor;
self.mathLabel.backgroundColor = UIColor.clearColor;There was a problem hiding this comment.
It turns out MTMathUILabel already sets background to clear when created from a xib. So this extra line would be unnecessary.
You actually pointed out a bug because you would expect the background color to be whatever you set it in the xib. Currently this just gets ignored.
…rs for night mode legibility
kostub
left a comment
There was a problem hiding this comment.
Code review — demo dark mode + letterbox/stepper fix
Thanks for this! The dark-mode work is well-scoped: it touches only the demo app, leaves the library + public LaTeX API untouched, and uses dynamic system colors (labelColor, systemXxxColor) that adapt automatically. The Default*.png launch-image removal is clean and internally consistent across all four pbxproj sections, and the "top test formulas didn't recolor" bug is genuinely fixed by setting textColor on the code-created labels.
One blocker before merge, plus two things to confirm — details inline.
🔴 Critical (must fix)
UILaunchStoryboardName→View.xibis an invalid launch screen. A launch nib is instantiated by the system outside your process and cannot have a custom File's Owner class with connected outlets, nor instantiate custom view classes.View.xibhas File's OwnercustomClass="ViewController"with six outlets and acustomClass="MTMathUILabel"subview. It will fail to load / render blank (and can fail launch-image validation), which defeats the letterbox fix. Add a dedicated minimalLaunchScreen.storyboard(plainUIViewwithsystemBackgroundColor, no File's Owner class, no outlets, no custom views) and pointUILaunchStoryboardNameat that instead.
🟡 Important (should fix)
colorField.backgroundColor = UIColor.labelColorpaints the swatch field solid black (light) / white (dark) on init; the field is meant to preview the selected color. Suggest initializing to the first palette color instead.- A hardcoded opaque-black
backgroundColorremains on the font-swatch field inView.xibwhile its siblings were converted to system colors — it'll be invisible in dark mode. Confirm whether intentional.
🟢 Minor / fine
- Highlight color change (sat 0.2→0.5, alpha 1.0→0.5) is a sensible dark-mode-friendly tweak.
MathExamples.hcolorbox hex dimming is cosmetic demo-only — fine.
Verdict: approve with fixes — the launch-screen item is the one real blocker. Recommend building the demo in both light and dark on an iPhone 16 sim to confirm no launch-nib console error and that the letterbox is actually gone.
| <key>LSRequiresIPhoneOS</key> | ||
| <true/> | ||
| <key>UILaunchStoryboardName</key> | ||
| <string>View.xib</string> |
There was a problem hiding this comment.
🔴 Critical: pointing UILaunchStoryboardName at the app's main View.xib is not a valid launch screen.
A launch storyboard/nib is instantiated by the system outside the app process to draw a static splash. It cannot:
- have a File's Owner with a custom class + connected outlets — but
View.xib's File's Owner iscustomClass="ViewController"with six outlets, or - instantiate custom view classes / run custom code — but
View.xibcontains acustomClass="MTMathUILabel"subview (which runs CoreText layout).
Result: the launch nib fails to load (blank/default launch) or fails launch-image validation, so the letterbox fix doesn't actually take effect.
Fix: add a dedicated minimal LaunchScreen.storyboard (plain UIView with systemBackgroundColor, no File's Owner custom class, no outlets, no custom views) and point this key at that instead of View.xib.
| self.colorField.inputView = picker; | ||
| self.colorField.delegate = self; | ||
|
|
||
| self.colorField.backgroundColor = UIColor.labelColor; |
There was a problem hiding this comment.
🟡 Important: labelColor is black in light / white in dark, so this paints the swatch field as a solid black-or-white box. This field previews the currently selected color (the picker sets colorField.backgroundColor = selectedColor on selection), so initializing it to labelColor is conceptually off and can make the placeholder/cursor invisible in light mode. Consider initializing to the first palette color, e.g. self.colorField.backgroundColor = self.colorPickerDelegate.colors.firstObject;.
| <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> | ||
| <color key="tintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> | ||
| <rect key="frame" x="141.66666666666666" y="10" width="35" height="35"/> | ||
| <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
There was a problem hiding this comment.
🟡 Important: this backgroundColor is left as hardcoded opaque black while the sibling fields were converted to system colors. In dark mode a pure-black field is invisible against the dark background. If this is the font-color preview swatch and the black is intentional, ignore — otherwise convert it to a system/dynamic color for consistency.
- updated demo project to use UIScene
|
I just addressed your feedback and added UIScene support to prevent assertion failures in the near future. |
kostub
left a comment
There was a problem hiding this comment.
Approved ✅
Verified all prior review comments against the current head (ddab4c5):
- 🔴 Critical — invalid launch screen (
UILaunchStoryboardName→View.xib): Fixed. A dedicated minimalLaunch Screen.storyboardwas added (plain view controller, no File's Owner custom class, no outlets, no custom view classes,systemBackgroundColor) and wired up in Info.plist + Copy Bundle Resources. - 🟡 colorField init: Now initialized to the first palette color in
viewDidLoad, consistent with the math label's default text color. - 🟡 Opaque-black bg in
View.xib: Overridden at load, so it never renders (the dead value could be cleaned from the XIB, but it's harmless). - 🔴 mathLabel white background (white-on-white in dark mode): Fixed — now clear in the XIB.
The UIScene migration is clean: AppDelegate stripped of window setup, SceneDelegate owns the window with systemBackgroundColor, manifest + pbxproj wiring consistent.
Only nitpicks remain (stale black value in View.xib, guard ordering in SceneDelegate) — neither blocks merge. Nice work!
Test dark mode in simulator with cmd+shift+A
I noticed the equation you create yourself (at the top) does not change color or change font/size like the rest. Is this by design? I mean I could easily fix this.
Oh and I suggest you change the default
textColorfromUIColor.blacktoUIColor.label.