Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CGColors to update on trait collection changes #4513

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mats-stripe
Copy link
Collaborator

Summary

CGColor's (which are the underlying color system used for shadows and borders) don't automatically update to their light / dark equivalent when the system theme changes. Because of this, we need to observe those changes (via traitCollectionDidChange) and manually update the colors.

This is a bit of a tedious change, but is needed for proper dark mode support.

Implementation based on: https://www.jessesquires.com/blog/2020/03/23/implementing-dark-mode-with-cgcolor/

Motivation

Polish dark mode to work correctly with shadows and borders.

Testing

Before:

Screen.Recording.2025-01-29.at.3.45.37.PM.mov

After:

Screen.Recording.2025-01-29.at.3.44.52.PM.mov

Changelog

N/a

@mats-stripe mats-stripe changed the title Fix CGColors to update on trait collection changes Fix CGColors to update on trait collection changes Jan 29, 2025
Copy link

🚨 New dead code detected in this PR:

InstitutionSearchBar.swift:22 warning: Property 'shadowLayer' is unused

Please remove the dead code before merging.

If this is intentional, you can bypass this check by adding the label skip dead code check to this PR.

ℹ️ If this comment appears to be left in error, double check that the flagged code is actually used and/or make sure your branch is up-to-date with master.

@mats-stripe mats-stripe force-pushed the mats/fix_cgcolors_to_be_dynamic branch from d4a0ec3 to 4f2556e Compare January 30, 2025 15:54
@mats-stripe mats-stripe marked this pull request as ready for review January 31, 2025 14:32
@mats-stripe mats-stripe requested review from a team as code owners January 31, 2025 14:32
Base automatically changed from mats/fc_configuration_api to master January 31, 2025 16:37
Copy link

emerge-tools bot commented Jan 31, 2025

⚠️ 1 new unused protocol, 1 build increased size, 5 builds decreased size, 2 builds errored

Name Version Download Change Install Change Approval
StripeSize
com.stripe.StripeSize
1.0 (1) 2.1 MB ⬇️ 2.3 kB (-0.11%) 6.9 MB ⬇️ 1.4 kB (-0.02%) N/A
StripePaymentsSize
com.stripe.StripePaymentsSize
1.0 (1) 1.2 MB ⬇️ 2.8 kB (-0.23%) 4.2 MB ⬇️ 1.4 kB (-0.03%) N/A
StripePaymentsUISize
com.stripe.StripePaymentsUISize
1.0 (1) 1.9 MB ⬇️ 2.8 kB (-0.15%) 6.4 MB ⬇️ 1.4 kB (-0.02%) N/A
StripePaymentSheetSize
com.stripe.StripePaymentSheetSize
1.0 (1) 3.7 MB ⬇️ 8.4 kB (-0.22%) 11.1 MB ⬇️ 21.6 kB (-0.2%) N/A
StripeApplePaySize
com.stripe.StripeApplePaySize
1.0 (1) 486.8 kB ⬇️ 2.0 kB (-0.42%) 1.7 MB ⬇️ 108 B N/A
StripeFinancialConnectionsSize
com.stripe.StripeFinancialConnectionsSize
1.0 (1) 1.5 MB ⬆️ 1.2 kB (0.08%) 4.8 MB ⬆️ 6.4 kB (0.13%) N/A

StripeSize 1.0 (1)
com.stripe.StripeSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 1.4 kB (-0.02%)
Total download size change: ⬇️ 2.3 kB (-0.11%)

Largest size changes

Item Install Size Change
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
Other ⬆️ 2.8 kB
View Treemap

Image of diff

StripePaymentsSize 1.0 (1)
com.stripe.StripePaymentsSize

⚠️ Found new unused protocol: EmbeddedPaymentElementDelegate
⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 1.4 kB (-0.03%)
Total download size change: ⬇️ 2.8 kB (-0.23%)

Largest size changes

Item Install Size Change
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
DYLD.Exports ⬇️ -720 B
Other ⬆️ 3.5 kB
View Treemap

Image of diff

StripePaymentsUISize 1.0 (1)
com.stripe.StripePaymentsUISize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 1.4 kB (-0.02%)
Total download size change: ⬇️ 2.8 kB (-0.15%)

Largest size changes

Item Install Size Change
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
Other ⬆️ 2.7 kB
View Treemap

Image of diff

StripePaymentSheetSize 1.0 (1)
com.stripe.StripePaymentSheetSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 21.6 kB (-0.2%)
Total download size change: ⬇️ 8.4 kB (-0.22%)

Largest size changes

Item Install Size Change
🗑 StripePaymentSheet.EmbeddedPaymentElementViewModel ⬇️ -5.6 kB
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
DYLD.Exports ⬇️ -1.6 kB
DYLD.Fixups ⬇️ -960 B
DYLD.String Table ⬇️ -904 B
View Treemap

