Exemple #1
0
        private async void HandleStepChanged(OrderStep oldStep, OrderStep newStep)
        {
            if (oldStep == newStep)
            {
                return;
            }
            var fromController = _currentPresentedStep;
            var toController   = default(UIViewController);

            if (newStep == OrderStep.EnterDeliveryAddress)
            {
                toController = new AddressBarView
                {
                    ViewModel = this.ViewModel.AddressBar,
                };
            }
            else if (newStep == OrderStep.ConfirmDelivery)
            {
                toController = new ConfirmationView()
                {
                    ViewModel = this.ViewModel.Confirmation,
                };
            }
            else if (newStep == OrderStep.AwaitingDelivery)
            {
                toController = new StatusView()
                {
                    ViewModel = this.ViewModel.Status,
                };
            }
            else
            {
                throw new InvalidOperationException();
            }

            fromController.WillMoveToParentViewController(null);
            toController.View.Frame = new CGRect(0, TopLayoutGuide.Length, View.Bounds.Width, toController.View.Bounds.Height);
            AddChildViewController(toController);

            await this.TransitionAsync(fromController, toController, .6, UIViewAnimationOptions.TransitionCrossDissolve, () => {
                fromController.RemoveFromParentViewController();
                fromController.Dispose();
                toController.DidMoveToParentViewController(this);
            });

            _currentPresentedStep = toController;
        }
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _mapView = new MapKit.MKMapView(View.Bounds);
            View.Add(_mapView);
            new GeocoderViewControllerAdapter(this, _mapView, ViewModel.NotifyAddressChanged);

            var addressBar = new AddressBarView();

            AddChildViewController(addressBar);
            View.Add(addressBar.View);
            addressBar.DidMoveToParentViewController(this);
            _currentPresentedStep = addressBar;

            var set = this.CreateBindingSet <PizzaDeliveryView, Core.PizzaDeliveryViewModel>();

            set.Bind(addressBar).For(v => v.DataContext).To(vm => vm.AddressBar);
            set.Bind().For(v => v.Step).To(vm => vm.Step);
            set.Apply();
        }