-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(auth): allow customizing top app bar colors via AuthUITheme #2391
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
Open
demolaf
wants to merge
5
commits into
version-10.0.0-beta04
Choose a base branch
from
fix/customizable-top-app-bar-colors
base: version-10.0.0-beta04
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
796d58a
fix(auth): allow customizing top app bar colors via AuthUITheme
demolaf 52b9650
sample(app): demo custom topAppBarColors in HighLevelApiDemoActivity
demolaf 284730f
docs(auth): document topAppBarColors customization
demolaf 73765d9
sample(app): use adaptive theme and Firebase brand color for demo top…
demolaf 8aa50f0
fix(auth): wire topAppBarColors into MFA screen and dedupe resolution…
demolaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import androidx.compose.material3.ColorScheme | |
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Shapes | ||
| import androidx.compose.material3.TopAppBarColors | ||
| import androidx.compose.material3.TopAppBarDefaults | ||
| import androidx.compose.material3.Typography | ||
| import androidx.compose.material3.darkColorScheme | ||
|
|
@@ -81,6 +82,12 @@ class AuthUITheme( | |
| * ``` | ||
| */ | ||
| val providerButtonShape: Shape? = null, | ||
|
|
||
| /** | ||
| * Custom colors for the top app bar shown on auth screens. If null, falls back to | ||
| * colors derived from [colorScheme] (see [AuthUITheme.topAppBarColors]). | ||
| */ | ||
| val topAppBarColors: TopAppBarColors? = null, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LocalAuthUITheme.current.topAppBarColors ?: AuthUITheme.topAppBarColors is copied into all 6 screen files - can we pull that into one resolved property on AuthUITheme instead? Saves updating 6 files next time this logic changes. |
||
| ) { | ||
|
|
||
| /** | ||
|
|
@@ -91,6 +98,7 @@ class AuthUITheme( | |
| * @param shapes The shapes to use. Defaults to this theme's shapes. | ||
| * @param providerStyles Custom styling for individual providers. Defaults to this theme's provider styles. | ||
| * @param providerButtonShape Default shape for provider buttons. Defaults to this theme's provider button shape. | ||
| * @param topAppBarColors Custom top app bar colors. Defaults to this theme's top app bar colors. | ||
| * @return A new AuthUITheme instance with the specified properties. | ||
| */ | ||
| fun copy( | ||
|
|
@@ -99,13 +107,15 @@ class AuthUITheme( | |
| shapes: Shapes = this.shapes, | ||
| providerStyles: Map<String, ProviderStyle> = this.providerStyles, | ||
| providerButtonShape: Shape? = this.providerButtonShape, | ||
| topAppBarColors: TopAppBarColors? = this.topAppBarColors, | ||
| ): AuthUITheme { | ||
| return AuthUITheme( | ||
| colorScheme = colorScheme, | ||
| typography = typography, | ||
| shapes = shapes, | ||
| providerStyles = providerStyles, | ||
| providerButtonShape = providerButtonShape | ||
| providerButtonShape = providerButtonShape, | ||
| topAppBarColors = topAppBarColors | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -118,6 +128,7 @@ class AuthUITheme( | |
| if (shapes != other.shapes) return false | ||
| if (providerStyles != other.providerStyles) return false | ||
| if (providerButtonShape != other.providerButtonShape) return false | ||
| if (topAppBarColors != other.topAppBarColors) return false | ||
|
|
||
| return true | ||
| } | ||
|
|
@@ -128,12 +139,14 @@ class AuthUITheme( | |
| result = 31 * result + shapes.hashCode() | ||
| result = 31 * result + providerStyles.hashCode() | ||
| result = 31 * result + (providerButtonShape?.hashCode() ?: 0) | ||
| result = 31 * result + (topAppBarColors?.hashCode() ?: 0) | ||
| return result | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return "AuthUITheme(colorScheme=$colorScheme, typography=$typography, shapes=$shapes, " + | ||
| "providerStyles=$providerStyles, providerButtonShape=$providerButtonShape)" | ||
| "providerStyles=$providerStyles, providerButtonShape=$providerButtonShape, " + | ||
| "topAppBarColors=$topAppBarColors)" | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -236,6 +249,15 @@ class AuthUITheme( | |
| titleContentColor = MaterialTheme.colorScheme.onPrimary, | ||
| navigationIconContentColor = MaterialTheme.colorScheme.onPrimary, | ||
| ) | ||
|
|
||
| /** | ||
| * Resolves the top app bar colors to use for the current [LocalAuthUITheme], falling back | ||
| * to [topAppBarColors] when the current theme doesn't specify its own. | ||
| */ | ||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @get:Composable | ||
| val resolvedTopAppBarColors: TopAppBarColors | ||
| get() = LocalAuthUITheme.current.topAppBarColors ?: topAppBarColors | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.