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

Commit

Permalink
Merged branch dev (#271)
Browse files Browse the repository at this point in the history
* Add FlatViewCell (#260)

* Adds OverlayContent to Application (#262)

* Add rotary event manager (#259)

* Add rotary event manager

* Change internal event to delegate

* Remove unused using statements

* Change class name to RotaryEventManager

* Update using directive

* Update CircularUI.cs

* Revert "Adds OverlayContent to Application (#262)"

This reverts commit 1d10147.

Co-authored-by: Jay Cho <chojoong@gmail.com>
  • Loading branch information
rookiejava and JoonghyunCho committed Apr 14, 2020
1 parent 4b432d4 commit f5a25ec
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Xamarin.Forms.Platform.Tizen;
using Xamarin.Forms.Platform.Tizen.Native;
using XForms = Xamarin.Forms.Forms;
using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager;

using XToolbarItem = Xamarin.Forms.ToolbarItem;

Expand Down Expand Up @@ -428,7 +429,7 @@ void ActivateRotaryWidget()
{
if (_currentRotaryFocusObject is IRotaryEventReceiver)
{
RotaryEventManager.Rotated += OnRotaryEventChanged;
ERotaryEventManager.Rotated += OnRotaryEventChanged;
}
else if (_currentRotaryFocusObject is IRotaryFocusable)
{
Expand All @@ -439,7 +440,7 @@ void DeactivateRotaryWidget()
{
if (_currentRotaryFocusObject is IRotaryEventReceiver)
{
RotaryEventManager.Rotated -= OnRotaryEventChanged;
ERotaryEventManager.Rotated -= OnRotaryEventChanged;
}
else if (_currentRotaryFocusObject is IRotaryFocusable)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Tizen.Wearable.CircularUI.Forms.Renderer/CircularUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ElmSharp;
using System.Diagnostics;
using Tizen.Applications;

Expand Down Expand Up @@ -51,7 +50,6 @@ public static void Init()

public static void Init(string apiKey)
{

if (!string.IsNullOrEmpty(apiKey))
{
GoogleMaps.Init(apiKey);
Expand All @@ -60,7 +58,6 @@ public static void Init(string apiKey)
{
Debug.Assert(!string.IsNullOrEmpty(apiKey), "apiKey is null or empty!");
}

Init();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Tizen.Wearable.CircularUI.Forms;
using Tizen.Wearable.CircularUI.Forms.Renderer;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;

[assembly: ExportRenderer(typeof(FlatViewCell), typeof(FlatViewCellRenderer))]
namespace Tizen.Wearable.CircularUI.Forms.Renderer
{
public class FlatViewCellRenderer : ViewCellRenderer
{
public FlatViewCellRenderer()
{
Style = "full_effect_off";
}
}
}
54 changes: 54 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms.Renderer/RotaryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using Xamarin.Forms;
using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager;
using ERotaryEventArgs = ElmSharp.Wearable.RotaryEventArgs;

[assembly: Dependency(typeof(Tizen.Wearable.CircularUI.Forms.Renderer.RotaryService))]
namespace Tizen.Wearable.CircularUI.Forms.Renderer
{
public class RotaryService : IRotaryService
{
EventHandler<RotaryEventArgs> _rotated;

public event EventHandler<RotaryEventArgs> Rotated
{
add
{
if (_rotated == null)
{
ERotaryEventManager.Rotated += OnRotaryChanged;
}
_rotated += value;
}
remove
{
_rotated -= value;
if (_rotated == null)
{
ERotaryEventManager.Rotated -= OnRotaryChanged;
}
}
}

void OnRotaryChanged(ERotaryEventArgs args)
{
_rotated?.Invoke(this, new RotaryEventArgs() { IsClockwise = args.IsClockwise });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using ELayout = ElmSharp.Layout;
using EWidget = ElmSharp.Widget;
using EButton = ElmSharp.Button;
using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager;

namespace Tizen.Wearable.CircularUI.Forms.Renderer
{
Expand Down Expand Up @@ -262,7 +263,7 @@ void InitializeDrawerBox()
_gestureOnDrawer.SetMomentumCallback(GestureLayer.GestureState.Abort, OnDrawerDragEnded);
_gestureOnDrawer.Attach(_drawerIconBox);

RotaryEventManager.Rotated += OnRotateEventReceived;
ERotaryEventManager.Rotated += OnRotateEventReceived;
}

void SetDrawerIcon(ImageSource source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Xamarin.Forms;
using Xamarin.Forms.Platform.Tizen;
using XForms = Xamarin.Forms.Forms;
using ERotaryEventManager = ElmSharp.Wearable.RotaryEventManager;

[assembly: ExportEffect(typeof(Tizen.Wearable.CircularUI.Forms.Renderer.TizenCircleSurfaceEffect), "CircleSurfaceEffect")]
namespace Tizen.Wearable.CircularUI.Forms.Renderer
Expand Down Expand Up @@ -151,7 +152,7 @@ void ActivateRotaryFocusable(IRotaryFocusable focusable)
if (focusable is IRotaryEventReceiver)
{
_rotaryReceiver = focusable as IRotaryEventReceiver;
RotaryEventManager.Rotated += OnRotaryEventChanged;
ERotaryEventManager.Rotated += OnRotaryEventChanged;
}
else if (focusable is IRotaryFocusable)
{
Expand All @@ -169,7 +170,7 @@ void DeativateRotaryFocusable(IRotaryFocusable focusable)
if (focusable is IRotaryEventReceiver)
{
_rotaryReceiver = null;
RotaryEventManager.Rotated -= OnRotaryEventChanged;
ERotaryEventManager.Rotated -= OnRotaryEventChanged;
}
else if (focusable is IRotaryFocusable)
{
Expand Down
29 changes: 29 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/FlatViewCell.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Xamarin.Forms;

namespace Tizen.Wearable.CircularUI.Forms
{
/// <summary>
/// FlatViewCell contains a developer-defined Xamarin.Forms.View.
/// It has no fish-eye effect while ViewCell has fish-eye effect.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public class FlatViewCell : ViewCell
{
}
}
9 changes: 9 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/IRotaryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Tizen.Wearable.CircularUI.Forms
{
interface IRotaryService
{
event EventHandler<RotaryEventArgs> Rotated;
}
}
Empty file modified src/Tizen.Wearable.CircularUI.Forms/RotaryEventHandler.cs
100755 → 100644
Empty file.
53 changes: 53 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/RotaryEventManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using Xamarin.Forms;

namespace Tizen.Wearable.CircularUI.Forms
{
/// <summary>
/// The RotaryEventManager provides an event for the global rotary event for wearable devices.
/// </summary>
/// <since_tizen> 4 </since_tizen>
/// <example>
/// <code>
/// RotaryEventManager.Rotated += (s, e) =>
/// {
/// Console.WriteLine($"Rotated! Rotated direction: ${e.IsClockwise}");
/// };
/// </code>
/// </example>
public static class RotaryEventManager
{
static IRotaryService ProxyService { get; } = DependencyService.Get<IRotaryService>();

/// <summary>
/// Rotated will be triggered when the rotatable device's Bezel is rotated.
/// </summary>
public static event EventHandler<RotaryEventArgs> Rotated
{
add
{
ProxyService.Rotated += value;
}
remove
{
ProxyService.Rotated -= value;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?>
<w:CirclePage
x:Class="WearableUIGallery.TC.TCCircleListViewNoItemEffect"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:WearableUIGallery.TC"
xmlns:sys="clr-namespace:System;assembly=netstandard"
xmlns:w="clr-namespace:Tizen.Wearable.CircularUI.Forms;assembly=Tizen.Wearable.CircularUI.Forms"
RotaryFocusObject="{x:Reference mylist}">
<w:CirclePage.Resources>
<DataTemplate x:Key="FlatItem">
<w:FlatViewCell>
<Grid>
<BoxView HeightRequest="200" BackgroundColor="Blue"/>
<Label Text="Flat ViewCell" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
</Grid>
</w:FlatViewCell>
</DataTemplate>
<DataTemplate x:Key="NormalItem">
<TextCell Text="{Binding .}" />
</DataTemplate>
<local:MyItemSelector x:Key="myItemSelector"
FlatItemTemplate="{StaticResource FlatItem}"
NormalItemTemplate="{StaticResource NormalItem}" />
</w:CirclePage.Resources>
<w:CirclePage.Content>
<w:CircleListView x:Name="mylist" ItemTapped="OnItemTapped" ItemTemplate="{StaticResource myItemSelector}">
<w:CircleListView.ItemsSource>
<x:Array Type="{x:Type sys:String}">
<x:String>Item 1</x:String>
<x:String>Item 2</x:String>
<x:String>Item 3</x:String>
<x:String>Item 4</x:String>
<x:String>Item 5</x:String>
</x:Array>
</w:CircleListView.ItemsSource>
<w:CircleListView.Header>
<x:String>Header</x:String>
</w:CircleListView.Header>
<w:CircleListView.Footer>
<x:String>Footer</x:String>
</w:CircleListView.Footer>
<w:CircleListView.HeaderTemplate>
<DataTemplate>
<Label
w:CircleListView.CancelEffect="True"
HeightRequest="120"
FontAttributes="Bold"
FontSize="Large"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
Text="{Binding .}"
TextColor="Red" />
</DataTemplate>
</w:CircleListView.HeaderTemplate>
<w:CircleListView.FooterTemplate>
<DataTemplate>
<Label
w:CircleListView.CancelEffect="True"
HeightRequest="120"
FontAttributes="Bold"
FontSize="Large"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
Text="{Binding .}"
TextColor="Blue" />
</DataTemplate>
</w:CircleListView.FooterTemplate>
</w:CircleListView>
</w:CirclePage.Content>
</w:CirclePage>
Loading

0 comments on commit f5a25ec

Please sign in to comment.