moreButton.ThemeChangeSensitive = true;
moreButton.Position2D = new Position2D(Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, TopBarButtonsY);
rightView.Add(moreButton);
+ moreButton.Clicked += OnMoreButtonClicked;
+ }
+
+ private Menu CreateMenu()
+ {
+ Menu moreMenu = new Menu()
+ {
+ Anchor = moreButton,
+ HorizontalPositionToAnchor = Menu.RelativePosition.End,
+ VerticalPositionToAnchor = Menu.RelativePosition.End,
+ };
+ return moreMenu;
+ }
+
+ private void OnMoreButtonClicked(object sender, ClickedEventArgs e)
+ {
+ Menu moreMenu = CreateMenu();
+ var share = new MenuItem { Text = "Share" };
+ share.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ moreMenu?.Dismiss();
+ viewModel.OnCurrentTrackShare();
+ };
+
+ var delete = new MenuItem { Text = "Delete" };
+ delete.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ moreMenu?.Dismiss();
+ OnDeleteClicked();
+ };
+
+ moreMenu.Items = new MenuItem[] { share, delete };
+ moreMenu.Post();
+ }
+
+ private void RemoveAlertDialog(AlertDialog alertDialog, Button cancelButton, Button deleteButton)
+ {
+ Window.Instance.Remove(alertDialog);
+ alertDialog.Dispose();
+ cancelButton.Dispose();
+ deleteButton.Dispose();
+ }
+
+ private void OnDeleteClicked()
+ {
+ Button cancelbutton = new Button("CancelButton")
+ {
+ ThemeChangeSensitive = true,
+ };
+ cancelbutton.TextLabel.FontStyle = UIFontStyles.AllNormal;
+
+ Button deleteButton = new Button()
+ {
+ Text = "Delete",
+ };
+
+ AlertDialog alertDialog = new AlertDialog()
+ {
+ Title = "Delete",
+ Message = "This track will be deleted",
+ Actions = new List<View> { cancelbutton, deleteButton },
+ };
+
+ cancelbutton.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ RemoveAlertDialog(alertDialog, cancelbutton, deleteButton);
+ };
+ deleteButton.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ viewModel.OnCurrentTrackDelete();
+ RemoveAlertDialog(alertDialog, cancelbutton, deleteButton);
+ };
+ Window.Instance.Add(alertDialog);
}
private void AddControlView()
{
class PlaylistView : BaseContentView
{
+
+ private const string DefaultPlaylistName = "My playlist";
+
private TextLabel playlistCountLabel;
private Button playlistCreateButton;
private PlaylistViewModel viewModel;
private void OnPlaylistCreate(object sender, ClickedEventArgs e)
{
- // CreatePlaylistPopup();
+ CreatePlaylistAlertDialog();
}
private void OnPlaylistSelectionChange(object sender, SelectionChangedEventArgs e)
collectionView.SelectedItem = null;
}
- private void CreatePlaylistPopup()
+ private TextLabel CreateAlertDialogTitle()
{
TextLabel titleLabel = new TextLabel()
{
+ Name = "AlertDialogTitle",
StyleName = "LabelText",
ThemeChangeSensitive = true,
PixelSize = 40,
FontStyle = UIFontStyles.AllNormal,
Text = "Create playlist",
};
+ return titleLabel;
+ }
- View contentArea = new View()
- {
- SizeHeight = 144,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- BackgroundColor = Color.Transparent,
- };
-
+ private TextLabel CreateAlertDialogContentMessgae()
+ {
TextLabel contentLabel = new TextLabel()
{
+ Name = "AlertDialogContentMessage",
StyleName = "LabelText",
ThemeChangeSensitive = true,
PixelSize = 32,
FontFamily = "BreezeSans",
FontStyle = UIFontStyles.NormalLight,
Text = "Create a playlist",
- WidthResizePolicy = ResizePolicyType.FillToParent,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 40,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ };
+ return contentLabel;
+ }
+
+ private TextField CreatePlaylistNameField()
+ {
+ TextField inputTextField = new TextField()
+ {
+ Name = "AlertDialogInputField",
+ PlaceholderText = "Enter Playlist Name",
+ Text = DefaultPlaylistName,
HorizontalAlignment = HorizontalAlignment.Begin,
- PositionY = 40,
};
- contentArea.Add(contentLabel);
+ return inputTextField;
+ }
+
+ private Button CreateClearButton()
+ {
+ Button clearButton = new Button("ClearButton")
+ {
+ Name = "AlertDialogClearButton",
+ ThemeChangeSensitive = true,
+ Margin = new Extents(48, 0, 0, 0),
+ };
+ return clearButton;
+ }
+
+ private View CreateInputContent()
+ {
+ View inputArea = new View()
+ {
+ Name = "AlertDialogInputArea",
+ BackgroundColor = Color.Transparent,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = 48,
+ Margin = new Extents(0, 0, 24, 0),
+ Layout = new RelativeLayout()
+ };
+ return inputArea;
+ }
+
+ private View CreateAlertDialogContent()
+ {
+ View contentArea = new View()
+ {
+ Name = "AlertDialogContent",
+ SizeWidth = 1024,
+ WidthSpecification = 1024,
+ SizeHeight = 240,
+ HeightSpecification = 240,
+ BackgroundColor = Color.Transparent,
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ LinearAlignment = LinearLayout.Alignment.Center,
+ Margin = new Extents(0, 0, 0, 24),
+ }
+ };
+ return contentArea;
+ }
+ private Button CreateAlertDialogCancelButton()
+ {
Button cancelbutton = new Button("CancelButton")
{
+ Name = "AlertDialogCancelButton",
ThemeChangeSensitive = true,
};
cancelbutton.TextLabel.FontStyle = UIFontStyles.AllNormal;
- //cancelbutton.Clicked += OnCanelClicked;
+ return cancelbutton;
+ }
- Button allowButton = new Button()
+ private Button CreateAlertDialogCreateButton()
+ {
+ Button createButton = new Button()
{
+ Name = "AlertDialogCreateButton",
Text = "Allow",
};
- //allowButton.Clicked += OnAllowClicked;
+ return createButton;
+ }
+
+ private void DeleteChildren(List<View> childrenList)
+ {
+ if(childrenList == null || childrenList.Count == 0)
+ {
+ Tizen.Log.Error(AppConstants.LogTag, "List is empty, can't delete children");
+ return;
+ }
+ foreach(View child in childrenList)
+ {
+ child?.Dispose();
+ }
+ }
+
+ private void RemoveAlertDialog(AlertDialog alertDialog)
+ {
+ List<View> contentChilds = alertDialog.Content.Children.GetRange(0, alertDialog.Content.Children.Count);
+ List<View> actionContentChilds = alertDialog.ActionContent.Children.GetRange(0, alertDialog.ActionContent.Children.Count);
+ foreach (View child in contentChilds)
+ {
+ if (child != null)
+ {
+ if (child.Name == "AlertDialogInputArea")
+ {
+ List<View> inputAreaChildrenList = child.Children.GetRange(0, child.Children.Count);
+ DeleteChildren(inputAreaChildrenList);
+ }
+ child.Dispose();
+ }
+ }
+ DeleteChildren(actionContentChilds);
+ Window.Instance.Remove(alertDialog);
+ alertDialog.Dispose();
+ }
+
+ private View CreateInputBaseLine()
+ {
+ View view = new View()
+ {
+ Name = "InputLineView",
+ StyleName = "InputLine",
+ HeightSpecification = 2,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ return view;
+ }
+
+ private View CreateButtonArea()
+ {
+ View buttonArea = new View()
+ {
+ HeightSpecification = 136,
+ WidthSpecification = 1024,
+ Layout = new RelativeLayout(),
+ };
+ return buttonArea;
+ }
+
+ private void CreatePlaylistAlertDialog()
+ {
+ View contentArea = CreateAlertDialogContent();
+
+ TextLabel contentMessgae = CreateAlertDialogContentMessgae();
+ contentArea.Add(contentMessgae);
+
+ View inputArea = CreateInputContent();
+ contentArea.Add(inputArea);
+
+ View inputBaseLine = CreateInputBaseLine();
+ contentArea.Add(inputBaseLine);
+
+ TextField inputFiled = CreatePlaylistNameField();
+ inputArea.Add(inputFiled);
+ RelativeLayout.SetLeftRelativeOffset(inputFiled, 0.0f);
+ RelativeLayout.SetFillHorizontal(inputFiled, true);
+ RelativeLayout.SetHorizontalAlignment(inputFiled, RelativeLayout.Alignment.Start);
+
+ Button clearButton = CreateClearButton();
+ inputArea.Add(clearButton);
+ clearButton.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ inputFiled.Text = string.Empty;
+ };
+ RelativeLayout.SetRightRelativeOffset(clearButton, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(clearButton, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightTarget(inputFiled, clearButton);
+ RelativeLayout.SetRightRelativeOffset(inputFiled, 0.0f);
+
+ View buttonArea = CreateButtonArea();
+
+ Button cancelButton = CreateAlertDialogCancelButton();
+ buttonArea.Add(cancelButton);
+ RelativeLayout.SetLeftRelativeOffset(cancelButton, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(cancelButton, RelativeLayout.Alignment.Start);
+ RelativeLayout.SetVerticalAlignment(cancelButton, RelativeLayout.Alignment.Start);
+
+ Button createButton = CreateAlertDialogCreateButton();
+ buttonArea.Add(createButton);
+ RelativeLayout.SetRightRelativeOffset(createButton, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(createButton, RelativeLayout.Alignment.End);
+ RelativeLayout.SetVerticalAlignment(createButton, RelativeLayout.Alignment.Start);
AlertDialog alertDialog = new AlertDialog()
{
- TitleContent = titleLabel,
+ TitleContent = CreateAlertDialogTitle(),
Content = contentArea,
- Actions = new List<View> { cancelbutton, allowButton },
+ ActionContent = buttonArea
};
Window.Instance.Add(alertDialog);
+
+ cancelButton.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ RemoveAlertDialog(alertDialog);
+ };
+
+ createButton.Clicked += (object o, ClickedEventArgs e) =>
+ {
+ if(OnPlaylistCreate(inputFiled.Text) == true)
+ {
+ RemoveAlertDialog(alertDialog);
+ }
+ };
+ }
+
+ private void ShowInfoMessage(string messgae)
+ {
+ Notification.MakeToast(messgae, Notification.ToastBottom).Post(Notification.ToastShort);
+ }
+
+ private bool OnPlaylistCreate(string name)
+ {
+ if(string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
+ {
+ ShowInfoMessage("Can't create playlist with empty or whitespace character only");
+ return false;
+ }
+ if(name.Length > 64)
+ {
+ ShowInfoMessage("Playlist name can't be longer than 64 characters");
+ return false;
+ }
+ if(viewModel.CreatePlaylist(name) == false)
+ {
+ ShowInfoMessage("Playlist name is already in use.");
+ return false;
+ }
+ return true;
}
private void OnDeleteClick(object sender, ClickedEventArgs e)