Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
hiii

Ataul Munim ataulm

💭
hiii
View GitHub Profile
View StyleAttrUsesThemeDetector.kt
internal class StyleAttrUsesThemeDetector : ResourceXmlDetector() {
companion object {
val ISSUE = createErrorThemesAndStylesIssue(StyleAttrUsesThemeDetector::class, Scope.RESOURCE_FILE_SCOPE)
}
override fun appliesTo(folderType: ResourceFolderType) = folderType == ResourceFolderType.LAYOUT
override fun getApplicableAttributes(): Collection<String> = XmlScannerConstants.ALL
View MonzoButton.kt
private val DEF_STYLE_ATTR = R.attr.monzoButtonStyle
class MonzoButton(ctx: Context, attrs: AttributeSet) : AppCompatButton(
wrapContext(ctx, attrs),
attrs,
DEF_STYLE_ATTR
) {
companion object {
fun wrapContext(context: Context, attrs: AttributeSet): Context {
View themes.xml
<style name="ThemeOverlay.Monzo.MonzoButton.Pill" parent="">
<!-- any value larger than `button.height / 2` -->
<item name="monzoButtonCornerRadius">1000dp</item>
</style>
View button_background_shape.xml
<shape android:shape="rectangle">
<corners android:radius="?attr/monzoButtonCornerRadius" />
<!-- ... -->
View widgets.xml
<style name="Widget.Monzo.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox">
<item name="android:textColor">?attr/mdsColorPrimaryContent</item>
<item name="materialThemeOverlay">@style/ThemeOverlay.Monzo.CompoundButton</item>
</style>
<style name="Widget.Monzo.CompoundButton.RadioButton" parent="Widget.MaterialComponents.CompoundButton.RadioButton">
<item name="android:textColor">?attr/mdsColorPrimaryContent</item>
<item name="materialThemeOverlay">@style/ThemeOverlay.Monzo.CompoundButton</item>
</style>
View themes.xml
<style name="ThemeOverlay.Monzo.CompoundButton" parent="">
<item name="colorSecondary">?attr/mdsColorBlueTint</item>
</style>
View layout.xml
<androidx.appcompat.widget.Toolbar
android:id="@+id/loanCalculatorToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.Monzo.Toolbar.LoansNavy" />
View themes.xml
<style name="ThemeOverlay.Monzo.Toolbar.Loans" parent="">
<item name="colorPrimary">@color/navy</item>
<item name="colorOnPrimary">@color/white</item>
</style>
View res_values-v23_widgets.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Monzo.CompoundButton.CheckBox.OnLight" />
<style name="Widget.Monzo.CompoundButton.CheckBox.OnDark" />
</resources>
View themes.xml
<style name="Theme.Monzo.Light" parent="Base.Theme.Monzo">
<item name="checkboxStyle">@style/Widget.Monzo.CompoundButton.CheckBox.OnLight</item>
<!-- ... -->
</style>
<style name="Theme.Monzo.Dark" parent="Base.Theme.Monzo">
<item name="checkboxStyle">@style/Widget.Monzo.CompoundButton.CheckBox.OnDark</item>
<!-- ... -->
</style>