summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authoradrianknight89 <adrianknight89@outlook.com>2017-04-06 18:25:47 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-04-06 18:25:47 (GMT)
commit6966dd6cc7456a6100f65a907869781736484d6a (patch)
treee0d521d744514152292938608330e31a7acb6bf7 /Xamarin.Forms.Platform.iOS
parent3d9d1d3d222c8b4edaa1cf28e7ad102e8e341eed (diff)
downloadxamarin-forms-6966dd6cc7456a6100f65a907869781736484d6a.zip
xamarin-forms-6966dd6cc7456a6100f65a907869781736484d6a.tar.gz
xamarin-forms-6966dd6cc7456a6100f65a907869781736484d6a.tar.bz2
[iOS] ActivityIndicator should not disappear when used in a ViewCell (#495)
* preserve activity indicator state * changed to using listviewrenderer * remove whitespace * moved message to constructor * add sample code * remove message sending * changes * remove curly braces
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ActivityIndicatorRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs31
2 files changed, 31 insertions, 6 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ActivityIndicatorRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ActivityIndicatorRenderer.cs
index abd8f24..e77778c 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ActivityIndicatorRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ActivityIndicatorRenderer.cs
@@ -44,5 +44,11 @@ namespace Xamarin.Forms.Platform.iOS
else
Control.StopAnimating();
}
+
+ internal void PreserveState()
+ {
+ if (Control != null && !Control.IsAnimating && Element != null && Element.IsRunning)
+ Control.StartAnimating();
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
index 99a1066..8581e26 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
@@ -780,12 +780,13 @@ namespace Xamarin.Forms.Platform.iOS
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
- UITableViewCell nativeCell = null;
+ Cell cell;
+ UITableViewCell nativeCell;
var cachingStrategy = Controller.CachingStrategy;
if (cachingStrategy == ListViewCachingStrategy.RetainElement)
{
- var cell = GetCellForPath(indexPath);
+ cell = GetCellForPath(indexPath);
nativeCell = CellTableViewCell.GetNativeCell(tableView, cell);
}
else if (cachingStrategy == ListViewCachingStrategy.RecycleElement)
@@ -794,13 +795,13 @@ namespace Xamarin.Forms.Platform.iOS
nativeCell = tableView.DequeueReusableCell(ContextActionsCell.Key + id);
if (nativeCell == null)
{
- var cell = GetCellForPath(indexPath);
+ cell = GetCellForPath(indexPath);
nativeCell = CellTableViewCell.GetNativeCell(tableView, cell, true, id.ToString());
}
else
{
var templatedList = TemplatedItemsView.TemplatedItems.GetGroup(indexPath.Section);
- var cell = (Cell)((INativeElementView)nativeCell).Element;
+ cell = (Cell)((INativeElementView)nativeCell).Element;
ICellController controller = cell;
controller.SendDisappearing();
templatedList.UpdateContent(cell, indexPath.Row);
@@ -813,10 +814,10 @@ namespace Xamarin.Forms.Platform.iOS
var bgColor = tableView.IndexPathForSelectedRow != null && tableView.IndexPathForSelectedRow.Equals(indexPath) ? UIColor.Clear : DefaultBackgroundColor;
SetCellBackgroundColor(nativeCell, bgColor);
-
+ PreserveActivityIndicatorState(cell);
return nativeCell;
}
-
+
public override nfloat GetHeightForHeader(UITableView tableView, nint section)
{
if (List.IsGroupingEnabled)
@@ -1079,6 +1080,24 @@ namespace Xamarin.Forms.Platform.iOS
base.Dispose(disposing);
}
+
+ void PreserveActivityIndicatorState(Element element)
+ {
+ if (element == null)
+ return;
+
+ var activityIndicator = element as ActivityIndicator;
+ if (activityIndicator != null)
+ {
+ var renderer = Platform.GetRenderer(activityIndicator) as ActivityIndicatorRenderer;
+ renderer?.PreserveState();
+ }
+ else
+ {
+ foreach (Element childElement in (element as IElementController).LogicalChildren)
+ PreserveActivityIndicatorState(childElement);
+ }
+ }
}
}