Skip to content

Commit

Permalink
Merge remote tracking branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Dec 13, 2023
2 parents 44308fb + e280a46 commit 62b7655
Show file tree
Hide file tree
Showing 102 changed files with 1,599 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.hyperskill.app.android.main.view.ui.navigation.switch
import org.hyperskill.app.android.progress.navigation.ProgressScreen
import org.hyperskill.app.android.view.base.ui.extension.setElevationOnCollapsed
import org.hyperskill.app.gamification_toolbar.presentation.GamificationToolbarFeature
import org.hyperskill.app.streaks.domain.model.StreakState
import ru.nobird.android.view.base.ui.extension.setTextIfChanged

class GamificationToolbarDelegate(
Expand All @@ -29,11 +28,6 @@ class GamificationToolbarDelegate(
gamificationAppBar.setElevationOnCollapsed(lifecycleOwner.lifecycle)
gamificationAppBar.setExpanded(true)

gamificationGemsCountTextView.setOnClickListener {
onNewMessage(
GamificationToolbarFeature.Message.ClickedGems
)
}
gamificationStreakDurationTextView.setOnClickListener {
onNewMessage(
GamificationToolbarFeature.Message.ClickedStreak
Expand All @@ -47,34 +41,31 @@ class GamificationToolbarDelegate(
}
}

fun render(state: GamificationToolbarFeature.State) {
if (state is GamificationToolbarFeature.State.Content) {
fun render(state: GamificationToolbarFeature.ViewState) {
if (state is GamificationToolbarFeature.ViewState.Content) {
with(viewBinding.gamificationStreakDurationTextView) {
isVisible = true
text = state.currentStreak.toString()
text = state.streak.formattedValue
setCompoundDrawablesWithIntrinsicBounds(
/* left = */ when {
state.historicalStreak.state == StreakState.RECOVERED -> R.drawable.ic_menu_recovered_streak
state.historicalStreak.isCompleted -> R.drawable.ic_menu_enabled_streak
state.streak.isRecovered -> R.drawable.ic_menu_recovered_streak
state.streak.isCompleted -> R.drawable.ic_menu_enabled_streak
else -> R.drawable.ic_menu_empty_streak
},
/* top = */ 0,
/* right = */ 0,
/* bottom = */ 0
)
}
with(viewBinding.gamificationGemsCountTextView) {
isVisible = true
text = state.hypercoinsBalance.toString()
}

state.trackProgress.let { trackProgress ->
viewBinding.gamificationTrackProgressLinearLayout.isVisible = trackProgress != null
if (trackProgress != null) {
state.progress.let { progress ->
viewBinding.gamificationTrackProgressLinearLayout.isVisible = progress != null
if (progress != null) {
viewBinding.gamificationTrackProgressView.setProgress(
trackProgress.averageProgress,
trackProgress.isCompleted
progress.value,
progress.isCompleted
)
viewBinding.gamificationTrackProgressTextView.text = progress.formattedValue
}
}
}
Expand All @@ -90,6 +81,9 @@ class GamificationToolbarDelegate(
mainScreenRouter.switch(Tabs.PROFILE)
GamificationToolbarFeature.Action.ViewAction.ShowProgressScreen ->
router.navigateTo(ProgressScreen)
GamificationToolbarFeature.Action.ViewAction.ShowSearchScreen -> {
// TODO: ALTAPPS-1059 Show search screen
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ class ToolbarTrackProgressView @JvmOverloads constructor(
}
}

fun setProgress(progress: Int, isCompleted: Boolean) {
val normalizedProgress =
progress.coerceAtMost(100).coerceAtLeast(0)
val progressRadius = normalizedProgress / 100f * 360
fun setProgress(progress: Float, isCompleted: Boolean) {
val progressRadius = progress * 360
if (progressRadius != this.progressSweepAngel) {
this.progressSweepAngel = progressRadius
this.isCompleted = isCompleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class HomeFragment :
)
}

gamificationToolbarDelegate?.render(state.toolbarState)
gamificationToolbarDelegate?.render(state.toolbarViewState)
}

private fun renderSwipeRefresh(state: HomeFeature.ViewState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LeaderboardFragment : Fragment(R.layout.fragment_leaderboard) {
}
leaderboardViewModel.state
.flowWithLifecycle(viewLifecycleOwner.lifecycle, Lifecycle.State.STARTED)
.map { it.toolbarState }
.map { it.toolbarViewState }
.distinctUntilChanged()
.onEach { viewState ->
gamificationToolbarDelegate?.render(viewState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class StudyPlanFragment :

override fun render(state: StudyPlanScreenFeature.ViewState) {
renderSwipeRefresh(state)
gamificationToolbarDelegate?.render(state.toolbarState)
gamificationToolbarDelegate?.render(state.toolbarViewState)
gamificationToolbarDelegate?.setSubtitle(state.trackTitle)
problemsLimitDelegate?.render(state.problemsLimitViewState)
studyPlanWidgetDelegate?.render(state.studyPlanWidgetViewState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@
/>

<TextView
android:id="@+id/gamificationTrackProgressTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="14sp"
android:text="@string/track_progress_block_title"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
tools:text="21%" />

</LinearLayout>

Expand All @@ -86,25 +87,6 @@
tools:visibility="visible"
/>

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/gamificationGemsCountTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:textSize="14sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:drawableStartCompat="@drawable/ic_menu_gems_count"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:layout_gravity="center"
android:paddingHorizontal="4dp"
tools:text="3"
android:visibility="gone"
tools:visibility="visible"
/>

</com.google.android.material.appbar.MaterialToolbar>

<TextView
Expand Down
Loading

0 comments on commit 62b7655

Please sign in to comment.