Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
apply("com.dropbox.dependency-guard")
apply("mifos.detekt.plugin")
apply("mifos.spotless.plugin")
apply("mifos.ktlint.plugin")
apply("mifos.git.hooks")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
apply("mifospay.android.lint")
apply("mifos.detekt.plugin")
apply("mifos.spotless.plugin")
apply("mifos.ktlint.plugin")
apply("mifospay.android.koin")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class CMPFeatureConventionPlugin : Plugin<Project> {
add("commonMainImplementation", project(":core:designsystem"))
add("commonMainImplementation", project(":core:data"))

add("commonMainImplementation", libs.findLibrary("koin.compose").get())
add("commonMainImplementation", libs.findLibrary("koin.compose.viewmodel").get())

add("commonMainImplementation", libs.findLibrary("jb.composeRuntime").get())
add("commonMainImplementation", libs.findLibrary("jb.composeViewmodel").get())
add("commonMainImplementation", libs.findLibrary("jb.lifecycleViewmodel").get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ interface SavingsAccountRepository {

suspend fun createSavingsAccount(savingAccount: SavingAccountEntity): Flow<Result<GenericResponse>>

suspend fun blockUnblockAccount(
suspend fun unblockAccount(
accountId: Long,
command: String?,
): Flow<Result<GenericResponse>>
): Result<String>

suspend fun blockAccount(
accountId: Long,
): Result<String>

suspend fun getSavingAccountTransaction(
accountId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface UserRepository {

suspend fun updateUser(userId: Int, updatedUser: NewUser): Flow<Result<GenericResponse>>

suspend fun updateUserPassword(userId: Long, password: String): Result<String>

suspend fun deleteUser(userId: Int): Result<CommonResponse>

suspend fun assignClientToUser(userId: Int, clientId: Int): Result<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,30 @@ class SavingsAccountRepositoryImpl(
.asResult().flowOn(ioDispatcher)
}

override suspend fun blockUnblockAccount(
override suspend fun unblockAccount(
accountId: Long,
command: String?,
): Flow<Result<GenericResponse>> {
return apiManager.savingsAccountsApi
.blockUnblockAccount(accountId, command)
.asResult().flowOn(ioDispatcher)
): Result<String> {
return try {
withContext(ioDispatcher) {
apiManager.savingsAccountsApi.blockUnblockAccount(accountId, "unblock")
}

Result.Success("Account unblocked successfully")
} catch (e: Exception) {
Result.Error(e)
}
}

override suspend fun blockAccount(accountId: Long): Result<String> {
return try {
withContext(ioDispatcher) {
apiManager.savingsAccountsApi.blockUnblockAccount(accountId, "block")
}

Result.Success("Account blocked successfully")
} catch (e: Exception) {
Result.Error(e)
}
}

override suspend fun getSavingAccountTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.mifospay.core.network.FineractApiManager
import org.mifospay.core.network.model.CommonResponse
import org.mifospay.core.network.model.GenericResponse
import org.mifospay.core.network.model.entity.UserWithRole
import org.mifospay.core.network.model.entity.user.UpdateUserEntityPassword

class UserRepositoryImpl(
private val apiManager: FineractApiManager,
Expand Down Expand Up @@ -56,6 +57,19 @@ class UserRepositoryImpl(
.asResult().flowOn(ioDispatcher)
}

override suspend fun updateUserPassword(userId: Long, password: String): Result<String> {
return try {
apiManager.userApi.updateUserPassword(
userId = userId,
updateUserEntity = UpdateUserEntityPassword(password, password),
)

Result.Success("Password updated successfully")
} catch (e: Exception) {
Result.Error(e)
}
}

override suspend fun deleteUser(userId: Int): Result<CommonResponse> {
return try {
val result = withContext(ioDispatcher) {
Expand Down
4 changes: 0 additions & 4 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,4 @@ kotlin {
compose.resources {
publicResClass = true
generateResClass = always
}

dependencies {
lintPublish(projects.lint)
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,58 @@ fun MifosBasicDialog(
}
}

@Composable
fun MifosBasicDialog(
visibilityState: BasicDialogState,
onConfirm: () -> Unit,
onDismissRequest: () -> Unit,
): Unit = when (visibilityState) {
BasicDialogState.Hidden -> Unit
is BasicDialogState.Shown -> {
AlertDialog(
onDismissRequest = onDismissRequest,
confirmButton = {
MifosTextButton(
content = {
Text(text = "Ok")
},
onClick = onConfirm,
modifier = Modifier.testTag("AcceptAlertButton"),
)
},
dismissButton = {
MifosTextButton(
content = {
Text(text = "Cancel")
},
onClick = onDismissRequest,
modifier = Modifier.testTag("DismissAlertButton"),
)
},
title = visibilityState.title.let {
{
Text(
text = it,
style = MaterialTheme.typography.headlineSmall,
modifier = Modifier.testTag("AlertTitleText"),
)
}
},
text = {
Text(
text = visibilityState.message,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.testTag("AlertContentText"),
)
},
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
modifier = Modifier.semantics {
testTag = "AlertPopup"
},
)
}
}

@Preview
@Composable
private fun MifosBasicDialog_preview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
Expand All @@ -35,8 +34,8 @@ fun MifosScaffold(
topBarTitle: String? = null,
floatingActionButtonContent: FloatingActionButtonContent? = null,
snackbarHost: @Composable () -> Unit = {},
scaffoldContent: @Composable (PaddingValues) -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
content: @Composable (PaddingValues) -> Unit = {},
) {
Scaffold(
topBar = {
Expand All @@ -58,7 +57,8 @@ fun MifosScaffold(
}
},
snackbarHost = snackbarHost,
content = scaffoldContent,
containerColor = Color.Transparent,
content = content,
modifier = modifier,
)
}
Expand All @@ -71,8 +71,8 @@ fun MifosScaffold(
floatingActionButton: @Composable () -> Unit = {},
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() },
floatingActionButtonPosition: FabPosition = FabPosition.End,
containerColor: Color = MaterialTheme.colorScheme.background,
contentColor: Color = contentColorFor(containerColor),
containerColor: Color = Color.Transparent,
contentColor: Color = MaterialTheme.colorScheme.onSurface,
contentWindowInsets: WindowInsets = ScaffoldDefaults.contentWindowInsets,
content: @Composable (PaddingValues) -> Unit,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
package org.mifospay.core.designsystem.component

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
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.Color
import org.mifospay.core.designsystem.icon.MifosIcons

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -29,26 +28,21 @@ fun MifosTopBar(
modifier: Modifier = Modifier,
actions: @Composable RowScope.() -> Unit = {},
) {
TopAppBar(
CenterAlignedTopAppBar(
title = {
Text(
text = topBarTitle,
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.titleMedium,
)
},
navigationIcon = {
IconButton(onClick = { backPress.invoke() }) {
Icon(
imageVector = MifosIcons.ArrowBack,
contentDescription = "Back",
tint = MaterialTheme.colorScheme.onSurface,
)
}
IconBox(
icon = MifosIcons.ArrowBack2,
onClick = backPress,
)
},
colors =
TopAppBarDefaults.mediumTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surface,
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = Color.Transparent,
),
actions = actions,
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ package org.mifospay.core.designsystem.component
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -38,10 +35,10 @@ fun MifosOutlinedTextField(
trailingIcon: @Composable (() -> Unit)? = null,
keyboardOptions: KeyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
) {
OutlinedTextField(
MifosCustomTextField(
value = value,
onValueChange = onValueChange,
label = { Text(label) },
label = label,
modifier = modifier,
leadingIcon = if (icon != null) {
{
Expand All @@ -56,10 +53,6 @@ fun MifosOutlinedTextField(
trailingIcon = trailingIcon,
maxLines = maxLines,
singleLine = singleLine,
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = MaterialTheme.colorScheme.onSurface,
focusedLabelColor = MaterialTheme.colorScheme.onSurface,
),
textStyle = LocalDensity.current.run {
TextStyle(fontSize = 18.sp, color = MaterialTheme.colorScheme.onSurface)
},
Expand Down
Loading