TizenRefApp-8628 Implement project skeleton for Call app 60/137760/4
authorRuslan Zakharov <r.zakharov@samsung.com>
Fri, 7 Jul 2017 10:27:10 +0000 (13:27 +0300)
committerRuslan Zakharov <r.zakharov@samsung.com>
Tue, 11 Jul 2017 14:18:25 +0000 (17:18 +0300)
Added common Controls and Helpers

Change-Id: Ic157409f60bf643d5186f22460ae6ecdabdb32ec

CallApp.Tizen/CallApp.Tizen.csproj
CallApp.Tizen/Common/Controls/CustomGrid.xaml [new file with mode: 0644]
CallApp.Tizen/Common/Controls/CustomGrid.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Common/Controls/CustomImage.xaml [new file with mode: 0644]
CallApp.Tizen/Common/Controls/CustomImage.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Common/Controls/GesturesContainer.xaml [new file with mode: 0644]
CallApp.Tizen/Common/Controls/GesturesContainer.xaml.cs [new file with mode: 0644]
CallApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs [new file with mode: 0644]
CallApp.Tizen/Common/Helpers/BaseModel.cs [new file with mode: 0644]
CallApp.Tizen/Common/Helpers/Logger.cs [new file with mode: 0644]
CallApp.Tizen/Common/Helpers/PageNavigator.cs [new file with mode: 0644]

index 4e5aa62..bd9b357 100644 (file)
   <ItemGroup>
     <Compile Include="CallApp.cs" />
     <Compile Include="CallApp.Tizen.cs" />
+    <Compile Include="Common\Controls\CustomGrid.xaml.cs">
+      <DependentUpon>CustomGrid.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\Controls\CustomImage.xaml.cs">
+      <DependentUpon>CustomImage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\Controls\GesturesContainer.xaml.cs">
+      <DependentUpon>GesturesContainer.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Common\Controls\Renderers\CustomImageRenderer.cs" />
+    <Compile Include="Common\Helpers\BaseModel.cs" />
+    <Compile Include="Common\Helpers\Logger.cs" />
+    <Compile Include="Common\Helpers\PageNavigator.cs" />
     <Compile Include="loc\loc.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
       <LastGenOutput>loc.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Common\Controls\CustomGrid.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Common\Controls\CustomImage.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Common\Controls\GesturesContainer.xaml">
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
                Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/CallApp.Tizen/Common/Controls/CustomGrid.xaml b/CallApp.Tizen/Common/Controls/CustomGrid.xaml
