1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

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
This commit is contained in:
Allan Wang 2017-11-22 12:49:56 -05:00 committed by GitHub
parent f6499a8741
commit f619522bd8
10 changed files with 50 additions and 66 deletions

View File

@ -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 }))
}
}

View File

@ -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) {

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
@ -14,36 +13,14 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
<include layout="@layout/view_main_toolbar" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorHeight="0dp" />
<include layout="@layout/view_main_tab_layout" />
</android.support.design.widget.AppBarLayout>
<com.pitchedapps.frost.views.FrostViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/view_main_viewpager" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/kau_fab_margin"
android:visibility="gone" />
<include layout="@layout/view_main_fab" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -21,40 +19,17 @@
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<include layout="@layout/view_main_toolbar" />
</android.support.design.widget.AppBarLayout>
<com.pitchedapps.frost.views.FrostViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/kau_fab_margin"
android:visibility="gone" />
<include layout="@layout/view_main_viewpager" />
<include layout="@layout/view_main_fab" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:tabIndicatorHeight="0dp" />
<include layout="@layout/view_main_tab_layout" />
</LinearLayout>

View File

@ -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">
<android.support.constraint.Guideline
android:id="@+id/g_v_c"
android:layout_width="1dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"
@ -17,7 +18,7 @@
<android.support.constraint.Guideline
android:id="@+id/g_h_c"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"
tools:layout_editor_absoluteX="0dp"

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/kau_fab_margin"
android:visibility="gone" />

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tabs"
style="@style/Widget.Design.TabLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_bar_height"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed" />

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay" />

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.pitchedapps.frost.views.FrostViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

View File

@ -5,5 +5,6 @@
<dimen name="context_menu_height">60dp</dimen>
<dimen name="tab_bar_height">50dp</dimen>
<dimen name="intro_bar_height">64dp</dimen>
</resources>