diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs new file mode 100644 index 00000000..2bea3848 --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/Cells/TextCellRenderer.cs @@ -0,0 +1,72 @@ +using ElmSharp; +using System.Collections.Generic; + +namespace Xamarin.Forms.Platform.Tizen +{ + public class TextCellRenderer : CellRenderer + { + public TextCellRenderer() : this("double_label") { } + protected TextCellRenderer(string style) : base(style) + { + MainPart = "elm.text"; + DetailPart = "elm.text.sub"; + } + + protected string MainPart { get; set; } + protected string DetailPart { get; set; } + + protected override Span OnGetText(Cell cell, string part) + { + var textCell = (TextCell)cell; + if (part == MainPart) + { + return OnMainText(textCell); + } + if (part == DetailPart) + { + return OnDetailText(textCell); + } + return null; + } + + protected virtual Span OnMainText(TextCell cell) + { + return new Span() + { + Text = cell.Text, + ForegroundColor = cell.TextColor + }; + } + + protected virtual Span OnDetailText(TextCell cell) + { + return new Span() + { + Text = cell.Detail, + ForegroundColor = cell.DetailColor + }; + } + + protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary<string, EvasObject> realizedView) + { + if (property == TextCell.TextProperty.PropertyName || + property == TextCell.TextColorProperty.PropertyName || + property == TextCell.DetailProperty.PropertyName || + property == TextCell.DetailColorProperty.PropertyName) + { + return true; + } + return base.OnCellPropertyChanged(cell, property, realizedView); + } + } + + internal class GroupCellTextRenderer : TextCellRenderer + { + + public GroupCellTextRenderer() : this("group_index") + { + DetailPart = "elm.text.end"; + } + protected GroupCellTextRenderer(string style) : base(style) { } + } +} |