Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Update the RadioCell impl #318

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,13 @@ protected override EvasObject OnGetContent(Cell cell, string part)
{
if (part == RadioPart)
{
var radioButton = new RadioButton()
{
BindingContext = cell,
Parent = cell.Parent
};
radioButton.SetBinding(RadioButton.IsCheckedProperty, new Binding(RadioCell.OnProperty.PropertyName, BindingMode.OneTime));
radioButton.SetBinding(RadioButton.GroupNameProperty, new Binding(RadioCell.GroupNameProperty.PropertyName));
radioButton.CheckedChanged += (s, e) =>
{
cell.SetValueFromRenderer(RadioCell.OnProperty, e.Value);
};
var nativeView = Platform.GetOrCreateRenderer(radioButton).NativeView;
var nativeView = Platform.GetOrCreateRenderer(((RadioCell)cell).RadioButton).NativeView;
nativeView.PropagateEvents = false;
return nativeView;
}
return null;
}

protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
{
if (!_cacheCandidate.ContainsKey(old))
{
return null;
}
_cacheCandidate[old].BindingContext = cell;
return old;
}

protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary<string, EvasObject> realizedView)
{
if (property == RadioCell.TextProperty.PropertyName || property == RadioCell.OnProperty.PropertyName || property == RadioCell.GroupNameProperty.PropertyName)
Expand Down
19 changes: 19 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/RadioCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using System;
using System.ComponentModel;
using Xamarin.Forms;

namespace Tizen.Wearable.CircularUI.Forms
Expand Down Expand Up @@ -74,5 +75,23 @@ public string Text
/// Triggered when the radio button has changed value.
/// </summary>
public event EventHandler<CheckedChangedEventArgs> OnChanged;


/// <summary>
/// Internal use only.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public RadioButton RadioButton { get; }

public RadioCell()
{
RadioButton = new RadioButton()
{
Parent = this,
BindingContext = this,
};
RadioButton.SetBinding(RadioButton.IsCheckedProperty, new Binding(OnProperty.PropertyName));
RadioButton.SetBinding(RadioButton.GroupNameProperty, new Binding(GroupNameProperty.PropertyName));
}
}
}