示例#1
0
        private void LayoutSubviews()
        {
            _hiddenInfo = _info.Height().EqualTo(0f);

            View.AddConstraints(_toggleButton.FullWidthOf(View));
            View.AddConstraints(_mapView.FullWidthOf(View));
            View.AddConstraints(new FluentLayout[]
            {
                _toggleButton.AtBottomOf(View),
                _mapView.AtTopOf(View),
                _mapView.Above(_toggleButton),

                _hiddenInfo,
                _info.AtBottomOf(_toggleButton),
                _info.AtLeftOf(View),
                _info.AtRightOf(View)
            });

            _info.AddConstraints(new FluentLayout[]
            {
                _colon.WithSameCenterX(_info),
                _colon.AtBottomOf(_info, 10f),
                _colon.AtTopOf(_info, 10f),

                _latitude.AtLeftOf(_info, 10f),
                _latitude.ToRightOf(_colon, 10f),
                _latitude.AtBottomOf(_info, 10f),
                _latitude.AtTopOf(_info, 10f),

                _longitude.AtRightOf(_info, 10f),
                _longitude.ToLeftOf(_colon, 10f),
                _longitude.AtBottomOf(_info, 10f),
                _longitude.AtTopOf(_info, 10f),
            });
        }
示例#2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _mapView = new BindingMKMapView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _delegate = new LocationTrackingMapDelegate(_mapView);

            _toggleButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Black
            };
            _toggleButton.SetTitle("Pins", UIControlState.Normal);

            View.AddSubviews(_mapView, _toggleButton);

            View.AddConstraints(new FluentLayout[]
            {
                _toggleButton.AtBottomOf(View),
                _toggleButton.AtLeftOf(View),
                _toggleButton.AtRightOf(View),

                _mapView.AtTopOf(View),
                _mapView.AtLeftOf(View),
                _mapView.AtRightOf(View),
                _mapView.Above(_toggleButton)
            });

            var bindingSet = this.CreateBindingSet <LocationTrackingView, LocationTrackingViewModel>();

            bindingSet.Bind(_mapView).For(v => v.UserCurrentLocation).To(vm => vm.UserLocation);
            bindingSet.Bind(_mapView).For(v => v.CenterMapLocation).To(vm => vm.UserLocation);
            bindingSet.Bind(_mapView).For(v => v.ShowsUserLocation).To(vm => vm.CanTrackLocation);
            bindingSet.Bind(_delegate).For(v => v.AnnotationSource).To(vm => vm.Pins);
            bindingSet.Bind(_toggleButton).To(vm => vm.NavigateToMapPinsCommand);
            bindingSet.Bind(_delegate).For(v => v.LocationChanged).To(vm => vm.UserLocationChangedCommand);

            _mapView.Delegate = _delegate;

            bindingSet.Apply();
        }