From f619522bd805e0e090fe9d47ed7b23c4210c634d Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 22 Nov 2017 12:49:56 -0500 Subject: Fix/tab layout (#510) * Test wrap content width * Compute badge icon dimensions * Reuse views * Remove unnecessary color set * Change image bound * Set min * Change dp * Snapshot * Hardcode dimensions * Add min width --- .../pitchedapps/frost/activities/MainActivity.kt | 4 +-- .../com/pitchedapps/frost/views/BadgedIcon.kt | 5 ++-- app/src/main/res/layout/activity_main.xml | 31 +++---------------- .../main/res/layout/activity_main_bottom_tabs.xml | 35 ++++------------------ app/src/main/res/layout/view_badged_icon.xml | 7 +++-- app/src/main/res/layout/view_main_fab.xml | 8 +++++ app/src/main/res/layout/view_main_tab_layout.xml | 10 +++++++ app/src/main/res/layout/view_main_toolbar.xml | 8 +++++ app/src/main/res/layout/view_main_viewpager.xml | 7 +++++ app/src/main/res/values/dimens.xml | 1 + 10 files changed, 50 insertions(+), 66 deletions(-) create mode 100644 app/src/main/res/layout/view_main_fab.xml create mode 100644 app/src/main/res/layout/view_main_tab_layout.xml create mode 100644 app/src/main/res/layout/view_main_toolbar.xml create mode 100644 app/src/main/res/layout/view_main_viewpager.xml (limited to 'app/src') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt index 5d7e3625..57cda44a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt @@ -210,9 +210,7 @@ class MainActivity : BaseActivity(), } adapter.pages.forEach { tabs.addTab(tabs.newTab() - .setCustomView(BadgedIcon(this).apply { - iicon = it.icon - })) + .setCustomView(BadgedIcon(this).apply { iicon = it.icon })) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt index c1015aad..ed7a3c4f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt @@ -7,6 +7,7 @@ import android.util.AttributeSet import android.widget.ImageView import android.widget.TextView import ca.allanwang.kau.utils.* +import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.Prefs @@ -31,12 +32,10 @@ class BadgedIcon @JvmOverloads constructor( badgeTextView.setTextColor(Prefs.mainActivityLayout.iconColor()) } - var iicon: IIcon? = null - get() = field set(value) { field = value - badgeImage.setImageDrawable(value?.toDrawable(context, color = Prefs.mainActivityLayout.iconColor())) + badgeImage.setImageDrawable(value?.toDrawable(context, sizeDp = 20, color = Prefs.mainActivityLayout.iconColor())) } fun setAllAlpha(alpha: Float) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 440cbba3..883221d9 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,5 @@ - + - - - + - + - + diff --git a/app/src/main/res/layout/activity_main_bottom_tabs.xml b/app/src/main/res/layout/activity_main_bottom_tabs.xml index 09742387..783aa455 100644 --- a/app/src/main/res/layout/activity_main_bottom_tabs.xml +++ b/app/src/main/res/layout/activity_main_bottom_tabs.xml @@ -1,7 +1,5 @@ - - - - + - - - + + + - + diff --git a/app/src/main/res/layout/view_badged_icon.xml b/app/src/main/res/layout/view_badged_icon.xml index cc6b16cc..c64e7809 100644 --- a/app/src/main/res/layout/view_badged_icon.xml +++ b/app/src/main/res/layout/view_badged_icon.xml @@ -3,11 +3,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="50dp"> + android:layout_height="@dimen/tab_bar_height" + android:minWidth="@dimen/tab_bar_height"> + \ No newline at end of file diff --git a/app/src/main/res/layout/view_main_tab_layout.xml b/app/src/main/res/layout/view_main_tab_layout.xml new file mode 100644 index 00000000..ed4f5d60 --- /dev/null +++ b/app/src/main/res/layout/view_main_tab_layout.xml @@ -0,0 +1,10 @@ + + diff --git a/app/src/main/res/layout/view_main_toolbar.xml b/app/src/main/res/layout/view_main_toolbar.xml new file mode 100644 index 00000000..b0a4de7c --- /dev/null +++ b/app/src/main/res/layout/view_main_toolbar.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_main_viewpager.xml b/app/src/main/res/layout/view_main_viewpager.xml new file mode 100644 index 00000000..0c3f314c --- /dev/null +++ b/app/src/main/res/layout/view_main_viewpager.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f7855b5b..888340e9 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -5,5 +5,6 @@ 60dp + 50dp 64dp -- cgit v1.2.3