Skip to content

Commit

Permalink
ANDROID-13833 Extract common functionality and add Override suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
dagonco committed Nov 7, 2023
1 parent 9c10aa2 commit a5c2562
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion library/src/main/res/values/themes_vivoNew.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</style>

<!-- Just a copy of the above. As themes do no support multiple inheritance -->
<style name="VivoNew_Customizations" parent="VivoNew_Base">
<style name="VivoNewOverride_Customizations" parent="VivoNewOverride_Base">
<!-- Gradients (assistant, pin fingerprint screens) -->
<item name="colorGradientBackgroundFirst">?colorBackgroundBrand</item>
<item name="colorGradientBackgroundSecond">?colorBackgroundBrand</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,32 @@ class GenerateXMLFiles(
}

private fun generateLightThemesFiles(tokens: TokensDTO, brand: Brand) {
val lightThemesXml = xml("resources", "utf-8", XmlVersion.V10) {
comment(AUTOGENERATED_COMMENT)

fun Node.generateTheme(themeName: String) {
"style" {
attribute("name", "MisticaTheme.${brand.name.capitalizeString()}")
attribute("parent", "MisticaTheme.${brand.name.capitalizeString()}_Customizations")
attribute("name", themeName)
attribute("parent", "${themeName}_Customizations")
}

"style" {
attribute("name", "MisticaTheme.${brand.name.capitalizeString()}_Base")
attribute("name", "${themeName}_Base")
mapColors(tokens.light, brand)
borderRadius(tokens)
presetFonts(tokens)
presetStyles(tokens)
presetSizes(tokens)
}
}

if (brand.createDuplicateWithoutInheritMistica) {
"style" {
attribute("name", brand.name.capitalizeString())
attribute("parent", "${brand.name.capitalizeString()}_Customizations")
}
val lightThemesXml = xml("resources", "utf-8", XmlVersion.V10) {
comment(AUTOGENERATED_COMMENT)

"style" {
attribute("name", "${brand.name.capitalizeString()}_Base")
mapColors(tokens.light, brand)
borderRadius(tokens)
presetFonts(tokens)
presetStyles(tokens)
presetSizes(tokens)
}
val brandName = brand.name.capitalizeString()

generateTheme("MisticaTheme.$brandName")

if (brand.createDuplicateWithoutInheritMistica) {
generateTheme("${brandName}Override")
}
}

Expand Down Expand Up @@ -170,21 +165,24 @@ class GenerateXMLFiles(
}

private fun generateDarkThemesFiles(tokens: TokensDTO, brand: Brand) {
val darkThemesXml = xml("resources", "utf-8", XmlVersion.V10) {
comment(AUTOGENERATED_COMMENT)

fun Node.generateTheme(themeName: String) {
"style" {
attribute("name", "MisticaTheme.${brand.name.capitalizeString()}")
attribute("parent", "MisticaTheme.${brand.name.capitalizeString()}_Customizations")
attribute("name", themeName)
attribute("parent", "${themeName}_Customizations")
mapColors(tokens.dark, brand)
}
}

val darkThemesXml = xml("resources", "utf-8", XmlVersion.V10) {
comment(AUTOGENERATED_COMMENT)

val brandName = brand.name.capitalizeString()

generateTheme("MisticaTheme.$brandName")

if (brand.createDuplicateWithoutInheritMistica) {
"style" {
attribute("name", brand.name.capitalizeString())
attribute("parent", "${brand.name.capitalizeString()}_Customizations")
mapColors(tokens.dark, brand)
}
generateTheme("${brandName}Override")
}
}

Expand Down

0 comments on commit a5c2562

Please sign in to comment.