new file mode 100644 (file)
index 0000000..c088543
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<Grid xmlns="http://xamarin.com/schemas/2014/forms"
+      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+      x:Class="CallApp.Tizen.Common.Controls.CustomGrid"
+      ColumnSpacing="0"
+      RowSpacing="0">
+
+</Grid>
\ No newline at end of file
diff --git a/CallApp.Tizen/Common/Controls/CustomGrid.xaml.cs b/CallApp.Tizen/Common/Controls/CustomGrid.xaml.cs
new file mode 100644 (file)
index 0000000..dafc716
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 CallApp.Tizen.Common.Controls
+{
+    /// <summary>
+    /// Extension of Xamarin Grid, with support:
+    /// Without Column spacing by default
+    /// Without Row spacing by default
+    /// </summary>
+    public partial class CustomGrid : Grid
+    {
+        public CustomGrid()
+        {
+            InitializeComponent();
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Controls/CustomImage.xaml b/CallApp.Tizen/Common/Controls/CustomImage.xaml
new file mode 100644 (file)
index 0000000..9f3432c
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<Image xmlns="http://xamarin.com/schemas/2014/forms"
+       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+       x:Class="CallApp.Tizen.Common.Controls.CustomImage">
+
+</Image>
\ No newline at end of file
diff --git a/CallApp.Tizen/Common/Controls/CustomImage.xaml.cs b/CallApp.Tizen/Common/Controls/CustomImage.xaml.cs
new file mode 100644 (file)
index 0000000..6a443eb
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 CallApp.Tizen.Common.Controls
+{
+    /// <summary>
+    /// Extension of Xamarin Image, with support:
+    /// Color blending
+    /// </summary>
+    public partial class CustomImage : Image
+    {
+        public CustomImage()
+        {
+            InitializeComponent();
+        }
+
+        /// <summary>
+        /// Color for blending
+        /// </summary>
+        public static readonly BindableProperty BlendingColorProperty = BindableProperty.Create(
+            "BlendingColor",
+            typeof(Color),
+            typeof(CustomImage),
+            Color.White);
+
+        public Color BlendingColor
+        {
+            get
+            {
+                return (Color)GetValue(BlendingColorProperty);
+            }
+            set
+            {
+                SetValue(BlendingColorProperty, value);
+            }
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Controls/GesturesContainer.xaml b/CallApp.Tizen/Common/Controls/GesturesContainer.xaml
new file mode 100644 (file)
index 0000000..210face
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="CallApp.Tizen.Common.Controls.GesturesContainer">
+
+</ContentView>
\ No newline at end of file
diff --git a/CallApp.Tizen/Common/Controls/GesturesContainer.xaml.cs b/CallApp.Tizen/Common/Controls/GesturesContainer.xaml.cs
new file mode 100644 (file)
index 0000000..5a0b303
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 CallApp.Tizen.Common.Controls
+{
+    /// <summary>
+    /// Container that performs freeform gestures. Can be wrapped around UI element
+    /// This class is workaround, until is not fixed http://suprem.sec.samsung.net/jira/browse/TCAPI-2519
+    /// </summary>
+    public partial class GesturesContainer : ContentView
+    {
+        /// <summary>
+        /// Event that is raised when the pan gesture changes
+        /// </summary>
+        public event EventHandler<PanUpdatedEventArgs> PanUpdated = delegate { };
+
+        private readonly PanGestureRecognizer _pan = new PanGestureRecognizer();
+
+        public GesturesContainer()
+        {
+            InitializeComponent();
+
+            // Need to use last event during loading control. At this case it's a SizeChanged event
+            SizeChanged += OnSizeChanged;
+            _pan.PanUpdated += OnPanUpdated;
+        }
+
+        private void OnSizeChanged(object sender, EventArgs e)
+        {
+            if (!GestureRecognizers.Contains(_pan))
+            {
+                // TODO: May contain various gesture recognizers
+                GestureRecognizers.Add(_pan);
+            }
+        }
+
+        private void OnPanUpdated(object sender, PanUpdatedEventArgs e)
+        {
+            PanUpdated(sender, e);
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs b/CallApp.Tizen/Common/Controls/Renderers/CustomImageRenderer.cs
new file mode 100644 (file)
index 0000000..ec00679
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 CallApp.Tizen.Common.Controls;
+using CallApp.Tizen.Common.Controls.Renderers;
+using System.ComponentModel;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+
+[assembly: ExportRenderer(typeof(CustomImage), typeof(CustomImageRenderer))]
+namespace CallApp.Tizen.Common.Controls.Renderers
+{
+    /// <summary>
+    /// A renderer for CustomImage
+    /// </summary>
+    class CustomImageRenderer : ImageRenderer
+    {
+        /// <summary>
+        /// <see cref="ImageRenderer.OnElementChanged(ElementChangedEventArgs{Image})" />
+        /// </summary>
+        protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
+        {
+            base.OnElementChanged(e);
+
+            if (Control == null || Element == null)
+            {
+                return;
+            }
+
+            applyBlendingColor();
+        }
+
+        /// <summary>
+        /// <see cref="ImageRenderer.OnElementPropertyChanged(object, PropertyChangedEventArgs)" />
+        /// </summary>
+        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            base.OnElementPropertyChanged(sender, e);
+
+            // TODO: This is not working, seems a bug
+            /*
+            if (e.PropertyName == CustomImage.BlendingColorProperty.PropertyName)
+            {
+                applyBlendingColor();
+            }
+            */
+
+            applyBlendingColor();
+        }
+
+        private void applyBlendingColor()
+        {
+            Control.Color = ((CustomImage)Element).BlendingColor.ToNative();
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Helpers/BaseModel.cs b/CallApp.Tizen/Common/Helpers/BaseModel.cs
new file mode 100644 (file)
index 0000000..137ca91
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace CallApp.Tizen.Common.Helpers
+{
+    /// <summary>
+    /// Base class for ViewModels or Models, implements INotifyPropertyChanged interface
+    /// </summary>
+    public class BaseModel : INotifyPropertyChanged
+    {
+        /// <summary>
+        /// Property changed event
+        /// </summary>
+        public event PropertyChangedEventHandler PropertyChanged = delegate { };
+
+        /// <summary>
+        /// Raise PropertyChanged event
+        /// </summary>
+        /// <param name="propertyName">Changed property name</param>
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Helpers/Logger.cs b/CallApp.Tizen/Common/Helpers/Logger.cs
new file mode 100644 (file)
index 0000000..8aa8838
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 System.Runtime.CompilerServices;
+
+namespace CallApp.Tizen.Common.Helpers
+{
+    static class Logger
+    {
+        public static void Debug(string message, [CallerFilePath] string file = "", [CallerMemberName] string method = "")
+        {
+            Console.WriteLine("{0}, {1}, {2}", file, method, message);
+        }
+    }
+}
diff --git a/CallApp.Tizen/Common/Helpers/PageNavigator.cs b/CallApp.Tizen/Common/Helpers/PageNavigator.cs
new file mode 100644 (file)
index 0000000..3ccc54f
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * 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 CallApp.Tizen.Common.Helpers
+{
+    /// <summary>
+    /// Helper with navigation logics through pages
+    /// </summary>
+    class PageNavigator
+    {
+        /// <summary>
+        /// Navigate to new page in modal state
+        /// </summary>
+        /// <param name="page">Page to navigate</param>
+        public static void NavigateModal(Page page)
+        {
+            if (Application.Current.MainPage != null)
+            {
+                Application.Current.MainPage.Navigation.PushModalAsync(page);
+            }
+            else
+            {
+                Logger.Debug("Application.Current.MainPage is null");
+            }
+        }
+    }
+}