Skip to content

Commit

Permalink
refactor #2503: migrated home screen to compose
Browse files Browse the repository at this point in the history
  • Loading branch information
AvneetSingh2001 committed Feb 6, 2024
1 parent b17de99 commit e0bfa8f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
19 changes: 6 additions & 13 deletions app/src/main/java/org/mifos/mobile/ui/home/HomeContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.mifos.mobile.ui.home
import android.graphics.Bitmap
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
Expand All @@ -28,7 +27,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -124,7 +122,6 @@ fun UserDetailsRow(
.padding(20.dp),
verticalAlignment = Alignment.CenterVertically
) {

MifosUserImage(
modifier = Modifier
.size(84.dp)
Expand All @@ -135,14 +132,10 @@ fun UserDetailsRow(
bitmap = userBitmap,
username = username
)

Text(
text = stringResource(
R.string.hello_client,
username
),
text = stringResource(R.string.hello_client, username),
style = MaterialTheme.typography.headlineSmall,
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
color = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth(1f)
Expand Down Expand Up @@ -179,7 +172,7 @@ private fun HomeCard(
text = stringResource(id = titleId),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black
color = MaterialTheme.colorScheme.onSurface
)
}
}
Expand Down Expand Up @@ -208,7 +201,7 @@ private fun AccountOverviewCard(
Text(
text = stringResource(id = R.string.accounts_overview),
style = MaterialTheme.typography.bodyMedium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black
color = MaterialTheme.colorScheme.onSurface
)

Divider(modifier = Modifier.padding(top = 8.dp, bottom = 4.dp))
Expand Down Expand Up @@ -253,7 +246,7 @@ private fun ContactUsRow(
Text(
text = stringResource(id = R.string.need_help),
modifier = Modifier.weight(1f),
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.bodyMedium
)

Expand All @@ -279,7 +272,7 @@ private fun ContactUsRow(
fun PreviewHomeContent() {
MifosMobileTheme {
HomeContent(
username = "Mifos",
username = stringResource(id = R.string.app_name),
totalLoanAmount = 32.32,
totalSavingsAmount = 34.43,
userBitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -34,13 +35,13 @@ fun EmptyDataView(
.padding(bottom = 12.dp),
painter = painterResource(id = icon),
contentDescription = null,
tint = if (isSystemInDarkTheme()) Color.White else Color.Gray
tint = MaterialTheme.colorScheme.onSecondary
)

Text(
text = stringResource(id = error),
style = TextStyle(fontSize = 20.sp),
color = if (isSystemInDarkTheme()) Color.White else Color.Gray
color = MaterialTheme.colorScheme.onSecondary
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -42,7 +43,7 @@ fun MifosTitleSearchCard(
) {
Text(
text = stringResource(id = titleResourceId),
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 24.sp),
modifier = Modifier.weight(1f),
maxLines = 1
Expand All @@ -52,7 +53,7 @@ fun MifosTitleSearchCard(
Icon(
imageVector = Icons.Default.Search,
contentDescription = "Search Icon",
tint = if (isSystemInDarkTheme()) Color.White else Color.Black,
tint = MaterialTheme.colorScheme.onSurface,
)
}
}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/main/java/org/mifos/mobile/core/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ private val LightThemeColors = lightColorScheme(
error = RedErrorDark,
background = BackgroundLight,
onSurface = Black2,
outlineVariant = Color.Gray
onSecondary = Color.Gray,
outlineVariant = Color.Gray,
)

private val DarkThemeColors = darkColorScheme(
Expand All @@ -24,6 +25,8 @@ private val DarkThemeColors = darkColorScheme(
error = RedErrorDark,
background = BackgroundDark,
surface = Black1,
onSurface = Color.White,
onSecondary = Color.White,
outlineVariant = Color.White
)

Expand Down

0 comments on commit e0bfa8f

Please sign in to comment.