Implementation of outerview and closebutton in SharePanel 94/318094/2
authorMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Tue, 24 Sep 2024 11:05:34 +0000 (17:05 +0600)
committerMd. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
Wed, 25 Sep 2024 04:16:01 +0000 (10:16 +0600)
[Problem] N/A

[Cause & Measure]
 Cause : N/A
 Measure : Implemented outerview and closebutton in SharePanel.

Change-Id: I1eabff44ccf5cd239e2a3e761d92554cc068e38e
Signed-off-by: Md. Shahrukh Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <shahrukh.i@samsung.com>
SharePanel/SharePanel/Common/AppConstants.cs
SharePanel/SharePanel/Common/PropertyNotifier.cs [new file with mode: 0644]
SharePanel/SharePanel/ViewModels/SharePanelViewModel.cs [new file with mode: 0644]
SharePanel/SharePanel/Views/MainView.cs
SharePanel/SharePanel/Views/SharePanelView.cs
SharePanel/SharePanel/res/Images/close.png [new file with mode: 0644]

index cc7cc0ee245b761d0cc36cd7b97fd061ef5906d7..436ec154413244e739a08bdd16b5c5e0db21e238 100644 (file)
@@ -16,9 +16,17 @@ namespace SharePanel.Common
 
         public static Size SharePanelSize = new Size2D(SharePanelWidth, SharePanelHeight);
         public static int SharePanelPositionY = WindowHeight - SharePanelHeight - TaskBarHeight;
-
+        public static int TopViewWidth = WindowWidth;
+        public static int TopViewHeight = (int)((90 * WindowHeight) / 1080);
+        public static int SharePanelCornerRadius = (28 * WindowHeight) / 1080;
+        public static int HeaderWidth = (WindowWidth * 9) / 10;
+        public static float TextPointSize = (14.5f * 1080) / WindowHeight;
         public static Size OuterViewSize = new Size2D(OuterViewWidth, OuterViewHeight);
 
+        public static int CloseButtonWidth = WindowWidth / 10;
+        public static int CloseButtonHeight = (int)((80 * WindowHeight) / 1080);
+        public static Size CloseButtonSize = new Size2D(CloseButtonWidth, CloseButtonHeight);
+
         public static string KEY_BACK = "XF86Back";
         public static string KEY_ESCAPE = "Escape";
     }
diff --git a/SharePanel/SharePanel/Common/PropertyNotifier.cs b/SharePanel/SharePanel/Common/PropertyNotifier.cs
new file mode 100644 (file)
index 0000000..11f5138
--- /dev/null
@@ -0,0 +1,28 @@
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace SharePanel.Common
+{
+    class PropertyNotifier : INotifyPropertyChanged
+    {
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
+        {
+            if (Equals(storage, value))
+            {
+                return false;
+            }
+
+            storage = value;
+            OnPropertyChanged(propertyName);
+            Logger.Info(propertyName + " Set to " + value);
+            return true;
+        }
+
+        protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+        }
+    }
+}
\ No newline at end of file
diff --git a/SharePanel/SharePanel/ViewModels/SharePanelViewModel.cs b/SharePanel/SharePanel/ViewModels/SharePanelViewModel.cs
new file mode 100644 (file)
index 0000000..70fc68d
--- /dev/null
@@ -0,0 +1,38 @@
+using SharePanel.Common;
+using System.Collections;
+using System.Collections.Generic;
+using System.Windows.Input;
+using Tizen.Applications;
+using Tizen.NUI.Binding;
+
+namespace SharePanel.ViewModels
+{
+    internal class SharePanelViewModel: PropertyNotifier
+    {
+        private ICommand closeClicked;
+        private IEnumerable itemModelList;
+
+        public SharePanelViewModel()
+        {
+            CloseClicked = new Command(onCloseClicked);
+        }
+
+        public ICommand CloseClicked
+        {
+            get => closeClicked;
+            set => SetProperty(ref closeClicked, value);
+        }
+
+        public IEnumerable ItemModelList
+        {
+            get => itemModelList;
+            set => SetProperty(ref itemModelList, value);
+        }
+
+        public void onCloseClicked()
+        {
+            Logger.Info("Closing Share Panel");
+            Application.Current.Exit();
+        }
+    }
+}
index d6d82bb46078ef2b9cb5a4b6aeeac8c4a6fd57fa..931090e6258f676f41042b942e29f2fd76a92591 100644 (file)
@@ -1,6 +1,9 @@
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 using SharePanel.Common;
+using Tizen.NUI.Components;
+using SharePanel.ViewModels;
+using Tizen.NUI.Binding;
 
 namespace SharePanel.Views
 {
@@ -8,6 +11,7 @@ namespace SharePanel.Views
     {
         private SharePanelView sharePanelView;
         private View outerView;
+        private SharePanelViewModel viewModel;
 
         public MainView()
         {
@@ -23,7 +27,7 @@ namespace SharePanel.Views
 
         private void AddOuterView()
         {
-            Logger.Debug("AddOuterView()");
+            Logger.Debug("AddOuterView(): Outer View Created");
 
             outerView = new View()
             {
@@ -41,10 +45,22 @@ namespace SharePanel.Views
 
         private void AddSharePanel()
         {
-            Logger.Debug("AddSharePanel()");
+            Logger.Debug("AddSharePanel(): Share Panel View Created");
 
+            viewModel = new SharePanelViewModel();
             sharePanelView = new SharePanelView();
+            sharePanelView.BindingContext = viewModel;
+
+            sharePanelView.closeButton.SetBinding(Control.CommandProperty, "CloseClicked");
+
             Add(sharePanelView);
         }
+
+        private bool OnOuterViewTouched(object sender, TouchEventArgs e)
+        {
+            Logger.Info("Outer View Touched");
+            viewModel.onCloseClicked();
+            return true;
+        }
     }
 }
\ No newline at end of file
index 259675719fc98dbf74ab0434cb5a2b8e98c830f8..d71cc76917935c51a44fad985820aee641f84b29 100644 (file)
@@ -1,22 +1,93 @@
 using Tizen.NUI;
+using Tizen.NUI.Components;
 using Tizen.NUI.BaseComponents;
 using SharePanel.Common;
+using System.Reflection.PortableExecutable;
 
 namespace SharePanel.Views
 {
     internal class SharePanelView : View
     {
+        private View topBar;
+        private View headerView;
+        public Button closeButton;
+        public TextLabel header;
+
         public SharePanelView()
         {
             Size = AppConstants.SharePanelSize;
             BackgroundColor = Color.White;
             PositionY = AppConstants.SharePanelPositionY;
+            CornerRadius = AppConstants.SharePanelCornerRadius;
 
             Layout = new LinearLayout
             {
                 LinearOrientation = LinearLayout.Orientation.Vertical,
                 HorizontalAlignment = HorizontalAlignment.Center,
             };
+
+            AddTopBar();
+        }
+
+        public void AddTopBar()
+        {
+            topBar = new View
+            {
+                BackgroundColor = Color.White,
+                WidthSpecification = AppConstants.TopViewWidth,
+                HeightSpecification = AppConstants.TopViewHeight,
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Horizontal,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                },
+                CornerRadius = AppConstants.SharePanelCornerRadius
+            };
+            AddHeaderView();
+            AddCloseButton();
+            Add(topBar);
+        }
+
+        public void AddHeaderView()
+        {
+            headerView = new View()
+            {
+                WidthSpecification = AppConstants.HeaderWidth,
+                HeightSpecification = AppConstants.TopViewHeight,
+
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Horizontal,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center
+                }
+            };
+
+            Logger.Debug("height under headerview is " + AppConstants.TopViewHeight);
+
+            header = new TextLabel()
+            {
+                Text = "Share",
+                PointSize = AppConstants.TextPointSize,
+                Margin = new Extents((ushort)AppConstants.CloseButtonWidth, 0, 0, 0)
+            };
+            Logger.Debug("Header pointsize is " + header.PointSize);
+            headerView.Add(header);
+
+            topBar.Add(headerView);
+        }
+
+        public void AddCloseButton()
+        {
+            closeButton = new Button()
+            {
+                IconURL = "*Resource*/Images/close.png",
+                Size = AppConstants.CloseButtonSize,
+                CornerRadius = AppConstants.SharePanelCornerRadius,
+                BackgroundColor = Color.White,
+                CellHorizontalAlignment = HorizontalAlignmentType.Right
+            };
+            topBar.Add(closeButton);
         }
     }
 }
\ No newline at end of file
diff --git a/SharePanel/SharePanel/res/Images/close.png b/SharePanel/SharePanel/res/Images/close.png
new file mode 100644 (file)
index 0000000..766201e
Binary files /dev/null and b/SharePanel/SharePanel/res/Images/close.png differ