Changes to cell separators now happen more reactively.
This commit is contained in:
parent
eb2a8ec367
commit
e4cb4e1123
|
@ -41,6 +41,7 @@ namespace Ooui.Forms.Renderers
|
|||
e.NewElement.ScrollToRequested += ListView_ScrollToRequested;
|
||||
|
||||
UpdateItems ();
|
||||
UpdateSeparator ();
|
||||
UpdateBackgroundColor ();
|
||||
}
|
||||
|
||||
|
@ -53,6 +54,10 @@ namespace Ooui.Forms.Renderers
|
|||
|
||||
if (e.PropertyName == ItemsView<Cell>.ItemsSourceProperty.PropertyName)
|
||||
UpdateItems ();
|
||||
else if (e.PropertyName == Xamarin.Forms.ListView.SeparatorColorProperty.PropertyName)
|
||||
UpdateSeparator ();
|
||||
else if (e.PropertyName == Xamarin.Forms.ListView.SeparatorVisibilityProperty.PropertyName)
|
||||
UpdateSeparator ();
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
|
@ -76,6 +81,7 @@ namespace Ooui.Forms.Renderers
|
|||
private void OnCollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UpdateItems ();
|
||||
UpdateSeparator ();
|
||||
}
|
||||
|
||||
private void UnsubscribeCellClicks ()
|
||||
|
@ -108,11 +114,6 @@ namespace Ooui.Forms.Renderers
|
|||
for (var i = listItems.Count; i < items.Count; i++) {
|
||||
var li = new ListItem ();
|
||||
li.Style["list-style-type"] = "none";
|
||||
if (Element.SeparatorVisibility == SeparatorVisibility.Default)
|
||||
{
|
||||
var color = Element.SeparatorColor.ToOouiColor(Color.FromStyleValue("#999"));
|
||||
li.Style["border-bottom"] = string.Format("{0}px {1} {2}", 1, "solid", color.ToString());
|
||||
}
|
||||
li.Click += ListItem_Click;
|
||||
Control.AppendChild (li);
|
||||
listItems.Add (li);
|
||||
|
@ -139,6 +140,27 @@ namespace Ooui.Forms.Renderers
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateSeparator()
|
||||
{
|
||||
if (Control == null)
|
||||
return;
|
||||
|
||||
var listItems = Control.Children.OfType<ListItem>().ToList();
|
||||
|
||||
foreach (var li in listItems)
|
||||
{
|
||||
if (Element.SeparatorVisibility == SeparatorVisibility.Default)
|
||||
{
|
||||
var color = Element.SeparatorColor.ToOouiColor(Color.FromStyleValue("#999"));
|
||||
li.Style["border-bottom"] = string.Format("{0}px {1} {2}", 1, "solid", color.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
li.Style["border-bottom"] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListItem_Click (object sender, TargetEventArgs e)
|
||||
{
|
||||
if (Control == null)
|
||||
|
|
Loading…
Reference in New Issue