@@ -2,29 +2,40 @@ package expo.modules.t3nativecontrols
22
33import android.content.Context
44import android.view.ViewGroup
5+ import androidx.compose.foundation.background
6+ import androidx.compose.foundation.layout.Box
7+ import androidx.compose.foundation.layout.Row
58import androidx.compose.foundation.layout.WindowInsets
69import androidx.compose.foundation.layout.Spacer
10+ import androidx.compose.foundation.layout.fillMaxHeight
711import androidx.compose.foundation.layout.fillMaxSize
12+ import androidx.compose.foundation.layout.padding
13+ import androidx.compose.foundation.selection.selectable
14+ import androidx.compose.foundation.selection.selectableGroup
15+ import androidx.compose.foundation.shape.CircleShape
816import androidx.compose.material3.Icon
17+ import androidx.compose.material3.LocalContentColor
918import androidx.compose.material3.MaterialTheme
10- import androidx.compose.material3.NavigationBar
11- import androidx.compose.material3.NavigationBarItem
12- import androidx.compose.material3.NavigationBarItemDefaults
1319import androidx.compose.material3.NavigationRail
1420import androidx.compose.material3.NavigationRailItem
1521import androidx.compose.material3.NavigationRailItemDefaults
22+ import androidx.compose.material3.Surface
1623import androidx.compose.material3.Text
1724import androidx.compose.material3.darkColorScheme
1825import androidx.compose.material3.lightColorScheme
1926import androidx.compose.runtime.Composable
2027import androidx.compose.runtime.getValue
2128import androidx.compose.runtime.mutableStateOf
2229import androidx.compose.runtime.setValue
30+ import androidx.compose.ui.Alignment
2331import androidx.compose.ui.Modifier
32+ import androidx.compose.ui.draw.clip
2433import androidx.compose.ui.graphics.Color
2534import androidx.compose.ui.platform.ComposeView
2635import androidx.compose.ui.platform.ViewCompositionStrategy
2736import androidx.compose.ui.res.painterResource
37+ import androidx.compose.ui.semantics.Role
38+ import androidx.compose.ui.unit.dp
2839import androidx.compose.ui.unit.sp
2940import expo.modules.kotlin.AppContext
3041import expo.modules.kotlin.modules.Module
@@ -59,7 +70,7 @@ class T3WorkspaceNavigationModule : Module() {
5970 }
6071}
6172
62- /* * One Material3 selection surface moves from below the list to its leading edge . */
73+ /* * Compact windows use an icon pill; expanded windows retain the Material navigation rail . */
6374class T3WorkspaceNavigationView (
6475 context : Context ,
6576 appContext : AppContext
@@ -100,8 +111,12 @@ class T3WorkspaceNavigationView(
100111 }
101112
102113 init {
114+ clipChildren = false
115+ clipToPadding = false
103116 addView(
104117 ComposeView (context).apply {
118+ clipChildren = false
119+ clipToPadding = false
105120 setViewCompositionStrategy(
106121 ViewCompositionStrategy .DisposeOnDetachedFromWindowOrReleasedFromPool
107122 )
@@ -136,29 +151,39 @@ class T3WorkspaceNavigationView(
136151 Spacer (Modifier .weight(1f ))
137152 }
138153 } else {
139- NavigationBar (
154+ Surface (
140155 modifier = Modifier .fillMaxSize(),
141- containerColor = Color (containerColor),
142- tonalElevation = androidx.compose.ui.unit.Dp (0f ),
143- windowInsets = WindowInsets (0 ),
156+ shape = CircleShape ,
157+ color = Color (containerColor),
158+ // Match the resting elevation of the Compose New thread FAB.
159+ shadowElevation = 6 .dp,
144160 ) {
145- tabs.forEach { tab ->
146- NavigationBarItem (
147- selected = selectedTab == tab,
148- onClick = { onTabSelected(mapOf (" tab" to tab)) },
149- icon = { tabIcon(tab) },
150- label = {
151- val title = if (tab == " threads" ) " Chats" else " Pull requests"
152- Text (title, fontSize = (12 * textScale).sp)
153- },
154- colors = NavigationBarItemDefaults .colors(
155- selectedIconColor = Color (selectedColor),
156- selectedTextColor = Color (selectedColor),
157- indicatorColor = Color (indicatorColor),
158- unselectedIconColor = Color (unselectedColor),
159- unselectedTextColor = Color (unselectedColor),
160- ),
161- )
161+ Row (
162+ modifier = Modifier .fillMaxSize().selectableGroup(),
163+ verticalAlignment = Alignment .CenterVertically ,
164+ ) {
165+ tabs.forEach { tab ->
166+ val selected = selectedTab == tab
167+ Box (
168+ modifier = Modifier
169+ .weight(1f )
170+ .fillMaxHeight()
171+ .clip(CircleShape )
172+ .selectable(
173+ selected = selected,
174+ role = Role .Tab ,
175+ onClick = { onTabSelected(mapOf (" tab" to tab)) },
176+ )
177+ .padding(4 .dp)
178+ .background(
179+ if (selected) Color (indicatorColor) else Color .Transparent ,
180+ CircleShape ,
181+ ),
182+ contentAlignment = Alignment .Center ,
183+ ) {
184+ tabIcon(tab, Color (if (selected) selectedColor else unselectedColor))
185+ }
186+ }
162187 }
163188 }
164189 }
@@ -170,7 +195,7 @@ class T3WorkspaceNavigationView(
170195 }
171196
172197 @Composable
173- private fun tabIcon (tab : String ) {
198+ private fun tabIcon (tab : String , tint : Color = LocalContentColor .current ) {
174199 val drawable = if (tab == " threads" ) {
175200 R .drawable.t3_chats
176201 } else {
@@ -179,6 +204,7 @@ class T3WorkspaceNavigationView(
179204 Icon (
180205 painter = painterResource(drawable),
181206 contentDescription = if (tab == " threads" ) " Chats" else " Pull requests" ,
207+ tint = tint,
182208 )
183209 }
184210}
0 commit comments