Skip to content

Demo app dark mode support and letterbox/stepper fix#241

Merged
kostub merged 5 commits into
kostub:masterfrom
Janneman84:master
Jun 25, 2026
Merged

Demo app dark mode support and letterbox/stepper fix#241
kostub merged 5 commits into
kostub:masterfrom
Janneman84:master

Conversation

@Janneman84

@Janneman84 Janneman84 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Test dark mode in simulator with cmd+shift+A

Simulator Screenshot - iPhone 17 - 2026-06-15 at 15 44 45

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 textColor from UIColor.black to UIColor.label.

… 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread iosMathExample/View.xib Outdated
<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"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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"/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit where I changed it to clear.

Comment thread iosMathExample/example/ViewController.m Outdated
Comment on lines +100 to +101
// For night mode compatibility we use .labelColor
self.mathLabel.textColor = UIColor.labelColor;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kostub kostub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

  • UILaunchStoryboardNameView.xib is 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.xib has File's Owner customClass="ViewController" with six outlets and a customClass="MTMathUILabel" subview. It will fail to load / render blank (and can fail launch-image validation), which defeats the letterbox fix. Add a dedicated minimal LaunchScreen.storyboard (plain UIView with systemBackgroundColor, no File's Owner class, no outlets, no custom views) and point UILaunchStoryboardName at that instead.

🟡 Important (should fix)

  • colorField.backgroundColor = UIColor.labelColor paints 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 backgroundColor remains on the font-swatch field in View.xib while 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.h colorbox 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.

Comment thread iosMathExample/iosMath-Info.plist Outdated
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>View.xib</string>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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 is customClass="ViewController" with six outlets, or
  • instantiate custom view classes / run custom code — but View.xib contains a customClass="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.

Comment thread iosMathExample/example/ViewController.m Outdated
self.colorField.inputView = picker;
self.colorField.delegate = self;

self.colorField.backgroundColor = UIColor.labelColor;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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;.

Comment thread iosMathExample/View.xib
<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"/>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
@Janneman84

Copy link
Copy Markdown
Contributor Author

I just addressed your feedback and added UIScene support to prevent assertion failures in the near future.

@kostub kostub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✅

Verified all prior review comments against the current head (ddab4c5):

  • 🔴 Critical — invalid launch screen (UILaunchStoryboardNameView.xib): Fixed. A dedicated minimal Launch Screen.storyboard was 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!

@kostub kostub merged commit 52a36b6 into kostub:master Jun 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants