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

Commit

Permalink
Merge branch 1.5.0 into master (#308)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed May 19, 2020
1 parent bf8ead1 commit 5da2088
Show file tree
Hide file tree
Showing 32 changed files with 555 additions and 3,053 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Flora License, Version 1.1 (the "License");
Expand All @@ -20,6 +20,7 @@
using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager;
using AppSpecific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Application;

[assembly: ExportRenderer(typeof(BezelInteractionPage), typeof(Tizen.Wearable.CircularUI.Forms.Renderer.BezelInteractionPageRenderer))]

Expand Down Expand Up @@ -76,17 +77,15 @@ protected override void OnElementReady()
}
}

//// TODO.Need to update
//protected virtual void OnMoreOptionClosed()
//{
// DeactivateRotaryWidget();
//}
protected override void OnMoreOptionClosed()
{
DeactivateRotaryWidget();
}

//// TODO. Need to update
//protected virtual void OnMoreOptionOpened()
//{
// ActivateRotaryWidget();
//}
protected override void OnMoreOptionOpened()
{
ActivateRotaryWidget();
}

void UpdateRotaryFocusObject(bool initialize)
{
Expand Down Expand Up @@ -115,6 +114,7 @@ void ActivateRotaryWidget()
{
GetRotaryWidget(_currentRotaryFocusObject)?.Activate();
}
AppSpecific.SetActiveBezelInteractionElement(Application.Current, base.Element);
}

void DeactivateRotaryWidget()
Expand All @@ -127,6 +127,8 @@ void DeactivateRotaryWidget()
{
GetRotaryWidget(_currentRotaryFocusObject)?.Deactivate();
}
if (AppSpecific.GetActiveBezelInteractionElement(Application.Current) == base.Element)
AppSpecific.SetActiveBezelInteractionElement(Application.Current, null);
}

void OnPageDisappearing(object sender, EventArgs e)
Expand Down Expand Up @@ -171,4 +173,35 @@ ICircleWidget GetCircleWidget(CircleSurfaceItem item)
return (Platform.GetRenderer(item.Parent) as ICircleSurfaceItemRenderer)?.GetCircleWidget(item);
}
}

public static class BezelInteractionExtension
{
public static IBezelInteractionRouter FindBezelRouter(this Element element)
{
while (element != null)
{
if (element is IBezelInteractionRouter router)
{
return router;
}
element = element.Parent;
}
return null;
}

public static IBezelInteractionController FindBezelController(this Element element)
{
while (element != null)
{
if (element is IBezelInteractionRouter router)
{
return Platform.GetRenderer(element) as IBezelInteractionController;
}
element = element.Parent;
}
return null;
}

}

}
10 changes: 0 additions & 10 deletions src/Tizen.Wearable.CircularUI.Forms.Renderer/CheckRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class CheckRenderer : SwitchRenderer
public CheckRenderer()
{
RegisterPropertyHandler(Check.DisplayStyleProperty, UpdateStyle);
RegisterPropertyHandler(Check.ColorProperty, UpdateColor);
}

protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
Expand Down Expand Up @@ -85,15 +84,6 @@ void UpdateStyle()
((IVisualElementController)Element).NativeSizeChanged();
}

void UpdateColor()
{
var color = ((Check)Element).Color;
if(color != Color.Default)
{
Control.Color = ((Check)Element).Color.ToNative();
}
}

void OnStateChanged(object sender, EventArgs e)
{
Element.SetValue(Switch.IsToggledProperty, Control.IsChecked);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
using Xamarin.Forms.Platform.Tizen.Native;
using Xamarin.Forms.Platform.Tizen.Native.Watch;
using XForms = Xamarin.Forms.Forms;
using ECircleDateTimeSelector = ElmSharp.Wearable.CircleDateTimeSelector;
using EDateTimeFieldType = ElmSharp.DateTimeFieldType;

[assembly: ExportRenderer(typeof(Tizen.Wearable.CircularUI.Forms.CircleDateTimeSelector), typeof(Tizen.Wearable.CircularUI.Forms.Renderer.CircleDateTimeSelectorRenderer))]

[assembly: ExportRenderer(typeof(Tizen.Wearable.CircularUI.Forms.CircleDateTimeSelector), typeof(Tizen.Wearable.CircularUI.Forms.Renderer.CircleDateTimeSelectorRenderer))]

namespace Tizen.Wearable.CircularUI.Forms.Renderer
{
public class CircleDateTimeSelectorRenderer : ViewRenderer<CircleDateTimeSelector, ECircleDateTimeSelector>
public class CircleDateTimeSelectorRenderer : ViewRenderer<CircleDateTimeSelector, WatchDateTimePicker>
{
public CircleDateTimeSelectorRenderer()
{
Expand All @@ -53,7 +54,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<CircleDateTimeS
var surface = this.GetSurface();
if (null != surface)
{
SetNativeControl(new ECircleDateTimeSelector(XForms.NativeParent, surface));
SetNativeControl(new WatchDateTimePicker(XForms.NativeParent, surface));
Control.DateTimeChanged += OnDateTimeChanged;
}
}
Expand All @@ -70,51 +71,41 @@ protected override ElmSharp.Size Measure(int availableWidth, int availableHeight
return new ElmSharp.Size(300, 290);
}

void UpdateMinimum()
protected override void UpdateRotaryInteraction(bool enable)
{
if (null != Control && null != Element)
if (Element.FindBezelRouter() == null)
{
Control.MinimumDateTime = Element.MinimumDate;
base.UpdateRotaryInteraction(enable);
}
}

void UpdateMinimum()
{
Control.MinimumDateTime = Element.MinimumDate;
}

void UpdateMaximum()
{
if (null != Control && null != Element)
{
Control.MaximumDateTime = Element.MaximumDate;
}
Control.MaximumDateTime = Element.MaximumDate;
}

void UpdateDateTime()
{
if (null != Control && null != Element && Element.DateTime != Control.DateTime)
if (Element.DateTime != Control.DateTime)
{
Control.DateTime = Element.DateTime;
}
}

void UpdateValueType()
{
if (null != Control && null != Element)
{
if (Element.ValueType == DateTimeType.Date)
{
Control.Style = "datepicker/circle";
Control.Format = "%d/%b/%Y";
}
else if (Element.ValueType == DateTimeType.Time)
{
Control.Style = "timepicker/circle";
Control.Format = "%d/%b/%Y%I:%M%p";
}
}
Control.Mode = Element.ValueType.ToNative();
}

void UpdateMarkerColor()
{
#pragma warning disable CS0618 // MarkerColor is obsolete
if (null != Control && null != Element && Element.MarkerColor != Xamarin.Forms.Color.Default)
if (Element.MarkerColor != Xamarin.Forms.Color.Default)
{
Control.MarkerColor = Element.MarkerColor.ToNative();
}
Expand All @@ -123,57 +114,52 @@ void UpdateMarkerColor()

void OnDateTimeChanged(object sender, EventArgs e)
{
if (null != Control && null != Element)
{
Element.DateTime = Control.DateTime;
}
Element.DateTime = Control.DateTime;
}

void UpdateFieldVisibilityOfYear()
{
if (null != Control && null != Element)
{
Control.SetFieldVisible(EDateTimeFieldType.Year, Element.IsVisibleOfYear);
}
Control.SetFieldVisible(EDateTimeFieldType.Year, Element.IsVisibleOfYear);
}

void UpdateFieldVisibilityOfMonth()
{
if (null != Control && null != Element)
{
Control.SetFieldVisible(EDateTimeFieldType.Month, Element.IsVisibleOfMonth);
}
Control.SetFieldVisible(EDateTimeFieldType.Month, Element.IsVisibleOfMonth);
}

void UpdateFieldVisibilityOfDate()
{
if (null != Control && null != Element)
{
Control.SetFieldVisible(EDateTimeFieldType.Date, Element.IsVisibleOfDate);
}
Control.SetFieldVisible(EDateTimeFieldType.Date, Element.IsVisibleOfDate);
}

void UpdateFieldVisibilityOfHour()
{
if (null != Control && null != Element)
{
Control.SetFieldVisible(EDateTimeFieldType.Hour, Element.IsVisibleOfHour);
}
Control.SetFieldVisible(EDateTimeFieldType.Hour, Element.IsVisibleOfHour);
}

void UpdateFieldVisibilityOfMinute()
{
if (null != Control && null != Element)
{
Control.SetFieldVisible(EDateTimeFieldType.Minute, Element.IsVisibleOfMinute);
}
Control.SetFieldVisible(EDateTimeFieldType.Minute, Element.IsVisibleOfMinute);
}

void UpdateFieldVisibilityOfAmPm()
{
if (null != Control && null != Element)
Control.SetFieldVisible(EDateTimeFieldType.AmPm, Element.IsVisibleOfAmPm);
}
}

internal static class DateTimeTypeEntensions
{
internal static DateTimePickerMode ToNative(this DateTimeType type)
{
switch (type)
{
Control.SetFieldVisible(EDateTimeFieldType.AmPm, Element.IsVisibleOfAmPm);
case DateTimeType.Date:
return DateTimePickerMode.Date;
case DateTimeType.Time:
return DateTimePickerMode.Time;
default:
throw new NotImplementedException($"DateTimeType {type} not supported");
}
}
}
Expand Down
Loading

0 comments on commit 5da2088

Please sign in to comment.