Skip to content

Commit

Permalink
Merge pull request Samsung#21 from pius-lee/master
Browse files Browse the repository at this point in the history
Change Namespace and implement IRotaryEventReceiver
  • Loading branch information
idkiller authored and GitHub Enterprise committed Nov 30, 2017
2 parents e6b1eb4 + a985f41 commit 0fa221f
Show file tree
Hide file tree
Showing 30 changed files with 161 additions and 72 deletions.
10 changes: 5 additions & 5 deletions WearableUIGallery/WearableUIGallery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WearableUIGallery.Tizen.Wea
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.CircularUI", "..\Xamarin.Forms.CircularUI\Xamarin.Forms.CircularUI.csproj", "{571EFE9E-B539-4FF7-8E28-A6F451C64652}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.CircularUI.Renderer", "..\Xamarin.Forms.CircularUI.Renderer\Xamarin.Forms.CircularUI.Renderer.csproj", "{0A00329D-37E9-4B18-BF30-5E5597826B29}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Forms.CircularUI.Tizen", "..\Xamarin.Forms.CircularUI.Tizen\Xamarin.Forms.CircularUI.Tizen.csproj", "{8B32EE6A-0ADD-4E64-80E9-B2375690CC70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,10 +29,10 @@ Global
{571EFE9E-B539-4FF7-8E28-A6F451C64652}.Debug|Any CPU.Build.0 = Debug|Any CPU
{571EFE9E-B539-4FF7-8E28-A6F451C64652}.Release|Any CPU.ActiveCfg = Release|Any CPU
{571EFE9E-B539-4FF7-8E28-A6F451C64652}.Release|Any CPU.Build.0 = Release|Any CPU
{0A00329D-37E9-4B18-BF30-5E5597826B29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A00329D-37E9-4B18-BF30-5E5597826B29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A00329D-37E9-4B18-BF30-5E5597826B29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A00329D-37E9-4B18-BF30-5E5597826B29}.Release|Any CPU.Build.0 = Release|Any CPU
{8B32EE6A-0ADD-4E64-80E9-B2375690CC70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B32EE6A-0ADD-4E64-80E9-B2375690CC70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B32EE6A-0ADD-4E64-80E9-B2375690CC70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B32EE6A-0ADD-4E64-80E9-B2375690CC70}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
{
var app = new Program();
global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
Xamarin.Forms.CircularUI.Renderer.CircularUI.Init();
Xamarin.Forms.CircularUI.Tizen.CircularUI.Init();
app.Run(args);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<!-- If solution already has PCL project, will reference -->
<ItemGroup>
<ProjectReference Include="..\..\..\Xamarin.Forms.CircularUI.Renderer\Xamarin.Forms.CircularUI.Renderer.csproj" />
<ProjectReference Include="..\..\..\Xamarin.Forms.CircularUI.Tizen\Xamarin.Forms.CircularUI.Tizen.csproj" />
<ProjectReference Include="..\WearableUIGallery\WearableUIGallery.csproj" />
</ItemGroup>

Expand All @@ -32,7 +32,11 @@
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
<PackageReference Include="Xamarin.Forms.Platform.Tizen" Version="2.5.0.77107" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Platform.Tizen">
<HintPath>..\..\..\..\Xamarin.Forms\Xamarin.Forms.Platform.Tizen\bin\Debug\tizen40\Xamarin.Forms.Platform.Tizen.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class AppViewModel
public AppViewModel()
{
TCs = new ObservableCollection<TCDescribe>();

TCs.Add(new TCDescribe { Title = "CirclePage", Class = typeof(TCCirclePage) });
TCs.Add(new TCDescribe { Title = "CircleListView", Class = typeof(TCCircleListView) });
TCs.Add(new TCDescribe { Title = "CircleScroller", Class = typeof(TCCircleScroller) });
Expand All @@ -21,6 +20,7 @@ public AppViewModel()
TCs.Add(new TCDescribe { Title = "ContextPopup", Class = typeof(TCContextPopup) });
TCs.Add(new TCDescribe { Title = "TwoButtonPage", Class = typeof(TCTwoButtonPage) });
TCs.Add(new TCDescribe { Title = "TwoButtonPopup", Class = typeof(TCTwoButtonPopup) });
TCs.Add(new TCDescribe { Title = "RotationReceiver", Class = typeof(TCIRotaryEventReceiver) });
}

public IList<TCDescribe> TCs { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
xmlns:local="clr-namespace:WearableUIGallery"
xmlns:w="clr-namespace:Xamarin.Forms.CircularUI;assembly=Xamarin.Forms.CircularUI"
xmlns:sys="clr-namespace:System;assembly=netstandard"
x:Class="WearableUIGallery.TC.TCCircleListView">
x:Class="WearableUIGallery.TC.TCCircleListView"
RotaryFocusTargetName="mylist">
<w:CirclePage.Content>
<w:CircleListView>
<w:CircleListView x:Name="mylist">
<w:CircleListView.ItemsSource>
<x:Array Type="{x:Type sys:String}" x:Key="array">
<x:String>Item 1</x:String>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<w:CirclePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:WearableUIGallery.TC"
xmlns:w="clr-namespace:Xamarin.Forms.CircularUI;assembly=Xamarin.Forms.CircularUI"
x:Name="MyCirclePage"
x:Class="WearableUIGallery.TC.TCIRotaryEventReceiver"
RotaryFocusTargetName="MyCirclePage">
<w:CirclePage.Content>
<Image x:Name="Cat" Source="image/cat360.png"/>
</w:CirclePage.Content>
</w:CirclePage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.CircularUI;
using Xamarin.Forms.Xaml;

namespace WearableUIGallery.TC
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class TCIRotaryEventReceiver : CirclePage, IRotaryEventReceiver
{
bool _rotating;
double _angle;
public TCIRotaryEventReceiver ()
{
InitializeComponent ();
_angle = 0;
}

public void Rotate(RotaryEventArgs args)
{
if (_rotating) return;

_rotating = true;
_angle += args.IsClockwise ? 30 : -30;
Cat.RotateTo(_angle).ContinueWith(
(b) =>
{
_rotating = false;
if (_angle == 360)
{
Cat.Rotation = 0;
_angle = 0;
}
});
}
}
}
4 changes: 2 additions & 2 deletions Xamarin.Forms.CircularUI.Tizen/CheckRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.ComponentModel;
using Xamarin.Forms.CircularUI;
using Xamarin.Forms.CircularUI.Renderer;
using Xamarin.Forms.CircularUI.Tizen;
using Xamarin.Forms.Platform.Tizen;
using ECheck = ElmSharp.Check;
using TForms = Xamarin.Forms.Platform.Tizen.Forms;

[assembly: ExportRenderer(typeof(Check), typeof(CheckRenderer))]

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
internal static class CheckStyle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
using Xamarin.Forms.Platform.Tizen;
using ElmSharp;

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


namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
public class CircleDateTimeSelectorRenderer : ViewRenderer<CircleDateTimeSelector, ElmSharp.Wearable.CircleDateTimeSelector>
{
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.CircularUI.Tizen/CircleListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Xamarin.Forms.Internals;
using System.ComponentModel;

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
using GroupList = TemplatedItemsList<ItemsView<Cell>, Cell>;

Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.CircularUI.Tizen/CircleListViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.Tizen;

[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleListView), typeof(Xamarin.Forms.CircularUI.Renderer.CircleListViewRenderer))]
[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleListView), typeof(Xamarin.Forms.CircularUI.Tizen.CircleListViewRenderer))]

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
using GroupList = TemplatedItemsList<ItemsView<Cell>, Cell>;

Expand Down
88 changes: 59 additions & 29 deletions Xamarin.Forms.CircularUI.Tizen/CirclePageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using Xamarin.Forms.Platform.Tizen;
using System.ComponentModel;

[assembly: ExportRenderer(typeof(CirclePage), typeof(Xamarin.Forms.CircularUI.Renderer.CirclePageRenderer))]
[assembly: ExportRenderer(typeof(CirclePage), typeof(Xamarin.Forms.CircularUI.Tizen.CirclePageRenderer))]

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
public class CirclePageRenderer : VisualElementRenderer<CirclePage>
{
Expand Down Expand Up @@ -51,12 +51,12 @@ protected override void OnElementChanged(ElementChangedEventArgs<CirclePage> arg

protected void OnCirclePageAppearing(object sender, EventArgs e)
{
GetRotaryWidget(Element?.RotaryFocusObject)?.Activate();
ActivateRotaryWidget();
}

protected void OnCirclePageDisappearing(object sender, EventArgs e)
{
GetRotaryWidget(Element?.RotaryFocusObject)?.Deactivate();
DeactivateRotaryWidget();
}

protected override void UpdateBackgroundColor(bool initialize)
Expand All @@ -72,50 +72,80 @@ protected override void UpdateBackgroundColor(bool initialize)
_widget.BackgroundColor = Element.BackgroundColor.ToNative();
}
}

void OnToolbarClosed(object sender, EventArgs e)
{
GetRotaryWidget(_currentRotaryFocusObject)?.Activate();
}

void OnToolbarOpened(object sender, EventArgs e)
{
GetRotaryWidget(_currentRotaryFocusObject)?.Deactivate();
}

IRotaryActionWidget GetRotaryWidget(IRotaryFocusable focusable)
{
var consumer = focusable as BindableObject;
IRotaryActionWidget rotaryWidget = null;
if (consumer != null)
{
var consumerRenderer = Xamarin.Forms.Platform.Tizen.Platform.GetRenderer(consumer);
IRotaryActionWidget rotaryWidget = null;
if (consumerRenderer != null)
{
var nativeView = consumerRenderer.NativeView;
rotaryWidget = nativeView as ElmSharp.Wearable.IRotaryActionWidget;
}
else if (consumer is Xamarin.Forms.CircularUI.CircleSliderSurfaceItem)
if (consumer is CircleSliderSurfaceItem)
{
ICircleSurfaceItem item = consumer as ICircleSurfaceItem;
rotaryWidget = _widget.GetCircleWidget(item) as IRotaryActionWidget;
}

if (rotaryWidget != null)
else
{
return rotaryWidget;
var consumerRenderer = Platform.Tizen.Platform.GetRenderer(consumer);
rotaryWidget = consumerRenderer?.NativeView as IRotaryActionWidget;
}
}
return null;
return rotaryWidget;
}

void ActivateRotaryWidget()
{
if (_currentRotaryFocusObject is IRotaryEventReceiver)
{
RotaryEventManager.Rotated += OnRotaryEventChanged;
}
else if (_currentRotaryFocusObject is IRotaryFocusable)
{
GetRotaryWidget(_currentRotaryFocusObject)?.Activate();
}
}

void DeactivateRotaryWidget()
{
if (_currentRotaryFocusObject is IRotaryEventReceiver)
{
RotaryEventManager.Rotated -= OnRotaryEventChanged;
}
else if (_currentRotaryFocusObject is IRotaryFocusable)
{
GetRotaryWidget(_currentRotaryFocusObject)?.Deactivate();
}
}

void OnRotaryEventChanged(ElmSharp.Wearable.RotaryEventArgs args)
{
if (_currentRotaryFocusObject is IRotaryEventReceiver)
{
var receiver = _currentRotaryFocusObject as IRotaryEventReceiver;
receiver.Rotate(new RotaryEventArgs { IsClockwise = args.IsClockwise });
}
}

void OnToolbarClosed(object sender, EventArgs e)
{
ActivateRotaryWidget();
}

void OnToolbarOpened(object sender, EventArgs e)
{
DeactivateRotaryWidget();
}

void UpdateRotaryFocusObject(bool initialize)
{
if (!initialize)
GetRotaryWidget(_currentRotaryFocusObject)?.Deactivate();
{
DeactivateRotaryWidget();
}
_currentRotaryFocusObject = Element.RotaryFocusObject;
if (!initialize)
GetRotaryWidget(_currentRotaryFocusObject)?.Activate();
{
ActivateRotaryWidget();
}
}

void OnLayoutUpdated(object sender, Platform.Tizen.Native.LayoutEventArgs args)
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.CircularUI.Tizen/CirclePageWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Xamarin.Forms.Platform.Tizen;
using Xamarin.Forms.Platform.Tizen.Native;

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
class CirclePageWidget : ElmSharp.Layout, IContainable<EvasObject>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using Xamarin.Forms.Platform.Tizen;

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
class CircleProgressBarSurfaceItemImplements : ElmSharp.Wearable.CircleProgressBar
{
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.CircularUI.Tizen/CircleScrollViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Text;
using Xamarin.Forms.Platform.Tizen;

[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleScrollView), typeof(Xamarin.Forms.CircularUI.Renderer.CircleScrollViewRenderer))]
[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleScrollView), typeof(Xamarin.Forms.CircularUI.Tizen.CircleScrollViewRenderer))]

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
class CircleScrollViewRenderer : ScrollViewRenderer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Xamarin.Forms.CircularUI;
using Xamarin.Forms.Platform.Tizen;

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
public class CircleSliderSurfaceItemImplements : ElmSharp.Wearable.CircleSlider
{
Expand Down
4 changes: 2 additions & 2 deletions Xamarin.Forms.CircularUI.Tizen/CircleStepperRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
using ESize = ElmSharp.Size;
using Xamarin.Forms.Platform.Tizen;

[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleStepper), typeof(Xamarin.Forms.CircularUI.Renderer.CircleStepperRenderer))]
[assembly: ExportRenderer(typeof(Xamarin.Forms.CircularUI.CircleStepper), typeof(Xamarin.Forms.CircularUI.Tizen.CircleStepperRenderer))]


namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
public class CircleStepperRenderer : ViewRenderer<CircleStepper, ESpinner>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using Xamarin.Forms.Platform.Tizen;

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
static class CircleWidgetRendererExtension
{
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.CircularUI.Tizen/CircularUI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

namespace Xamarin.Forms.CircularUI.Renderer
namespace Xamarin.Forms.CircularUI.Tizen
{
public static class CircularUI
{
Expand Down
Loading

0 comments on commit 0fa221f

Please sign in to comment.