Skip to content

Commit

Permalink
Refactor- [:feature:user-profile] Apply & Fix Detekt, Ktlint Rules (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
niyajali authored Sep 2, 2024
1 parent 7c5217c commit 865175d
Show file tree
Hide file tree
Showing 35 changed files with 451 additions and 472 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ import org.mifos.mobile.feature.qr.navigation.navigateToQrDisplayScreen
import org.mifos.mobile.feature.qr.navigation.navigateToQrImportScreen
import org.mifos.mobile.feature.qr.navigation.navigateToQrReaderScreen
import org.mifos.mobile.feature.qr.navigation.qrNavGraph
import org.mifos.mobile.feature.transaction.navigation.navigateToRecentTransaction
import org.mifos.mobile.feature.transaction.navigation.recentTransactionNavGraph
import org.mifos.mobile.feature.savings.navigation.navigateToSavingsApplicationScreen
import org.mifos.mobile.feature.savings.navigation.navigateToSavingsDetailScreen
import org.mifos.mobile.feature.savings.navigation.navigateToSavingsMakeTransfer
Expand All @@ -60,12 +58,14 @@ import org.mifos.mobile.feature.settings.navigation.navigateToSettings
import org.mifos.mobile.feature.settings.navigation.settingsNavGraph
import org.mifos.mobile.feature.third.party.transfer.third_party_transfer.navigation.navigateToThirdPartyTransfer
import org.mifos.mobile.feature.third.party.transfer.third_party_transfer.navigation.thirdPartyTransferNavGraph
import org.mifos.mobile.feature.transaction.navigation.navigateToRecentTransaction
import org.mifos.mobile.feature.transaction.navigation.recentTransactionNavGraph
import org.mifos.mobile.feature.transfer.process.navigation.navigateToTransferProcessScreen
import org.mifos.mobile.feature.transfer.process.navigation.transferProcessNavGraph
import org.mifos.mobile.feature.update_password.navigation.navigateToUpdatePassword
import org.mifos.mobile.feature.update_password.navigation.updatePasswordNavGraph
import org.mifos.mobile.feature.user_profile.navigation.navigateToUserProfile
import org.mifos.mobile.feature.user_profile.navigation.userProfileNavGraph
import org.mifos.mobile.feature.user.profile.navigation.navigateToUserProfile
import org.mifos.mobile.feature.user.profile.navigation.userProfileNavGraph
import org.mifos.mobile.ui.activities.HomeActivity
import org.mifos.mobile.ui.activities.PassCodeActivity

Expand Down Expand Up @@ -105,7 +105,7 @@ fun RootNavGraph(
)

userProfileNavGraph(
navController = navController,
navigateBack = navController::popBackStack,
navigateToChangePassword = navController::navigateToUpdatePassword
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.mifos.mobile.R
import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.feature.home.navigation.HomeNavigation
import org.mifos.mobile.feature.user_profile.viewmodel.UserDetailViewModel
import org.mifos.mobile.feature.user.profile.viewmodel.UserDetailViewModel
import org.mifos.mobile.navigation.RootNavGraph
import org.mifos.mobile.utils.Toaster
import org.mifos.mobile.utils.fcm.RegistrationIntentService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mifos.mobile.R
import org.mifos.mobile.api.local.PreferencesHelper
import org.mifos.mobile.feature.user.profile.viewmodel.UserDetailViewModel
import org.mifos.mobile.models.client.Client
import org.mifos.mobile.repositories.HomeRepositoryImp
import org.mifos.mobile.repositories.UserDetailRepositoryImp
Expand Down Expand Up @@ -47,12 +48,12 @@ class UserDetailViewModelTest {
private lateinit var preferencesHelper: PreferencesHelper


private lateinit var viewModel: org.mifos.mobile.feature.user_profile.viewmodel.UserDetailViewModel
private lateinit var viewModel: UserDetailViewModel

@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
viewModel = org.mifos.mobile.feature.user_profile.viewmodel.UserDetailViewModel(
viewModel = UserDetailViewModel(
userDetailRepositoryImp,
homeRepositoryImp
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.home.utils
package org.mifos.mobile.core.ui.utils

import android.graphics.Bitmap
import android.graphics.BitmapFactory
Expand All @@ -16,7 +7,7 @@ import android.graphics.Matrix
import android.graphics.Paint
import android.util.Log

internal object ImageUtil {
object ImageUtil {
private const val DEFAULT_MAX_WIDTH = 816f
private const val DEFAULT_MAX_HEIGHT = 612f

Expand Down Expand Up @@ -138,4 +129,4 @@ private fun createScaledBitmap(
}

return scaledBitmap
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import org.mifos.mobile.core.data.repository.HomeRepository
import org.mifos.mobile.core.datastore.PreferencesHelper
import org.mifos.mobile.core.model.entity.accounts.loan.LoanAccount
import org.mifos.mobile.core.model.entity.accounts.savings.SavingAccount
import org.mifos.mobile.core.ui.utils.ImageUtil
import org.mifos.mobile.feature.home.R
import org.mifos.mobile.feature.home.utils.HomeState
import org.mifos.mobile.feature.home.utils.HomeUiState
import org.mifos.mobile.feature.home.utils.ImageUtil
import javax.inject.Inject

@HiltViewModel
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions feature/user-profile/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.kotlin.parcelize)
}


android {
namespace = "org.mifos.mobile.feature.user.profile"
}

dependencies {
implementation(libs.squareup.okhttp)
}
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions feature/user-profile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Mifos Initiative
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.user.profile.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import org.mifos.mobile.feature.user.profile.screens.UserProfileScreen

fun NavController.navigateToUserProfile() {
navigate(UserProfileNavigation.UserProfileBase.route)
}

fun NavGraphBuilder.userProfileNavGraph(
navigateBack: () -> Unit,
navigateToChangePassword: () -> Unit,
) {
navigation(
startDestination = UserProfileNavigation.UserProfileScreen.route,
route = UserProfileNavigation.UserProfileBase.route,
) {
userProfileRoute(
navigateBack = navigateBack,
navigateToChangePassword = navigateToChangePassword,
)
}
}

private fun NavGraphBuilder.userProfileRoute(
navigateBack: () -> Unit,
navigateToChangePassword: () -> Unit,
) {
composable(
route = UserProfileNavigation.UserProfileScreen.route,
) {
UserProfileScreen(
navigateBack = navigateBack,
changePassword = navigateToChangePassword,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.user.profile.navigation

const val USER_PROFILE_NAVIGATION_ROUTE_BASE = "user_profile_base_route"
const val USER_PROFILE_SCREEN_ROUTE = "user_profile_screen_route"

internal sealed class UserProfileNavigation(val route: String) {
data object UserProfileBase : UserProfileNavigation(route = USER_PROFILE_NAVIGATION_ROUTE_BASE)
data object UserProfileScreen : UserProfileNavigation(route = USER_PROFILE_SCREEN_ROUTE)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package org.mifos.mobile.feature.user_profile.screens
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.user.profile.screens

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -15,19 +24,17 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.mifos.mobile.feature.third.party.user_profile.R
import org.mifos.mobile.feature.user_profile.utils.UserDetails

/**
* @author pratyush
* @since 20/12/2023
*/
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.ui.utils.DevicePreviews
import org.mifos.mobile.feature.user.profile.R
import org.mifos.mobile.feature.user.profile.utils.UserDetails

@Composable
fun UserProfileDetails(
userDetails: UserDetails
internal fun UserProfileDetails(
userDetails: UserDetails,
modifier: Modifier = Modifier,
) {
Column {
Column(modifier) {
Text(
modifier = Modifier.padding(top = 16.dp, start = 8.dp),
text = stringResource(id = R.string.user_details),
Expand All @@ -36,57 +43,81 @@ fun UserProfileDetails(
)
Row(
modifier = Modifier.padding(start = 8.dp),
verticalAlignment = Alignment.Bottom
verticalAlignment = Alignment.Bottom,
) {
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_phone_24dp),
tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
contentDescription = null,
)
if( userDetails.phoneNumber != null ){
if (userDetails.phoneNumber != null) {
Text(
text = userDetails.phoneNumber,
color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
style = TextStyle(fontSize = 14.sp),
)
}
}
Row(
modifier = Modifier.padding(start = 8.dp),
verticalAlignment = Alignment.Bottom
verticalAlignment = Alignment.Bottom,
) {
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_cake_24dp),
tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
contentDescription = null,
)
if( userDetails.dob != null ){
if (userDetails.dob != null) {
Text(
text = userDetails.dob,
color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
style = TextStyle(fontSize = 14.sp),
)
}
}
Row(
modifier = Modifier.padding(start = 8.dp),
verticalAlignment = Alignment.Bottom
verticalAlignment = Alignment.Bottom,
) {
Icon(
modifier = Modifier.padding(top = 8.dp, end = 8.dp),
painter = painterResource(id = R.drawable.ic_gender_24dp),
tint = MaterialTheme.colorScheme.surfaceTint,
contentDescription = null
contentDescription = null,
)
if(userDetails.gender != null) {
if (userDetails.gender != null) {
Text(
text = userDetails.gender,
color = MaterialTheme.colorScheme.onSurface,
style = TextStyle(fontSize = 14.sp)
style = TextStyle(fontSize = 14.sp),
)
}
}
}
}
}

@DevicePreviews
@Composable
private fun UserProfileDetailsPreview(
modifier: Modifier = Modifier,
) {
MifosMobileTheme {
UserProfileDetails(
userDetails = UserDetails(
userName = "John Doe",
accountNumber = "123456",
activationDate = "01/01/2021",
officeName = "Office Name",
clientType = "Client Type",
groups = "Groups",
clientClassification = "Client Classification",
phoneNumber = "1234567890",
dob = "01/01/1990",
gender = "Male",
),
modifier = modifier,
)
}
}
Loading

0 comments on commit 865175d

Please sign in to comment.