Add nav menu items
This commit is contained in:
parent
c2912cbb7e
commit
4d2763a87a
1 changed files with 48 additions and 31 deletions
|
@ -1,19 +1,15 @@
|
||||||
package com.wbrawner.nanoflux.ui
|
package com.wbrawner.nanoflux.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.text.BasicText
|
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Home
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.filled.Menu
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.wbrawner.nanoflux.NanofluxApp
|
import com.wbrawner.nanoflux.NanofluxApp
|
||||||
|
@ -23,13 +19,23 @@ import kotlinx.coroutines.launch
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScreen(authViewModel: AuthViewModel) {
|
fun MainScreen(authViewModel: AuthViewModel) {
|
||||||
MainScaffold(
|
MainScaffold(
|
||||||
authViewModel::logout
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScaffold(
|
fun MainScaffold(
|
||||||
onLogoutClicked: () -> Unit
|
onUnreadClicked: () -> Unit,
|
||||||
|
onStarredClicked: () -> Unit,
|
||||||
|
onHistoryClicked: () -> Unit,
|
||||||
|
onFeedsClicked: () -> Unit,
|
||||||
|
onCategoriesClicked: () -> Unit,
|
||||||
|
onSettingsClicked: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val scaffoldState = rememberScaffoldState()
|
val scaffoldState = rememberScaffoldState()
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
@ -46,36 +52,47 @@ fun MainScaffold(
|
||||||
}, title = { Text(text = "Unread") })
|
}, title = { Text(text = "Unread") })
|
||||||
},
|
},
|
||||||
drawerContent = {
|
drawerContent = {
|
||||||
TextButton(onClick = onLogoutClicked, modifier = Modifier.fillMaxWidth()) {
|
DrawerButton(onClick = onUnreadClicked, icon = Icons.Default.Email, text = "Unread")
|
||||||
Row(
|
DrawerButton(onClick = onStarredClicked, icon = Icons.Default.Star, text = "Starred")
|
||||||
horizontalArrangement = Arrangement.Start,
|
DrawerButton(onClick = onHistoryClicked, icon = Icons.Default.DateRange, text = "History")
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
DrawerButton(onClick = onFeedsClicked, icon = Icons.Default.List, text = "Feeds")
|
||||||
modifier = Modifier.fillMaxWidth()
|
DrawerButton(onClick = onCategoriesClicked, icon = Icons.Default.Info, text = "Categories")
|
||||||
) {
|
DrawerButton(onClick = onSettingsClicked, icon = Icons.Default.Settings, text = "Settings")
|
||||||
// Image(
|
|
||||||
// imageVector = icon,
|
|
||||||
// contentDescription = null, // decorative
|
|
||||||
// colorFilter = ColorFilter.tint(textIconColor),
|
|
||||||
// alpha = imageAlpha
|
|
||||||
// )
|
|
||||||
// Spacer(Modifier.width(16.dp))
|
|
||||||
Text(
|
|
||||||
text = "Logout",
|
|
||||||
modifier = Modifier.padding(8.dp),
|
|
||||||
style = MaterialTheme.typography.body2
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DrawerButton(onClick: () -> Unit, icon: ImageVector, text: String) {
|
||||||
|
TextButton(onClick = onClick, modifier = Modifier.fillMaxWidth()) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.Start,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
imageVector = icon,
|
||||||
|
contentDescription = null, // decorative
|
||||||
|
// colorFilter = ColorFilter.tint(textIconColor),
|
||||||
|
// alpha = imageAlpha
|
||||||
|
)
|
||||||
|
Spacer(Modifier.width(16.dp))
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
color = MaterialTheme.colors.onSurface,
|
||||||
|
modifier = Modifier.padding(8.dp),
|
||||||
|
style = MaterialTheme.typography.body2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
||||||
fun MainScaffold_Preview() {
|
fun MainScaffold_Preview() {
|
||||||
NanofluxApp {
|
NanofluxApp {
|
||||||
MainScaffold {}
|
MainScaffold({}, {}, {}, {}, {}, {})
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue