summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Button.cs30
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ButtonStyle.cs9
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs30
-rw-r--r--Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs9
-rw-r--r--Xamarin.Forms.Core/Xamarin.Forms.Core.csproj5
-rwxr-xr-xXamarin.Forms.Maps.Tizen/FormsMaps.cs54
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Maps.Tizen/GeocoderBackend.cs41
-rwxr-xr-xXamarin.Forms.Maps.Tizen/MapControl.cs14
-rwxr-xr-xXamarin.Forms.Maps.Tizen/MapRenderer.cs287
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.csproj1
-rwxr-xr-xXamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.project.json6
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Maps/Properties/AssemblyInfo.cs1
-rw-r--r--Xamarin.Forms.Platform.Tizen/Forms.cs5
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Button.cs39
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Platform.Tizen/Native/Span.cs4
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs34
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs3
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs31
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Platform.Tizen/ResourcePath.cs17
-rw-r--r--Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs2
-rw-r--r--packaging/xamarin-forms-tizen.spec9
21 files changed, 513 insertions, 118 deletions
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Button.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Button.cs
new file mode 100644
index 00000000..e74650fc
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Button.cs
@@ -0,0 +1,30 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Button;
+
+ public static class Button
+ {
+ public static readonly BindableProperty ButtonStyleProperty = BindableProperty.Create("ButtonStyle", typeof(ButtonStyle), typeof(FormsElement), ButtonStyle.Default);
+
+ public static ButtonStyle GetButtonStyle(BindableObject element)
+ {
+ return (ButtonStyle)element.GetValue(ButtonStyleProperty);
+ }
+
+ public static void SetButtonStyle(BindableObject element, ButtonStyle value)
+ {
+ element.SetValue(ButtonStyleProperty, value);
+ }
+
+ public static ButtonStyle GetButtonStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetButtonStyle(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetButtonStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config, ButtonStyle value)
+ {
+ SetButtonStyle(config.Element, value);
+ return config;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ButtonStyle.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ButtonStyle.cs
new file mode 100644
index 00000000..abe7bd81
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/ButtonStyle.cs
@@ -0,0 +1,9 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum ButtonStyle
+ {
+ Default,
+ Circle,
+ Bottom
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs
new file mode 100644
index 00000000..cef38f34
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/Switch.cs
@@ -0,0 +1,30 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ using FormsElement = Forms.Switch;
+
+ public static class Switch
+ {
+ public static readonly BindableProperty SwitchStyleProperty = BindableProperty.Create("SwitchStyle", typeof(SwitchStyle), typeof(FormsElement), SwitchStyle.Default);
+
+ public static SwitchStyle GetSwitchStyle(BindableObject element)
+ {
+ return (SwitchStyle)element.GetValue(SwitchStyleProperty);
+ }
+
+ public static void SetSwitchStyle(BindableObject element, SwitchStyle value)
+ {
+ element.SetValue(SwitchStyleProperty, value);
+ }
+
+ public static SwitchStyle GetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config)
+ {
+ return GetSwitchStyle(config.Element);
+ }
+
+ public static IPlatformElementConfiguration<Tizen, FormsElement> SetSwitchStyle(this IPlatformElementConfiguration<Tizen, FormsElement> config, SwitchStyle value)
+ {
+ SetSwitchStyle(config.Element, value);
+ return config;
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs
new file mode 100644
index 00000000..a7980fe2
--- /dev/null
+++ b/Xamarin.Forms.Core/PlatformConfiguration/TizenSpecific/SwitchStyle.cs
@@ -0,0 +1,9 @@
+namespace Xamarin.Forms.PlatformConfiguration.TizenSpecific
+{
+ public enum SwitchStyle
+ {
+ Default,
+ CheckBox,
+ Favorite
+ }
+}
diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
index 07dc83ea..47f49f79 100644
--- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
+++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj
@@ -101,6 +101,10 @@
<Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\Image.cs" />
<Compile Include="PlatformConfiguration\TizenSpecific\ProgressBar.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Button.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\ButtonStyle.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\Switch.cs" />
+ <Compile Include="PlatformConfiguration\TizenSpecific\SwitchStyle.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
<Compile Include="Configuration.cs" />
@@ -455,7 +459,6 @@
<Name>Xamarin.Forms.Platform</Name>
</ProjectReference>
</ItemGroup>
- <ItemGroup />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
diff --git a/Xamarin.Forms.Maps.Tizen/FormsMaps.cs b/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
index b41b50d8..0fd7029c 100755
--- a/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
+++ b/Xamarin.Forms.Maps.Tizen/FormsMaps.cs
@@ -1,19 +1,49 @@
-using Xamarin.Forms.Maps.Tizen;
+using System.Diagnostics;
+using Tizen.Maps;
+using Xamarin.Forms.Maps.Tizen;
namespace Xamarin
{
- public static class FormsMaps
- {
- public static bool IsInitialized { get; private set; }
+ public static class FormsMaps
+ {
+ static MapService _mapService = null;
- public static void Init()
- {
- if (IsInitialized)
- return;
+ static string ProviderName { get; set; }
- IsInitialized = true;
+ static string AuthenticationToken { get; set; }
- GeocoderBackend.Register();
- }
- }
+ internal static bool IsInitialized { get; private set; }
+
+ internal static MapService MapService
+ {
+ get
+ {
+ Debug.Assert(_mapService != null, "FormsMaps is not initialized");
+ return _mapService;
+ }
+ }
+
+ public static void Init(string provider, string authenticationToken)
+ {
+ ProviderName = provider;
+ AuthenticationToken = authenticationToken;
+ Init();
+ }
+
+ internal static async void Init()
+ {
+ if (IsInitialized)
+ return;
+ var requestResult = await MapService.RequestUserConsent(ProviderName);
+ if (requestResult)
+ {
+ _mapService = new MapService(ProviderName, AuthenticationToken);
+ if (_mapService != null)
+ {
+ GeocoderBackend.Register();
+ IsInitialized = true;
+ }
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/Xamarin.Forms.Maps.Tizen/GeocoderBackend.cs b/Xamarin.Forms.Maps.Tizen/GeocoderBackend.cs
index a18990d4..dbf93979 100644..100755
--- a/Xamarin.Forms.Maps.Tizen/GeocoderBackend.cs
+++ b/Xamarin.Forms.Maps.Tizen/GeocoderBackend.cs
@@ -1,25 +1,32 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-using System;
namespace Xamarin.Forms.Maps.Tizen
{
- public class Position {};
+ internal class GeocoderBackend
+ {
+ public static void Register()
+ {
+ Geocoder.GetPositionsForAddressAsyncFunc = GetPositionsForAddressAsync;
+ Geocoder.GetAddressesForPositionFuncAsync = GetAddressesForPositionAsync;
+ }
- internal class GeocoderBackend
- {
- public static void Register()
- {
- }
+ public static async Task<IEnumerable<Position>> GetPositionsForAddressAsync(string address)
+ {
+ var request = FormsMaps.MapService.CreateGeocodeRequest(address);
+ var positions = new List<Position>();
+ foreach (var result in await request.GetResponseAsync())
+ positions.Add(new Position(result.Latitude, result.Longitude));
+ return positions;
+ }
- public static async Task<IEnumerable<Position>> GetPositionsForAddressAsync(string address)
- {
- return new Position[]{};
- }
-
- public static async Task<IEnumerable<string>> GetAddressesForPositionAsync(Position position)
- {
- return new String[]{"Not supported"};
- }
- }
+ public static async Task<IEnumerable<string>> GetAddressesForPositionAsync(Position position)
+ {
+ var request = FormsMaps.MapService.CreateReverseGeocodeRequest(position.Latitude, position.Longitude);
+ var addresses = new List<string>();
+ foreach (var result in await request.GetResponseAsync())
+ addresses.Add(result.Freetext);
+ return addresses;
+ }
+ }
} \ No newline at end of file
diff --git a/Xamarin.Forms.Maps.Tizen/MapControl.cs b/Xamarin.Forms.Maps.Tizen/MapControl.cs
deleted file mode 100755
index a10bb804..00000000
--- a/Xamarin.Forms.Maps.Tizen/MapControl.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using TLabel = Xamarin.Forms.Platform.Tizen.Native.Label;
-
-namespace Xamarin.Forms.Maps.Tizen
-{
- public class MapControl : TLabel
- {
- public MapControl(ElmSharp.EvasObject parent) : base(parent)
- {
- Text = "Can not supported Maps";
- TextColor = ElmSharp.Color.Red;
- }
- }
-}
-
diff --git a/Xamarin.Forms.Maps.Tizen/MapRenderer.cs b/Xamarin.Forms.Maps.Tizen/MapRenderer.cs
index b7278dcc..d61f6a27 100755
--- a/Xamarin.Forms.Maps.Tizen/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.Tizen/MapRenderer.cs
@@ -1,47 +1,250 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using ElmSharp;
+using Tizen.Location;
+using Tizen.Maps;
using Xamarin.Forms.Platform.Tizen;
-using TForms = Xamarin.Forms.Platform.Tizen.Forms;
namespace Xamarin.Forms.Maps.Tizen
{
- public class MapRenderer : ViewRenderer<Map, MapControl>
- {
- public MapRenderer()
- {
- RegisterPropertyHandler(Map.MapTypeProperty, UpdateMapType);
- RegisterPropertyHandler(Map.IsShowingUserProperty, UpdateIsShowingUser);
- RegisterPropertyHandler(Map.HasScrollEnabledProperty, UpdateHasScrollEnabled);
- RegisterPropertyHandler(Map.HasZoomEnabledProperty, UpdateHasZoomEnabled);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<Map> e)
- {
- base.OnElementChanged(e);
-
- if (Control == null)
- {
- var mapControl = new MapControl(TForms.Context.MainWindow);
- SetNativeControl(mapControl);
- }
- }
-
- void UpdateMapType()
- {
- // TODO
- }
-
- void UpdateIsShowingUser()
- {
- // TODO
- }
-
- void UpdateHasScrollEnabled()
- {
- // TODO
- }
-
- void UpdateHasZoomEnabled()
- {
- // TODO
- }
- }
+ public class MapRenderer : ViewRenderer<Map, MapView>
+ {
+ const string MoveMessageName = "MapMoveToRegion";
+
+ bool _disposed;
+ Overlay _marker;
+ bool _isLocatorStarted = false;
+ Lazy<Locator> _locator = new Lazy<Locator>(InitializeLocator);
+ Dictionary<Pin, MapObject> _pins = new Dictionary<Pin, MapObject>();
+
+ static Locator InitializeLocator()
+ {
+ var locator = new Locator(LocationType.Hybrid)
+ {
+ // Set the default interval to 15s same as UWP
+ Interval = 15
+ };
+ return locator;
+ }
+
+ public MapRenderer()
+ {
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs<Map> e)
+ {
+ if (Control == null)
+ {
+ var mapControl = new MapView(Platform.Tizen.Forms.Context.MainWindow, FormsMaps.MapService);
+ SetNativeControl(mapControl);
+ }
+
+ if (e.OldElement != null)
+ {
+ ((ObservableCollection<Pin>)e.OldElement.Pins).CollectionChanged -= OnCollectionChanged;
+
+ MessagingCenter.Unsubscribe<Map, MapSpan>(this, MoveMessageName);
+ }
+ if (e.NewElement != null)
+ {
+ ((ObservableCollection<Pin>)e.NewElement.Pins).CollectionChanged += OnCollectionChanged;
+ if (e.NewElement.Pins.Count > 0)
+ {
+ AddPins(e.NewElement.Pins);
+ }
+
+ MessagingCenter.Subscribe<Map, MapSpan>(this, MoveMessageName, OnMoveToRegion, e.NewElement);
+
+ UpdateMapType();
+ UpdateHasScrollEnabled();
+ UpdateHasZoomEnabled();
+ UpdateIsShowingUser();
+ }
+ base.OnElementChanged(e);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+
+ _disposed = true;
+
+ if (disposing)
+ {
+ MessagingCenter.Unsubscribe<Map, MapSpan>(this, "MapMoveToRegion");
+ if (Element != null)
+ {
+ ((ObservableCollection<Pin>)Element.Pins).CollectionChanged -= OnCollectionChanged;
+ }
+ Control.Unrealize();
+ }
+ base.Dispose(disposing);
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == Map.MapTypeProperty.PropertyName)
+ UpdateMapType();
+ else if (e.PropertyName == Map.IsShowingUserProperty.PropertyName)
+ UpdateIsShowingUser();
+ else if (e.PropertyName == Map.HasScrollEnabledProperty.PropertyName)
+ UpdateHasScrollEnabled();
+ else if (e.PropertyName == Map.HasZoomEnabledProperty.PropertyName)
+ UpdateHasZoomEnabled();
+ }
+
+ void OnMoveToRegion(Map map, MapSpan span)
+ {
+ var newCenter = new Geocoordinates(span.Center.Latitude, span.Center.Longitude);
+ Control.Center = newCenter;
+ }
+
+
+ void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ if (e.NewItems != null)
+ {
+ AddPins(e.NewItems);
+ }
+ if (e.OldItems != null)
+ {
+ RemovePins(e.OldItems);
+ }
+ if (e.Action == NotifyCollectionChangedAction.Reset)
+ {
+ ClearPins();
+ }
+ }
+
+ void AddPins(IEnumerable pins)
+ {
+ foreach (Pin pin in pins)
+ {
+ var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
+ var rectangle = new Background(Platform.Tizen.Forms.Context.MainWindow);
+ // TODO: Need to change BubbleOverlay to default Marker
+ // TODO: Need to handle Pin.Clicked event
+ var nativePin = new BubbleOverlay(coordinates, rectangle);
+ Control.Add(nativePin);
+ _pins.Add(pin, nativePin);
+ }
+ }
+
+ void RemovePins(IEnumerable pins)
+ {
+ foreach (Pin pin in pins)
+ {
+ if (_pins.ContainsKey(pin))
+ {
+ Control.Remove(_pins[pin]);
+ _pins.Remove(pin);
+ }
+ }
+ }
+
+ void ClearPins()
+ {
+ foreach (var pin in _pins)
+ {
+ Control.Remove(pin.Value);
+ }
+ _pins.Clear();
+ }
+
+ void UpdateHasZoomEnabled()
+ {
+ if (Element.HasZoomEnabled == true)
+ Control.ZoomChanged += Dummy;
+ else
+ Control.ZoomChanged -= Dummy;
+ }
+
+ void UpdateHasScrollEnabled()
+ {
+ if (Element.HasScrollEnabled == true)
+ Control.Scrolled += Dummy;
+ else
+ Control.Scrolled -= Dummy;
+ }
+
+ void Dummy(object sender, MapGestureEventArgs e)
+ {
+ //TODO: The implementation of Tizen.Maps needs to be changed to remove this method
+ }
+
+ void ApplyIsShowingUser(Geocoordinates coordinates)
+ {
+ if (_marker == null)
+ {
+ var rectangle = new Background(Platform.Tizen.Forms.Context.MainWindow);
+ // TODO: Need to change BubbleOverlay to Default Overlay
+ _marker = new BubbleOverlay(coordinates, rectangle);
+ _marker.IsVisible = false;
+ Control.Add(_marker);
+ }
+ _marker.Coordinates = coordinates;
+
+ if (!_marker.IsVisible)
+ {
+ _marker.IsVisible = true;
+ Control.Center = coordinates;
+ Control.ZoomLevel = 13;
+ }
+ }
+ void UpdateIsShowingUser()
+ {
+ if (Element.IsShowingUser)
+ {
+ _locator.Value.LocationChanged += OnLocationChanged;
+ if (!_isLocatorStarted)
+ {
+ _locator.Value.Start();
+ _isLocatorStarted = true;
+ }
+ }
+ else
+ {
+ if (_locator.IsValueCreated)
+ {
+ _locator.Value.LocationChanged -= OnLocationChanged;
+ _locator.Value.Stop();
+ _isLocatorStarted = false;
+ }
+ if (_marker != null)
+ _marker.IsVisible = false;
+ }
+ }
+
+ void OnLocationChanged(object sender, LocationChangedEventArgs e)
+ {
+ ApplyIsShowingUser(new Geocoordinates(e.Location.Latitude, e.Location.Longitude));
+ }
+
+ void UpdateMapType()
+ {
+ switch (Element.MapType)
+ {
+ case MapType.Street:
+ Control.MapType = MapTypes.Normal;
+ break;
+ case MapType.Satellite:
+ Control.MapType = MapTypes.Satellite;
+ break;
+ case MapType.Hybrid:
+ Control.MapType = MapTypes.Hybrid;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+ }
}
diff --git a/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.csproj b/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.csproj
index 9b163767..98733eeb 100644..100755
--- a/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.csproj
+++ b/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.csproj
@@ -40,7 +40,6 @@
<Compile Include="FormsMaps.cs" />
<Compile Include="GeocoderBackend.cs" />
<Compile Include="MapRenderer.cs" />
- <Compile Include="MapControl.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Xamarin.Forms.Maps.Tizen.project.json" />
diff --git a/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.project.json b/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.project.json
index f4511fe7..c381ec60 100755
--- a/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.project.json
+++ b/Xamarin.Forms.Maps.Tizen/Xamarin.Forms.Maps.Tizen.project.json
@@ -2,11 +2,13 @@
"dependencies": {
"ElmSharp": "1.1.0-*",
"NETStandard.Library": "1.6.0",
- "Tizen.Applications": "1.0.2"
+ "Tizen.Applications": "1.0.2",
+ "Tizen.Location": "1.0.3",
+ "Tizen.Maps": "1.0.1"
},
"frameworks": {
"netstandard1.6": {
"imports": "portable-net45+win8+wpa81+wp8"
}
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Maps/Properties/AssemblyInfo.cs b/Xamarin.Forms.Maps/Properties/AssemblyInfo.cs
index 2220ffff..f050be06 100644..100755
--- a/Xamarin.Forms.Maps/Properties/AssemblyInfo.cs
+++ b/Xamarin.Forms.Maps/Properties/AssemblyInfo.cs
@@ -16,6 +16,7 @@ using Xamarin.Forms.Internals;
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.iOS")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.iOS.Classic")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.Android")]
+[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.Tizen")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.WP8")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.UWP")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Maps.WinRT.Phone")]
diff --git a/Xamarin.Forms.Platform.Tizen/Forms.cs b/Xamarin.Forms.Platform.Tizen/Forms.cs
index 453bab82..a12d9513 100644
--- a/Xamarin.Forms.Platform.Tizen/Forms.cs
+++ b/Xamarin.Forms.Platform.Tizen/Forms.cs
@@ -123,10 +123,8 @@ namespace Xamarin.Forms.Platform.Tizen
Elementary.ThemeOverlay();
}
- //TO-DO: Need to change to Tizen.
- Device.OS = TargetPlatform.Other;
+ Device.OS = TargetPlatform.Tizen;
-#if !NET45
// In .NETCore, AppDomain feature is not supported.
// The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually.
// The assembly of the executing application and referenced assemblies of it are added into the list here.
@@ -147,7 +145,6 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
}
-#endif
Device.PlatformServices = new TizenPlatformServices(); ;
if (Device.info != null)
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Button.cs b/Xamarin.Forms.Platform.Tizen/Native/Button.cs
index 8f85da63..71ec0c10 100644
--- a/Xamarin.Forms.Platform.Tizen/Native/Button.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Button.cs
@@ -20,7 +20,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
/// <summary>
/// The internal padding of the button, helps to determine the size.
/// </summary>
- readonly ESize _internalPadding;
+ ESize _internalPadding;
/// <summary>
/// Optional image, if set will be drawn on the button.
@@ -201,6 +201,18 @@ namespace Xamarin.Forms.Platform.Tizen.Native
var padding = _internalPadding;
+ if (Style == "circle")
+ {
+ var circleTextPadding = (EdjeObject["icon_text_padding"]?.Geometry.Height).GetValueOrDefault(0);
+ var circleHeight = padding.Height + ((rawSize.Width == 0) ? 0 : circleTextPadding + formattedSize.Height);
+
+ return new ESize
+ {
+ Width = padding.Width,
+ Height = circleHeight
+ };
+ }
+
if (rawSize.Width > availableWidth)
{
// if the raw text width is larger than the available width, use
@@ -299,5 +311,30 @@ namespace Xamarin.Forms.Platform.Tizen.Native
SetPartContent("icon", _image);
}
}
+
+ public void UpdateStyle(string style)
+ {
+ if (Style != style)
+ {
+ Style = style;
+
+ if (Style == "circle")
+ {
+ var circleSize = (EdjeObject["bg"]?.Geometry.Width).GetValueOrDefault(0);
+ _internalPadding = new ESize(circleSize, circleSize);
+ _span.HorizontalTextAlignment = TextAlignment.Center;
+ }
+ else if (Style == "bottom")
+ {
+ _internalPadding = GetInternalPadding();
+ _span.HorizontalTextAlignment = TextAlignment.Auto;
+ }
+ else
+ {
+ _span.HorizontalTextAlignment = TextAlignment.Auto;
+ }
+ ApplyTextAndStyle();
+ }
+ }
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs
index 0e3f0000..c92fefcf 100644..100755
--- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs
@@ -144,7 +144,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
/// <summary>
/// This method return text decorated with markup if FormattedText is set or plain text otherwise.
/// </summary>
- internal string GetDecoratedText()
+ public string GetDecoratedText()
{
if (FormattedText != null)
{
@@ -275,7 +275,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native
.Replace("\n", "<br>");
}
- internal string GetStyle()
+ public string GetStyle()
{
StringBuilder sb = new StringBuilder();
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
index a34df549..8af7bb69 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
@@ -1,5 +1,8 @@
using System;
+using System.ComponentModel;
using EColor = ElmSharp.Color;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Button;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -38,12 +41,23 @@ namespace Xamarin.Forms.Platform.Tizen
if (e.NewElement != null)
{
+ UpdateStyle();
Control.Clicked += ButtonClickedHandler;
}
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == Specific.ButtonStyleProperty.PropertyName)
+ {
+ UpdateStyle();
+ }
+ }
+
protected override Size MinimumSize()
{
return new Size(Control.MinimumWidth, Control.MinimumHeight);
@@ -84,6 +98,26 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
+ void UpdateStyle()
+ {
+ string style;
+ switch (Specific.GetButtonStyle(Element))
+ {
+ case ButtonStyle.Circle:
+ style = "circle";
+ break;
+ case ButtonStyle.Bottom:
+ style = "bottom";
+ break;
+ default:
+ style = "default";
+ break;
+ }
+
+ Control.UpdateStyle(style);
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
+
void UpdateBorder()
{
/* The simpler way is to create some specialized theme for button in
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
index 09353b2a..1f56eddf 100644..100755
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs
@@ -59,7 +59,10 @@ namespace Xamarin.Forms.Platform.Tizen
{
bool success = await Control.LoadFromImageSourceAsync(source);
if (!IsDisposed && success)
+ {
((IVisualElementController)Element).NativeSizeChanged();
+ UpdateBlendColor();
+ }
}
if (!IsDisposed)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
index b3539e6c..c67a69a2 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SwitchRenderer.cs
@@ -1,5 +1,8 @@
using System;
+using System.ComponentModel;
using ElmSharp;
+using Xamarin.Forms.PlatformConfiguration.TizenSpecific;
+using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Switch;
namespace Xamarin.Forms.Platform.Tizen
{
@@ -28,14 +31,22 @@ namespace Xamarin.Forms.Platform.Tizen
if (e.NewElement != null)
{
- Control.Style = "toggle";
-
+ UpdateStyle();
Control.StateChanged += CheckChangedHandler;
}
base.OnElementChanged(e);
}
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == Specific.SwitchStyleProperty.PropertyName)
+ {
+ UpdateStyle();
+ }
+ base.OnElementPropertyChanged(sender, e);
+ }
+
void CheckChangedHandler(object sender, EventArgs e)
{
Element.SetValue(Switch.IsToggledProperty, Control.IsChecked);
@@ -46,5 +57,21 @@ namespace Xamarin.Forms.Platform.Tizen
Control.IsChecked = Element.IsToggled;
}
+ void UpdateStyle()
+ {
+ switch (Specific.GetSwitchStyle(Element))
+ {
+ case SwitchStyle.CheckBox:
+ Control.Style = "default";
+ break;
+ case SwitchStyle.Favorite:
+ Control.Style = "favorite";
+ break;
+ default:
+ Control.Style = "toggle";
+ break;
+ }
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/ResourcePath.cs b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs
index d2387793..b3678727 100644..100755
--- a/Xamarin.Forms.Platform.Tizen/ResourcePath.cs
+++ b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs
@@ -1,13 +1,10 @@
using System.IO;
-#if NET45
-using System.Reflection;
-#endif
using AppFW = Tizen.Applications;
namespace Xamarin.Forms.Platform.Tizen
{
- internal static class ResourcePath
+ public static class ResourcePath
{
public static string GetPath(string res)
{
@@ -26,18 +23,6 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
-#if NET45
- string exedir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- // ind resource in "exepath/../res/"
- {
- string resPath = exedir + "/../res/" + res;
- if (File.Exists(resPath))
- {
- return resPath;
- }
- }
-#endif
-
return res;
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs
index db7ee1de..bb7183a9 100644
--- a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs
+++ b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs
@@ -192,7 +192,6 @@ namespace Xamarin.Forms.Platform.Tizen
#endregion
-#if !NET45
// In .NETCore, AppDomain is not supported. The list of the assemblies should be generated manually.
internal class AppDomain
{
@@ -226,7 +225,6 @@ namespace Xamarin.Forms.Platform.Tizen
return _assemblies.ToArray();
}
}
-#endif
}
}
diff --git a/packaging/xamarin-forms-tizen.spec b/packaging/xamarin-forms-tizen.spec
index 81bbe540..0d457845 100644
--- a/packaging/xamarin-forms-tizen.spec
+++ b/packaging/xamarin-forms-tizen.spec
@@ -1,7 +1,7 @@
%define XF_VERSION 2.3.3.175
# Increase this XF_TIZEN_VERSION when any public APIs of Xamarin.Forms.Platform.Tizen are changed.
-%define XF_TIZEN_VERSION b02
+%define XF_TIZEN_VERSION b03
Name: xamarin-forms-tizen
Summary: Xamarin.Forms for Tizen platform
@@ -18,7 +18,7 @@ Source1: %{name}.manifest
# let's override Mono provided portion
%define __mono_requires %{_builddir}/%name-%version/packaging/custom-find-requires
-ExcludeArch: aarch64 %ix86
+ExcludeArch: aarch64
BuildRequires: mono-compiler
BuildRequires: mono-devel
@@ -30,6 +30,8 @@ BuildRequires: dotnet-build-tools
BuildRequires: csapi-tizen-nuget
BuildRequires: csapi-application-nuget
BuildRequires: csapi-system-nuget
+BuildRequires: csapi-location-nuget
+BuildRequires: csapi-maps-nuget
BuildRequires: elm-sharp-nuget
%description
@@ -52,6 +54,7 @@ cp %{SOURCE1} .
# Create NuGet Packages
%dotnet_pack .nuspec/Xamarin.Forms.Platform.Tizen.nuspec %{NUPKG_VERSION} "-BasePath ./.nuspec"
+%dotnet_pack .nuspec/Xamarin.Forms.Maps.Tizen.nuspec %{NUPKG_VERSION} "-BasePath ./.nuspec"
%install
function install_asm()
@@ -64,6 +67,8 @@ install_asm Xamarin.Forms.Core
install_asm Xamarin.Forms.Xaml
install_asm Xamarin.Forms.Platform
install_asm Xamarin.Forms.Platform.Tizen
+install_asm Xamarin.Forms.Maps
+install_asm Xamarin.Forms.Maps.Tizen
mkdir -p %{buildroot}/nuget
install -p -m 644 *.nupkg %{buildroot}/nuget