-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor pinned quick pairs widget (#117)
* Handle display quick pairs in widget by group * Update icon * Refactor quick pairs widget * Move findActivity to utils * Refactor ActionCallback * Handle new pair nav in MainScreen instead of QuickScreen * Accept group in AddQuickScreen, pass group on new pair from widget * Extract common login between NextPageAction and PreviousPageAction --------- Co-authored-by: Hieu Vu <[email protected]>
- Loading branch information
Showing
16 changed files
with
240 additions
and
144 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
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
31 changes: 31 additions & 0 deletions
31
app/src/main/java/dev/arkbuilders/rate/domain/usecase/GetSortedPinnedQuickPairsUseCase.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,31 @@ | ||
package dev.arkbuilders.rate.domain.usecase | ||
|
||
import dev.arkbuilders.rate.domain.model.PinnedQuickPair | ||
import dev.arkbuilders.rate.domain.model.QuickPair | ||
import dev.arkbuilders.rate.domain.repo.QuickRepo | ||
import java.time.OffsetDateTime | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class GetSortedPinnedQuickPairsUseCase @Inject constructor( | ||
private val quickRepo: QuickRepo, | ||
private val convertUseCase: ConvertWithRateUseCase, | ||
) { | ||
suspend operator fun invoke() = | ||
quickRepo.getAll() | ||
.filter { it.isPinned() } | ||
.map { | ||
mapPairToPinned(it) | ||
} | ||
.sortedByDescending { it.pair.pinnedDate } | ||
|
||
private suspend fun mapPairToPinned(pair: QuickPair): PinnedQuickPair { | ||
val actualTo = | ||
pair.to.map { to -> | ||
val (amount, _) = convertUseCase.invoke(pair.from, pair.amount, to.code) | ||
amount | ||
} | ||
return PinnedQuickPair(pair, actualTo, OffsetDateTime.now()) | ||
} | ||
} |
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
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.