Skip to content
Closed
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ val NetworkModule = module {
baseManager
}

single { (context: Any) ->
single {
ImageLoaderUtils(
prefManager = get<UserPreferencesRepository>(),
imageLoader = get<ImageLoader>(),
context = context,
// imageLoader = get<ImageLoader>(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import kotlinx.coroutines.flow.first

class ImageLoaderUtils(
private val prefManager: UserPreferencesRepository,
private val imageLoader: ImageLoader,
private val context: Any,
// private val imageLoader: ImageLoader,
) {

private suspend fun buildImageUrl(clientId: Int): String {
Expand All @@ -32,12 +31,21 @@ class ImageLoaderUtils(
)
}

suspend fun loadImage(clientId: Int): ImageResult {
//TODO : if in future the image getting api i.e https://tt.mifos.community/fineract-provider/api/v1/clients/75/images?maxHeight=150 works then change the things accordingly
suspend fun loadImage(clientId: Int): String {
val imageUrl = buildImageUrl(clientId)

val request = buildPlatformImageRequest(context, imageUrl)
return imageLoader.execute(request)
return imageUrl
}

//TODO : for future reference currently the api is not working
// suspend fun loadImage(clientId: Int): ImageResult {
// val request = ImageRequest.Builder(context)
// .data(buildImageUrl(clientId))
// .addHeader(MifosInterceptor.HEADER_TENANT, prefManager.serverConfig.tenant)
// .addHeader(MifosInterceptor.HEADER_AUTH, prefManager.token)
// .addHeader("Accept", "application/octet-stream")
// .build()
// return imageLoader.execute(request)
// }
}

expect fun buildPlatformImageRequest(context: Any, imageUrl: String): ImageRequest

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import io.github.vinceglb.filekit.dialogs.FileKitType
import io.github.vinceglb.filekit.dialogs.compose.rememberFilePickerLauncher
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.getString
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.koin.compose.viewmodel.koinViewModel

Expand Down Expand Up @@ -385,6 +386,7 @@ private fun MifosClientDetailsScreen(
},
contentDescription = null,
contentScale = ContentScale.FillBounds,
error = painterResource(Res.drawable.feature_client_ic_launcher)
)
}
Spacer(modifier = Modifier.height(10.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package com.mifos.feature.client.clientDetails
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import coil3.request.ImageResult
import com.mifos.core.common.utils.Constants
import com.mifos.core.common.utils.DataState
import com.mifos.core.data.repository.ClientDetailsRepository
Expand Down Expand Up @@ -145,7 +144,7 @@ class ClientDetailsViewModel(
}
}

suspend fun getClientImageUrl(clientId: Int): ImageResult {
suspend fun getClientImageUrl(clientId: Int): String {
return imageLoaderUtils.loadImage(clientId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal fun PaymentsDetailsScreen(
paymentTypeOptionList: List<String>,
paymentTypeOptions: List<PaymentTypeOptions>,
modifier: Modifier = Modifier,
getClientImage: (Int) -> ImageResult?,
getClientImage: (Int) -> String?,
) {
val loanCollectionSheetItem = loanAndClientNameItem.loan
val scrollState = rememberScrollState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class PaymentDetailsViewModel(
val loanAndClientName = args.loanAndClientName
val paymentTypeOptions = args.paymentTypeOptions

fun getClientImageUrl(clientId: Int): ImageResult? {
var image: ImageResult? = null
fun getClientImageUrl(clientId: Int): String? {
var image: String? = null
viewModelScope.launch {
image = imageLoaderUtils.loadImage(clientId)
}
Expand Down
Loading