Made Taskbar Scrollable 68/313968/8 accepted/tizen_unified_dev accepted/tizen/unified/20240718.143622 accepted/tizen/unified/dev/20240724.110153 accepted/tizen/unified/toolchain/20240812.131500 accepted/tizen/unified/x/20240719.012634 accepted/tizen/unified/x/asan/20240813.225735
authorMobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
Wed, 3 Jul 2024 09:40:29 +0000 (15:40 +0600)
committerMobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
Mon, 15 Jul 2024 12:34:38 +0000 (18:34 +0600)
[Problem] Taskbar was not scrollable, so adding more apps was inconvenient.

[Cause & Measure]
 Cause : Using Regular View With LinearLayout
 Measure : Using ScrollableBase instead of View

Change-Id: Ib32b7f0730337b3912d17a8afe0f78cf289d0639
Signed-off-by: Mobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
TaskBar/Common/Resources.cs
TaskBar/ViewModels/ApplicationsViewModel.cs
TaskBar/Views/BaseView.cs
TaskBar/Views/MainView.cs
packaging/org.tizen.taskbar-1.0.0.tpk

index 6ee20eb56b80de9c9e2f7aa8ab5fd15db94abd80..6cb40bac5347eeb1a8f973b94b9f0ee38577b6b8 100644 (file)
@@ -49,6 +49,8 @@ namespace TaskBar.Common
         public static Color DisabledMenuItemTextColor => IsLightTheme ? new Color("#CACACA") : new Color("#666666");
         public static Color RunningAppBackgroundColor => IsLightTheme ? new Color("rgba(255, 230, 214, 0.5)") : new Color("rgba(255, 255, 255, 0.08)");
 
+        public const int MaxAppPinnedCount = 128;
+
         public static string AddButtonIconURL => GetImagePath() + (IsLightTheme ? "light" : "dark") + "/add.png";
         public static string AppIndicatorURL => GetImagePath() + (IsLightTheme ? "light" : "dark") + "/indicator.png";
 
index 7c5979ce0c6d4a9191da9f0a9addc98ec2a56277..e849bf34fe17691572ed3773427b21fd16aa7d51 100644 (file)
@@ -31,7 +31,7 @@ namespace TaskBar.ViewModels
         Dictionary<string, int> pinnedAppsInfo;
         List<string> allAppsInfo;
         Dictionary<string, AppInfoModel> appInfoModelDictionary;
-        private const int maxPinnedApps = 12;
+        private const int maxPinnedApps = Resources.MaxAppPinnedCount;
 
         public ApplicationsViewModel()
         {
index 58ebc4d593cab293360334f95cba2a0b150ea390..becc618c56e74b40e99ef6adc083039da8f5f63d 100644 (file)
@@ -49,6 +49,7 @@ namespace TaskBar.Views
         defaultValueCreator: (bindable) => (bindable as BaseView).appList);
 
         public event Action<AppItemView, bool> MenuUpdated;
+        public event Action<BaseView, int> AppListUpdated;
 
         public BaseView()
         {
@@ -104,6 +105,8 @@ namespace TaskBar.Views
                 return;
             }
 
+            int diff = apps.Count;
+
             foreach (AppItemView item in apps)
             {
                 item.BindingContext = null;
@@ -127,6 +130,10 @@ namespace TaskBar.Views
                 appItemView.MoreMenuAdded += (AppItemView sender) => { MenuUpdated?.Invoke(sender, true); };
                 appItemView.MoreMenuRemoved += (AppItemView sender) => { MenuUpdated?.Invoke(sender, false); };
             }
+
+            diff = apps.Count - diff;
+            AppListUpdated?.Invoke(this, diff);
+
             Tizen.Log.Info(Resources.LogTag, "Buttons Added");
         }
 
index e9fd9ceea4e1728b6d80299aa12cb7576ded3ed2..17a46ee79b1c832ae4f52397825addd60e9466ac 100644 (file)
@@ -22,11 +22,11 @@ using Tizen.NUI.Components;
 using TaskBar.Common;
 using TaskBar.Core;
 using TaskBar.ViewModels;
-using TaskBar.TextResources;
+using System.Linq;
 
 namespace TaskBar.Views
 {
-    class MainView : View
+    class MainView : ScrollableBase
     {
         private ApplicationsViewModel applicationsViewModel;
         private QuickAccessViewModel quickAccessViewModel;
@@ -40,6 +40,7 @@ namespace TaskBar.Views
         private int moreMenuPositionY;
         private LongPressGestureDetector addAppsLongPressDetector;
         private BaseView quickAccessView;
+        private View paddToCenter;
 
         private const int AddButtonSize = 48;
 
@@ -56,11 +57,24 @@ namespace TaskBar.Views
                 VerticalAlignment = VerticalAlignment.Center,
                 CellPadding = new Size2D(8, 0).SpToPx(),
             };
+            ScrollingDirection = Direction.Horizontal;
+            HideScrollbar = false;
+            FadeScrollbar = false;
+            setScrollBar();
+
+            paddToCenter = new View()
+            {
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+                WidthSpecification = 16.SpToPx(),
+            };
+            Add(paddToCenter);
+
             applicationsViewModel = new ApplicationsViewModel();
             applicationsView = new BaseView();
             Add(applicationsView);
             applicationsView.BindingContext = applicationsViewModel;
             applicationsView.MenuUpdated += OnMenuUpdated;
+            applicationsView.AppListUpdated += OnAppListUpdate;
             applicationsView.SetBinding(BaseView.AppListProperty, "ButtonsInfo");
 
             CreateAddPinnedAppsView();
@@ -71,9 +85,79 @@ namespace TaskBar.Views
             Add(quickAccessView);
             quickAccessView.BindingContext = quickAccessViewModel;
             quickAccessView.MenuUpdated += OnMenuUpdated;
+            quickAccessView.AppListUpdated += OnAppListUpdate;
             quickAccessView.SetBinding(BaseView.AppListProperty, "ButtonsInfo");
             UpdateTheme();
             ThemeManager.ThemeChanged += OnThemeUpdated;
+
+            applicationsView.Relayout += (s, e) =>
+            {
+                OnAppListUpdate(this, 0);
+            };
+            quickAccessView.Relayout += (s, e) =>
+            {
+                OnAppListUpdate(this, 0);
+            };
+            Window.Instance.OrientationChanged += (s, e) =>
+            {
+                OnAppListUpdate(this, 0);
+            };
+        }
+
+        private void setScrollBar()
+        {
+            var scrollbarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.Scrollbar") as ScrollbarStyle;
+            scrollbarStyle.ThumbColor = new Color("#FFFEFE");
+            scrollbarStyle.TrackPadding = new Extents(0, 0, 0, 3).SpToPx();
+            scrollbarStyle.Opacity = 0.35f;
+            scrollbarStyle.TrackThickness = 4f;
+            scrollbarStyle.ThumbColor = new Color("#FFFEFE");
+            scrollbarStyle.CornerRadius = new Vector4(4, 4, 4, 4);
+            Scrollbar = new Scrollbar(scrollbarStyle);
+
+            var thumb = Scrollbar.Children.Skip(1).FirstOrDefault() as ImageView;
+
+            if (thumb != null)
+            {
+                thumb.Opacity = 0.7f;
+                thumb.SizeHeight = 2f;
+                thumb.SizeWidth = 4f;
+                thumb.CornerRadius = new Vector4(4.5f, 4.5f, 4.5f, 4.5f);
+                thumb.BoxShadow = new Shadow(8.0f, new Color(0.0f, 0.0f, 0.0f, 0.16f), new Vector2(0.0f, 2.0f));
+            }
+
+            scrollbarStyle.Dispose();
+        }
+
+        private void OnAppListUpdate(View view, int diff)
+        {
+            if (applicationsView == null || quickAccessView == null || addPinnedAppsButton == null)
+            {
+                return;
+            }
+
+            int taskBarWindowSize = Window.Instance.WindowSize.Width.PxToSp();
+            int appsViewSize = (int) (applicationsView.SizeWidth.PxToSp() + diff * 48);
+            int quickViewSize = (int) quickAccessView.SizeWidth.PxToSp();
+            int addButonSize = (int) addPinnedAppsView.SizeWidth.PxToSp();
+
+            int remaining = taskBarWindowSize - appsViewSize - quickViewSize - addButonSize;
+
+            if(remaining < 16) remaining = 16;
+
+            paddToCenter.SizeWidth = (remaining / 2).SpToPx();
+
+            bool flag = (taskBarWindowSize - addButonSize - 16) <= (appsViewSize + quickViewSize);
+            Tizen.Log.Debug(Resources.LogTag, $"flag: {flag}");
+
+            if (flag)
+            {
+                CornerRadius = new Vector4(0, 0, 0, 0);
+            }
+            else
+            {
+                CornerRadius = new Vector4(24, 24, 0, 0);
+            }
         }
 
         private void OnMenuUpdated(View sender, bool isMenuAdded)
@@ -100,6 +184,7 @@ namespace TaskBar.Views
         private void OnThemeUpdated(object sender, ThemeChangedEventArgs e)
         {
             UpdateTheme();
+            setScrollBar();
         }
 
         private void UpdateTheme()
index 27edee417e7bcf9d2ed204d7af96bd113ab3349f..a5340ff06d6b467b3963de7b7e45532cd83802cc 100644 (file)
Binary files a/packaging/org.tizen.taskbar-1.0.0.tpk and b/packaging/org.tizen.taskbar-1.0.0.tpk differ