-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WIP] Compose Theme #6753
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
Draft
mikescamell
wants to merge
14
commits into
develop
Choose a base branch
from
feature/mike/compose/theme_v2
base: develop
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.
+2,536
−13
Draft
[WIP] Compose Theme #6753
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6d498df
add compose dependencies
mikescamell e72e7f7
add coil
mikescamell 0be4f9d
add AndroidX activity compose dependency
mikescamell e89873f
Add kotlinx.collections.immutable dependency
mikescamell 358222e
turn on strong skipping
mikescamell 0503934
Add NoComposeViewUsageDetector to enforce ComposeView usage guidelines
mikescamell a09779d
Add NoSetContentDetector to prevent usage of setContent in Activities
mikescamell 1ca5a40
Apply suggestion from @Copilot
mikescamell 88d40e0
Apply suggestion from @Copilot
mikescamell 4e6ab03
Add DuckDuckGo theme components: colors, shapes, and typography
mikescamell 44bf06f
Add DuckDuckGoTextStyle
mikescamell 5fcbbad
Add DaxText composable for primary and secondary text styles
mikescamell 7c73a41
Add DaxButton and related button components for primary, secondary, a…
mikescamell d964ad8
Add ComposeView components for typography demonstration in Typography…
mikescamell 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
55 changes: 55 additions & 0 deletions
55
common/common-ui/src/main/java/com/duckduckgo/common/ui/compose/theme/Color.kt
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2024 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.common.ui.compose.theme | ||
|
||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.Color | ||
|
||
@Immutable | ||
data class DuckDuckGoColors( | ||
val background: Color, | ||
val backgroundInverted: Color, | ||
val surface: Color, | ||
val container: Color, | ||
val window: Color, | ||
val text: DuckDuckGoTextColors, | ||
val primaryIcon: Color, | ||
val iconDisabled: Color, | ||
val destructive: Color, | ||
val lines: Color, | ||
val accentBlue: Color, | ||
val accentYellow: Color, | ||
val containerDisabled: Color, | ||
val textDisabled: Color, | ||
val ripple: Color, | ||
val logoTitleText: Color, | ||
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. Should these last 2 colors go to |
||
val omnibarTextColorHighlight: Color, | ||
) | ||
|
||
@Immutable | ||
data class DuckDuckGoTextColors( | ||
val primary: Color, | ||
val primaryInverted: Color, | ||
val secondary: Color, | ||
val secondaryInverted: Color, | ||
val tertiaryText: Color, | ||
) | ||
|
||
val LocalDuckDuckGoColors = staticCompositionLocalOf<DuckDuckGoColors> { | ||
error("No DuckDuckGoColors provided") | ||
} |
32 changes: 32 additions & 0 deletions
32
common/common-ui/src/main/java/com/duckduckgo/common/ui/compose/theme/Shape.kt
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2025 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.common.ui.compose.theme | ||
|
||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.Shape | ||
|
||
@Immutable | ||
data class DuckDuckGoShapes( | ||
val small: Shape, | ||
val medium: Shape, | ||
val large: Shape, | ||
) | ||
|
||
val LocalDuckDuckGoShapes = staticCompositionLocalOf<DuckDuckGoShapes> { | ||
error("No DuckDuckGoShapes provided") | ||
} |
127 changes: 127 additions & 0 deletions
127
common/common-ui/src/main/java/com/duckduckgo/common/ui/compose/theme/Theme.kt
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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright (c) 2025 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.common.ui.compose.theme | ||
|
||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.dimensionResource | ||
import com.duckduckgo.mobile.android.R | ||
|
||
object DuckDuckGoTheme { | ||
|
||
val colors: DuckDuckGoColors | ||
@Composable | ||
get() = LocalDuckDuckGoColors.current | ||
|
||
val textColors: DuckDuckGoTextColors | ||
@Composable | ||
get() = LocalDuckDuckGoColors.current.text | ||
|
||
val shapes | ||
@Composable | ||
get() = LocalDuckDuckGoShapes.current | ||
|
||
val typography | ||
@Composable | ||
get() = LocalDuckDuckGoTypography.current | ||
} | ||
|
||
@Composable | ||
fun ProvideDuckDuckGoTheme( | ||
colors: DuckDuckGoColors, | ||
shapes: DuckDuckGoShapes, | ||
typography: DuckDuckGoTypography = DuckDuckGoTypography(colors.text.primary), | ||
content: @Composable () -> Unit, | ||
) { | ||
CompositionLocalProvider( | ||
LocalDuckDuckGoColors provides colors, | ||
LocalDuckDuckGoShapes provides shapes, | ||
LocalDuckDuckGoTypography provides typography, | ||
content = content, | ||
) | ||
} | ||
|
||
@Composable | ||
fun DuckDuckGoTheme( | ||
isDarkTheme: Boolean = isSystemInDarkTheme(), | ||
content: @Composable () -> Unit, | ||
) { | ||
val lightColorPalette = DuckDuckGoColors( | ||
background = colorResource(R.color.gray0), | ||
backgroundInverted = colorResource(R.color.gray100), | ||
surface = colorResource(R.color.white), | ||
container = colorResource(R.color.black6), | ||
window = colorResource(R.color.white), | ||
primaryIcon = colorResource(R.color.black84), | ||
iconDisabled = colorResource(R.color.black40), | ||
destructive = colorResource(R.color.alertRedOnLightDefault), | ||
containerDisabled = colorResource(R.color.black6), | ||
textDisabled = colorResource(R.color.black36), | ||
lines = colorResource(R.color.black9), | ||
accentBlue = colorResource(R.color.blue50), | ||
accentYellow = colorResource(R.color.yellow50), | ||
ripple = colorResource(R.color.black6), | ||
logoTitleText = colorResource(R.color.gray85), | ||
omnibarTextColorHighlight = colorResource(R.color.blue50_20), | ||
text = DuckDuckGoTextColors( | ||
primary = colorResource(R.color.black84), | ||
primaryInverted = colorResource(R.color.white84), | ||
secondary = colorResource(R.color.black60), | ||
secondaryInverted = colorResource(R.color.white60), | ||
tertiaryText = colorResource(R.color.black48), | ||
) | ||
) | ||
|
||
val darkColorPalette = DuckDuckGoColors( | ||
background = colorResource(R.color.gray100), | ||
backgroundInverted = colorResource(R.color.gray0), | ||
surface = colorResource(R.color.gray90), | ||
container = colorResource(R.color.white12), | ||
window = colorResource(R.color.gray85), | ||
primaryIcon = colorResource(R.color.white84), | ||
iconDisabled = colorResource(R.color.white40), | ||
destructive = colorResource(R.color.alertRedOnDarkDefault), | ||
containerDisabled = colorResource(R.color.white18), | ||
textDisabled = colorResource(R.color.white36), | ||
lines = colorResource(R.color.white9), | ||
accentBlue = colorResource(R.color.blue30), | ||
accentYellow = colorResource(R.color.yellow50), | ||
ripple = colorResource(R.color.white12), | ||
logoTitleText = colorResource(R.color.white), | ||
omnibarTextColorHighlight = colorResource(R.color.blue30_20), | ||
text = DuckDuckGoTextColors( | ||
primary = colorResource(R.color.white84), | ||
primaryInverted = colorResource(R.color.black84), | ||
secondary = colorResource(R.color.white60), | ||
secondaryInverted = colorResource(R.color.black60), | ||
tertiaryText = colorResource(R.color.white48), | ||
) | ||
) | ||
|
||
val shapes = DuckDuckGoShapes( | ||
small = RoundedCornerShape(dimensionResource(R.dimen.smallShapeCornerRadius)), | ||
medium = RoundedCornerShape(dimensionResource(R.dimen.mediumShapeCornerRadius)), | ||
large = RoundedCornerShape(dimensionResource(R.dimen.largeShapeCornerRadius)), | ||
) | ||
|
||
val colors = if (isDarkTheme) darkColorPalette else lightColorPalette | ||
|
||
ProvideDuckDuckGoTheme(colors = colors, shapes = shapes, content = content) | ||
} |
101 changes: 101 additions & 0 deletions
101
common/common-ui/src/main/java/com/duckduckgo/common/ui/compose/theme/Typography.kt
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (c) 2025 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.common.ui.compose.theme | ||
|
||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
|
||
@Immutable | ||
data class DuckDuckGoTypography( | ||
|
||
val defaultTextColor: Color, | ||
|
||
val title: TextStyle = TextStyle( | ||
fontSize = 32.sp, | ||
lineHeight = 36.sp, | ||
fontWeight = FontWeight.Bold, | ||
color = defaultTextColor, | ||
), | ||
|
||
val h1: TextStyle = TextStyle( | ||
fontSize = 24.sp, | ||
lineHeight = 30.sp, | ||
fontWeight = FontWeight.Bold, | ||
color = defaultTextColor, | ||
), | ||
|
||
val h2: TextStyle = TextStyle( | ||
fontSize = 20.sp, | ||
lineHeight = 24.sp, | ||
fontWeight = FontWeight.Medium, | ||
color = defaultTextColor, | ||
), | ||
|
||
val h3: TextStyle= TextStyle( | ||
fontSize = 16.sp, | ||
lineHeight = 21.sp, | ||
fontWeight = FontWeight.Medium, | ||
color = defaultTextColor, | ||
), | ||
|
||
val h4: TextStyle = TextStyle( | ||
fontSize = 14.sp, | ||
lineHeight = 20.sp, | ||
fontWeight = FontWeight.Medium, | ||
color = defaultTextColor, | ||
), | ||
|
||
val h5: TextStyle = TextStyle( | ||
fontSize = 13.sp, | ||
lineHeight = 16.sp, | ||
fontWeight = FontWeight.Medium, | ||
color = defaultTextColor, | ||
), | ||
|
||
val body1: TextStyle = TextStyle( | ||
fontSize = 16.sp, | ||
lineHeight = 20.sp, | ||
color = defaultTextColor, | ||
), | ||
|
||
val body2: TextStyle = TextStyle( | ||
fontSize = 14.sp, | ||
lineHeight = 18.sp, | ||
color = defaultTextColor, | ||
), | ||
|
||
val button: TextStyle = TextStyle( | ||
fontSize = 15.sp, | ||
lineHeight = 20.sp, | ||
fontWeight = FontWeight.Bold, | ||
color = defaultTextColor, | ||
), | ||
|
||
val caption: TextStyle = TextStyle( | ||
fontSize = 12.sp, | ||
lineHeight = 16.sp, | ||
color = defaultTextColor, | ||
), | ||
) | ||
|
||
val LocalDuckDuckGoTypography = staticCompositionLocalOf<DuckDuckGoTypography> { | ||
error("No DuckDuckGoTypography provided") | ||
} |
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.
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.
There are some missing colors: