-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor Center details fragment to compose (#2112)
* refactor: refactor center details fragment to compose * fix : fix scaffold
- Loading branch information
1 parent
8fa9130
commit 6b9fd65
Showing
30 changed files
with
722 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
core/data/src/main/java/com/mifos/core/data/repository/CenterDetailsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.mifos.core.data.repository | ||
|
||
import com.mifos.core.objects.group.CenterInfo | ||
import com.mifos.core.objects.group.CenterWithAssociations | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
/** | ||
* Created by Aditya Gupta on 06/08/23. | ||
*/ | ||
interface CenterDetailsRepository { | ||
|
||
suspend fun getCentersGroupAndMeeting(id: Int): Flow<CenterWithAssociations> | ||
|
||
suspend fun getCenterSummaryInfo( | ||
centerId: Int, | ||
genericResultSet: Boolean | ||
): Flow<List<CenterInfo>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
core/designsystem/src/main/java/com/mifos/core/designsystem/icon/MifosIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
package com.mifos.core.designsystem.icon | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.DateRange | ||
import androidx.compose.material.icons.outlined.EventRepeat | ||
import androidx.compose.material.icons.outlined.Group | ||
import androidx.compose.material.icons.rounded.Add | ||
import androidx.compose.material.icons.rounded.ArrowBackIosNew | ||
import androidx.compose.material.icons.rounded.PersonOutline | ||
|
||
object MifosIcons { | ||
val Add = Icons.Rounded.Add | ||
val person = Icons.Rounded.PersonOutline | ||
val group = Icons.Outlined.Group | ||
val eventRepeat = Icons.Outlined.EventRepeat | ||
val date = Icons.Outlined.DateRange | ||
val arrowBack = Icons.Rounded.ArrowBackIosNew | ||
} |
35 changes: 35 additions & 0 deletions
35
core/domain/src/main/java/com/mifos/core/domain/use_cases/GetCenterDetailsUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.mifos.core.domain.use_cases | ||
|
||
import com.mifos.core.common.utils.Resource | ||
import com.mifos.core.data.repository.CenterDetailsRepository | ||
import com.mifos.core.objects.group.CenterInfo | ||
import com.mifos.core.objects.group.CenterWithAssociations | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.zip | ||
import javax.inject.Inject | ||
|
||
class GetCenterDetailsUseCase @Inject constructor(private val repository: CenterDetailsRepository) { | ||
|
||
suspend operator fun invoke( | ||
centerId: Int, | ||
genericResultSet: Boolean | ||
): Flow<Resource<Pair<CenterWithAssociations, List<CenterInfo>>>> = flow { | ||
try { | ||
emit(Resource.Loading()) | ||
repository.getCentersGroupAndMeeting(centerId) | ||
.zip( | ||
repository.getCenterSummaryInfo( | ||
centerId, | ||
genericResultSet | ||
) | ||
) { centerGroup, centerInfo -> | ||
Pair(centerGroup, centerInfo) | ||
}.collect { | ||
emit(Resource.Success(it)) | ||
} | ||
} catch (exception: Exception) { | ||
emit(Resource.Error(exception.message.toString())) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.