-
Notifications
You must be signed in to change notification settings - Fork 168
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
Auto theme #123
base: main
Are you sure you want to change the base?
Auto theme #123
Conversation
…lying an accentColor to the ChatView. It handles switching certain images out for SFSymbols that are then tinted with said accent color.
…or auto-themeing a `ChatView`. By default it creates a ChatTheme with an accentColor and backgroundColor and adjusts some images to use SFSymbols instead of the bundled ones (allows for tinting of the icons). This method attempts to maintain contrast and readability when provided with very bright / dark colors by calcualting the luminance and adjusting it accordingly. This method is only available in iOS 18+ due to the use of `Color.mix(with:, by:)` method.
…y can be seen. Doesn't need to be merged!
fullscreenTint: .white | ||
) | ||
) | ||
// .mediaPickerTheme( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about prior to ios 18? will the media picker be not themed at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, the mediaPickerTheme was overridden in commit 88d097e.
This section in AttachmentsEditor.swift
.mediaPickerTheme(
main: .init(
text: theme.colors.mainText,
albumSelectionBackground: theme.colors.mainBG,
fullscreenPhotoBackground: theme.colors.mainBG,
cameraBackground: theme.colors.mainBG,
cameraSelectionBackground: theme.colors.mainBG),
selection: .init(selectedTint: theme.colors.sendButtonBackground)
)
Should probably be replaced with just
.mediaPickerTheme(pickerTheme)
In order to honor the users ChatView.mediaPickerTheme
modifier.
The problem is that the default values want to match that of the ChatTheme but if we apply these default values in the chatTheme modifier then we could potentially overwrite an already defined mediaPickerTheme.
ChatView( ... )
.mediaPickerTheme( ... custom theme ... )
.chatTheme( ... custom theme ... ) // If we set mediaPickerTheme defaults here, we override the changes made above.
If we bring mediaPickerTheme
into the ChatTheme
struct, then we could provide some nice default values without having to worry about potentially overriding a previously defined MediaPickerTheme.
ChatView( ... )
.chatTheme(
colors: ...,
images: ...,
mediaPickerTheme: ...
)
What do you think?
colors: .init( | ||
mainTint: accentColor, | ||
messageMyBG: accentColor, | ||
messageMyTimeText: Color.white.opacity(0.5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does white come together with accentColor? could you use your contrast magic for this too?
also, would you please move all of these to a separate file like "Theme+Convenience" or smth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The senders text is always .white
, similar to your default ChatTheme value and Apple's message app. I was adjusting the message bubble color to improve contrast as opposed to altering the text color. I think a solid .white
text color will always be easier to read over a tinted / off-white text on a colored background. What do you think?
…e .mediaPickerTheme modifier is currently broken and doesn't have an effect on the MediaPickers appearance.
What:
ChatView
Simply changing the accent color of the
ChatView
ChatView
.Comprehensive Theme
Requires:
#122 to be merged in order for the theme to be applied correctly
Disclosure:
Important
The comprehensive theme requires iOS 18+ due to its use of the Color.mix(with:, by:) method.
Backwards compatibility is maintained by decorating these functions with
@available(iOS 18.0, *)