Skip to content

Commit

Permalink
Sample UI improvements for iPhone X (#573)
Browse files Browse the repository at this point in the history
This merge updates nearly all iOS samples to use AutoLayout and account for notches/rotation.

* Update List related features for iPhone X

Note: also improves behavior when rotating device into landscape

* Update Buffer list for iPhone X

* Update buffer sample for iPhone X

* Update statistical query for iPhone X

* Fix issue in buffer list

* Update Find route for iPhone X

* Update TakeScreenshot for better use of AutoLayout

* Update display a grid for iPhone X

* Update Open map URL for iPhone X

* Update manage bookmarks for iPhone X

* Set view background color when using toolbars

Toolbars are slightly transparent, so if there is a black background, the toolbar looks weird.

* Update closest facility (static) to not use navigationcontroller toolbar

* Update change basemap for iPhone X

* Update Author map for iPhone X

* Update display device location for iPhone X

* Raster rendering rule updated for iPhone X

* Update feature layer definition expression for iPhone X

* Update export tiles for iPhone X

* Update change sublayer visibility for iPhone X

* Update change sublayer renderer for iPhone X

* Update change feature layer renderer for iPhone X

* Update Vector tiled layer URL for iPhone X

* Update change ENC display settings for iPhone X

* Update cut geometry for iPhone X

* Update convex hull list for iPhone X

* Update create convex hull for iPhone X

* Remove unnecessary code from Access load status

* Update clip geometries for iPhone X

* Update symbolize shapefile for iPhone X

* Update generate geodatabase for iPhone X

* Update feature layer query for iPhone X

* Update viewshed camera for iPhone X

* Update query feature count and extent for iPhone X

* Update distance measure analysis for iPhone X

* Update feature layer rendering mode (map) for iPhone X

* Update feature layer rendering mode (scene) for iPhone X

* Update List geodatabase versions for iPhone X

* Update statistical query group and sort for iPhone X

* Update Find place for iPhone X

* Update change stretch renderer for iPhone X

* Update Edit and sync features for iPhone X

* Update Animate 3D graphic for iPhone X

* Update Search a portal for maps for iPhone X

* Update Densify and generalize for iPhone X

* Update List transformations for iPhone X

* Update Geodatabase transactions for iPhone X

* Update Format coordinates for iPhone X

* First attempt at viewshed location

* Update viewshed location for iPhone X

* Update Raster RGB renderer for iPhone X

* Update Raster hillshade for iPhone X

* Update Blend renderer for iPhone X

* Update Generate offline map for iPhone X

* Update WMS service catalog for iPhone X

* Fix misc. details

* Fix issue with statistical query

* Update token secured challenge for iPhone X

* Automated clean up and refactoring - iOS

* Rearrange sample code to follow common pattern

* Misc. tweaks and improvements

* Changes from review
  • Loading branch information
nCastle1 authored Jan 17, 2019
1 parent d58a7a2 commit 4b2678b
Show file tree
Hide file tree
Showing 137 changed files with 7,028 additions and 8,174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

using System;
using System.Diagnostics;
using CoreGraphics;
using Esri.ArcGISRuntime;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
Expand All @@ -29,13 +28,9 @@ namespace ArcGISRuntime.Samples.DistanceMeasurement
"Featured")]
public class DistanceMeasurement : UIViewController
{
// Create and hold references to the UI controls.
private readonly UIToolbar _helpToolbar = new UIToolbar();
// Hold references to the UI controls.
private SceneView _mySceneView;
private UILabel _helpLabel;
private UILabel _resultLabel;
private UIToolbar _resultArea;
private UIButton _unitChangeButton;

// URLs to various services used to provide an interesting scene for the sample.
private readonly Uri _buildingService = new Uri("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0");
Expand Down Expand Up @@ -116,43 +111,6 @@ private async void MySceneView_GeoViewTapped(object sender, GeoViewInputEventArg
}
}

private void CreateLayout()
{
// Create the scene view.
_mySceneView = new SceneView();

// Create the help label.
_helpLabel = new UILabel
{
Text = "Tap to update.",
TextAlignment = UITextAlignment.Center
};

// Create the result label.
_resultLabel = new UILabel
{
TextAlignment = UITextAlignment.Center,
AdjustsFontSizeToFitWidth = true
};

// Create the result toolbar.
_resultArea = new UIToolbar();

// Create the unit change button.
_unitChangeButton = new UIButton();
_unitChangeButton.SetTitle("Unit systems", UIControlState.Normal);
_unitChangeButton.BackgroundColor = View.TintColor;
_unitChangeButton.SetTitleColor(UIColor.White, UIControlState.Normal);
_unitChangeButton.Layer.CornerRadius = 10;
_unitChangeButton.ClipsToBounds = true;

// Handle the unit change button press.
_unitChangeButton.TouchUpInside += UnitChangeButton_TouchUpInside;

// Add views to the page.
View.AddSubviews(_mySceneView, _helpToolbar, _resultArea, _helpLabel, _resultLabel, _unitChangeButton);
}

private void UnitChangeButton_TouchUpInside(object sender, EventArgs e)
{
// Create the view controller that will present the list of unit systems.
Expand Down Expand Up @@ -180,37 +138,69 @@ private void UnitChangeButton_TouchUpInside(object sender, EventArgs e)
PresentViewController(unitSystemSelectionAlert, true, null);
}

public override void ViewDidLoad()
private void ShowHelp_Click(object sender, EventArgs e)
{
CreateLayout();
Initialize();
// Prompt for the type of convex hull to create.
UIAlertController unionAlert = UIAlertController.Create("Tap to update", "Tap in the scene to set a new end point for the distance measurement.", UIAlertControllerStyle.Alert);
unionAlert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));

// Show the alert.
PresentViewController(unionAlert, true, null);
}

public override void ViewDidLoad()
{
base.ViewDidLoad();
Initialize();
}

public override void ViewDidLayoutSubviews()
public override void LoadView()
{
try
// Create and configure the views.
View = new UIView {BackgroundColor = UIColor.White};

_mySceneView = new SceneView();
_mySceneView.TranslatesAutoresizingMaskIntoConstraints = false;

UIToolbar toolbar = new UIToolbar();
toolbar.TranslatesAutoresizingMaskIntoConstraints = false;

_resultLabel = new UILabel
{
nfloat topMargin = NavigationController.NavigationBar.Frame.Height + UIApplication.SharedApplication.StatusBarFrame.Height;
nfloat toolbarHeight = 40;
nfloat controlHeight = 30;

// Reposition the views.
_mySceneView.Frame = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height);
_mySceneView.ViewInsets = new UIEdgeInsets(topMargin + toolbarHeight, 0, toolbarHeight, 0);
_helpToolbar.Frame = new CGRect(0, topMargin, View.Bounds.Width, 40);
_helpLabel.Frame = new CGRect(5, topMargin + 5, View.Bounds.Width - 10, controlHeight);
_resultArea.Frame = new CGRect(0, View.Bounds.Height - toolbarHeight, View.Bounds.Width, toolbarHeight);
_resultLabel.Frame = new CGRect(10, View.Bounds.Height - toolbarHeight + 5, View.Bounds.Width - 20, toolbarHeight - 10);
_unitChangeButton.Frame = new CGRect(View.Bounds.Width / 4, View.Bounds.Height - 3 * toolbarHeight, View.Bounds.Width / 2, toolbarHeight);

base.ViewDidLayoutSubviews();
}
// Needed to prevent crash when NavigationController is null. This happens sometimes when switching between samples.
catch (NullReferenceException)
Text = "Tap to measure distance.",
BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
TextColor = UIColor.White,
TextAlignment = UITextAlignment.Center,
TranslatesAutoresizingMaskIntoConstraints = false
};

toolbar.Items = new[]
{
}
new UIBarButtonItem("Help", UIBarButtonItemStyle.Plain, ShowHelp_Click),
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
new UIBarButtonItem("Change units", UIBarButtonItemStyle.Plain, UnitChangeButton_TouchUpInside)
};

// Add the views.
View.AddSubviews(_mySceneView, toolbar, _resultLabel);

