For #12461: Add tab count to tab tray
parent
c94bdc4267
commit
284ec7b58f
|
@ -18,6 +18,7 @@ import com.google.android.material.tabs.TabLayout
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
||||||
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
||||||
|
import kotlinx.android.synthetic.main.tabs_tray_tab_counter.*
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -245,6 +246,8 @@ class TabTrayView(
|
||||||
View.VISIBLE
|
View.VISIBLE
|
||||||
}
|
}
|
||||||
view.tab_tray_overflow.isVisible = !hasNoTabs
|
view.tab_tray_overflow.isVisible = !hasNoTabs
|
||||||
|
|
||||||
|
counter_text.text = "${state.normalTabs.size}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,27 +46,28 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:background="@color/foundation_normal_theme"
|
android:background="@color/foundation_normal_theme"
|
||||||
app:tabIndicatorColor="@color/accent_normal_theme"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:tabIconTint="@color/tab_icon"
|
|
||||||
app:tabRippleColor="@android:color/transparent"
|
|
||||||
app:tabGravity="fill"
|
|
||||||
app:layout_constraintWidth_percent="0.5"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/handle"
|
app:layout_constraintTop_toBottomOf="@+id/handle"
|
||||||
app:layout_constraintStart_toStartOf="parent">
|
app:layout_constraintWidth_percent="0.5"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabIconTint="@color/tab_icon"
|
||||||
|
app:tabIndicatorColor="@color/accent_normal_theme"
|
||||||
|
app:tabRippleColor="@android:color/transparent">
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabItem
|
<com.google.android.material.tabs.TabItem
|
||||||
android:id="@+id/default_tab_item"
|
android:id="@+id/default_tab_item"
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:icon="@drawable/ic_tabs"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="@string/tab_header_label" />
|
android:contentDescription="@string/tab_header_label"
|
||||||
|
android:layout="@layout/tabs_tray_tab_counter"
|
||||||
|
app:tabIconTint="@color/tab_icon" />
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabItem
|
<com.google.android.material.tabs.TabItem
|
||||||
android:id="@+id/private_tab_item"
|
android:id="@+id/private_tab_item"
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:icon="@drawable/ic_private_browsing"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="@string/tabs_header_private_tabs_title" />
|
android:contentDescription="@string/tabs_header_private_tabs_title"
|
||||||
|
android:icon="@drawable/ic_private_browsing" />
|
||||||
|
|
||||||
</com.google.android.material.tabs.TabLayout>
|
</com.google.android.material.tabs.TabLayout>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/counter_root"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/counter_box"
|
||||||
|
android:layout_width="@dimen/tab_counter_box_width_height"
|
||||||
|
android:layout_height="@dimen/tab_counter_box_width_height"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
app:tint="@color/tab_icon"
|
||||||
|
app:srcCompat="@drawable/ic_tabs"/>
|
||||||
|
|
||||||
|
<!-- This text size auto adjusts based on num digits in `TabCounter` -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/counter_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textColor="@color/tab_icon"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="16" />
|
||||||
|
</FrameLayout>
|
Loading…
Reference in New Issue