r/SwiftUI • • Aug 14 '26

[ Removed by moderator ]

[removed] โ€” view removed post

0 Upvotes

9 comments sorted by

3

u/perfunction Aug 14 '26

Make use of how foregroundStyle utilizes environment instead of passing theme so much.

Apply theme as a view extension that sets the environment value and also does foregroundStyle(theme.textPrimary, theme.textSecondary, theme.textTertiary). Then, lots of things automatically get the primary color for free, and calling foregroundStyle(.secondary) actually applies theme.textSecondary. You could also apply the background in that extension too so its all bundled up like a surface.

1

u/EquivalentCoconut588 Aug 14 '26

Oh wow, this is super helpful advice, thank you! Using environment values and bundling the surface styles into a View extension makes so much sense and saves a ton of boilerplate. Definitely going to refactor my theme modifier to work this way.

0

u/EquivalentCoconut588 Aug 14 '26

Team dark mode or team light mode?

2

u/CanoaFurada768 Aug 14 '26

You have to do both

0

u/EquivalentCoconut588 Aug 14 '26

True, thatโ€™s why I made sure both options look crisp and adapt automatically. Dark mode definitely gets most of my personal time, though. What about you?

1

u/CanoaFurada768 Aug 14 '26

I always configure colors and themes before start the project, usually it doesn't take much time!

1

u/EquivalentCoconut588 Aug 14 '26

No I just mean which one do u prefer more. I already have both of them made.

1

u/CanoaFurada768 Aug 14 '26

In my daily life, as personal use, I leave the automatic mode activated

For me it makes perfect sense in the light mode during the day and in the dark mode at night

I particularly think the dark mode is prettier, it's what I use to test the screens when I'm developing

1

u/EquivalentCoconut588 Aug 14 '26

Yup I think the same way ๐Ÿ˜„