Image of diff

StripeApplePaySize 1.0 (1)
com.stripe.StripeApplePaySize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬇️ 108 B
Total download size change: ⬇️ 2.0 kB (-0.42%)

Largest size changes

Item Install Size Change
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
Other ⬆️ 4.1 kB
View Treemap

Image of diff

StripeFinancialConnectionsSize 1.0 (1)
com.stripe.StripeFinancialConnectionsSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 6.4 kB (0.13%)
Total download size change: ⬆️ 1.2 kB (0.08%)

Largest size changes

Item Install Size Change
StripeCore.STPAnalyticEvent.init(rawValue) ⬇️ -4.2 kB
🗑 StripeFinancialConnections.AccountPickerRowView.isSelected ⬇️ -1.2 kB
📝 StripeFinancialConnections.AccountPickerRowView.updateLayer ⬆️ 1.1 kB
📝 StripeFinancialConnections.ConsentLogoView.traitCollectionDidChan... ⬆️ 532 B
Other ⬆️ 10.1 kB
View Treemap

Image of diff

Unsuccessful Builds

Name Message
StripeIdentitySize
com.stripe.StripeIdentitySize
The diff could not be determined because no build for 847b7cb was uploaded
StripeConnectSize
com.stripe.StripeConnectSize
The diff could not be determined because no build for 847b7cb was uploaded

🛸 Powered by Emerge Tools

Copy link

emerge-tools bot commented Jan 31, 2025

2 builds increased size, 6 builds had no size change

Name Version Download Change Install Change Approval
StripeSize
com.stripe.StripeSize
1.0 (1) 2.1 MB - 6.9 MB - N/A
StripePaymentsSize
com.stripe.StripePaymentsSize
1.0 (1) 1.2 MB - 4.2 MB - N/A
StripePaymentsUISize
com.stripe.StripePaymentsUISize
1.0 (1) 1.9 MB - 6.4 MB - N/A
StripePaymentSheetSize
com.stripe.StripePaymentSheetSize
1.0 (1) 3.8 MB ⬆️ 2 B 11.1 MB - N/A
StripeIdentitySize
com.stripe.StripeIdentitySize
1.0 (1) 1.4 MB ⬇️ 2 B 4.4 MB - N/A
StripeApplePaySize
com.stripe.StripeApplePaySize
1.0 (1) 488.9 kB - 1.7 MB - N/A
StripeFinancialConnectionsSize
com.stripe.StripeFinancialConnectionsSize
1.0 (1) 1.5 MB ⬆️ 3.2 kB (0.21%) 4.8 MB ⬆️ 6.1 kB (0.13%) N/A
StripeConnectSize
com.stripe.StripeConnectSize
1.0 (1) 1.7 MB ⬆️ 2.5 kB (0.15%) 5.4 MB ⬆️ 6.5 kB (0.12%) N/A

StripeSize 1.0 (1)
com.stripe.StripeSize

No changes to report

StripePaymentsSize 1.0 (1)
com.stripe.StripePaymentsSize

No changes to report

StripePaymentsUISize 1.0 (1)
com.stripe.StripePaymentsUISize

No changes to report

StripePaymentSheetSize 1.0 (1)
com.stripe.StripePaymentSheetSize

No changes to report

StripeIdentitySize 1.0 (1)
com.stripe.StripeIdentitySize

No changes to report

StripeApplePaySize 1.0 (1)
com.stripe.StripeApplePaySize

No changes to report

StripeFinancialConnectionsSize 1.0 (1)
com.stripe.StripeFinancialConnectionsSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 6.1 kB (0.13%)
Total download size change: ⬆️ 3.2 kB (0.21%)

Largest size changes

Item Install Size Change
🗑 StripeFinancialConnections.AccountPickerRowView.isSelected ⬇️ -1.2 kB
📝 StripeFinancialConnections.AccountPickerRowView.updateLayer ⬆️ 1.1 kB
📝 StripeFinancialConnections.ConsentLogoView.traitCollectionDidChan... ⬆️ 532 B
Other ⬆️ 5.7 kB
View Treemap

Image of diff

StripeConnectSize 1.0 (1)
com.stripe.StripeConnectSize

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 6.5 kB (0.12%)
Total download size change: ⬆️ 2.5 kB (0.15%)

Largest size changes

Item Install Size Change
🗑 StripeFinancialConnections.AccountPickerRowView.isSelected ⬇️ -1.2 kB
📝 StripeFinancialConnections.AccountPickerRowView.updateLayer ⬆️ 1.1 kB
📝 StripeFinancialConnections.ConsentLogoView.traitCollectionDidChan... ⬆️ 532 B
Other ⬆️ 6.1 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

@mats-stripe mats-stripe force-pushed the mats/fix_cgcolors_to_be_dynamic branch from 4f2556e to 74b0a44 Compare January 31, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant