-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
37 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...c/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/extensions/TypographyExtensions.kt
This file contains 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,37 @@ | ||
package com.revenuecat.purchases.ui.revenuecatui.extensions | ||
|
||
import androidx.compose.material3.Typography | ||
import androidx.compose.ui.text.TextStyle | ||
import com.revenuecat.purchases.ui.revenuecatui.fonts.FontProvider | ||
import com.revenuecat.purchases.ui.revenuecatui.fonts.TypographyType | ||
|
||
fun Typography.copyWithFontProvider(fontProvider: FontProvider): Typography { | ||
with(this) { | ||
return copy( | ||
displayLarge = displayLarge.modifyFontIfNeeded(TypographyType.DISPLAY_LARGE, fontProvider), | ||
displayMedium = displayMedium.modifyFontIfNeeded(TypographyType.DISPLAY_MEDIUM, fontProvider), | ||
displaySmall = displaySmall.modifyFontIfNeeded(TypographyType.DISPLAY_SMALL, fontProvider), | ||
headlineLarge = headlineLarge.modifyFontIfNeeded(TypographyType.HEADLINE_LARGE, fontProvider), | ||
headlineMedium = headlineMedium.modifyFontIfNeeded(TypographyType.HEADLINE_MEDIUM, fontProvider), | ||
headlineSmall = headlineSmall.modifyFontIfNeeded(TypographyType.HEADLINE_SMALL, fontProvider), | ||
titleLarge = titleLarge.modifyFontIfNeeded(TypographyType.TITLE_LARGE, fontProvider), | ||
titleMedium = titleMedium.modifyFontIfNeeded(TypographyType.TITLE_MEDIUM, fontProvider), | ||
titleSmall = titleSmall.modifyFontIfNeeded(TypographyType.TITLE_SMALL, fontProvider), | ||
bodyLarge = bodyLarge.modifyFontIfNeeded(TypographyType.BODY_LARGE, fontProvider), | ||
bodyMedium = bodyMedium.modifyFontIfNeeded(TypographyType.BODY_MEDIUM, fontProvider), | ||
bodySmall = bodySmall.modifyFontIfNeeded(TypographyType.BODY_SMALL, fontProvider), | ||
labelLarge = labelLarge.modifyFontIfNeeded(TypographyType.LABEL_LARGE, fontProvider), | ||
labelMedium = labelMedium.modifyFontIfNeeded(TypographyType.LABEL_MEDIUM, fontProvider), | ||
labelSmall = labelSmall.modifyFontIfNeeded(TypographyType.LABEL_SMALL, fontProvider), | ||
) | ||
} | ||
} | ||
|
||
private fun TextStyle.modifyFontIfNeeded(typographyType: TypographyType, fontProvider: FontProvider): TextStyle { | ||
val font = fontProvider.getFont(typographyType) | ||
return if (font == null) { | ||
this | ||
} else { | ||
this.copy(fontFamily = font) | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
...venuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/fonts/FontProvider.kt
This file contains 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 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