Skip to content

Commit

Permalink
fix : fix scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Jun 19, 2024
1 parent bf986b1 commit bd96d5d
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 302 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
@file:OptIn(ExperimentalMaterial3Api::class)

package com.mifos.core.designsystem.component

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import com.mifos.core.designsystem.theme.Black
import com.mifos.core.designsystem.theme.White

@Composable
fun MifosScaffold(
modifier: Modifier = Modifier,
topBar: @Composable () -> Unit,
isAppBarPresent: Boolean = true,
icon: ImageVector? = null,
title: String? = null,
onBackPressed: () -> Unit = {},
actions: @Composable () -> Unit = {},
snackbarHostState: SnackbarHostState?,
bottomBar: @Composable () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
Expand All @@ -20,7 +39,41 @@ fun MifosScaffold(

Scaffold(
modifier = modifier,
topBar = topBar,
topBar = {
if (isAppBarPresent) {
TopAppBar(
colors = TopAppBarDefaults.mediumTopAppBarColors(containerColor = White),
navigationIcon = {
if (icon != null) {
IconButton(
onClick = { onBackPressed() },
) {
Icon(
imageVector = icon,
contentDescription = null,
tint = Black,
)
}
}
},
title = {
title?.let {
Text(
text = it,
style = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal
),
color = Black,
textAlign = TextAlign.Start
)
}
},
actions = { actions() }
)
}
},
snackbarHost = { snackbarHostState?.let { SnackbarHost(it) } },
containerColor = White,
bottomBar = bottomBar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.outlined.DateRange
import androidx.compose.material.icons.outlined.EventRepeat
import androidx.compose.material.icons.outlined.Group
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.PersonOutline
import androidx.compose.material.icons.rounded.ArrowBackIosNew
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu
Expand All @@ -29,8 +23,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -114,54 +106,27 @@ fun CenterDetailsScreen(
var centerActive by remember { mutableStateOf(true) }

MifosScaffold(
topBar = {
TopAppBar(
colors = TopAppBarDefaults.mediumTopAppBarColors(containerColor = White),
navigationIcon = {
IconButton(
onClick = { onBackPressed() },
) {
Icon(
imageVector = MifosIcons.arrowBack,
contentDescription = null,
tint = Black,
)
}

},
title = {
Text(
text = stringResource(id = R.string.feature_center_center),
style = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal
),
color = Black,
textAlign = TextAlign.Start
)

},
actions = {
IconButton(onClick = { showMenu = showMenu.not() }) {
Icon(imageVector = Icons.Default.MoreVert, contentDescription = null)
}
DropdownMenu(
modifier = Modifier.background(White),
expanded = showMenu,
onDismissRequest = { showMenu = false }
) {
MifosMenuDropDownItem(option = stringResource(id = R.string.feature_center_add_savings_account)) {
onMenuClick(MenuItems.ADD_SAVINGS_ACCOUNT)
showMenu = false
}
MifosMenuDropDownItem(option = stringResource(id = R.string.feature_center_group_list)) {
onMenuClick(MenuItems.GROUP_LIST)
showMenu = false
}
}
icon = MifosIcons.arrowBack,
title = stringResource(id = R.string.feature_center_center),
onBackPressed = onBackPressed,
actions = {
IconButton(onClick = { showMenu = showMenu.not() }) {
Icon(imageVector = Icons.Default.MoreVert, contentDescription = null)
}
DropdownMenu(
modifier = Modifier.background(White),
expanded = showMenu,
onDismissRequest = { showMenu = false }
) {
MifosMenuDropDownItem(option = stringResource(id = R.string.feature_center_add_savings_account)) {
onMenuClick(MenuItems.ADD_SAVINGS_ACCOUNT)
showMenu = false
}
)
MifosMenuDropDownItem(option = stringResource(id = R.string.feature_center_group_list)) {
onMenuClick(MenuItems.GROUP_LIST)
showMenu = false
}
}
},
snackbarHostState = snackbarHostState,
bottomBar = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -60,7 +60,6 @@ import androidx.paging.compose.collectAsLazyPagingItems
import coil.compose.AsyncImage
import com.mifos.core.designsystem.component.MifosCircularProgress
import com.mifos.core.designsystem.component.MifosPagingAppendProgress
import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.component.MifosSweetError
import com.mifos.core.designsystem.icon.MifosIcons
import com.mifos.core.designsystem.theme.Black
Expand Down Expand Up @@ -135,7 +134,7 @@ fun CenterListScreen(
}
}

MifosScaffold(
Scaffold(
modifier = Modifier,
topBar = {
if (isInSelectionMode) {
Expand All @@ -146,8 +145,7 @@ fun CenterListScreen(
)
}
},
snackbarHostState = snackbarHostState,
bottomBar = { },
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
floatingActionButton = {
FloatingActionButton(
onClick = { createNewCenter() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowBackIosNew
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -26,9 +20,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand All @@ -40,7 +32,7 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.mifos.core.designsystem.component.MifosCircularProgress
import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.component.MifosSweetError
import com.mifos.core.designsystem.theme.Black
import com.mifos.core.designsystem.icon.MifosIcons
import com.mifos.core.designsystem.theme.White
import com.mifos.feature.checker_inbox_task.R

Expand All @@ -65,37 +57,9 @@ fun CheckerInboxTasksScreen(
}

MifosScaffold(
topBar = {
TopAppBar(
colors = TopAppBarDefaults.mediumTopAppBarColors(containerColor = White),
navigationIcon = {
IconButton(
onClick = { onBackPressed() },
) {
Icon(
imageVector = Icons.Rounded.ArrowBackIosNew,
contentDescription = null,
tint = Black,
)
}

},
title = {
Text(
text = stringResource(id = R.string.feature_checker_inbox_task_checker_inbox_and_pending_tasks),
style = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal
),
color = Black,
textAlign = TextAlign.Start
)
},
actions = { }
)

},
icon = MifosIcons.arrowBack,
title = stringResource(id = R.string.feature_checker_inbox_task_checker_Inbox),
onBackPressed = onBackPressed,
snackbarHostState = null,
bottomBar = { })
{ padding ->
Expand Down
Loading

0 comments on commit bd96d5d

Please sign in to comment.