-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALTAPPS-1031: Android FillBlanks onboarding animation (#746)
Implement FillBlanks onboarding animation
- Loading branch information
Showing
9 changed files
with
128 additions
and
83 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
...yperskill/app/android/step_quiz/view/dialog/ProblemOnboardingBottomSheetDialogFragment.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,110 @@ | ||
package org.hyperskill.app.android.step_quiz.view.dialog | ||
|
||
import android.app.Dialog | ||
import android.content.Context | ||
import android.content.DialogInterface | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.RawRes | ||
import by.kirich1409.viewbindingdelegate.viewBinding | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import org.hyperskill.app.android.R | ||
import org.hyperskill.app.android.core.extensions.argument | ||
import org.hyperskill.app.android.databinding.FragmentStepQuizProblemOnboardingBinding | ||
import org.hyperskill.app.android.view.base.ui.extension.wrapWithTheme | ||
import org.hyperskill.app.step_quiz.presentation.StepQuizFeature | ||
import org.hyperskill.app.step_quiz_fill_blanks.model.FillBlanksMode | ||
|
||
class ProblemOnboardingBottomSheetDialogFragment : BottomSheetDialogFragment() { | ||
|
||
companion object { | ||
const val TAG = "ProblemOnboardingBottomSheetDialogFragment" | ||
|
||
fun newInstance( | ||
modalType: StepQuizFeature.ProblemOnboardingModal | ||
): ProblemOnboardingBottomSheetDialogFragment = | ||
ProblemOnboardingBottomSheetDialogFragment().apply { | ||
this.modalType = modalType | ||
} | ||
} | ||
|
||
private var modalType: StepQuizFeature.ProblemOnboardingModal by argument( | ||
StepQuizFeature.ProblemOnboardingModal.serializer() | ||
) | ||
|
||
private val viewBinding: FragmentStepQuizProblemOnboardingBinding by viewBinding( | ||
FragmentStepQuizProblemOnboardingBinding::bind | ||
) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setStyle(STYLE_NORMAL, R.style.TopCornersRoundedBottomSheetDialog) | ||
} | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = | ||
BottomSheetDialog(requireContext(), theme).also { dialog -> | ||
dialog.setOnShowListener { | ||
dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED | ||
if (savedInstanceState == null) { | ||
(parentFragment as? Callback)?.problemOnboardingShown(modalType) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? = | ||
inflater.wrapWithTheme(requireActivity()) | ||
.inflate( | ||
R.layout.fragment_step_quiz_problem_onboarding, | ||
container, | ||
false | ||
) | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
with(viewBinding) { | ||
parsonsOnboardingAnimation.setAnimation(getAnimation(modalType)) | ||
parsonsOnboardingDescription.text = | ||
getDescription(requireContext(), modalType) | ||
} | ||
} | ||
|
||
override fun onDismiss(dialog: DialogInterface) { | ||
super.onDismiss(dialog) | ||
(parentFragment as? Callback)?.problemOnboardingHidden(modalType) | ||
} | ||
|
||
@RawRes | ||
private fun getAnimation(modalType: StepQuizFeature.ProblemOnboardingModal): Int = | ||
when (modalType) { | ||
StepQuizFeature.ProblemOnboardingModal.Parsons -> R.raw.parsons_problem_onboarding_animation | ||
is StepQuizFeature.ProblemOnboardingModal.FillBlanks -> when (modalType.mode) { | ||
FillBlanksMode.INPUT -> R.raw.fill_blanks_input_onboarding_animation | ||
FillBlanksMode.SELECT -> R.raw.fill_blanks_select_onboarding_animation | ||
} | ||
} | ||
|
||
private fun getDescription( | ||
context: Context, | ||
modalType: StepQuizFeature.ProblemOnboardingModal | ||
): String = | ||
context.getString( | ||
when (modalType) { | ||
StepQuizFeature.ProblemOnboardingModal.Parsons -> | ||
org.hyperskill.app.R.string.step_quiz_problem_onboarding_modal_parsons_description | ||
is StepQuizFeature.ProblemOnboardingModal.FillBlanks -> | ||
org.hyperskill.app.R.string.step_quiz_problem_onboarding_modal_fill_blanks_description | ||
} | ||
) | ||
|
||
interface Callback { | ||
fun problemOnboardingShown(modalType: StepQuizFeature.ProblemOnboardingModal) | ||
fun problemOnboardingHidden(modalType: StepQuizFeature.ProblemOnboardingModal) | ||
} | ||
} |
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
60 changes: 0 additions & 60 deletions
60
...droid/step_quiz_parsons/view/dialog/ParsonsStepQuizOnboardingBottomSheetDialogFragment.kt
This file was deleted.
Oops, something went wrong.
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
Binary file added
BIN
+3.83 KB
androidHyperskillApp/src/main/res/raw-night/fill_blanks_input_onboarding_animation.zip
Binary file not shown.
Binary file added
BIN
+2.94 KB
androidHyperskillApp/src/main/res/raw-night/fill_blanks_select_onboarding_animation.zip
Binary file not shown.
Binary file added
BIN
+3.85 KB
androidHyperskillApp/src/main/res/raw/fill_blanks_input_onboarding_animation.zip
Binary file not shown.
Binary file added
BIN
+2.93 KB
androidHyperskillApp/src/main/res/raw/fill_blanks_select_onboarding_animation.zip
Binary file not shown.
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