Skip to content

Commit

Permalink
Stats: Viewing the history of operation reports requires the pro version
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Jul 5, 2024
1 parent 046cf58 commit 7514d19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,20 @@ class DashboardViewModel @Inject constructor(
)
}

private val statsItem: Flow<StatsDashCardVH.Item?> = statsRepo.state.map {
if (it.isEmpty) return@map null
private val statsItem: Flow<StatsDashCardVH.Item?> = combine(
statsRepo.state,
upgradeInfo.map { it?.isPro ?: false },
) { state, isPro ->
if (state.isEmpty) return@combine null
StatsDashCardVH.Item(
state = it,
state = state,
showProRequirement = !isPro,
onViewAction = {
DashboardFragmentDirections.actionDashboardFragmentToReportsFragment().navigate()
if (isPro) {
DashboardFragmentDirections.actionDashboardFragmentToReportsFragment()
} else {
MainDirections.goToUpgradeFragment()
}.navigate()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ class StatsDashCardVH(parent: ViewGroup) :
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}

viewAction.apply {
if (item.showProRequirement) {
setIconResource(R.drawable.ic_baseline_stars_24)
} else {
icon = null
}
}
root.setOnClickListener { item.onViewAction() }
}

data class Item(
val state: StatsRepo.State,
val showProRequirement: Boolean,
val onViewAction: () -> Unit,
) : DashboardAdapter.Item {
override val stableId: Long = this.javaClass.hashCode().toLong()
Expand Down

0 comments on commit 7514d19

Please sign in to comment.