sealed class FlowCustomStep<T : FlowStepFragment>(
open val stepId: Int,
open val stepClass: KClass<T>
) {
/** Represents the custom step which will be inserted before the eula step*/
data class BeforeEula<T : FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
/** Represents the custom step which will be inserted after the eula step*/
data class BeforeActivation<T : FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
data class BeforeAuthentication<T: FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
data class BeforePasscodeCreation<T: FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
/** Represents the custom step which will be inserted after passcode creation step*/
data class BeforeConsent<T : FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
/** Represents the custom step which will be inserted after the consent steps*/
data class BeforeEnd<T : FlowStepFragment>(
override val stepId: Int,
override val stepClass: KClass<T>
) : FlowCustomStep<T>(stepId, stepClass)
}
open fun getFlowCustomizationStep(runningFlowName: String?) = listOf<FlowCustomStep<*>>()
//1. Create a child class of 'FlowActionHandler' and override 'getFlowCustomizationStep'
class MyFlowActionHandler : FlowActionHandler() {
override fun getFlowCustomizationStep(runningFlowName: String?): List<FlowCustomStep<*>> {
return if (runningFlowName == FlowType.ONBOARDING.name) {
listOf(
FlowCustomStep.BeforeActivation(R.id.stepPrivacyTerm, PrivacyStepFragment::class)
)
} else super.getFlowCustomizationStep(runningFlowName)
}
}
//2. When starting the onboarding flow, create an instance of the above FlowActionHandler and set it into 'FlowContext'
val flowContext = FlowContext(
appConfig = AppConfig.Builder().applicationId("app_id").build(),
multipleUserMode = true,
flowStateListener = MyFlowStateListener(application = application),
flowActionHandler = MyFlowActionHandler(),
flowOptions = FlowOptions(
activationOption = ActivationOption.QR_ONLY )
)
Flow.start(this@SplashActivity, flowContext) { _, resultCode, _ ->
if (resultCode == Activity.RESULT_OK) {
startMainBusinessActivity()
}
finish()
}
class PrivacyStepFragment : FlowStepFragment() {
private lateinit var binding: PrivacyTermStepBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
😞 View {
binding = PrivacyTermStepBinding.inflate(cloneLayoutInflater(inflater), container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.agreeButton.setOnClickListener {
stepDone(R.id.stepPrivacyTerm)
}
binding.denyButton.setOnClickListener {
//Terminate the current flow
FlowInterruptEvent.notifyInterruptEvent(
flowViewModel.businessData,
FlowInterruptEvent.Error()
)
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
58 | |
20 | |
11 | |
11 | |
8 | |
7 | |
6 | |
6 | |
6 | |
4 |