mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
feat: update demo
This commit is contained in:
@@ -34,7 +34,8 @@ enum class Locales { EN, ZH_CN }
|
||||
fun locales() = Locales.entries.toTypedArray()
|
||||
|
||||
@Stable
|
||||
fun Locales.toName() = when (this) {
|
||||
val Locales.displayName
|
||||
get() = when (this) {
|
||||
Locales.EN -> "English"
|
||||
Locales.ZH_CN -> "简体中文"
|
||||
}
|
||||
|
@@ -74,10 +74,10 @@ import com.highcapable.flexiui.demo.PROJECT_URL
|
||||
import com.highcapable.flexiui.demo.Preferences
|
||||
import com.highcapable.flexiui.demo.Screen
|
||||
import com.highcapable.flexiui.demo.Style
|
||||
import com.highcapable.flexiui.demo.displayName
|
||||
import com.highcapable.flexiui.demo.locales
|
||||
import com.highcapable.flexiui.demo.rememberRouter
|
||||
import com.highcapable.flexiui.demo.strings
|
||||
import com.highcapable.flexiui.demo.toName
|
||||
import com.highcapable.flexiui.displayName
|
||||
import com.highcapable.flexiui.resources.FlexiIcons
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -120,23 +120,27 @@ fun MainScreen() {
|
||||
)
|
||||
},
|
||||
navigationBar = {
|
||||
NavigationBarRow(
|
||||
arrangement = Arrangement.SpaceAround
|
||||
) {
|
||||
NavigationBarRow(arrangement = Arrangement.SpaceAround) {
|
||||
repeat(pageCount) { index ->
|
||||
NavigationBarItem(
|
||||
selected = pagerState.currentPage == 0,
|
||||
onClick = { scope.launch { pagerState.animateScrollToPage(page = 0) } },
|
||||
icon = { Icon(FlexiIcons.Home, style = IconDefaults.style(size = 24.dp)) },
|
||||
text = { Text(strings.home) }
|
||||
)
|
||||
NavigationBarItem(
|
||||
selected = pagerState.currentPage == 1,
|
||||
onClick = { scope.launch { pagerState.animateScrollToPage(page = 1) } },
|
||||
icon = { Icon(FlexiIcons.Component, style = IconDefaults.style(size = 24.dp)) },
|
||||
text = { Text(strings.component) }
|
||||
selected = pagerState.currentPage == index,
|
||||
onClick = { scope.launch { pagerState.animateScrollToPage(page = index) } },
|
||||
icon = {
|
||||
Icon(when (index) {
|
||||
0 -> FlexiIcons.Home
|
||||
else -> FlexiIcons.Component
|
||||
}, style = IconDefaults.style(size = 24.dp))
|
||||
},
|
||||
text = {
|
||||
Text(when (index) {
|
||||
0 -> strings.home
|
||||
else -> strings.component
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) { innerPadding ->
|
||||
HorizontalPager(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@@ -177,7 +181,7 @@ fun MainHomePage(modifier: Modifier) {
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
expanded = expanded,
|
||||
onExpandedChange = { expanded = it },
|
||||
text = { Text(locale.toName()) },
|
||||
text = { Text(locale.displayName) },
|
||||
) {
|
||||
locales.forEach {
|
||||
DropdownMenuItem(
|
||||
@@ -186,7 +190,7 @@ fun MainHomePage(modifier: Modifier) {
|
||||
expanded = false
|
||||
locale = it
|
||||
}
|
||||
) { Text(it.toName()) }
|
||||
) { Text(it.displayName) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user