public override Fragment GetItem(int position)
        {
            var wizardStep = WizardFlow.GetSteps()[position];

            StateManager.LoadStepContext(wizardStep);
            return(wizardStep);
        }
 public WizardPagerAdapter(FragmentManager fragmentManager, WizardFlow wizardFlow, IStateManager stateManager, Wizard wizard)
     : base(fragmentManager)
 {
     WizardFlow   = wizardFlow;
     StateManager = stateManager;
     Wizard       = wizard;
 }
 public WizardPagerAdapter(FragmentManager fragmentManager, WizardFlow wizardFlow, IStateManager stateManager, Wizard wizard)
     : base(fragmentManager)
 {
     WizardFlow = wizardFlow;
     StateManager = stateManager;
     Wizard = wizard;
 }
        /// <summary>
        /// Called once the fragment is associated with its activity.
        /// </summary>
        /// <param name="activity"></param>
        public override void OnAttach(Android.App.Activity activity)
        {
            base.OnAttach(activity);

            WizardFlow = OnSetup(); //Require the user to Setup the Wizard flow when the fragment is attached 

            if (WizardFlow == null) 
                throw new ArgumentException("Error setting up the Wizard's flow. You must override WizardFragment.OnSetup and create a WizardFlow using the WizardFlow.Builder.");
        }
Example #5
0
        /// <summary>
        /// Called once the fragment is associated with its context.
        /// </summary>
        /// <param name="context"></param>
        public override void OnAttach(Context context)
        {
            base.OnAttach(context);

            WizardFlow = OnSetup(); //Require the user to Setup the Wizard flow when the fragment is attached

            if (WizardFlow == null)
            {
                throw new ArgumentException("Error setting up the Wizard's flow. You must override WizardFragment.OnSetup and create a WizardFlow using the WizardFlow.Builder.");
            }
        }
Example #6
0
        /// <summary>
        /// Constructs the Wizard
        /// </summary>
        /// <param name="wizardFlow">WizardFlow instance. See WizardFlow.Builder for more information on creating WizardFlow objects</param>
        /// <param name="contextManager"></param>
        /// <param name="callbacks"></param>
        /// <param name="fragmentManager"></param>
        public Wizard(WizardFlow wizardFlow,
                      IStateManager stateManager,
                      FragmentManager fragmentManager)
        {
            this.WizardFlow      = wizardFlow;
            this.StateManager    = stateManager;
            this.FragmentManager = fragmentManager;


            FragmentManager.BackStackChanged += (o, sender) =>
            {
                if (FragmentManager.BackStackEntryCount < ViewPager.CurrentItem)                //Backbutton has been pressed
                {
                    ViewPager.SetCurrentItem(ViewPager.CurrentItem - 1, true /*smoothScroll*/); // Go to the previous item on the stack
                }
            };

            MessageBus.GetInstance().Register(this, typeof(StepCompletedEvent)); //Listen for the StepCompeltedEvent on the buss
        }
Example #7
0
        public void Receive <T>(T eventArgs)
        {
            var stepCompletedEvent = eventArgs as StepCompletedEvent;

            if (stepCompletedEvent == null || stepCompletedEvent.WizardStep != CurrentStep)
            {
                return;
            }

            // Check that the step is not already in this state to avoid spamming the viewpager
            if (WizardFlow.IsStepCompleted(ViewPager.CurrentItem) == stepCompletedEvent.IsStepCompleted)
            {
                return;
            }

            WizardFlow.SetStepCompleted(ViewPager.CurrentItem, stepCompletedEvent.IsStepCompleted);

            ViewPager.Adapter.NotifyDataSetChanged(); //Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

            if (StepChanged != null)                  //Trigger the Event handler.. may be used to refresh the UI
            {
                StepChanged();
            }
        }
Example #8
0
 private void ProcessStepBeforeChange(WizardStep wizardStep, int position)
 {
     wizardStep.OnExit(StepExitCode.ExitNext);
     WizardFlow.SetStepCompleted(position, true);
     StateManager.PersistStepContext(wizardStep);
 }