Updated install from storage button to be more expressive

This commit is contained in:
Viktor De Pasquale 2019-11-18 17:49:03 +01:00
parent 332c1a6c59
commit 833269fd0a
5 changed files with 33 additions and 7 deletions

View File

@ -84,6 +84,12 @@ class RepoRvItem(val item: Repo) : ComparableRvItem<RepoRvItem>() {
object InstallModule : ComparableRvItem<InstallModule>() { object InstallModule : ComparableRvItem<InstallModule>() {
override val layoutRes = R.layout.item_module_download override val layoutRes = R.layout.item_module_download
override fun onBindingBound(binding: ViewDataBinding) {
super.onBindingBound(binding)
val params = binding.root.layoutParams as? StaggeredGridLayoutManager.LayoutParams
params?.isFullSpan = true
}
override fun contentSameAs(other: InstallModule) = this == other override fun contentSameAs(other: InstallModule) = this == other
override fun itemSameAs(other: InstallModule) = this === other override fun itemSameAs(other: InstallModule) = this === other
} }
@ -116,8 +122,8 @@ class SectionTitle(
override fun onBindingBound(binding: ViewDataBinding) { override fun onBindingBound(binding: ViewDataBinding) {
super.onBindingBound(binding) super.onBindingBound(binding)
val params = binding.root.layoutParams as StaggeredGridLayoutManager.LayoutParams val params = binding.root.layoutParams as? StaggeredGridLayoutManager.LayoutParams
params.isFullSpan = true params?.isFullSpan = true
} }
override fun itemSameAs(other: SectionTitle): Boolean = this === other override fun itemSameAs(other: SectionTitle): Boolean = this === other

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:tools="http://schemas.android.com/tools">
<data> <data>
@ -16,15 +15,15 @@
</data> </data>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="?styleButtonTextSecondary" style="?styleButtonOutlined"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="@{() -> viewModel.installPressed()}" android:onClick="@{() -> viewModel.installPressed()}"
android:text="@string/module_action_install_external" android:text="@string/module_action_install_external"
android:textAllCaps="false" android:textAllCaps="false"
android:textSize="12sp" android:textSize="12sp"
app:cornerRadius="@dimen/r1"
app:icon="@drawable/ic_module_storage_md2" app:icon="@drawable/ic_module_storage_md2"
app:iconPadding="@dimen/l_50" app:iconPadding="@dimen/l_50" />
tools:layout_width="150dp" />
</layout> </layout>

View File

@ -24,6 +24,8 @@
<!--Button--> <!--Button-->
<attr name="styleButtonDefault" format="reference" /> <attr name="styleButtonDefault" format="reference" />
<attr name="styleButtonDefaultOnPrimary" format="reference" /> <attr name="styleButtonDefaultOnPrimary" format="reference" />
<attr name="styleButtonOutlined" format="reference" />
<attr name="styleButtonOutlinedOnPrimary" format="reference" />
<attr name="styleButtonFlat" format="reference" /> <attr name="styleButtonFlat" format="reference" />
<attr name="styleButtonFlatOnPrimary" format="reference" /> <attr name="styleButtonFlatOnPrimary" format="reference" />
<attr name="styleButtonText" format="reference" /> <attr name="styleButtonText" format="reference" />

View File

@ -36,6 +36,10 @@
<item name="styleButtonDefault">@style/WidgetFoundation.Button</item> <item name="styleButtonDefault">@style/WidgetFoundation.Button</item>
<item name="styleButtonDefaultOnPrimary">@style/WidgetFoundation.Button.OnPrimary</item> <item name="styleButtonDefaultOnPrimary">@style/WidgetFoundation.Button.OnPrimary</item>
<item name="styleButtonOutlined">@style/WidgetFoundation.Button.Outlined</item>
<item name="styleButtonOutlinedOnPrimary">
@style/WidgetFoundation.Button.Outlined.OnPrimary
</item>
<item name="styleButtonFlat">@style/WidgetFoundation.Button.Flat</item> <item name="styleButtonFlat">@style/WidgetFoundation.Button.Flat</item>
<item name="styleButtonFlatOnPrimary">@style/WidgetFoundation.Button.Flat.OnPrimary</item> <item name="styleButtonFlatOnPrimary">@style/WidgetFoundation.Button.Flat.OnPrimary</item>
<item name="styleButtonText">@style/WidgetFoundation.Button.Text</item> <item name="styleButtonText">@style/WidgetFoundation.Button.Text</item>

View File

@ -66,6 +66,21 @@ variant. Make sure to use style referenced by attribute defined it attrs.xml.
<item name="iconTint">?colorPrimary</item> <item name="iconTint">?colorPrimary</item>
</style> </style>
<style name="WidgetFoundation.Button.Outlined" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="android:textStyle">bold</item>
<item name="iconGravity">textStart</item>
<item name="iconPadding">@dimen/l1</item>
<item name="strokeColor">?colorPrimary</item>
<item name="android:textColor">?colorPrimary</item>
</style>
<style name="WidgetFoundation.Button.Outlined.OnPrimary">
<item name="strokeColor">?colorOnPrimary</item>
<item name="rippleColor">?colorOnPrimary</item>
<item name="android:textColor">?colorOnPrimary</item>
<item name="iconTint">?colorOnPrimary</item>
</style>
<style name="WidgetFoundation.Button.Flat" parent="Widget.MaterialComponents.Button.UnelevatedButton"> <style name="WidgetFoundation.Button.Flat" parent="Widget.MaterialComponents.Button.UnelevatedButton">
<item name="android:textStyle">bold</item> <item name="android:textStyle">bold</item>
<item name="iconGravity">textStart</item> <item name="iconGravity">textStart</item>