Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Redesign finance screen #1777

Merged
merged 11 commits into from
Oct 3, 2024
2 changes: 2 additions & 0 deletions build-logic/convention/src/main/kotlin/org/mifospay/Detekt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.named
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

internal fun Project.configureDetekt(extension: DetektExtension) = extension.apply {
tasks.named<Detekt>("detekt") {
jvmTarget = "17"
reports {
xml.required.set(true)
html.required.set(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package org.mifospay.core.designsystem.component
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedIconButton
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand All @@ -21,7 +22,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.mifospay.core.designsystem.icon.MifosIcons
import org.mifospay.core.designsystem.theme.MifosTheme
import org.mifospay.core.designsystem.theme.NewUi

@Composable
fun IconBox(
Expand All @@ -33,7 +33,7 @@ fun IconBox(
onClick = onClick,
modifier = modifier,
shape = RoundedCornerShape(12.dp),
border = BorderStroke(2.dp, NewUi.onSurface.copy(alpha = 0.1f)),
border = BorderStroke(2.dp, MaterialTheme.colorScheme.onSurface.copy(alpha = 0.1f)),
) {
Icon(
imageVector = icon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package org.mifospay.core.designsystem.component
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -43,6 +44,7 @@ fun MifosScaffold(
onClick = content.onClick,
contentColor = content.contentColor,
content = content.content,
containerColor = MaterialTheme.colorScheme.primary,
)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,43 @@
*/
package org.mifospay.core.designsystem.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

@Composable
fun MifosTab(
text: String,
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
selectedContentColor: Color = MaterialTheme.colorScheme.onSurface,
unselectedContentColor: Color = Color.LightGray,
selectedContentColor: Color = MaterialTheme.colorScheme.primary,
unselectedContentColor: Color = MaterialTheme.colorScheme.primaryContainer,
) {
Tab(
text = {
Text(
text = text,
color = MaterialTheme.colorScheme.onSurface,
color = if (selected) {
MaterialTheme.colorScheme.onPrimary
} else {
MaterialTheme.colorScheme.onSurface
},
)
},
selected = selected,
modifier = modifier,
modifier = modifier
.clip(RoundedCornerShape(25.dp))
.background(if (selected) selectedContentColor else unselectedContentColor)
.padding(horizontal = 20.dp),
selectedContentColor = selectedContentColor,
unselectedContentColor = unselectedContentColor,
onClick = onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -57,7 +58,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.mifospay.core.designsystem.theme.MifosTheme
import org.mifospay.core.designsystem.theme.NewUi

@Composable
fun MfOutlinedTextField(
Expand All @@ -84,18 +84,15 @@ fun MfOutlinedTextField(
},
singleLine = singleLine,
trailingIcon = trailingIcon,
keyboardActions =
KeyboardActions {
keyboardActions = KeyboardActions {
onKeyboardActions?.invoke()
},
keyboardOptions = keyboardOptions,
colors =
OutlinedTextFieldDefaults.colors(
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = MaterialTheme.colorScheme.onSurface,
focusedLabelColor = MaterialTheme.colorScheme.onSurface,
),
textStyle =
LocalDensity.current.run {
textStyle = LocalDensity.current.run {
TextStyle(fontSize = 18.sp, color = MaterialTheme.colorScheme.onSurface)
},
)
Expand All @@ -118,8 +115,7 @@ fun MfPasswordTextField(
onValueChange = onPasswordChange,
label = { Text(label) },
isError = isError,
visualTransformation =
if (isPasswordVisible) {
visualTransformation = if (isPasswordVisible) {
VisualTransformation.None
} else {
PasswordVisualTransformation()
Expand Down Expand Up @@ -157,14 +153,12 @@ fun MifosOutlinedTextField(
onValueChange = onValueChange,
label = { Text(stringResource(id = label)) },
modifier = modifier,
leadingIcon =
if (icon != null) {
leadingIcon = if (icon != null) {
{
Image(
painter = painterResource(id = icon),
contentDescription = null,
colorFilter =
ColorFilter.tint(
colorFilter = ColorFilter.tint(
MaterialTheme.colorScheme.onSurface,
),
)
Expand All @@ -175,13 +169,11 @@ fun MifosOutlinedTextField(
trailingIcon = trailingIcon,
maxLines = maxLines,
singleLine = singleLine,
colors =
OutlinedTextFieldDefaults.colors(
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = MaterialTheme.colorScheme.onSurface,
focusedLabelColor = MaterialTheme.colorScheme.onSurface,
),
textStyle =
LocalDensity.current.run {
textStyle = LocalDensity.current.run {
TextStyle(fontSize = 18.sp, color = MaterialTheme.colorScheme.onSurface)
},
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
Expand Down Expand Up @@ -209,6 +201,9 @@ fun MifosTextField(
minLines: Int = 1,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
keyboardOptions: KeyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
trailingIcon: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
indicatorColor: Color? = null,
) {
var isFocused by rememberSaveable { mutableStateOf(false) }

Expand All @@ -232,31 +227,56 @@ fun MifosTextField(
singleLine = singleLine,
maxLines = maxLines,
minLines = minLines,
cursorBrush = SolidColor(NewUi.primaryColor),
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
decorationBox = { innerTextField ->
Column {
Text(
text = label,
color = NewUi.primaryColor,
color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.labelLarge,
modifier = Modifier.align(alignment = Alignment.Start),
)

Spacer(modifier = Modifier.height(5.dp))

innerTextField()
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth(),
) {
if (leadingIcon != null) {
leadingIcon()
}

Spacer(modifier = Modifier.height(5.dp))
HorizontalDivider(
thickness = 1.dp,
color = if (isFocused) {
NewUi.secondaryColor
} else {
NewUi.onSurface.copy(alpha = 0.05f)
},
)
Box(modifier = Modifier.weight(1f)) {
innerTextField()
}

if (trailingIcon != null) {
trailingIcon()
}
}
indicatorColor?.let { color ->
HorizontalDivider(
thickness = 1.dp,
color = if (isFocused) {
color
} else {
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.05f)
},
)
} ?: run {
HorizontalDivider(
thickness = 1.dp,
color = if (isFocused) {
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.05f)
},
)
}
}
},

)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ package org.mifospay.core.designsystem.theme

import androidx.compose.ui.graphics.Color

val md_theme_light_primary = Color(0xFF000000)
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFFFD9E2)
val md_theme_light_primary = Color(0xFF0673BA) // primary
val md_theme_light_onPrimary = Color(0xFFFFFFFF) // gradientOne
val md_theme_light_primaryContainer = Color(0xFFF5F5F5) // container color
val md_theme_light_onPrimaryContainer = Color(0xFF3E001D)
val md_theme_light_secondary = Color(0xFF984061)
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
Expand All @@ -30,7 +30,7 @@ val md_theme_light_onErrorContainer = Color(0xFF410002)
val md_theme_light_background = Color(0xFFFFFBFF)
val md_theme_light_onBackground = Color(0xFF330045)
val md_theme_light_surface = Color(0xFFFFFBFF)
val md_theme_light_onSurface = Color(0xFF000000)
val md_theme_light_onSurface = Color(0xFF333333) // onSurface
val md_theme_light_surfaceVariant = Color(0xFFF2DDE1)
val md_theme_light_onSurfaceVariant = Color(0xFF514347)
val md_theme_light_outline = Color(0xFF837377)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fun EmptyContentScreen(
.fillMaxWidth()
.padding(start = 24.dp, end = 24.dp),
textAlign = TextAlign.Center,
color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)
Expand All @@ -76,9 +77,9 @@ fun EmptyContentScreen(
text = subTitle,
modifier = Modifier
.fillMaxWidth()
.padding(start = 24.dp, end = 24.dp),
.padding(start = 37.dp, end = 37.dp),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
)
}
Expand All @@ -98,7 +99,7 @@ fun EmptyContentScreen(
subTitle = subTitle,
imageContent = {
Image(
modifier = Modifier.size(64.dp),
modifier = Modifier.size(200.dp),
painter = painterResource(id = iconDrawable),
colorFilter = if (iconTint != Color.Unspecified) ColorFilter.tint(iconTint) else null,
contentDescription = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fun MifosScrollableTabRow(
tabContents: List<TabContent>,
pagerState: PagerState,
modifier: Modifier = Modifier,
containerColor: Color = MaterialTheme.colorScheme.surface,
selectedContentColor: Color = MaterialTheme.colorScheme.onSurface,
unselectedContentColor: Color = Color.LightGray,
containerColor: Color = MaterialTheme.colorScheme.primaryContainer,
selectedContentColor: Color = MaterialTheme.colorScheme.primary,
unselectedContentColor: Color = MaterialTheme.colorScheme.primaryContainer,
edgePadding: Dp = 8.dp,
) {
val scope = rememberCoroutineScope()
Expand All @@ -41,6 +41,8 @@ fun MifosScrollableTabRow(
containerColor = containerColor,
selectedTabIndex = pagerState.currentPage,
edgePadding = edgePadding,
indicator = {},
divider = {},
) {
tabContents.forEachIndexed { index, currentTab ->
MifosTab(
Expand Down
Loading
Loading