Open VijaiGunasekar opened 5 years ago
I am working in kotlin. So please ignore the syntax. Just consider the logic and help me out. Thanks in advance
class StepperActivity() : AppCompatActivity(), StepperLayout.StepperListener {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.stepper_layout) val stepperLayout = findViewById<StepperLayout>(R.id.stepperLayout) stepperLayout.adapter = StepperAdapter(supportFragmentManager, this) stepperLayout.setListener(this) stepperLayout.currentStepPosition = intent.getIntExtra(MainActivity.POSITION, 2) } override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_stepper, menu) return true } override fun onStepSelected(newStepPosition: Int) { } override fun onError(verificationError: VerificationError?) {} override fun onReturn() {} override fun onCompleted(completeButton: View?) { }
}
class StepperAdapter(fm: FragmentManager, context: Context): AbstractFragmentStepAdapter(fm, context){ override fun getCount() = 3
override fun createStep(position: Int): Step { when(position){ 0 -> return CreateFrag() 1 -> return FilterFrag() else -> return PublishFrag() } } override fun getViewModel(position: Int): StepViewModel { when(position){ 0 -> return StepViewModel.Builder(context).setTitle("Create").create() 1 -> return StepViewModel.Builder(context).setTitle("Filter").create() else -> return StepViewModel.Builder(context).setTitle("Publish").create() } }
class CreateFrag: Fragment(), BlockingStep {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.target_create, container, false) view.saveExitCreate.background = getGradientDrawable(Color.rgb(42,208,147), Color.WHITE) return view } private fun getGradientDrawable(borderColor: Int, bgColor: Int = Color.rgb(242,244,247)): GradientDrawable { return GradientDrawable().apply { color = ColorStateList.valueOf(bgColor) cornerRadius = 20f setStroke(4, borderColor) } } override fun onBackClicked(callback: StepperLayout.OnBackClickedCallback?) { callback?.goToPrevStep() } override fun onSelected() { } override fun onCompleteClicked(callback: StepperLayout.OnCompleteClickedCallback?) { callback?.complete() } override fun onNextClicked(callback: StepperLayout.OnNextClickedCallback?) { Toast.makeText(context, "Next Clicked", Toast.LENGTH_SHORT).show() callback?.goToNextStep() } override fun verifyStep(): VerificationError = VerificationError("") override fun onError(error: VerificationError) { }
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".StepperActivity">
<com.stepstone.stepper.StepperLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/stepperLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:ms_showBackButtonOnFirstStep="true" app:ms_nextButtonColor="#FFFFFF" app:ms_backButtonColor="#FFFFFF" app:ms_completeButtonText="" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:ms_stepperType="tabs" />
</android.support.constraint.ConstraintLayout>
I am working in kotlin. So please ignore the syntax. Just consider the logic and help me out. Thanks in advance
class StepperActivity() : AppCompatActivity(), StepperLayout.StepperListener {
}
class StepperAdapter(fm: FragmentManager, context: Context): AbstractFragmentStepAdapter(fm, context){ override fun getCount() = 3
}
class CreateFrag: Fragment(), BlockingStep {
}
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".StepperActivity">
</android.support.constraint.ConstraintLayout>