public CustomBorder(Size2D screenSize)
{
ResizePolicy = Window.BorderResizePolicyType.Free;
- float minWidthRatio = 704.0f / 1920;
- float minHeightRatio = 436.0f / 1080;
- int minWidth = (int)(screenSize.Width * minWidthRatio);
- int minHeight = (int)(screenSize.Height * minHeightRatio);
+ int minWidth = (int)(screenSize.Width * AppConstants.MinWidthRatio);
+ int minHeight = (int)(screenSize.Height * AppConstants.MinHeightRatio);
MinSize = new Size2D(minWidth, minHeight);
}
public void UpdateMinSize(Size2D screenSize)
{
- float minWidthRatio = 704.0f / 1920;
- float minHeightRatio = 436.0f / 1080;
- int minWidth = (int)(screenSize.Width * minWidthRatio);
- int minHeight = (int)(screenSize.Height * minHeightRatio);
+ int minWidth = (int)(screenSize.Width * AppConstants.MinWidthRatio);
+ int minHeight = (int)(screenSize.Height * AppConstants.MinHeightRatio);
MinSize = new Size2D(minWidth, minHeight);
}
{
return false;
}
- BorderLineThickness = (uint)BorderThickness.SpToPx();
- bottomView.HeightSpecification = BottomViewHeight.SpToPx();
+ BorderLineThickness = (uint)BorderThickness;
+ bottomView.HeightSpecification = BottomViewHeight;
bottomView.Layout = new RelativeLayout()
{
- Padding = new Extents(0, 24, 0, 0).SpToPx(),
+ Padding = new Extents(0, 24, 0, 0),
};
minimalizeIcon = new ImageView()
{
- Size2D = IconSize.SpToPx(),
+ Size2D = IconSize,
ResourceUrl = Resources.GetImagePath() + "/minimalize.png",
AccessibilityHighlightable = true,
};
maximalizeIcon = new ImageView()
{
- Size2D = IconSize.SpToPx(),
+ Size2D = IconSize,
ResourceUrl = Resources.GetImagePath() + "/maximalize.png",
AccessibilityHighlightable = true,
};
closeIcon = new ImageView()
{
- Size2D = IconSize.SpToPx(),
+ Size2D = IconSize,
ResourceUrl = Resources.GetImagePath() + "/close.png",
AccessibilityHighlightable = true,
};
leftCornerIcon = new ImageView()
{
- Size2D = IconSize.SpToPx(),
+ Size2D = IconSize,
ResourceUrl = Resources.GetImagePath() + "/leftCorner.png",
AccessibilityHighlightable = true,
};
{
e.Name = "Resize";
};
- minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
- maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
- closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
- leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+ minimalizeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+ maximalizeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+ closeIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
+ leftCornerIcon.SetAccessibilityReadingInfoTypes(AccessibilityReadingInfoTypes.Name);
return true;
}
return;
}
borderView.CornerRadiusPolicy = VisualTransformPolicyType.Absolute;
- borderView.CornerRadius = BorderCornerRadius.SpToPx();
+ borderView.CornerRadius = BorderCornerRadius;
if (maximalizeIcon == null)
{
using Tizen.NUI.Binding;
using Tizen.NUI.Components;
using Notifications.Common;
+using Notifications.ViewModels;
+using System.Windows.Input;
+using System.Collections;
+using Notifications.Models;
namespace Notifications.Views
{
+ static class ViewBindings
+ {
+ public static BindingProperty<BaseView, bool> IsContentAvailableProperty { get; } = new BindingProperty<BaseView, bool>
+ {
+ Setter = (v, value) => v.IsContentAvailable = value,
+ };
+
+ public static BindingProperty<View, ICommand> CommandProperty { get; } = new BindingProperty<View, ICommand>
+ {
+ Setter = (v, value) => ((Control)v).Command = value,
+ };
+ }
+
+ static class RecyclerViewBindings
+ {
+ public static BindingProperty<RecyclerView, IEnumerable> ItemsSourceProperty { get; } = new BindingProperty<RecyclerView, IEnumerable>
+ {
+ Setter = (v, value) => v.ItemsSource = value,
+ };
+ }
+
+ static class CollectionViewBindings
+ {
+ public static BindingProperty<CollectionView, ICommand> SelectionChangedCommandProperty { get; } = new BindingProperty<CollectionView, ICommand>
+ {
+ Setter = (v, value) => v.SelectionChangedCommand = value,
+ };
+ }
+
+ static class ButtonBindings
+ {
+ public static BindingProperty<Button, bool> IsSelectedProperty { get; } = new BindingProperty<Button, bool>
+ {
+ Setter = (v, value) => v.IsSelected = value,
+ };
+
+ public static BindingProperty<Button, string> TextProperty { get; } = new BindingProperty<Button, string>
+ {
+ Setter = (v, value) => v.Text = value,
+ };
+
+ public static BindingProperty<Button, ICommand> CommandProperty { get; } = new BindingProperty<Button, ICommand>
+ {
+ Setter = (v, value) => v.Command = value,
+ };
+
+ public static BindingProperty<Button, bool> IsEnabledProperty { get; } = new BindingProperty<Button, bool>
+ {
+ Setter = (v, value) => v.IsEnabled = value,
+ };
+ }
+
class BaseView : View
{
public static BindableProperty IsContentAvailableProperty = BindableProperty.Create(nameof(IsContentAvailable), typeof(bool), typeof(BaseView), false, propertyChanged: (bindable, oldValue, newValue) =>
public BaseView() : base()
{
ThemeChangeSensitive = true;
- Size2D = Window.Instance.Size;
- CornerRadius = (AppConstants.BorderCornerRadius - AppConstants.BorderWindowPadding).SpToPx();
+ Size2D = NUIApplication.GetDefaultWindow().Size;
+ CornerRadius = (AppConstants.BorderCornerRadius - AppConstants.BorderWindowPadding);
Layout = new LinearLayout()
{
LinearOrientation = LinearLayout.Orientation.Vertical,
AddTopView();
UpdateContent();
- this.SetBinding(IsContentAvailableProperty, "IsNotificationsPresent");
+
+ var session = new BindingSession <NotificationsViewModel>();
+
+ this.BindingContextChanged += (sender, e) =>
+ {
+ if (this.BindingContext is NotificationsViewModel model)
+ {
+ session.ViewModel = model;
+ }
+ };
+ this.SetBinding(session, ViewBindings.IsContentAvailableProperty, "IsNotificationsPresent");
}
public void UpdateContent()
public void AddDetailContentView()
{
-
RemoveContent();
if (detailContentView == null)
{
- ButtonStyle buttonStyle = new ButtonStyle()
+ var text = new TextLabel()
{
BackgroundColor = Color.Transparent,
- Text = new TextLabelStyle()
- {
- BackgroundColor = Color.Transparent,
- MultiLine = true,
- FontFamily = "BreezeSans",
- HorizontalAlignment = HorizontalAlignment.Begin,
- },
- Margin = AppConstants.DetailContentMargin.SpToPx(),
- IsEnabled = true,
- IsSelectable = false,
+ MultiLine = true,
+ FontFamily = "BreezeSans",
+ HorizontalAlignment = HorizontalAlignment.Begin,
};
- detailContentView = new Button(buttonStyle)
+ detailContentView = new Button()
{
+ BackgroundColor = Color.Transparent,
+
+ Margin = AppConstants.DetailContentMargin,
+ IsEnabled = true,
+ IsSelectable = false,
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.WrapContent,
};
- detailContentView.SetBinding(Button.TextProperty, "DetailContent");
- detailContentView.SetBinding(Control.CommandProperty, "AppLaunchCommand");
+ detailContentView.Add(text);
+
+ var session = new BindingSession<NotificationsDetailViewModel>();
+
+ detailContentView.BindingContextChanged += (sender, e) =>
+ {
+ if (detailContentView.BindingContext is NotificationsDetailViewModel viewModel)
+ {
+ session.ViewModel = viewModel;
+ }
+ };
+
+ detailContentView.SetBinding(session, ButtonBindings.TextProperty, "DetailContent");
+ detailContentView.SetBinding(session, ButtonBindings.CommandProperty, "AppLaunchCommand");
}
Add(detailContentView);
}
public void UpdateSize()
{
- Size2D = Window.Instance.Size;
+ Size2D = NUIApplication.GetDefaultWindow().Size;
UpdateNotificationsViewItemTemplate();
}
{
ThemeChangeSensitive = true,
WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = AppConstants.HeaderHeight.SpToPx(),
+ HeightSpecification = AppConstants.HeaderHeight,
Layout = new RelativeLayout()
{
- Padding = AppConstants.HeaderPadding.SpToPx(),
+ Padding = AppConstants.HeaderPadding,
},
};
Add(topView);
private void AddTopViewElements()
{
- ButtonStyle buttonStyle = new ButtonStyle()
+ var buttonSize = AppConstants.BackButtonSize;
+
+ ImageView icon = new ImageView
{
BackgroundColor = Color.Transparent,
- Size = AppConstants.BackButtonSize.SpToPx(),
- Icon = new ImageViewStyle()
- {
- BackgroundColor = Color.Transparent,
- Size = AppConstants.BackButtonSize.SpToPx(),
- },
+ Size = buttonSize,
+ };
+
+ backButton = new Button()
+ {
+ BackgroundColor = Color.Transparent,
+ Size = buttonSize,
+
IsEnabled = true,
IsSelectable = false,
};
- backButton = new Button(buttonStyle);
+ backButton.Add(icon);
+
RelativeLayout.SetVerticalAlignment(backButton, RelativeLayout.Alignment.Center);
RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start);
- backButton.SetBinding(Control.CommandProperty, "BackCommand");
+
+ var session = new BindingSession<NotificationsDetailViewModel>();
+ backButton.BindingContextChanged += (sender, e) =>
+ {
+ if (backButton.BindingContext is NotificationsDetailViewModel model)
+ {
+ session.ViewModel = model;
+ }
+ };
+ backButton.SetBinding(session, ButtonBindings.CommandProperty, "BackCommand");
topView.Add(backButton);
titleText = new TextLabel()
TranslatableText = "IDS_ST_HEADER_NOTIFICATIONS",
HeightSpecification = LayoutParamPolicies.MatchParent,
VerticalAlignment = VerticalAlignment.Center,
- PixelSize = AppConstants.TextPixelSize.SpToPx(),
+ PixelSize = AppConstants.TextPixelSize,
FontFamily = "BreezeSans",
};
RelativeLayout.SetLeftTarget(titleText, backButton);
SelectionMode = ItemSelectionMode.Single,
};
UpdateNotificationsViewItemTemplate();
- notificationsView.SetBinding(RecyclerView.ItemsSourceProperty, "NotificationsListSource");
- notificationsView.SetBinding(CollectionView.SelectionChangedCommandProperty, "SelectionChangedCommand");
+
+ var session = new BindingSession<NotificationsViewModel>();
+
+ notificationsView.BindingContextChanged += (sender, e) =>
+ {
+ if (notificationsView.BindingContext is NotificationsViewModel model)
+ {
+ session.ViewModel = model;
+ }
+ };
+
+ notificationsView.SetBinding(session, RecyclerViewBindings.ItemsSourceProperty, "NotificationsListSource");
+ notificationsView.SetBinding(session, CollectionViewBindings.SelectionChangedCommandProperty, "SelectionChangedCommand");
}
notificationsView.SelectedItem = null;
Add(notificationsView);
{
return;
}
- notificationsView.SizeWidth = Window.Instance.Size.Width;
+ notificationsView.SizeWidth = NUIApplication.GetDefaultWindow().Size.Width;
notificationsView.ItemTemplate = new DataTemplate(() =>
{
ItemLayout item = new ItemLayout();
- item.Label.SetBinding(TextLabel.TextProperty, "Title");
- item.SubLabel.SetBinding(TextLabel.TextProperty, "SubTitle");
- item.Extra.SetBinding(Control.CommandProperty, "ClearNotificationCommand");
+
+ var session = new BindingSession<NotificationsModel>();
+
+ item.BindingContextChanged += (sender, e) =>
+ {
+ if (item.BindingContext is NotificationsModel model)
+ {
+ session.ViewModel = model;
+ }
+ };
+
+ item.Label.SetBinding(session, TextLabelBindings.TextProperty, "Title");
+ item.SubLabel.SetBinding(session, TextLabelBindings.TextProperty, "SubTitle");
+ item.Extra.SetBinding(session, ViewBindings.CommandProperty, "ClearNotificationCommand");
return item;
});
}
{
if (clearAllButton == null)
{
- ButtonStyle buttonStyle = new ButtonStyle()
+ var textLabel = new TextLabel()
{
- Size = AppConstants.ClearAllButtonSize.SpToPx(),
BackgroundColor = Color.Transparent,
- Text = new TextLabelStyle()
- {
- BackgroundColor = Color.Transparent,
- TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL",
- FontFamily = "BreezeSans",
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Center,
- },
+ TranslatableText = "IDS_ST_BUTTON_CLEAR_ALL",
+ FontFamily = "BreezeSans",
+ VerticalAlignment = VerticalAlignment.Center,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ };
+
+ clearAllButton = new Button()
+ {
+ Size = AppConstants.ClearAllButtonSize,
+ BackgroundColor = Color.Transparent,
};
- clearAllButton = new Button(buttonStyle);
+ clearAllButton.Add(textLabel);
RelativeLayout.SetVerticalAlignment(clearAllButton, RelativeLayout.Alignment.Center);
RelativeLayout.SetHorizontalAlignment(clearAllButton, RelativeLayout.Alignment.End);
- clearAllButton.SetBinding(Control.CommandProperty, "ClearAllNotificationsCommand");
+
+ var session = new BindingSession<NotificationsViewModel>();
+ clearAllButton.BindingContextChanged += (sender, e) =>
+ {
+ if (clearAllButton.BindingContext is NotificationsViewModel model)
+ {
+ session.ViewModel = model;
+ }
+ };
+ clearAllButton.SetBinding(session, ButtonBindings.CommandProperty, "ClearAllNotificationsCommand");
}
topView?.Add(clearAllButton);
}
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
FontFamily = "BreezeSans",
- PixelSize = AppConstants.TextPixelSize.SpToPx(),
+ PixelSize = AppConstants.TextPixelSize,
};
}
Add(noNotificationsText);
topView?.Dispose();
topView = null;
}
+
Tizen.Log.Info(AppConstants.LogTag, "Dispose BaseView");
base.Dispose(type);
}