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;
private int moreMenuPositionY;
private LongPressGestureDetector addAppsLongPressDetector;
private BaseView quickAccessView;
+ private View paddToCenter;
private const int AddButtonSize = 48;
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();
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)
private void OnThemeUpdated(object sender, ThemeChangedEventArgs e)
{
UpdateTheme();
+ setScrollBar();
}
private void UpdateTheme()