Skip to content

Commit

Permalink
Android topic completion continue next topic button (#370)
Browse files Browse the repository at this point in the history
^ALTAPPS-600
  • Loading branch information
XanderZhu authored Feb 22, 2023
1 parent e18efc3 commit df07c6a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.view.isVisible
import by.kirich1409.viewbindingdelegate.viewBinding
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
Expand All @@ -22,13 +23,18 @@ class TopicPracticeCompletedBottomSheet : BottomSheetDialogFragment() {
companion object {
const val Tag = "TopicPracticeCompletedBottomSheet"

fun newInstance(title: String): TopicPracticeCompletedBottomSheet =
fun newInstance(
title: String,
isNextStepAvailable: Boolean
): TopicPracticeCompletedBottomSheet =
TopicPracticeCompletedBottomSheet().apply {
this.title = title
this.isNextStepAvailable = isNextStepAvailable
}
}

private var title: String by argument()
private var isNextStepAvailable: Boolean by argument()

private val viewBinding: FragmentTopicPracticeCompletedBinding by viewBinding(FragmentTopicPracticeCompletedBinding::bind)

Expand Down Expand Up @@ -66,9 +72,30 @@ class TopicPracticeCompletedBottomSheet : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
with(viewBinding) {
completedDailyStepDescriptionTextView.text = title

completedDailyStepGoBackButton.isVisible = isNextStepAvailable
completedDailyStepGoBackButton.setOnClickListener {
dismiss()
onNewMessage(StepCompletionFeature.Message.TopicCompletedModalGoToHomeScreenClicked)
}

completedDailyStepPrimaryButton.setText(
if (isNextStepAvailable) {
org.hyperskill.app.R.string.step_quiz_topic_completed_continue_with_next_topic_button_text
} else {
org.hyperskill.app.R.string.go_to_homescreen
}
)
completedDailyStepPrimaryButton.setOnClickListener {
dismiss()
onNewMessage(
if (isNextStepAvailable) {
StepCompletionFeature.Message.TopicCompletedModalContinueNextTopicClicked
} else {
StepCompletionFeature.Message.TopicCompletedModalGoToHomeScreenClicked
}
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import by.kirich1409.viewbindingdelegate.viewBinding
import org.hyperskill.app.android.HyperskillApp
import org.hyperskill.app.android.R
import org.hyperskill.app.android.core.extensions.argument
import org.hyperskill.app.android.core.view.ui.dialog.dismissDialogFragmentIfExists
import org.hyperskill.app.android.core.view.ui.fragment.setChildFragment
import org.hyperskill.app.android.core.view.ui.navigation.requireMainRouter
import org.hyperskill.app.android.core.view.ui.navigation.requireRouter
Expand Down Expand Up @@ -96,8 +95,6 @@ class StepFragment :
StepCompletionFeature.Action.ViewAction.NavigateTo.HomeScreen -> {
requireRouter().backTo(MainScreen)
parentFragmentManager.requireMainRouter().switch(HomeScreen)
childFragmentManager
.dismissDialogFragmentIfExists(TopicPracticeCompletedBottomSheet.Tag)
}

is StepCompletionFeature.Action.ViewAction.ReloadStep -> {
Expand All @@ -109,8 +106,15 @@ class StepFragment :
}

is StepCompletionFeature.Action.ViewAction.ShowTopicCompletedModal -> {
TopicPracticeCompletedBottomSheet.newInstance(stepCompletionAction.modalText)
.showIfNotExists(childFragmentManager, TopicPracticeCompletedBottomSheet.Tag)
TopicPracticeCompletedBottomSheet
.newInstance(
stepCompletionAction.modalText,
stepCompletionAction.isNextStepAvailable
)
.showIfNotExists(
childFragmentManager,
TopicPracticeCompletedBottomSheet.Tag
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="20dp"
>

<ImageView
Expand All @@ -15,7 +16,6 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="20dp"
tools:ignore="ContentDescription"
/>

Expand Down Expand Up @@ -56,16 +56,28 @@
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/completedDailyStepGoBackButton"
android:id="@+id/completedDailyStepPrimaryButton"
android:layout_width="match_parent"
android:layout_height="@dimen/action_button_height"
style="@style/ThemeOverlay.Blue"
android:text="@string/go_to_homescreen"
tools:text="@string/step_quiz_topic_completed_continue_with_next_topic_button_text"
android:layout_marginTop="32dp"
android:layout_marginHorizontal="20dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="20dp"
app:layout_constraintTop_toBottomOf="@+id/completedDailyStepDescriptionTextView"
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/completedDailyStepGoBackButton"
android:layout_width="match_parent"
android:layout_height="@dimen/action_button_height"
style="@style/Widget.AppTheme.Button.OutlinedButton"
app:strokeColor="?colorPrimary"
android:text="@string/go_to_homescreen"
android:layout_marginTop="16dp"
android:layout_marginHorizontal="20dp"
app:layout_goneMarginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/completedDailyStepPrimaryButton"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit df07c6a

Please sign in to comment.