// Lay out the views.
NSLayoutConstraint.ActivateConstraints(new []
{
_mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
_mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
_mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
_mySceneView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),

toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

_resultLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
_resultLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
_resultLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
_resultLabel.HeightAnchor.ConstraintEqualTo(40)
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public class LineOfSightGeoElement : UIViewController
{
// Hold references to the UI controls.
private SceneView _mySceneView;
private UIToolbar _sliderToolbar;
private UISlider _mySlider;
private UILabel _statusLabel;

// URL of the elevation service - provides elevation component of the scene.
Expand Down Expand Up @@ -228,11 +226,11 @@ private void UpdateUiAndSelection()
private void MyHeightSlider_ValueChanged(object sender, EventArgs e)
{
// Constrain the min and max to 20 and 150 units.
double minHeight = 20;
double maxHeight = 150;
const double minHeight = 20;
const double maxHeight = 150;

// Scale the slider value; its default range is 0-10.
double value = _mySlider.Value;
double value = (sender as UISlider).Value;

// Get the current point.
MapPoint oldPoint = (MapPoint) _observerGraphic.Geometry;
Expand All @@ -250,54 +248,58 @@ public override void ViewDidLoad()

public override void LoadView()
{
// Create the views.
View = new UIView();
View.BackgroundColor = UIColor.White;

_mySceneView = new SceneView();
_mySceneView.TranslatesAutoresizingMaskIntoConstraints = false;
View.AddSubview(_mySceneView);

_sliderToolbar = new UIToolbar();
_sliderToolbar.TranslatesAutoresizingMaskIntoConstraints = false;
View.AddSubview(_sliderToolbar);

_statusLabel = new UILabel()
{
BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
TextColor = UIColor.White,
TextAlignment = UITextAlignment.Center,
TranslatesAutoresizingMaskIntoConstraints = false
};
View.AddSubview(_statusLabel);
UISlider heightSlider = new UISlider();
heightSlider.TranslatesAutoresizingMaskIntoConstraints = false;
// Subscribe to slider events.
heightSlider.ValueChanged += MyHeightSlider_ValueChanged;

_mySlider = new UISlider();
_mySlider.TranslatesAutoresizingMaskIntoConstraints = false;
UIBarButtonItem sliderWrapper = new UIBarButtonItem(_mySlider);
UIBarButtonItem sliderWrapper = new UIBarButtonItem(heightSlider);
sliderWrapper.Width = 300;

_sliderToolbar.Items = new[]
UIToolbar sliderToolbar = new UIToolbar();
sliderToolbar.TranslatesAutoresizingMaskIntoConstraints = false;
sliderToolbar.Items = new[]
{
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
sliderWrapper,
new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
};

_sliderToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true;
_sliderToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true;
_sliderToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;

_mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true;
_mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true;
_mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
_mySceneView.BottomAnchor.ConstraintEqualTo(_sliderToolbar.TopAnchor).Active = true;
_statusLabel = new UILabel
{
BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
TextColor = UIColor.White,
TextAlignment = UITextAlignment.Center,
TranslatesAutoresizingMaskIntoConstraints = false
};

_statusLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true;
_statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true;
_statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
_statusLabel.HeightAnchor.ConstraintEqualTo(40).Active = true;
// Add the views.
View.AddSubviews(_mySceneView, sliderToolbar, _statusLabel);

// Subscribe to slider events.
_mySlider.ValueChanged += MyHeightSlider_ValueChanged;
// Lay out the views.
NSLayoutConstraint.ActivateConstraints(new []
{
sliderToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
sliderToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
sliderToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

_mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
_mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
_mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
_mySceneView.BottomAnchor.ConstraintEqualTo(sliderToolbar.TopAnchor),

_statusLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
_statusLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
_statusLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
_statusLabel.HeightAnchor.ConstraintEqualTo(40)
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ArcGISRuntime.Samples.LineOfSightLocation
"Featured")]
public class LineOfSightLocation : UIViewController
{
// Create and hold a reference to the SceneView.
// Hold a reference to the SceneView.
private SceneView _mySceneView;

// URL for an image service to use as an elevation source.
Expand All @@ -49,27 +49,6 @@ public LineOfSightLocation()
Title = "Line of sight location";
}

public override void LoadView()
{
_mySceneView = new SceneView();
_mySceneView.TranslatesAutoresizingMaskIntoConstraints = false;

View = new UIView();
View.AddSubviews(_mySceneView);

_mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true;
_mySceneView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true;
_mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true;
_mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
}

public override void ViewDidLoad()
{
base.ViewDidLoad();

Initialize();
}

private void Initialize()
{
// Create a new Scene with an imagery basemap.
Expand Down Expand Up @@ -130,5 +109,32 @@ private void SceneViewTapped(object sender, GeoViewInputEventArgs e)
_observerLocation = null;
}
}

public override void ViewDidLoad()
{
base.ViewDidLoad();
Initialize();
}

public override void LoadView()
{
// Create the views.
_mySceneView = new SceneView();
_mySceneView.TranslatesAutoresizingMaskIntoConstraints = false;

View = new UIView {BackgroundColor = UIColor.White};

// Add the views.
View.AddSubviews(_mySceneView);

// Lay out the views.
NSLayoutConstraint.ActivateConstraints(new []
{
_mySceneView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
_mySceneView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
_mySceneView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
_mySceneView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor)
});
}
}
}
Loading

0 comments on commit 4b2678b

Please sign in to comment.