From: Mobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics Date: Wed, 3 Jul 2024 09:40:29 +0000 (+0600) Subject: Made Taskbar Scrollable X-Git-Tag: accepted/tizen/unified/20240718.143622^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ee98fe15c0cbad8c9c3a63c21a507189f3fe7f4;p=profile%2Fiot%2Fapps%2Fdotnet%2Ftaskbar.git Made Taskbar Scrollable [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 --- diff --git a/TaskBar/Common/Resources.cs b/TaskBar/Common/Resources.cs index 6ee20eb..6cb40ba 100644 --- a/TaskBar/Common/Resources.cs +++ b/TaskBar/Common/Resources.cs @@ -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"; diff --git a/TaskBar/ViewModels/ApplicationsViewModel.cs b/TaskBar/ViewModels/ApplicationsViewModel.cs index 7c5979c..e849bf3 100644 --- a/TaskBar/ViewModels/ApplicationsViewModel.cs +++ b/TaskBar/ViewModels/ApplicationsViewModel.cs @@ -31,7 +31,7 @@ namespace TaskBar.ViewModels Dictionary pinnedAppsInfo; List allAppsInfo; Dictionary appInfoModelDictionary; - private const int maxPinnedApps = 12; + private const int maxPinnedApps = Resources.MaxAppPinnedCount; public ApplicationsViewModel() { diff --git a/TaskBar/Views/BaseView.cs b/TaskBar/Views/BaseView.cs index 58ebc4d..becc618 100644 --- a/TaskBar/Views/BaseView.cs +++ b/TaskBar/Views/BaseView.cs @@ -49,6 +49,7 @@ namespace TaskBar.Views defaultValueCreator: (bindable) => (bindable as BaseView).appList); public event Action MenuUpdated; + public event Action 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"); } diff --git a/TaskBar/Views/MainView.cs b/TaskBar/Views/MainView.cs index e9fd9ce..17a46ee 100644 --- a/TaskBar/Views/MainView.cs +++ b/TaskBar/Views/MainView.cs @@ -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() diff --git a/packaging/org.tizen.taskbar-1.0.0.tpk b/packaging/org.tizen.taskbar-1.0.0.tpk index 27edee4..a5340ff 100644 Binary files a/packaging/org.tizen.taskbar-1.0.0.tpk and b/packaging/org.tizen.taskbar-1.0.0.tpk differ