internal NotFoundCard(MapViewModel viewModel) { _viewModel = viewModel; _headerLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Font = ApplicationTheme.HeaderFont, TextColor = ApplicationTheme.ForegroundColor, Text = "NotFoundTitle".Localize() }; var errorTextView = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, TextColor = ApplicationTheme.ForegroundColor, Text = "NotFoundCardMessage".Localize(), BackgroundColor = UIColor.Clear }; var closeButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; AddSubviews(_headerLabel, errorTextView, closeButton); NSLayoutConstraint.ActivateConstraints(new[] { // header label _headerLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), _headerLabel.CenterYAnchor.ConstraintEqualTo(closeButton.CenterYAnchor), _headerLabel.TrailingAnchor.ConstraintEqualTo(closeButton.LeadingAnchor, -ApplicationTheme.Margin), // close button closeButton.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), closeButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), closeButton.WidthAnchor.ConstraintEqualTo(32), closeButton.HeightAnchor.ConstraintEqualTo(32), // error description errorTextView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), errorTextView.TopAnchor.ConstraintEqualTo(closeButton.BottomAnchor, ApplicationTheme.Margin), errorTextView.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(errorTextView.BottomAnchor, ApplicationTheme.Margin) }); closeButton.TouchUpInside += Dismiss_Clicked; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }
internal RouteResultCard(MapViewModel viewModel) { _viewModel = viewModel; _stopsTable = new SelfSizedTableView { TranslatesAutoresizingMaskIntoConstraints = false, ScrollEnabled = false, BackgroundColor = UIColor.Clear, AllowsSelection = false }; // Future - consider supporting more travel modes? var travelModeImageView = new UIImageView(UIImage.FromBundle("walking")) { TranslatesAutoresizingMaskIntoConstraints = false, TintColor = ApplicationTheme.PrimaryLabelColor, ContentMode = UIViewContentMode.ScaleAspectFit }; _routeDurationLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false }; UIButton closeButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; var headerLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "RouteResultHeader".Localize(), Font = ApplicationTheme.HeaderFont, TextColor = ApplicationTheme.ForegroundColor }; AddSubviews(_stopsTable, travelModeImageView, _routeDurationLabel, closeButton, headerLabel); NSLayoutConstraint.ActivateConstraints(new[] { // result header headerLabel.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), headerLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), headerLabel.TrailingAnchor.ConstraintEqualTo(closeButton.LeadingAnchor, -ApplicationTheme.Margin), // close button closeButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), closeButton.CenterYAnchor.ConstraintEqualTo(headerLabel.CenterYAnchor), closeButton.WidthAnchor.ConstraintEqualTo(32), closeButton.HeightAnchor.ConstraintEqualTo(32), // stops view _stopsTable.LeadingAnchor.ConstraintEqualTo(LeadingAnchor), _stopsTable.TopAnchor.ConstraintEqualTo(_routeDurationLabel.BottomAnchor, ApplicationTheme.Margin), _stopsTable.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), // image travelModeImageView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), travelModeImageView.TopAnchor.ConstraintEqualTo(_routeDurationLabel.TopAnchor), travelModeImageView.BottomAnchor.ConstraintEqualTo(_routeDurationLabel.BottomAnchor), travelModeImageView.WidthAnchor.ConstraintEqualTo(32), // walk time label _routeDurationLabel.TopAnchor.ConstraintEqualTo(headerLabel.BottomAnchor, ApplicationTheme.Margin), _routeDurationLabel.LeadingAnchor.ConstraintEqualTo(travelModeImageView.TrailingAnchor, ApplicationTheme.Margin), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(_stopsTable.BottomAnchor, ApplicationTheme.Margin) }); closeButton.TouchUpInside += Close_Clicked; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }
internal RoutePlanningCard(MapViewModel viewModel) { _viewModel = viewModel; _startTextPlaceholder = new PseudoTextFieldButton { TranslatesAutoresizingMaskIntoConstraints = false }; _endTextPlaceholder = new PseudoTextFieldButton { TranslatesAutoresizingMaskIntoConstraints = false }; var searchRouteButton = new ActionButton { TranslatesAutoresizingMaskIntoConstraints = false }; searchRouteButton.SetTitle("SearchForRouteButtonText".Localize(), UIControlState.Normal); UIButton cancelRouteSearchButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; var searchStartLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "OriginRouteSearchFieldLabel".Localize() }; var searchEndLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "DestinationRouteSearchFieldLabel".Localize() }; searchStartLabel.SetContentHuggingPriority((float)UILayoutPriority.DefaultHigh, UILayoutConstraintAxis.Horizontal); var routeSearchHeader = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "DirectionsPanelHeader".Localize(), TextColor = ApplicationTheme.ForegroundColor, Font = ApplicationTheme.HeaderFont }; // swap origin and destination button var swapOriginDestinationButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false }; swapOriginDestinationButton.SetImage(UIImage.FromBundle("arrow-up-down"), UIControlState.Normal); swapOriginDestinationButton.TintColor = ApplicationTheme.ForegroundColor; AddSubviews(_startTextPlaceholder, _endTextPlaceholder, searchRouteButton, searchStartLabel, searchEndLabel, cancelRouteSearchButton, routeSearchHeader, swapOriginDestinationButton); NSLayoutConstraint.ActivateConstraints(new[] { // label routeSearchHeader.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), routeSearchHeader.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), routeSearchHeader.TrailingAnchor.ConstraintEqualTo(cancelRouteSearchButton.LeadingAnchor, -ApplicationTheme.Margin), // close button cancelRouteSearchButton.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), cancelRouteSearchButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), cancelRouteSearchButton.HeightAnchor.ConstraintEqualTo(32), cancelRouteSearchButton.WidthAnchor.ConstraintEqualTo(32), // labels searchStartLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), searchStartLabel.CenterYAnchor.ConstraintEqualTo(_startTextPlaceholder.CenterYAnchor), searchEndLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), searchEndLabel.CenterYAnchor.ConstraintEqualTo(_endTextPlaceholder.CenterYAnchor), searchEndLabel.TrailingAnchor.ConstraintEqualTo(searchStartLabel.TrailingAnchor), // search bars _startTextPlaceholder.LeadingAnchor.ConstraintEqualTo(searchStartLabel.TrailingAnchor, ApplicationTheme.Margin), _startTextPlaceholder.TopAnchor.ConstraintEqualTo(routeSearchHeader.BottomAnchor, ApplicationTheme.Margin), _startTextPlaceholder.TrailingAnchor.ConstraintEqualTo(swapOriginDestinationButton.LeadingAnchor, -ApplicationTheme.Margin), _startTextPlaceholder.HeightAnchor.ConstraintEqualTo(44), _endTextPlaceholder.LeadingAnchor.ConstraintEqualTo(_startTextPlaceholder.LeadingAnchor), _endTextPlaceholder.TrailingAnchor.ConstraintEqualTo(_startTextPlaceholder.TrailingAnchor), _endTextPlaceholder.TopAnchor.ConstraintEqualTo(_startTextPlaceholder.BottomAnchor, ApplicationTheme.Margin), _endTextPlaceholder.HeightAnchor.ConstraintEqualTo(44), // swap origin and destinations button swapOriginDestinationButton.HeightAnchor.ConstraintEqualTo(32), swapOriginDestinationButton.WidthAnchor.ConstraintEqualTo(32), swapOriginDestinationButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), swapOriginDestinationButton.CenterYAnchor.ConstraintEqualTo(_endTextPlaceholder.CenterYAnchor), // search button searchRouteButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), searchRouteButton.TopAnchor.ConstraintEqualTo(_endTextPlaceholder.BottomAnchor, ApplicationTheme.Margin), searchRouteButton.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(searchRouteButton.BottomAnchor, ApplicationTheme.Margin) }); searchRouteButton.TouchUpInside += SearchRouteButton_Clicked; cancelRouteSearchButton.TouchUpInside += CancelRouteSearchButton_Clicked; swapOriginDestinationButton.TouchUpInside += SwapOriginDestinationButton_Clicked; _startTextPlaceholder.Tapped += EditOriginField_Clicked; _endTextPlaceholder.Tapped += EditDestinationField_Clicked; _viewModel.PropertyChanged += ViewModel_PropertyChanged; }
public LocationInfoCard(MapViewModel viewModel) { _viewModel = viewModel; _startDirectionsButton = new ActionButton { TranslatesAutoresizingMaskIntoConstraints = false }; _startDirectionsButton.SetTitle("FindDirectionsButtonText".Localize(), UIControlState.Normal); var closeButton = new CloseButton { TranslatesAutoresizingMaskIntoConstraints = false }; _primaryLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, TextColor = ApplicationTheme.PrimaryLabelColor, Font = ApplicationTheme.HeaderFont, ClipsToBounds = false }; _secondaryLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, TextColor = ApplicationTheme.SecondaryLabelColor, Font = UIFont.PreferredTitle3, BaselineAdjustment = UIBaselineAdjustment.AlignCenters, ClipsToBounds = false }; _primaryLabel.Layer.MasksToBounds = false; _secondaryLabel.Layer.MasksToBounds = false; _secondaryLabel.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical); _primaryLabel.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical); AddSubviews(_primaryLabel, _secondaryLabel, closeButton, _startDirectionsButton); _directionsButtonToSecondaryLabelTopConstraint = _startDirectionsButton.TopAnchor.ConstraintEqualTo(_secondaryLabel.BottomAnchor, ApplicationTheme.Margin); _directionsButtonToPrimaryLabelTopConstraint = _startDirectionsButton.TopAnchor.ConstraintEqualTo(_primaryLabel.BottomAnchor, ApplicationTheme.Margin); NSLayoutConstraint.ActivateConstraints(new[] { // primary label _primaryLabel.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), _primaryLabel.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), _primaryLabel.TrailingAnchor.ConstraintEqualTo(closeButton.LeadingAnchor, -ApplicationTheme.Margin), // secondary label _secondaryLabel.LeadingAnchor.ConstraintEqualTo(_primaryLabel.LeadingAnchor), _secondaryLabel.TrailingAnchor.ConstraintEqualTo(_primaryLabel.TrailingAnchor), _secondaryLabel.TopAnchor.ConstraintEqualTo(_primaryLabel.BottomAnchor, ApplicationTheme.Margin), // close button closeButton.TopAnchor.ConstraintEqualTo(TopAnchor, ApplicationTheme.Margin), closeButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), closeButton.WidthAnchor.ConstraintEqualTo(32), closeButton.HeightAnchor.ConstraintEqualTo(32), // directions button _startDirectionsButton.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, ApplicationTheme.Margin), _startDirectionsButton.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, -ApplicationTheme.Margin), _directionsButtonToPrimaryLabelTopConstraint, _startDirectionsButton.TopAnchor.ConstraintGreaterThanOrEqualTo(closeButton.BottomAnchor, ApplicationTheme.Margin), _startDirectionsButton.HeightAnchor.ConstraintEqualTo(44), // constrains view bottom to bottom of last element BottomAnchor.ConstraintEqualTo(_startDirectionsButton.BottomAnchor, ApplicationTheme.Margin) }); // Handle closing location card. closeButton.TouchUpInside += Close_Clicked; // Check settings _startDirectionsButton.Hidden = !AppSettings.CurrentSettings.IsRoutingEnabled; // Wait for app state changes (particularly identify feature results) _viewModel.PropertyChanged += ViewModel_Changed; AppSettings.CurrentSettings.PropertyChanged += CurrentSettings_PropertyChanged; // Handle searching for directions _startDirectionsButton.TouchUpInside += SearchDirections_Clicked; }