-
Notifications
You must be signed in to change notification settings - Fork 32
Update renderers for Stepper and DateTimeSelector #296
Conversation
if (Control != null) | ||
{ | ||
var surface = this.GetSurface(); | ||
if (null != surface) | ||
if (Tizen.Common.DotnetUtil.TizenAPIVersion == 4) | ||
{ | ||
var spinner = new ESpinner(XForms.NativeParent, surface); | ||
spinner.Style = "circle"; | ||
|
||
SetNativeControl(spinner); | ||
Control.ValueChanged += OnValueChanged; | ||
|
||
if (Tizen.Common.DotnetUtil.TizenAPIVersion == 4) | ||
{ | ||
_listShow = new ElmSharp.SmartEvent(Control, "genlist,show"); | ||
_listHide = new ElmSharp.SmartEvent(Control, "genlist,hide"); | ||
} | ||
else | ||
{ | ||
_listShow = new ElmSharp.SmartEvent(Control, "list,show"); | ||
_listHide = new ElmSharp.SmartEvent(Control, "list,hide"); | ||
} | ||
_listShow.On += OnListShow; | ||
_listHide.On += OnListHide; | ||
_listShow = new ElmSharp.SmartEvent(Control, "genlist,show"); | ||
_listHide = new ElmSharp.SmartEvent(Control, "genlist,hide"); | ||
} | ||
else | ||
{ | ||
throw new CirclePageNotFoundException(); | ||
_listShow = new ElmSharp.SmartEvent(Control, "list,show"); | ||
_listHide = new ElmSharp.SmartEvent(Control, "list,hide"); | ||
} | ||
} | ||
|
||
base.OnElementChanged(e); | ||
} | ||
|
||
private void OnValueChanged(object sender, EventArgs e) | ||
{ | ||
double newValue = Control.Value; | ||
((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, newValue); | ||
|
||
if (Element.LabelFormat == null) | ||
{ | ||
// Determines how many decimal places are there in current Stepper's value. | ||
// The 15 pound characters below correspond to the maximum precision of Double type. | ||
var decimalValue = Decimal.Parse(newValue.ToString("0.###############")); | ||
|
||
// GetBits() method returns an array of four 32-bit integer values. | ||
// The third (0-indexing) element of an array contains the following information: | ||
// bits 00-15: unused, required to be 0 | ||
// bits 16-23: an exponent between 0 and 28 indicating the power of 10 to divide the integer number passed as a parameter. | ||
// Conversely this is the number of decimal digits in the number as well. | ||
// bits 24-30: unused, required to be 0 | ||
// bit 31: indicates the sign. 0 means positive number, 1 is for negative numbers. | ||
// | ||
// The precision information needs to be extracted from bits 16-23 of third element of an array | ||
// returned by GetBits() call. Right-shifting by 16 bits followed by zeroing anything else results | ||
// in a nice conversion of this data to integer variable. | ||
var precision = (Decimal.GetBits(decimalValue)[3] >> 16) & 0x000000FF; | ||
|
||
// Sets Stepper's inner label decimal format to use exactly as many decimal places as needed: | ||
Control.LabelFormat = string.Format("%.{0}f", precision); | ||
_listShow.On += OnListShow; | ||
_listHide.On += OnListHide; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just add the event handler here if native control provides events (e.g., WheelAppeared
and WheelDisappeared
)
Control.WheelAppeared += OnWheelAppeared;
Control.WheelDisappeared += OnWheelDisappeared;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added two events ListShow/ListHide into native control, and update this PR.
} | ||
|
||
void UpdateMarkerColor() | ||
{ | ||
#pragma warning disable CS0618 // MarkerColor is obsolete | ||
if (null != Control && null != Element && Element.MarkerColor != Color.Default) | ||
if ((Control is CircleSpinner cSpinner) && (Element is CircleStepper cStepper)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to read, I think, we need to sepate a native widght and XF widget
And no need to check a type, Element always CircleStepper because it is CircleStepper renderer, and Control is always CircleSpinner
new CircleSpinner Control => base.Control as CircleSpinner;
new CircleStepper Element => base.Element as CircleStepper;
* Refactoring CircularShell Renderer * Update bezel interaction behavior (#299) * Refactoring CircularShell Renderer * Update bezel interaction behavior * Update OnMoreOptionOpened/Closed * Update CircleScrollViewRenderer (#300) * Update CircleScrollViewRenderer * Obsolete BarColor property in CircleScrollView * Update the CircleScrollViewRenderer (#301) * Update CircleStepperRenderer and CircleDateTimeSelectorRenderer (#296) * Update ActiveBezelInteractionElement on Activate bezel interaction (#302) * Update CircleListViewRenderer (#303) * Update CircleListViewRenderer * Apply Review comment * Update Bezel Intercation behavior on closing dialog (#304) * Remove unused ListViewCache * Update Renderer to use disable rotary event on IBezelInteractionRoutor (#305) * Fix ExportRenderer (#306) * Fix CheckRendererer to avoid registerPropertyhandler issue * Fix build error on WearableGallery Co-authored-by: Seungkeun Lee <sngn.lee@samsung.com> Co-authored-by: shmin <shyun.min@samsung.com>
Description of Change
This PR updates CircleStepperRenderer and CircleDateTimeSelector.
It requires an update of Xamarin.Forms.Platform.Tizen.Native in advance.
API Changes
None
Behavioral Changes
None