#52 Restructuring finalised
This commit is contained in:
parent
0d65637d91
commit
f733e4bf14
7 changed files with 9 additions and 16 deletions
|
@ -5,16 +5,16 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
||||
import be.ugent.sel.studeez.common.ext.basicButton
|
||||
import be.ugent.sel.studeez.resources
|
||||
import be.ugent.sel.studeez.screens.templates.primary_screen.PrimaryScreen
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(
|
||||
openAndPopUp: (String, String) -> Unit,
|
||||
viewModel: HomeViewModel = hiltViewModel()
|
||||
) {
|
||||
PrimaryScreen(
|
||||
PrimaryScreenTemplate(
|
||||
title = resources().getString(R.string.home),
|
||||
onLogoutClick = { viewModel.onLogoutClick(openAndPopUp) }
|
||||
) {
|
||||
|
|
|
@ -27,7 +27,7 @@ fun LoginScreen(
|
|||
val uiState by viewModel.uiState
|
||||
|
||||
// TODO Make this a separate kind of screen?
|
||||
SecondaryScreenToolbar(title = resources().getString(AppText.sign_in), {}) {
|
||||
SecondaryScreenTemplate(title = resources().getString(AppText.sign_in), {}) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
@ -27,7 +27,7 @@ fun SignUpScreen(
|
|||
val uiState by viewModel.uiState
|
||||
val fieldModifier = Modifier.fieldModifier()
|
||||
|
||||
SecondaryScreenToolbar(title = resources().getString(AppText.create_account), {}) {
|
||||
SecondaryScreenTemplate(title = resources().getString(AppText.create_account), {}) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package be.ugent.sel.studeez.screens.templates.primary_screen
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.composable.CollapsedAddButton
|
||||
import be.ugent.sel.studeez.common.composable.Drawer
|
||||
import be.ugent.sel.studeez.common.composable.NavigationBar
|
||||
import be.ugent.sel.studeez.data.local.models.User
|
||||
import be.ugent.sel.studeez.resources
|
||||
import be.ugent.sel.studeez.ui.theme.StudeezTheme
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun PrimaryScreen(
|
||||
title: String,
|
||||
onLogoutClick: () -> Unit,
|
||||
content: @Composable (PaddingValues) -> Unit
|
||||
) {
|
||||
val scaffoldState: ScaffoldState = rememberScaffoldState()
|
||||
val coroutineScope: CoroutineScope = rememberCoroutineScope()
|
||||
|
||||
Scaffold(
|
||||
scaffoldState = scaffoldState,
|
||||
|
||||
topBar = { TopAppBar(
|
||||
title = { Text(text = title) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = {
|
||||
coroutineScope.launch { scaffoldState.drawerState.open() }
|
||||
}) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Menu,
|
||||
contentDescription = resources().getString(R.string.menu)
|
||||
)
|
||||
}
|
||||
}
|
||||
) },
|
||||
|
||||
drawerContent = {
|
||||
Drawer(
|
||||
onLogoutClick = { onLogoutClick() }
|
||||
)
|
||||
},
|
||||
|
||||
bottomBar = { NavigationBar() }, // TODO Pass arguments so that the current tab etc can be shown
|
||||
floatingActionButtonPosition = FabPosition.Center,
|
||||
isFloatingActionButtonDocked = true,
|
||||
floatingActionButton = { CollapsedAddButton() }
|
||||
) {
|
||||
content(it)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PrimaryScreenPreview() {
|
||||
StudeezTheme {
|
||||
PrimaryScreen(
|
||||
"Preview screen",
|
||||
{}
|
||||
) {}
|
||||
}
|
||||
}
|
Reference in a new issue