From 3ec1e5ffc8b5e4b94e45f1ebab7f230023896faf Mon Sep 17 00:00:00 2001 From: "aman.jeph" Date: Tue, 1 Jun 2021 12:55:51 +0530 Subject: [PATCH] Adding base layout and trackview classes Change-Id: I9242ea28821262489605bcc566c545603c2519f0 Signed-off-by: aman.jeph --- Common/PropertyNotifier.cs | 30 ++++ MediaContent/AlbumContents.cs | 4 +- MediaContent/ArtistContents.cs | 17 +- MediaContent/PlaylistContents.cs | 7 +- MediaContent/TrackContents.cs | 3 +- Models/Track.cs | 86 ++++++++++ Models/TrackDataProvider.cs | 34 ++++ MusicPlayer.cs | 8 +- ViewModels/TrackListViewModel.cs | 25 +++ ViewModels/TrackViewModel.cs | 37 +++++ Views/BaseContentView.cs | 75 +++++++++ Views/BaseView.cs | 267 +++++++++++++++++++++++++++++++ Views/TrackLayout.cs | 132 +++++++++++++++ Views/TrackView.cs | 70 ++++++++ music-player.csproj | 2 +- 15 files changed, 777 insertions(+), 20 deletions(-) create mode 100755 Common/PropertyNotifier.cs mode change 100644 => 100755 MediaContent/AlbumContents.cs mode change 100644 => 100755 MediaContent/ArtistContents.cs mode change 100644 => 100755 MediaContent/PlaylistContents.cs mode change 100644 => 100755 MediaContent/TrackContents.cs create mode 100755 Models/Track.cs create mode 100755 Models/TrackDataProvider.cs create mode 100755 ViewModels/TrackListViewModel.cs create mode 100755 ViewModels/TrackViewModel.cs create mode 100755 Views/BaseContentView.cs create mode 100755 Views/BaseView.cs create mode 100755 Views/TrackLayout.cs create mode 100755 Views/TrackView.cs mode change 100644 => 100755 music-player.csproj diff --git a/Common/PropertyNotifier.cs b/Common/PropertyNotifier.cs new file mode 100755 index 0000000..de87064 --- /dev/null +++ b/Common/PropertyNotifier.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace MusicPlayer.Common +{ + class PropertyNotifier : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) + { + if (Equals(storage, value)) + { + return false; + } + + storage = value; + OnPropertyChanged(propertyName); + return true; + } + + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/MediaContent/AlbumContents.cs b/MediaContent/AlbumContents.cs old mode 100644 new mode 100755 index 50ca286..312cf28 --- a/MediaContent/AlbumContents.cs +++ b/MediaContent/AlbumContents.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Specialized; using Tizen.Content.MediaContent; -using System.Text; +using MusicPlayer.Common; namespace MusicPlayer.Media { @@ -19,7 +19,7 @@ namespace MusicPlayer.Media Album info = dataReader.Current; albumList.Add(info.Id, info); } - Tizen.Log.Debug("MUSIC_PLAYER", "Total album retrived from database: " + albumList.Count); + Tizen.Log.Debug(Constants.LogTag, "Total album retrived from database: " + albumList.Count); dataReader.Dispose(); return albumList; } diff --git a/MediaContent/ArtistContents.cs b/MediaContent/ArtistContents.cs old mode 100644 new mode 100755 index 4814bdb..b0bc7be --- a/MediaContent/ArtistContents.cs +++ b/MediaContent/ArtistContents.cs @@ -1,8 +1,9 @@ -using System; -using System.Collections.Specialized; +using System.Collections.Specialized; using System.Collections.Generic; -using System.Text; using Tizen.Content.MediaContent; +using System; +using MusicPlayer.Common; + namespace MusicPlayer.Media { @@ -20,7 +21,7 @@ namespace MusicPlayer.Media string info = (string)dataReader.Current; artistList.Add(info); } - Tizen.Log.Debug("MUSIC_PLAYER", "Total artists retrived from database: " + artistList.Count); + Tizen.Log.Debug(Constants.LogTag, "Total artists retrived from database: " + artistList.Count); dataReader.Dispose(); return artistList; } @@ -52,19 +53,19 @@ namespace MusicPlayer.Media } catch (ObjectDisposedException ex) { - Tizen.Log.Error("MUSIC_PLAYER", "ObjectDisposedException: " + ex.Message); + Tizen.Log.Error(Constants.LogTag, "ObjectDisposedException: " + ex.Message); } catch (InvalidOperationException ex) { - Tizen.Log.Error("MUSIC_PLAYER", "InvalidOperationException: " + ex.Message); + Tizen.Log.Error(Constants.LogTag, "InvalidOperationException: " + ex.Message); } catch (MediaDatabaseException ex) { - Tizen.Log.Error("MUSIC_PLAYER", "MediaDatabaseException: " + ex.Message); + Tizen.Log.Error(Constants.LogTag, "MediaDatabaseException: " + ex.Message); } catch (Exception ex) { - Tizen.Log.Error("MUSIC_PLAYER", "Unknown Exception: " + ex.Message); + Tizen.Log.Error(Constants.LogTag, "Unknown Exception: " + ex.Message); } return count; diff --git a/MediaContent/PlaylistContents.cs b/MediaContent/PlaylistContents.cs old mode 100644 new mode 100755 index 677f574..d7f9f34 --- a/MediaContent/PlaylistContents.cs +++ b/MediaContent/PlaylistContents.cs @@ -1,7 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using Tizen.Content.MediaContent; +using MusicPlayer.Common; namespace MusicPlayer.Media { @@ -18,7 +17,7 @@ namespace MusicPlayer.Media Playlist playlist = dataReader.Current; playlists.Add(playlist); } - Tizen.Log.Debug("MUSIC_PLAYER", "PlayLists Count : " + playlists.Count); + Tizen.Log.Debug(Constants.LogTag, "PlayLists Count : " + playlists.Count); return playlists; } diff --git a/MediaContent/TrackContents.cs b/MediaContent/TrackContents.cs old mode 100644 new mode 100755 index d9b57cf..1ce5290 --- a/MediaContent/TrackContents.cs +++ b/MediaContent/TrackContents.cs @@ -1,5 +1,6 @@ using System.Collections.Specialized; using Tizen.Content.MediaContent; +using MusicPlayer.Common; namespace MusicPlayer.Media { @@ -17,7 +18,7 @@ namespace MusicPlayer.Media MediaInfo info = dataReader.Current; mediaList.Add(info.Id, info); } - Tizen.Log.Debug("MUSIC_PLAYER", "Total track retrived from database: " + mediaList.Count); + Tizen.Log.Debug(Constants.LogTag, "Total track retrived from database: " + mediaList.Count); dataReader.Dispose(); return mediaList; } diff --git a/Models/Track.cs b/Models/Track.cs new file mode 100755 index 0000000..c92dcae --- /dev/null +++ b/Models/Track.cs @@ -0,0 +1,86 @@ +using MusicPlayer.Common; + +namespace MusicPlayer.Models +{ + class Track : PropertyNotifier + { + private string title; + private string album; + private string id; + private string artist; + private int duration; + private string thumbnailPath; + private string filePath; + + public Track(Tizen.Content.MediaContent.AudioInfo audioInfo) + { + TrackTitle = audioInfo.Title; + AlbumName = audioInfo.Album; + Id = audioInfo.Id; + ArtistName = audioInfo.Artist; + Duration = audioInfo.Duration; + ThumbnailPath = audioInfo.ThumbnailPath; + FilePath = audioInfo.Path; + } + + public string TrackTitle + { + get => title; + set => SetProperty(ref title, value); + } + + public string AlbumName + { + get => album; + set + { + string name = string.IsNullOrEmpty(value) ? "Unknown" : value; + SetProperty(ref album, name); + } + } + public string ArtistName + { + get => artist; + set + { + string name = string.IsNullOrEmpty(value) ? "Unknown" : value; + SetProperty(ref artist, name); + } + } + public string Id + { + get => id; + set + { + id = value; + } + } + // TODO create new property of duration in string + public int Duration + { + get => duration; + set + { + duration = value; + } + } + public string ThumbnailPath + { + get => thumbnailPath; + set + { + string thumb = string.IsNullOrEmpty(value) ? Resources.GetImagePath() + "thumbnail.png" : value; + SetProperty(ref thumbnailPath, thumb); + } + } + + public string FilePath + { + get => filePath; + set + { + filePath = value; + } + } + } +} diff --git a/Models/TrackDataProvider.cs b/Models/TrackDataProvider.cs new file mode 100755 index 0000000..a37db2a --- /dev/null +++ b/Models/TrackDataProvider.cs @@ -0,0 +1,34 @@ +using System.Collections.Specialized; +using MusicPlayer.Media; + +namespace MusicPlayer.Models +{ + public static class TrackDataProvider + { + private static OrderedDictionary tracksList; + + static TrackDataProvider() + { + tracksList = Contents.GetTrackList(); + Contents.MusicItemUpdate += OnMusicItemUpdate; + Contents.MusicDBUpdate += OnMusicDatabaseUpdate; + } + + private static void OnMusicDatabaseUpdate(object sender, MusicDBUpdateEventArgs e) + { + tracksList = Contents.GetTrackList(); + // TODO implement database update event handler + return; + } + private static void OnMusicItemUpdate(object sender, MusicItemUpdateEventArgs e) + { + // TODO implement database item update event handler + return; + } + public static OrderedDictionary CurrentTrackList() + { + return tracksList; + } + + } +} diff --git a/MusicPlayer.cs b/MusicPlayer.cs index 0da2306..4ea8ee9 100755 --- a/MusicPlayer.cs +++ b/MusicPlayer.cs @@ -9,13 +9,13 @@ namespace MusicPlayer { protected override void OnCreate() { - Tizen.Log.Info("MUSIC_PLAYER", "OnCreate statrted"); + Tizen.Log.Info(Constants.LogTag, "OnCreate statrted"); base.OnCreate(); Window window = Window.Instance; window.BackgroundColor = Color.White; window.KeyEvent += OnKeyEvent; Size2D size = window.Size; - Tizen.Log.Info("MUSIC_PLAYER", "Window Size: " + size.Width + "x" + size.Height); + Tizen.Log.Info(Constants.LogTag, "Window Size: " + size.Width + "x" + size.Height); ViewManager manager = new ViewManager(Window.Instance); } @@ -30,10 +30,10 @@ namespace MusicPlayer static void Main(string[] args) { - Tizen.Log.Info("MUSIC_PLAYER", "Main statrted"); + Tizen.Log.Info(Constants.LogTag, "Main statrted"); var app = new Application(); app.Run(args); - Tizen.Log.Info("MUSIC_PLAYER", "Main finished"); + Tizen.Log.Info(Constants.LogTag, "Main finished"); } } } diff --git a/ViewModels/TrackListViewModel.cs b/ViewModels/TrackListViewModel.cs new file mode 100755 index 0000000..5b40008 --- /dev/null +++ b/ViewModels/TrackListViewModel.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Specialized; +using System.Collections.ObjectModel; +using MusicPlayer.Models; +using Tizen.Content.MediaContent; +using MusicPlayer.Common; + +namespace MusicPlayer.ViewModels +{ + class TrackListViewModel : ObservableCollection + { + public TrackListViewModel() + { + } + + public void CreateData(OrderedDictionary dict) + { + foreach(DictionaryEntry item in dict) + { + Add(new Track((AudioInfo)item.Value)); + } + Tizen.Log.Debug(Constants.LogTag, "Observable list item count: " + this.Count); + } + } +} diff --git a/ViewModels/TrackViewModel.cs b/ViewModels/TrackViewModel.cs new file mode 100755 index 0000000..38ed6cb --- /dev/null +++ b/ViewModels/TrackViewModel.cs @@ -0,0 +1,37 @@ +using System.Collections.Specialized; +using MusicPlayer.Models; +using MusicPlayer.Common; + +namespace MusicPlayer.ViewModels +{ + class TrackViewModel : PropertyNotifier + { + private string trackCount; + private TrackListViewModel listViewModel; + + public TrackViewModel() + { + OrderedDictionary trackList = TrackDataProvider.CurrentTrackList(); + listViewModel = new TrackListViewModel(); + listViewModel.CreateData(trackList); + listViewModel.CollectionChanged += OnTrackListChanges; + TrackCount = listViewModel.Count.ToString(); + } + + private void OnTrackListChanges(object sender, NotifyCollectionChangedEventArgs e) + { + TrackCount = listViewModel.Count.ToString(); + } + + public TrackListViewModel ListViewModel + { + get => listViewModel; + } + + public string TrackCount + { + get => trackCount; + set => SetProperty(ref trackCount, value); + } + } +} diff --git a/Views/BaseContentView.cs b/Views/BaseContentView.cs new file mode 100755 index 0000000..3514758 --- /dev/null +++ b/Views/BaseContentView.cs @@ -0,0 +1,75 @@ +using MusicPlayer.Common; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Components; + +namespace MusicPlayer.Views +{ + class BaseContentView : View + { + protected View titleView; + protected CollectionView collectionView; + public BaseContentView() : base() + { + WidthResizePolicy = ResizePolicyType.FillToParent; + HeightResizePolicy = ResizePolicyType.FillToParent; + Layout = new FlexLayout() + { + Direction = FlexLayout.FlexDirection.Column, + Padding = new Extents(64, 64, 0, 0), + }; + titleView = new View() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 60, + Layout = new RelativeLayout() + { + Padding = new Extents(0, 0, 13, 13), + }, + IsCreateByXaml = true, + }; + base.Add(titleView); + FlexLayout.SetFlexGrow(titleView, 0); + FlexLayout.SetFlexShrink(titleView, 0); + + collectionView = new CollectionView() + { + Size2D = new Size2D(1792, 108), + Margin = new Extents(0, 0, 0, 2), + BackgroundImage = Resources.GetImagePath() + "list_view_bg.png", + ItemsLayouter = new LinearLayouter(), + ItemTemplate = new DataTemplate(() => + { + TrackLayout layout = new TrackLayout(); + layout.Thumbnail.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath"); + layout.TitleText.SetBinding(TextLabel.TextProperty, "TrackTitle"); + layout.SubtitletText.SetBinding(TextLabel.TextProperty, "ArtistName"); + return layout; + }), + ScrollingDirection = ScrollableBase.Direction.Vertical, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.WrapContent, + SelectionMode = ItemSelectionMode.Single, + }; + base.Add(collectionView); + FlexLayout.SetFlexGrow(collectionView, 1); + FlexLayout.SetFlexShrink(collectionView, 1); + } + + protected override void Dispose(DisposeTypes type) + { + if (type == DisposeTypes.Explicit) + { + base.Remove(titleView); + titleView.Dispose(); + titleView = null; + + base.Remove(collectionView); + collectionView.Dispose(); + collectionView = null; + } + base.Dispose(type); + } + } +} diff --git a/Views/BaseView.cs b/Views/BaseView.cs new file mode 100755 index 0000000..6ed379e --- /dev/null +++ b/Views/BaseView.cs @@ -0,0 +1,267 @@ +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using MusicPlayer.Common; + +namespace MusicPlayer.Views +{ + class BaseView : View + { + private View topView; + private View bottomView; // TODO Used this for MiniController UI + private View contentView; + private TextLabel titleLabel; + private Button backButton; + private Button moreButton; + private Button searchButton; + private Tab tabs; + + // TODO these name strings are temporary...once the po files are added + // need to use Translatable names. + private static string[] TabNames = new string[] + { + "Playlists", + "Tracks", + "Albums", + "Artists", + }; + public BaseView() : base() + { + WidthSpecification = LayoutParamPolicies.MatchParent; + HeightSpecification = LayoutParamPolicies.MatchParent; + Layout = new FlexLayout() + { + Direction = FlexLayout.FlexDirection.Column, + ItemsAlignment = FlexLayout.AlignmentType.FlexStart, + Justification = FlexLayout.FlexJustification.FlexStart, + }; + topView = new View() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 120, + Layout = new RelativeLayout() + { + Padding = new Extents(64, 64, 30, 30), + }, + }; + base.Add(topView); + FlexLayout.SetFlexGrow(topView, 0); + FlexLayout.SetFlexShrink(topView, 0); + titleLabel = new TextLabel() + { + Text = "Music", + PixelSize = 40, + FontFamily = "BreezeSans", + TextColor = new Color(0.0f, 0.0078f, 0.0353f, 1.0f), + HorizontalAlignment = HorizontalAlignment.Begin, + Margin = new Extents(0, 0, 6, 6), + Ellipsis = true, + }; + topView.Add(titleLabel); + RelativeLayout.SetLeftTarget(titleLabel, topView); + RelativeLayout.SetLeftRelativeOffset(titleLabel, 0.0f); + RelativeLayout.SetRightTarget(titleLabel, topView); + RelativeLayout.SetRightRelativeOffset(titleLabel, 1.0f); + RelativeLayout.SetFillHorizontal(titleLabel, true); + + contentView = new View() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 876, + }; + base.Add(contentView); + FlexLayout.SetFlexGrow(contentView, 1); + FlexLayout.SetFlexShrink(contentView, 1); + + tabs = new Tab() + { + Size2D = new Size2D(Window.Instance.Size.Width, 84), + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = 84, + UnderLineBackgroundColor = Color.Blue, + UnderLineSize = new Size2D(1, 3), + PointSize = 25, + BackgroundColor = Color.White, + }; + tabs.TextColorSelector = new ColorSelector + { + Normal = Color.Black, + Selected = Color.Magenta, + }; + base.Add(tabs); + for(int i = 0; i<4; ++i) + { + Tab.TabItemData item = new Tab.TabItemData(); + item.Text = TabNames[i]; + tabs.AddItem(item); + } + tabs.SelectedItemIndex = 1; + + backButton = null; + moreButton = null; + searchButton = null; + } + + public Tab Tabs + { + get + { + return tabs; + } + } + + public string Title + { + set + { + titleLabel.Text = value; + } + get + { + return titleLabel.Text; + } + } + + public bool BackButton + { + set + { + if (value) + { + ButtonStyle buttonStyle = new ButtonStyle() + { + Icon = new ImageViewStyle() + { + ResourceUrl = Resources.GetImagePath() + "back_button.png", + }, + IsSelectable = false, + IsEnabled = true, + }; + + backButton = new Button(buttonStyle) + { + Size2D = new Size2D(48, 48), + Margin = new Extents(0, 32, 6, 6), + }; + topView.Add(backButton); + + RelativeLayout.SetLeftRelativeOffset(backButton, 0.0f); + RelativeLayout.SetRightRelativeOffset(backButton, 0.0f); + RelativeLayout.SetHorizontalAlignment(backButton, RelativeLayout.Alignment.Start); + + RelativeLayout.SetLeftTarget(titleLabel, backButton); + RelativeLayout.SetLeftRelativeOffset(titleLabel, 1.0f); + } + } + } + + public bool MoreButton + { + set + { + if (value) + { + ButtonStyle buttonStyle = new ButtonStyle() + { + Icon = new ImageViewStyle() + { + ResourceUrl = Resources.GetImagePath() + "more_button.png", + }, + IsSelectable = false, + IsEnabled = true, + }; + moreButton = new Button(buttonStyle) + { + Size2D = new Size2D(48, 48), + Margin = new Extents(24, 0, 6, 6), + }; + topView.Add(moreButton); + RelativeLayout.SetLeftRelativeOffset(moreButton, 1.0f); + RelativeLayout.SetRightRelativeOffset(moreButton, 1.0f); + RelativeLayout.SetHorizontalAlignment(moreButton, RelativeLayout.Alignment.End); + + RelativeLayout.SetRightTarget(titleLabel, moreButton); + RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); + } + } + } + + public bool SearchButton + { + set + { + if (value) + { + ButtonStyle buttonStyle = new ButtonStyle() + { + Icon = new ImageViewStyle() + { + ResourceUrl = Resources.GetImagePath() + "search_icon.png", + }, + IsSelectable = false, + IsEnabled = true, + }; + searchButton = new Button(buttonStyle) + { + Size2D = new Size2D(96, 60), + BackgroundImage = Resources.GetImagePath() + "search_button_bg.png", + Margin = new Extents(0, 32, 0, 0), + }; + topView.Add(searchButton); + RelativeLayout.SetRightTarget(searchButton, moreButton); + RelativeLayout.SetRightRelativeOffset(searchButton, 0.0f); + RelativeLayout.SetHorizontalAlignment(searchButton, RelativeLayout.Alignment.End); + + RelativeLayout.SetLeftTarget(titleLabel, RelativeLayout.GetLeftTarget(titleLabel)); + RelativeLayout.SetLeftRelativeOffset(titleLabel, RelativeLayout.GetLeftRelativeOffset(titleLabel)); + RelativeLayout.SetRightTarget(titleLabel, searchButton); + RelativeLayout.SetRightRelativeOffset(titleLabel, 0.0f); + } + } + } + + public View SetContent + { + set + { + contentView.Add(value); + } + } + + protected override void Dispose(DisposeTypes type) + { + if (Disposed) + { + return; + } + if (type == DisposeTypes.Explicit) + { + List children = topView?.Children; + foreach (View child in children) + { + topView.Remove(child); + child?.Dispose(); + } + base.Remove(topView); + topView?.Dispose(); + topView = null; + + // Do not delete the children of contentview as they are not owned by BaseView + base.Remove(contentView); + contentView?.Dispose(); + contentView = null; + + base.Remove(tabs); + tabs?.Dispose(); + tabs = null; + + base.Remove(bottomView); + bottomView?.Dispose(); + bottomView = null; + } + + base.Dispose(type); + } + } +} \ No newline at end of file diff --git a/Views/TrackLayout.cs b/Views/TrackLayout.cs new file mode 100755 index 0000000..a84b827 --- /dev/null +++ b/Views/TrackLayout.cs @@ -0,0 +1,132 @@ +using Tizen.NUI.Components; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; + +namespace MusicPlayer.Views +{ + class TrackLayout : RecyclerViewItem + { + private View itemSeperator; + private TextLabel titleLabel; + private TextLabel artistAndTimeLabel; + private ImageView icon; + + private static int WIDTH = 1792; + private static int HEIGHT = 108; + + private const int ICON_SIZE = 64; + private const int MARGIN = 16; + private const int PADDING = 32; + private const int SEPERATOR_HEIGHT = 1; + private const int LEFT_PADDING = 64; + private const int X = 0; + + public TrackLayout(int width = 1792, int height = 108) : base() + { + base.OnInitialize(); + base.IsCreateByXaml = true; + WIDTH = width; + HEIGHT = height; + WidthSpecification = WIDTH; + HeightSpecification = HEIGHT; + + // to show the rounded rect of the bg + BackgroundColor = Color.Transparent; + + icon = new ImageView() + { + WidthSpecification = ICON_SIZE, + HeightSpecification = ICON_SIZE, + IsCreateByXaml = true, + Position2D = new Position2D(X, ((HEIGHT / 2) - (ICON_SIZE / 2))), + }; + base.Add(icon); + + itemSeperator = new View() + { + WidthSpecification = (WIDTH - (2 * LEFT_PADDING)), + HeightSpecification = SEPERATOR_HEIGHT, + ExcludeLayouting = true, + Position2D = new Position2D(X, HEIGHT - SEPERATOR_HEIGHT), + BackgroundColor = new Color(0.75f, 0.79f, 0.82f, 1.0f) + }; + base.Add(itemSeperator); + + titleLabel = new TextLabel() + { + WidthSpecification = (WIDTH - (2 * LEFT_PADDING) - ICON_SIZE - PADDING), + HeightSpecification = 40, + TextColor = Color.Blue, + PixelSize = 32, + FontFamily = "BreezeSans", + VerticalAlignment = VerticalAlignment.Center, + IsCreateByXaml = true, + Position2D = new Position2D((X + ICON_SIZE + PADDING), MARGIN), + }; + base.Add(titleLabel); + + artistAndTimeLabel = new TextLabel() + { + WidthSpecification = (WIDTH - (2 * LEFT_PADDING) - ICON_SIZE - PADDING), + HeightSpecification = 36, + TextColor = Color.Black, + PixelSize = 28, + FontFamily = "BreezeSans", + VerticalAlignment = VerticalAlignment.Center, + IsCreateByXaml = true, + Position2D = new Position2D((X + ICON_SIZE + PADDING), MARGIN + 40) + }; + base.Add(artistAndTimeLabel); + IsCreateByXaml = true; + } + public ImageView Thumbnail + { + get + { + return icon; + } + } + public TextLabel TitleText + { + get + { + return titleLabel; + } + } + public TextLabel SubtitletText + { + get + { + return artistAndTimeLabel; + } + } + + protected override void Dispose(DisposeTypes type) + { + if(Disposed) + { + return; + } + if (type == DisposeTypes.Explicit) + { + base.Remove(itemSeperator); + itemSeperator?.Dispose(); + itemSeperator = null; + + base.Remove(icon); + icon?.Dispose(); + icon = null; + + base.Remove(titleLabel); + titleLabel?.Dispose(); + titleLabel = null; + + base.Remove(artistAndTimeLabel); + artistAndTimeLabel?.Dispose(); + artistAndTimeLabel = null; + } + + base.Dispose(type); + } + } +} diff --git a/Views/TrackView.cs b/Views/TrackView.cs new file mode 100755 index 0000000..7fa3141 --- /dev/null +++ b/Views/TrackView.cs @@ -0,0 +1,70 @@ +using MusicPlayer.ViewModels; +using Tizen.NUI.Components; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; +using Tizen.NUI.Binding; + +namespace MusicPlayer.Views +{ + class TrackView : BaseContentView + { + private TrackViewModel viewModel; + private TextLabel trackCountLabel; + private Button playAllIcon; // TODO need to implement playall feature + private Button addToPlaylistIcon; // TODO need to implement playlist manager + public TrackView(TrackViewModel viewModel) + { + this.viewModel = viewModel; + collectionView.ItemsSource = viewModel.ListViewModel; + collectionView.ScrollingDirection = ScrollableBase.Direction.Vertical; + collectionView.WidthSpecification = LayoutParamPolicies.WrapContent; + collectionView.SelectionMode = ItemSelectionMode.Single; + collectionView.SelectionChanged += OnTrackSelection; + + trackCountLabel = new TextLabel() + { + PixelSize = 28, + Text = "TRACK COUNT", + TextColor = new Color(0.0f, 0.0784f, 0.2754f, 1.0f), + VerticalAlignment = VerticalAlignment.Center, + FontFamily = "BreezeSans", + IsCreateByXaml = true, + }; + titleView.Add(trackCountLabel); + trackCountLabel.SetBinding(TextLabel.TextProperty, "TrackCount"); + RelativeLayout.SetLeftTarget(trackCountLabel, titleView); + RelativeLayout.SetLeftRelativeOffset(trackCountLabel, 1.0f); + RelativeLayout.SetRightRelativeOffset(trackCountLabel, 0.0f); + RelativeLayout.SetFillHorizontal(trackCountLabel, true); + } + + private void OnTrackSelection(object sender, SelectionChangedEventArgs e) + { + + } + + protected override void Dispose(DisposeTypes type) + { + if(Disposed) + { + return; + } + if(type == DisposeTypes.Explicit) + { + titleView.Remove(trackCountLabel); + trackCountLabel.Dispose(); + trackCountLabel = null; + + // TODO Uncomment after implementation is completed + //titleView.Remove(playAllIcon); + //playAllIcon.Dispose(); + //playAllIcon = null; + + //titleView.Remove(addToPlaylistIcon); + //addToPlaylistIcon.Dispose(); + //addToPlaylistIcon = null; + } + base.Dispose(type); + } + } +} diff --git a/music-player.csproj b/music-player.csproj old mode 100644 new mode 100755 index 6209aa5..782f6b6 --- a/music-player.csproj +++ b/music-player.csproj @@ -26,7 +26,7 @@ - + -- 2.34.1