summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungkeun Lee <sngn.lee@samsung.com>2017-08-04 03:06:00 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:34:39 (GMT)
commit97a443275963a35c7b609f23f41dce1a12a52a78 (patch)
treee9058935ecc2049c8aaf499d64b6ef4868803a71
parent2f6232a5c97b7b29915c529e30957b3e0118a580 (diff)
downloadxamarin-forms-97a443275963a35c7b609f23f41dce1a12a52a78.zip
xamarin-forms-97a443275963a35c7b609f23f41dce1a12a52a78.tar.gz
xamarin-forms-97a443275963a35c7b609f23f41dce1a12a52a78.tar.bz2
Refactoring Native.Window to extend
- Remove Native.Window - Remove hierarchy from ElmSharp.Window - We can easily change the window type with sub-class of Window Change-Id: I57a517e60b6e7c9acd2c32862a11db306e59a3d6
-rw-r--r--[-rwxr-xr-x]Xamarin.Forms.Platform.Tizen/FormsApplication.cs54
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs36
-rw-r--r--[-rwxr-xr-x]Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs6
-rw-r--r--Xamarin.Forms.Platform.Tizen/Native/Window.cs140
-rw-r--r--Xamarin.Forms.Platform.Tizen/Platform.cs2
5 files changed, 38 insertions, 200 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
index b725443..ba01268 100755..100644
--- a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
+++ b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs
@@ -7,6 +7,7 @@ using Tizen.Applications;
using Xamarin.Forms.Internals;
using EButton = ElmSharp.Button;
using EColor = ElmSharp.Color;
+using ELayout = ElmSharp.Layout;
using EProgressBar = ElmSharp.ProgressBar;
namespace Xamarin.Forms.Platform.Tizen
@@ -19,7 +20,7 @@ namespace Xamarin.Forms.Platform.Tizen
bool _isInitialStart;
int _pageBusyCount;
Native.Dialog _pageBusyDialog;
- Native.Window _window;
+ Window _window;
protected FormsApplication()
{
@@ -31,24 +32,29 @@ namespace Xamarin.Forms.Platform.Tizen
/// Gets the main window or <c>null</c> if it's not set.
/// </summary>
/// <value>The main window or <c>null</c>.</value>
- public Native.Window MainWindow
+ public Window MainWindow
{
get
{
return _window;
}
-
protected set
{
_window = value;
+ InitializeWindow();
}
}
+ public ELayout BaseLayout
+ {
+ get; protected set;
+ }
+
protected override void OnPreCreate()
{
base.OnPreCreate();
Application.ClearCurrent();
- CreateWindow();
+ MainWindow = new Window("FormsWindow");
}
protected override void OnTerminate()
@@ -283,43 +289,51 @@ namespace Xamarin.Forms.Platform.Tizen
_platform.SetPage(page);
}
- void CreateWindow()
+ void InitializeWindow()
{
- Debug.Assert(null == MainWindow);
+ Debug.Assert(MainWindow != null, "Window cannot be null");
+
+ MainWindow.Active();
+ MainWindow.Show();
+ var conformant = new Conformant(MainWindow);
+ conformant.Show();
+
+ // Create the base (default) layout for the application
+ var layout = new ELayout(conformant);
+ layout.SetTheme("layout", "application", "default");
+ layout.Show();
- var window = new Native.Window();
- window.Closed += (s, e) =>
+ conformant.SetContent(layout);
+ BaseLayout = layout;
+ MainWindow.AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_90 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270;
+
+ MainWindow.Deleted += (s, e) =>
{
Exit();
};
- window.RotationChanged += (sender, e) =>
+ MainWindow.RotationChanged += (sender, e) =>
{
- switch (_window.CurrentOrientation)
+ switch (MainWindow.Rotation)
{
- case Native.DisplayOrientations.None:
- Device.Info.CurrentOrientation = Internals.DeviceOrientation.Other;
- break;
-
- case Native.DisplayOrientations.Portrait:
+ case 0:
Device.Info.CurrentOrientation = Internals.DeviceOrientation.PortraitUp;
break;
- case Native.DisplayOrientations.Landscape:
+ case 90:
Device.Info.CurrentOrientation = Internals.DeviceOrientation.LandscapeLeft;
break;
- case Native.DisplayOrientations.PortraitFlipped:
+ case 180:
Device.Info.CurrentOrientation = Internals.DeviceOrientation.PortraitDown;
break;
- case Native.DisplayOrientations.LandscapeFlipped:
+ case 270:
Device.Info.CurrentOrientation = Internals.DeviceOrientation.LandscapeRight;
break;
}
};
-
- MainWindow = window;
}
+
public void Run()
{
Run(System.Environment.GetCommandLineArgs());
diff --git a/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs b/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs
deleted file mode 100644
index efb0952..0000000
--- a/Xamarin.Forms.Platform.Tizen/Native/DisplayOrientations.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- /// <summary>
- /// Enumeration for the orientation of a rectangular screen.
- /// </summary>
- [Flags]
- public enum DisplayOrientations
- {
- /// <summary>
- /// No display orientation is specified.
- /// </summary>
- None = 0,
-
- /// <summary>
- /// The display is oriented in a natural position.
- /// </summary>
- Portrait = 1,
-
- /// <summary>
- /// The display's left side is at the top.
- /// </summary>
- Landscape = 2,
-
- /// <summary>
- /// The display is upside down.
- /// </summary>
- PortraitFlipped = 4,
-
- /// <summary>
- /// The display's right side is at the top.
- /// </summary>
- LandscapeFlipped = 8
- }
-}
diff --git a/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs b/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs
index e7e1f24..6826073 100755..100644
--- a/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs
+++ b/Xamarin.Forms.Platform.Tizen/Native/MasterDetailPage.cs
@@ -295,10 +295,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native
if (behavior == MasterBehavior.SplitOnLandscape ||
behavior == MasterBehavior.SplitOnPortrait)
{
- var orientation = Forms.Context.MainWindow.CurrentOrientation;
+ var rotation = Forms.Context.MainWindow.Rotation;
- if (((orientation == DisplayOrientations.Landscape || orientation == DisplayOrientations.LandscapeFlipped) && behavior == MasterBehavior.SplitOnLandscape) ||
- ((orientation == DisplayOrientations.Portrait || orientation == DisplayOrientations.PortraitFlipped) && behavior == MasterBehavior.SplitOnPortrait))
+ if (((rotation == 90 || rotation == 270) && behavior == MasterBehavior.SplitOnLandscape) ||
+ ((rotation == 0 || rotation == 90) && behavior == MasterBehavior.SplitOnPortrait))
{
behavior = MasterBehavior.Split;
}
diff --git a/Xamarin.Forms.Platform.Tizen/Native/Window.cs b/Xamarin.Forms.Platform.Tizen/Native/Window.cs
deleted file mode 100644
index 3e982ae..0000000
--- a/Xamarin.Forms.Platform.Tizen/Native/Window.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using ElmSharp;
-using EWindow = ElmSharp.Window;
-using ELayout = ElmSharp.Layout;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- public class Window : EWindow
- {
- ELayout _layout;
- Conformant _conformant;
-
- /// <summary>
- /// Initializes a new instance of the Window class.
- /// </summary>
- public Window() : base("FormsWindow")
- {
- Initialize();
- }
-
- /// <summary>
- /// Notifies that the window has been closed.
- /// </summary>
- public event EventHandler Closed;
-
- /// <summary>
- /// Gets the current orientation.
- /// </summary>
- public DisplayOrientations CurrentOrientation
- {
- get
- {
- if (IsRotationSupported)
- {
- return GetDisplayOrientation();
- }
- else
- {
- return DisplayOrientations.None;
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the orientation of a rectangular screen.
- /// </summary>
- public DisplayOrientations AvailableOrientations
- {
- get
- {
- if (IsRotationSupported)
- {
- return (DisplayOrientations)AvailableRotations;
- }
- else
- {
- return DisplayOrientations.None;
- }
- }
- set
- {
- if (IsRotationSupported)
- {
- AvailableRotations = (DisplayRotation)value;
- }
- }
- }
-
- public ELayout BaseLayout
- {
- get
- {
- return _layout;
- }
-
- private set
- {
- _layout = value;
- }
- }
-
- /// <summary>
- /// Sets the main page of Window.
- /// </summary>
- /// <param name="content">ElmSharp.EvasObject type page to be set.</param>
- public void SetMainPage(EvasObject content)
- {
- _layout.SetContent(content);
- }
-
- void Initialize()
- {
- // events
- Deleted += (sender, e) =>
- {
- Closed?.Invoke(this, EventArgs.Empty);
- };
- CloseRequested += (sender, e) =>
- {
- Unrealize();
- };
-
- Active();
- AutoDeletion = false;
- Show();
-
- _conformant = new Conformant(this);
- _conformant.Show();
-
- // Create the base (default) layout for the application
- _layout = new ELayout(_conformant);
- _layout.SetTheme("layout", "application", "default");
- _layout.Show();
-
- _conformant.SetContent(_layout);
- BaseLayout = _layout;
- AvailableOrientations = DisplayOrientations.Portrait | DisplayOrientations.Landscape | DisplayOrientations.PortraitFlipped | DisplayOrientations.LandscapeFlipped;
- }
- DisplayOrientations GetDisplayOrientation()
- {
- switch (Rotation)
- {
- case 0:
- return Native.DisplayOrientations.Portrait;
-
- case 90:
- return Native.DisplayOrientations.Landscape;
-
- case 180:
- return Native.DisplayOrientations.PortraitFlipped;
-
- case 270:
- return Native.DisplayOrientations.LandscapeFlipped;
-
- default:
- return Native.DisplayOrientations.None;
- }
- }
- }
-}
diff --git a/Xamarin.Forms.Platform.Tizen/Platform.cs b/Xamarin.Forms.Platform.Tizen/Platform.cs
index 8111a83..b3cd88a 100644
--- a/Xamarin.Forms.Platform.Tizen/Platform.cs
+++ b/Xamarin.Forms.Platform.Tizen/Platform.cs
@@ -49,7 +49,7 @@ namespace Xamarin.Forms.Platform.Tizen
_naviframe.SetWeight(1.0, 1.0);
_naviframe.Show();
_naviframe.AnimationFinished += NaviAnimationFinished;
- Forms.Context.MainWindow.SetMainPage(_naviframe);
+ Forms.Context.BaseLayout.SetContent(_naviframe);
}
~Platform()