Adding light/dark theme support part 2 18/262818/3
authoraman.jeph <aman.jeph@samsung.com>
Fri, 20 Aug 2021 06:20:55 +0000 (11:50 +0530)
committeraman.jeph <aman.jeph@samsung.com>
Fri, 20 Aug 2021 11:35:55 +0000 (17:05 +0530)
Change-Id: Idbfd80c32b4c3a5a9c9393e239528c6cd8d2ac9f
Signed-off-by: aman.jeph <aman.jeph@samsung.com>
ViewModels/ListViewModel.cs
ViewModels/PlayerViewModel.cs
ViewModels/PlayingListViewModel.cs
Views/BaseContentView.cs
Views/BaseView.cs
Views/ListItemLayout.cs
Views/PlayerView.cs
Views/TrackView.cs

index cb70383615c0873f68a10588e138126c38573d50..24ea54ee39c62d7218c32879861e3bc11253125b 100755 (executable)
@@ -5,6 +5,7 @@ using MusicPlayer.Models;
 using Tizen.Content.MediaContent;\r
 using MusicPlayer.Common;\r
 using System;\r
+using System.Collections.Generic;\r
 \r
 namespace MusicPlayer.ViewModels\r
 {\r
@@ -22,5 +23,16 @@ namespace MusicPlayer.ViewModels
             }\r
             Tizen.Log.Debug(AppConstants.LogTag, "Observable list item count: " + this.Count);\r
         }\r
+\r
+        public void CreateData<U>(List<U> list)\r
+        {\r
+            foreach (var item in list)\r
+            {\r
+                Add((T)Activator.CreateInstance(typeof(T), new object[] { (U)item }));\r
+            }\r
+            Tizen.Log.Debug(AppConstants.LogTag, "Observable list item count: " + this.Count);\r
+        }\r
+\r
+\r
     }\r
 }\r
index 6ccc60c6b2899c3d665cfd787f76e4a559454d3d..0b53d162dbbecd511cd462e5a11cb3fb029c520b 100755 (executable)
@@ -12,6 +12,8 @@ namespace MusicPlayer.ViewModels
 {
     class PlayerViewModel : PropertyNotifier
     {
+        public const string PlayState = "Play";
+        public const string PauseState = "Pause";
         private const int PlaybackTimerDuration = 1000;
         private const int MinPaletteColorCount = 2;
 
@@ -26,7 +28,7 @@ namespace MusicPlayer.ViewModels
             playingListViewModel = new PlayingListViewModel();
             playerModel = new PlayerModel();
             playerModel.ElapsedTime = 0.0f;
-            PlayPauseUrl = Resources.GetImagePath() + "play.png";
+            PlayingStatus = PlayingStatus.None;
             PlayerController.Instance.PlayerEventOccurred += OnPlayerEventOccurred;
             playbackTimer = new Timer(PlaybackTimerDuration);
             playbackTimer.Tick += OnPlaybackTimerTick;
@@ -44,12 +46,12 @@ namespace MusicPlayer.ViewModels
             get => playingListViewModel;
         }
 
-        private string playPauseUrl;
+        private string playButtonState;
 
-        public string PlayPauseUrl
+        public string PlayButtonState
         {
-            get => playPauseUrl;
-            set => SetProperty(ref playPauseUrl, value);
+            get => playButtonState;
+            set => SetProperty(ref playButtonState, value);
         }
 
         private float volumeLevel;
@@ -84,6 +86,14 @@ namespace MusicPlayer.ViewModels
             set => SetProperty(ref playerBackground, value);
         }
 
+        private PlayingStatus playingStatus;
+
+        public PlayingStatus PlayingStatus
+        {
+            get => playingStatus;
+            set => UpdatePlayingStatus(value);
+        }
+
         public void SetPlayingList(ListViewModel<Track> trackListVM)
         {
             playingListViewModel.SetTrackListViewModel(trackListVM);
@@ -170,17 +180,15 @@ namespace MusicPlayer.ViewModels
 
         public void PlayingStatusChanged()
         {
-            if (playerModel.PlayingStatus == PlayingStatus.Playing)
+            if (PlayingStatus == PlayingStatus.Playing)
             {
-                playerModel.PlayingStatus = PlayingStatus.Paused;
-                PlayPauseUrl = Resources.GetImagePath() + "play.png";
+                PlayingStatus = PlayingStatus.Paused;
                 Pause();
                 playbackTimer.Stop();
             }
             else
             {
-                playerModel.PlayingStatus = PlayingStatus.Playing;
-                PlayPauseUrl = Resources.GetImagePath() + "pause.png";
+                PlayingStatus = PlayingStatus.Playing;
                 Resume();
                 playbackTimer.Start();
             }
@@ -220,6 +228,22 @@ namespace MusicPlayer.ViewModels
             AudioManager.VolumeController.Level[AudioVolumeType.Media] = value;
         }
 
+        private void UpdatePlayingStatus(PlayingStatus status)
+        {
+            playingStatus = status;
+            switch (status)
+            {
+                case PlayingStatus.Playing:
+                    PlayButtonState = PauseState;
+                    break;
+                case PlayingStatus.Paused:  // Fall Through
+                case PlayingStatus.Stopped: // Fall Through
+                case PlayingStatus.None:
+                    PlayButtonState = PlayState;
+                    break;
+            }
+        }
+
         private bool OnPlaybackTimerTick(object source, Timer.TickEventArgs e)
         {
             UpdatePlayingTime();
@@ -258,16 +282,14 @@ namespace MusicPlayer.ViewModels
 
         private void StartPlayback()
         {
-            playerModel.PlayingStatus = PlayingStatus.Playing;
-            PlayPauseUrl = Resources.GetImagePath() + "pause.png";
+            PlayingStatus = PlayingStatus.Playing;
             Play();
             playbackTimer.Start();
         }
 
         private void StopPlayback()
         {
-            playerModel.PlayingStatus = PlayingStatus.Stopped;
-            PlayPauseUrl = Resources.GetImagePath() + "play.png";
+            PlayingStatus = PlayingStatus.Stopped;
             Stop();
             playbackTimer.Stop();
         }
index 6358715b6442ada96a1eaec163d9104f64afb5d1..d84e547d6737dd40aca1e34b01b5168452773750 100755 (executable)
@@ -83,7 +83,7 @@ namespace MusicPlayer.ViewModels
             get => tracklistViewModel;
         }
 
-        public string ShuffleUrl
+        public string ShuffleButtonState
         {
             get => shuffleButtonUrl;
             set => SetProperty(ref shuffleButtonUrl, value);
@@ -106,14 +106,11 @@ namespace MusicPlayer.ViewModels
                         UpdateShuffleList(tracklistViewModel.Count);
                     }
                 }
-                if (shuffleMode == ShuffleMode.On)
-                    ShuffleUrl = Resources.GetImagePath() + "shuffle_on.png";
-                else
-                    ShuffleUrl = Resources.GetImagePath() + "shuffle_off.png";
+                ShuffleButtonState = shuffleMode.ToString();
             }
         }
 
-        public string RepeatUrl
+        public string RepeatButtonState
         {
             get => repeatButtonUrl;
             set => SetProperty(ref repeatButtonUrl, value);
@@ -125,12 +122,7 @@ namespace MusicPlayer.ViewModels
             set
             {
                 repeatMode = value;
-                if (repeatMode == RepeatMode.Off)
-                    RepeatUrl = Resources.GetImagePath() + "repeat_off.png";
-                else if (repeatMode == RepeatMode.RepeatOne)
-                    RepeatUrl = Resources.GetImagePath() + "repeat_one.png";
-                else
-                    RepeatUrl = Resources.GetImagePath() + "repeat_all.png";
+                RepeatButtonState = repeatMode.ToString();
             }
        }
 
index 1de2b3c5accac2348eb61ad30995cf1412506dd3..5aa5c443bd87c262e36b3a53af72a7f498e63111 100755 (executable)
@@ -11,6 +11,7 @@ namespace MusicPlayer.Views
         protected CollectionView collectionView;\r
         public BaseContentView() : base()\r
         {\r
+            ThemeChangeSensitive = true;\r
             WidthResizePolicy = ResizePolicyType.FillToParent;\r
             HeightResizePolicy = ResizePolicyType.FillToParent;\r
             Layout = new FlexLayout()\r
@@ -20,13 +21,13 @@ namespace MusicPlayer.Views
             };\r
             titleView = new View()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 WidthSpecification = LayoutParamPolicies.MatchParent,\r
                 HeightSpecification = 60,\r
                 Layout = new RelativeLayout()\r
                 {\r
                     Padding = new Extents(0, 0, 13, 13),\r
                 },\r
-                IsCreateByXaml = true,\r
             };\r
             base.Add(titleView);\r
             FlexLayout.SetFlexGrow(titleView, 0);\r
@@ -34,9 +35,10 @@ namespace MusicPlayer.Views
 \r
             collectionView = new CollectionView()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 Size2D = new Size2D(1792, 108),\r
                 Margin = new Extents(0, 0, 0, 2),\r
-                BackgroundImage = Resources.GetImagePath() + "list_view_bg.png",\r
+                BackgroundImage = GetBackgroundImagePath(ThemeManager.PlatformThemeId),\r
                 ItemsLayouter = new LinearLayouter(),\r
                 ScrollingDirection = ScrollableBase.Direction.Vertical,\r
                 WidthSpecification = LayoutParamPolicies.MatchParent,\r
@@ -48,6 +50,27 @@ namespace MusicPlayer.Views
             FlexLayout.SetFlexShrink(collectionView, 1);\r
         }\r
 \r
+        private string GetBackgroundImagePath(string platformThemeId)\r
+        {\r
+            if(platformThemeId.Equals(AppConstants.DarkPlatformThemeId))\r
+            {\r
+                return Resources.GetImagePath() + "dark/list_view_bg.png";\r
+            }\r
+            else\r
+            {\r
+                return Resources.GetImagePath() + "light/list_view_bg.png";\r
+            }\r
+        }\r
+\r
+        protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)\r
+        {\r
+            base.OnThemeChanged(sender, e);\r
+            if(e.IsPlatformThemeChanged)\r
+            {\r
+                collectionView.BackgroundImage = GetBackgroundImagePath(e.PlatformThemeId);\r
+            }\r
+        }\r
+\r
         protected override void Dispose(DisposeTypes type)\r
         {\r
             if (type == DisposeTypes.Explicit)\r
index ffc439635ea3561687722fb3ba67531b1069d5f6..1cddb26c18c184b6c8e217ee3e3ea899fa785dc0 100755 (executable)
@@ -29,6 +29,7 @@ namespace MusicPlayer.Views
         };\r
         public BaseView() : base()\r
         {\r
+            ThemeChangeSensitive = true;\r
             WidthSpecification = LayoutParamPolicies.MatchParent;\r
             HeightSpecification = LayoutParamPolicies.MatchParent;\r
             Layout = new FlexLayout()\r
@@ -39,6 +40,7 @@ namespace MusicPlayer.Views
             };\r
             topView = new View()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 WidthSpecification = LayoutParamPolicies.MatchParent,\r
                 HeightSpecification = 120,\r
                 Layout = new RelativeLayout()\r
@@ -51,6 +53,7 @@ namespace MusicPlayer.Views
             FlexLayout.SetFlexShrink(topView, 0);\r
             titleLabel = new TextLabel()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 Text = "Music",\r
                 PixelSize = 40,\r
                 FontFamily = "BreezeSans",\r
@@ -69,6 +72,7 @@ namespace MusicPlayer.Views
 \r
             contentView = new View()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 WidthSpecification = LayoutParamPolicies.MatchParent,\r
                 HeightSpecification = 876,\r
             };\r
@@ -78,6 +82,7 @@ namespace MusicPlayer.Views
 \r
             tabs = new Tab()\r
             {\r
+                ThemeChangeSensitive = true,\r
                 Size2D = new Size2D(Window.Instance.Size.Width, 84),\r
                 WidthSpecification = LayoutParamPolicies.MatchParent,\r
                 HeightSpecification = 84,\r
@@ -134,6 +139,7 @@ namespace MusicPlayer.Views
 \r
                     backButton = new Button(buttonStyle)\r
                     {\r
+                        ThemeChangeSensitive = true,\r
                         Size2D = new Size2D(48, 48),\r
                         Margin = new Extents(0, 24, 6, 6),\r
                     };\r
@@ -159,13 +165,14 @@ namespace MusicPlayer.Views
                     {\r
                         Icon = new ImageViewStyle()\r
                         {\r
-                            ResourceUrl = Resources.GetImagePath() + "more_button.png",\r
+                            ResourceUrl = Resources.GetImagePath() + "more.png",\r
                         },\r
                         IsSelectable = false,\r
                         IsEnabled = true,\r
                     };\r
                     moreButton = new Button(buttonStyle)\r
                     {\r
+                        ThemeChangeSensitive = true,\r
                         Size2D = new Size2D(48, 48),\r
                         Margin = new Extents(32, 0, 6, 6),\r
                     };\r
@@ -197,6 +204,7 @@ namespace MusicPlayer.Views
                     };\r
                     searchButton = new Button(buttonStyle)\r
                     {\r
+                        ThemeChangeSensitive = true,\r
                         Size2D = new Size2D(96, 60),\r
                         BackgroundImage = Resources.GetImagePath() + "search_button_bg.png",\r
                         Margin = new Extents(24, 0, 0, 0),\r
index 1c070d1e8778b67767256d54eca673f101669fef..071523ff9c61f07be8393f56291661ace41e4560 100755 (executable)
@@ -53,30 +53,41 @@ namespace MusicPlayer.Views
             };\r
             base.Add(itemSeperator);\r
 \r
-            titleLabel = new TextLabel()\r
+            titleLabel = new TextLabel("ItemLabel")\r
             {\r
+                ThemeChangeSensitive = true,\r
                 WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
                 HeightSpecification = 40,\r
-                TextColor = Color.Blue,\r
                 PixelSize = 32,\r
                 FontFamily = "BreezeSans",\r
                 VerticalAlignment = VerticalAlignment.Center,\r
                 IsCreateByXaml = true,\r
                 Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin),\r
             };\r
+            // ToDo need to make this a readonly const\r
+            PropertyMap titleFontStyle = new PropertyMap();\r
+            titleFontStyle.Add("width", new PropertyValue("normal"));\r
+            titleFontStyle.Add("weight", new PropertyValue("light"));\r
+            titleLabel.FontStyle = titleFontStyle;\r
             base.Add(titleLabel);\r
 \r
-            subtitleLabel = new TextLabel()\r
+            subtitleLabel = new TextLabel("ItemLabel")\r
             {\r
+                ThemeChangeSensitive = true,\r
                 WidthSpecification = (Width - (2 * LeftPadding) - IconSize - LayoutPadding),\r
                 HeightSpecification = 36,\r
-                TextColor = Color.Black,\r
                 PixelSize = 28,\r
                 FontFamily = "BreezeSans",\r
                 VerticalAlignment = VerticalAlignment.Center,\r
                 IsCreateByXaml = true,\r
                 Position2D = new Position2D((x + IconSize + LayoutPadding), LayoutMargin + 40)\r
             };\r
+            // ToDo need to make this a readonly const\r
+            PropertyMap subtitleFontStyle = new PropertyMap();\r
+            subtitleFontStyle.Add("width", new PropertyValue("normal"));\r
+            subtitleFontStyle.Add("weight", new PropertyValue("normal"));\r
+            subtitleFontStyle.Add("slant", new PropertyValue("normal"));\r
+            subtitleLabel.FontStyle = subtitleFontStyle;\r
             base.Add(subtitleLabel);\r
             IsCreateByXaml = true;\r
         }\r
index 06ee7735647e4c064b47628ce76b149755780213..b0a588387d79a3f30432309d6d56e3e26da78c8c 100755 (executable)
@@ -5,6 +5,8 @@ using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Binding;
 using MusicPlayer.Common;
 using MusicPlayer.ViewModels;
+using MusicPlayer.Views.Utils;
+using System.Collections.Generic;
 
 namespace MusicPlayer.Views
 {
@@ -34,11 +36,11 @@ namespace MusicPlayer.Views
 
         private View controlsView;
         private View sliderView;
-        private Button playButton;
+        private MultiStateButton playButton;
         private Button prevButton;
         private Button nextButton;
-        private Button shuffleButton;
-        private Button repeatButton;
+        private MultiStateButton shuffleButton;
+        private MultiStateButton repeatButton;
         private Slider volumeSlider;
         private Slider playbackSlider;
         private TextLabel titleLabel;
@@ -51,7 +53,7 @@ namespace MusicPlayer.Views
         private ImageView thumb;
         private Button listButton;
         private Button playlistButton;
-        private Button favouriteButton;
+        private MultiStateButton favouriteButton;
         private PlayingListView currentListView;
         private LyricsView lyricsView;
 
@@ -63,7 +65,7 @@ namespace MusicPlayer.Views
         {
             this.viewModel = viewModel;
             BindingContext = viewModel.playerModel;
-            BackgroundColor = Color.White;
+            StyleName = "AppBackground";
             WidthResizePolicy = ResizePolicyType.FillToParent;
             HeightResizePolicy = ResizePolicyType.FillToParent;
 
@@ -96,42 +98,6 @@ namespace MusicPlayer.Views
             playerBackgroundView.SetBinding(BackgroundProperty, "PlayerBackground");
         }
 
-        private Button CreateButton(ImageViewStyle style, int x, int y)
-        {
-            ButtonStyle buttonStyle = new ButtonStyle()
-            {
-                Icon = style,
-                IsSelectable = false,
-                IsEnabled = true,
-            };
-            Button button = new Button(buttonStyle)
-            {
-                Size2D = new Size2D(IconSize, IconSize),
-                Position2D = new Position2D(x, y),
-            };
-            return button;
-        }
-
-        private Button CreateButton(string url, int x, int y)
-        {
-            ButtonStyle buttonStyle = new ButtonStyle()
-            {
-                Icon = new ImageViewStyle()
-                {
-                    ResourceUrl = url,
-                },
-                IsSelectable = false,
-                IsEnabled = true,
-            };
-
-            Button button = new Button(buttonStyle)
-            {
-                Size2D = new Size2D(IconSize, IconSize),
-                Position2D = new Position2D(x, y),
-            };
-            return button;
-        }
-
         private View CreateLeftView()
         {
             View leftView = new View()
@@ -188,10 +154,14 @@ namespace MusicPlayer.Views
 
         private void AddTopButtons()
         {
-            backButton = CreateButton(Resources.GetImagePath() + "back_button.png", LayoutPadding, TopBarButtonsY);
+            backButton = new Button("BackButton");
+            backButton.ThemeChangeSensitive = true;
+            backButton.Position2D = new Position2D(LayoutPadding, TopBarButtonsY);
             leftView.Add(backButton);
 
-            moreButton = CreateButton(Resources.GetImagePath() + "more_button.png", Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, TopBarButtonsY);
+            moreButton = new Button("MoreButton");
+            moreButton.ThemeChangeSensitive = true;
+            moreButton.Position2D = new Position2D(Window.Instance.WindowSize.Width / 2 - LayoutPadding - IconSize, TopBarButtonsY);
             rightView.Add(moreButton);
         }
 
@@ -208,13 +178,13 @@ namespace MusicPlayer.Views
 
         private void AddTitleLabel()
         {
-            titleLabel = new TextLabel()
+            titleLabel = new TextLabel("LabelText")
             {
+                ThemeChangeSensitive = true,
                 Size2D = new Size2D(ControlViewWidth, TitleLabelHeight),
                 Position2D = new Position2D(0, 0),
                 PixelSize = 36,
                 FontFamily = "BreezeSans",
-                TextColor = UIColors.HEX001447,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 Ellipsis = true,
@@ -225,13 +195,13 @@ namespace MusicPlayer.Views
 
         private void AddArtistLabel()
         {
-            artistLabel = new TextLabel()
+            artistLabel = new TextLabel("LabelText")
             {
+                ThemeChangeSensitive = true,
                 Size2D = new Size2D(ControlViewWidth, ArtistLabelHeight),
                 Position2D = new Position2D(0, 62),
                 PixelSize = 28,
                 FontFamily = "BreezeSans",
-                TextColor = UIColors.HEX001447,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 Ellipsis = true,
@@ -248,9 +218,56 @@ namespace MusicPlayer.Views
 
         private void AddShuffleButton()
         {
-            shuffleButton = CreateButton(Resources.GetImagePath() + "shuffle.png", 0, 196);
-            shuffleButton.Icon.BindingContext = viewModel.playingListViewModel;
-            shuffleButton.Icon.SetBinding(ImageView.ResourceUrlProperty, "ShuffleUrl");
+            shuffleButton = new MultiStateButton()
+            {
+                Size2D = new Size2D(IconSize, IconSize),
+                Position2D = new Position2D(0, 196),
+                IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()
+                {
+                    {
+                        ThemeType.Light,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                ShuffleMode.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/shuffle_off.png",
+                                }
+                            },
+                            {
+                                ShuffleMode.On.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/shuffle_on.png",
+                                }
+                            },
+                        }
+                    },
+                    {
+                        ThemeType.Dark,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                ShuffleMode.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/shuffle_off.png",
+                                }
+                            },
+                            {
+                                ShuffleMode.On.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/shuffle_on.png",
+                                }
+                            },
+                        }
+                    }
+                },
+            };
+            shuffleButton.BindingContext = viewModel.playingListViewModel;
+            shuffleButton.SetBinding(MultiStateButton.CustomStateProperty, "ShuffleButtonState");
             // TODO need to implement command instead
             shuffleButton.Clicked += (object sender, ClickedEventArgs e) =>
             {
@@ -261,15 +278,8 @@ namespace MusicPlayer.Views
 
         private void AddPreviousButton()
         {
-            ImageViewStyle prevIconStyle = new ImageViewStyle()
-            {
-                ResourceUrl = new Selector<string>
-                {
-                    Normal = Resources.GetImagePath() + "prev.png",
-                    Disabled = Resources.GetImagePath() + "prev_disabled.png"
-                },
-            };
-            prevButton = CreateButton(prevIconStyle, 168, 196);
+            prevButton = new Button("PrevButton");
+            prevButton.ThemeChangeSensitive = true;
             // TODO need to implement command instead
             prevButton.Clicked += (object sender, ClickedEventArgs e) =>
             {
@@ -282,9 +292,65 @@ namespace MusicPlayer.Views
 
         private void AddPlayButton()
         {
-            playButton = CreateButton(Resources.GetImagePath() + "play.png", 296, 196);
-            playButton.Icon.BindingContext = viewModel;
-            playButton.Icon.SetBinding(ImageView.ResourceUrlProperty, "PlayPauseUrl");
+            playButton = new MultiStateButton()
+            {
+                Size2D = new Size2D(IconSize, IconSize),
+                Position2D = new Position2D(296, 196),
+                BackgroundColor = Color.Transparent,
+                IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()
+                {
+                    {
+                        ThemeType.Light,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                "Play",
+                                new StringSelector()
+                                {
+                                    Normal = Resources.GetImagePath() + "light/play.png",
+                                    Pressed = Resources.GetImagePath() + "play_pressed.png",
+                                    Disabled = Resources.GetImagePath() + "play_disabled.png",
+                                }
+                            },
+                            {
+                                "Pause",
+                                new StringSelector()
+                                {
+                                    Normal = Resources.GetImagePath() + "light/pause.png",
+                                    Pressed = Resources.GetImagePath() + "pause_pressed.png",
+                                    Disabled = Resources.GetImagePath() + "pause_disabled.png",
+                                }
+                            },
+                        }
+                    },
+                    {
+                        ThemeType.Dark,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                "Play",
+                                new StringSelector()
+                                {
+                                    Normal = Resources.GetImagePath() + "dark/play.png",
+                                    Pressed = Resources.GetImagePath() + "play_pressed.png",
+                                    Disabled = Resources.GetImagePath() + "play_disabled.png",
+                                }
+                            },
+                            {
+                                "Pause",
+                                new StringSelector()
+                                {
+                                    Normal = Resources.GetImagePath() + "dark/pause.png",
+                                    Pressed = Resources.GetImagePath() + "pause_pressed.png",
+                                    Disabled = Resources.GetImagePath() + "pause_disabled.png",
+                                }
+                            },
+                        }
+                    }
+                },
+            };
+            playButton.BindingContext = viewModel;
+            playButton.SetBinding(MultiStateButton.CustomStateProperty, "PlayButtonState");
             controlsView.Add(playButton);
             // TODO need to implement command instead
             playButton.Clicked += (object sender, ClickedEventArgs e) =>
@@ -295,16 +361,8 @@ namespace MusicPlayer.Views
 
         private void AddNextButton()
         {
-            ImageViewStyle nextIconStyle = new ImageViewStyle()
-            {
-                ResourceUrl = new Selector<string>
-                {
-                    Normal = Resources.GetImagePath() + "next.png",
-                    Disabled = Resources.GetImagePath() + "next_disabled.png",
-                },
-            };
-
-            nextButton = CreateButton(nextIconStyle, 424, 196);
+            nextButton = new Button("NextButton");
+            nextButton.ThemeChangeSensitive = true;
             // TODO need to implement command instead
             nextButton.Clicked += (object sender, ClickedEventArgs e) =>
             {
@@ -317,9 +375,70 @@ namespace MusicPlayer.Views
 
         private void AddRepeatButton()
         {
-            repeatButton = CreateButton(Resources.GetImagePath() + "repeat.png", 592, 196);
-            repeatButton.Icon.BindingContext = viewModel.playingListViewModel;
-            repeatButton.Icon.SetBinding(ImageView.ResourceUrlProperty, "RepeatUrl");
+            repeatButton = new MultiStateButton()
+            {
+                Size2D = new Size2D(IconSize, IconSize),
+                Position2D = new Position2D(592, 196),
+                IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()
+                {
+                    {
+                        ThemeType.Light,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                RepeatMode.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/repeat_off.png",
+                                }
+                            },
+                            {
+                                RepeatMode.RepeatOne.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/repeat_one.png",
+                                }
+                            },
+                            {
+                                RepeatMode.RepeatAll.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/repeat_all.png",
+                                }
+                            },
+                        }
+                    },
+                    {
+                        ThemeType.Dark,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                RepeatMode.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/repeat_off.png",
+                                }
+                            },
+                            {
+                                RepeatMode.RepeatOne.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/repeat_one.png",
+                                }
+                            },
+                            {
+                                RepeatMode.RepeatAll.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/repeat_all.png",
+                                }
+                            },
+                        }
+                    }
+                },
+            };
+            repeatButton.BindingContext = viewModel.playingListViewModel;
+            repeatButton.SetBinding(MultiStateButton.CustomStateProperty, "RepeatButtonState");
             controlsView.Add(repeatButton);
             // TODO need to implement command instead
             repeatButton.Clicked += (object sender, ClickedEventArgs e) =>
@@ -339,48 +458,24 @@ namespace MusicPlayer.Views
 
         private void AddLeftVolumeIcon()
         {
-            leftVolumeIcon = new ImageView(Resources.GetImagePath() + "left_sound_icon.png")
+            leftVolumeIcon = new ImageView()
             {
-                Size2D = new Size2D(IconSize, IconSize),
-                Position2D = new Position2D(0, 336),
+                ThemeChangeSensitive = true,
+                StyleName = "LeftVolume",
             };
             controlsView.Add(leftVolumeIcon);
         }
 
         private void AddRightVolumeIcon()
         {
-            rightVolumeIcon = new ImageView(Resources.GetImagePath() + "right_sound_icon.png")
+            rightVolumeIcon = new ImageView()
             {
-                Size2D = new Size2D(IconSize, IconSize),
-                Position2D = new Position2D(592, 336),
+                ThemeChangeSensitive = true,
+                StyleName = "RightVolume",
             };
             controlsView.Add(rightVolumeIcon);
         }
 
-        private SliderStyle CreateVolumeSliderStyle()
-        {
-            SliderStyle volumeSliderStyle = new SliderStyle()
-            {
-                IndicatorType = Slider.IndicatorType.Image,
-                TrackThickness = 4,
-                Track = new ImageViewStyle
-                {
-                    ResourceUrl = new Selector<string>
-                    {
-                        All = Resources.GetImagePath() + "empty_track.png",
-                    },
-                },
-                Progress = new ImageViewStyle
-                {
-                    ResourceUrl = new Selector<string>
-                    {
-                        All = Resources.GetImagePath() + "progress_track.png",
-                    },
-                },
-            };
-            return volumeSliderStyle;
-        }
-
         private void AddVolumeSliderEventHandlers()
         {
             volumeSlider.SlidingStarted += (object sender, SliderSlidingStartedEventArgs e) =>
@@ -399,14 +494,8 @@ namespace MusicPlayer.Views
 
         private void AddVolumeSlider()
         {
-            volumeSlider = new Slider(CreateVolumeSliderStyle());
-            volumeSlider.Indicator = Slider.IndicatorType.Text;
-            volumeSlider.TrackThickness = 4;
-            volumeSlider.ThumbImageURLSelector = new StringSelector
-            {
-                Normal = Resources.GetImagePath() + "nomal_slider_handler.png",
-                Pressed = Resources.GetImagePath() + "nomal_slider_handler.png"
-            };
+            volumeSlider = new Slider("Slider");
+            volumeSlider.ThemeChangeSensitive = true;
             volumeSlider.Size2D = new Size2D(496, 48);
             volumeSlider.Position2D = new Position2D(72, 336);
             volumeSlider.ThumbSize = new Tizen.NUI.Size(36, 36);
@@ -434,30 +523,6 @@ namespace MusicPlayer.Views
             AddVolumeSliderElements();
         }
 
-        private SliderStyle CreatePlaybackSliderStyle()
-        {
-            SliderStyle playbackSliderStyle = new SliderStyle()
-            {
-                IndicatorType = Slider.IndicatorType.Image,
-                TrackThickness = 4,
-                Track = new ImageViewStyle
-                {
-                    ResourceUrl = new Selector<string>
-                    {
-                        All = Resources.GetImagePath() + "empty_track.png",
-                    },
-                },
-                Progress = new ImageViewStyle
-                {
-                    ResourceUrl = new Selector<string>
-                    {
-                        All = Resources.GetImagePath() + "progress_track.png",
-                    },
-                },
-            };
-            return playbackSliderStyle;
-        }
-
         private void AddPlaybackSliderEventHandler()
         {
             playbackSlider.SlidingStarted += (object sender, SliderSlidingStartedEventArgs e) =>
@@ -476,20 +541,15 @@ namespace MusicPlayer.Views
 
         private void AddPlaybackSlider(View sliderView)
         {
-            playbackSlider = new Slider(CreatePlaybackSliderStyle())
+            playbackSlider = new Slider("Slider")
             {
-                ThumbImageURLSelector = new StringSelector
-                {
-                    Normal = Resources.GetImagePath() + "nomal_slider_handler.png",
-                    Pressed = Resources.GetImagePath() + "nomal_slider_handler.png"
-                },
+                ThemeChangeSensitive = true,
                 MinValue = 0.0f,
                 MaxValue = 1.0f,
                 WidthResizePolicy = ResizePolicyType.FillToParent,
                 SizeHeight = 44,
                 ThumbSize = new Tizen.NUI.Size(36, 36),
                 Direction = Slider.DirectionType.Horizontal,
-                IsCreateByXaml = true,
             };
             playbackSlider.SetBinding(Slider.CurrentValueProperty, "ElapsedTime");
             sliderView.Add(playbackSlider);
@@ -498,11 +558,11 @@ namespace MusicPlayer.Views
 
         private void AddCurrentTimeLabel(View sliderView)
         {
-            currentTime = new TextLabel()
+            currentTime = new TextLabel("LabelText")
             {
+                ThemeChangeSensitive = true,
                 Size2D = new Size2D(400, 32),
                 Position2D = new Position2D(0, 48),
-                TextColor = UIColors.HEX001447,
                 PixelSize = 24,
                 FontFamily = "BreezeSans",
                 Text = "00::00:00",
@@ -514,11 +574,11 @@ namespace MusicPlayer.Views
 
         private void AddTotalTimeLabel(View sliderView)
         {
-            totalTime = new TextLabel()
+            totalTime = new TextLabel("LabelText")
             {
+                ThemeChangeSensitive = true,
                 Size2D = new Size2D(400, 32),
                 Position2D = new Position2D(1792 - 400, 48),
-                TextColor = UIColors.HEX001447,
                 PixelSize = 24,
                 FontFamily = "BreezeSans",
                 HorizontalAlignment = HorizontalAlignment.End,
@@ -576,7 +636,10 @@ namespace MusicPlayer.Views
             };
             rightView.Add(actionButtonView);
 
-            listButton = CreateButton(Resources.GetImagePath() + "playing_queue.png", 0, 0);
+            listButton = new Button("ListButton")
+            {
+                ThemeChangeSensitive = true,
+            };
             listButton.Clicked += (object sender, ClickedEventArgs e) =>
             {
                 if(viewState == PlayerViewState.AlbumArt)
@@ -600,10 +663,61 @@ namespace MusicPlayer.Views
             };
             actionButtonView.Add(listButton);
 
-            playlistButton = CreateButton(Resources.GetImagePath() + "addtoplaylist.png", 88, 0);
+            playlistButton = new Button("PlaylistButton")
+            {
+                ThemeChangeSensitive = true,
+            };
             actionButtonView.Add(playlistButton);
 
-            favouriteButton = CreateButton(Resources.GetImagePath() + "favourite_off.png", 176, 0);
+            favouriteButton = new MultiStateButton()
+            {
+                Size2D = new Size2D(IconSize, IconSize),
+                Position2D = new Position2D(176, 0),
+                IconResources = new Dictionary<ThemeType, Dictionary<string, StringSelector>>()
+                {
+                    {
+                        ThemeType.Light,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                Favourite.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/favourite_off.png",
+                                }
+                            },
+                            {
+                                Favourite.On.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "light/favourite_on.png",
+                                }
+                            },
+                        }
+                    },
+                    {
+                        ThemeType.Dark,
+                        new Dictionary<string, StringSelector>()
+                        {
+                            {
+                                Favourite.Off.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/favourite_off.png",
+                                }
+                            },
+                            {
+                                Favourite.On.ToString(),
+                                new StringSelector()
+                                {
+                                    All = Resources.GetImagePath() + "dark/favourite_on.png",
+                                }
+                            },
+                        }
+                    }
+                },
+            };
+            favouriteButton.CusotmState = Favourite.Off.ToString();
             actionButtonView.Add(favouriteButton);
         }
 
index 95467e5b27f0d58a50ee9cdb40c0ccc15a161a23..daa7df15e74ee855f7281628fd008ed2603142a8 100755 (executable)
@@ -16,9 +16,8 @@ namespace MusicPlayer.Views
         public TrackView(TrackViewModel viewModel)\r
         {\r
             this.viewModel = viewModel;\r
-            BindingContext = viewModel;\r
             collectionView.ItemsSource = viewModel.ListViewModel;\r
-            collectionView.ItemTemplate= new DataTemplate(()=>\r
+            collectionView.ItemTemplate = new DataTemplate(() =>\r
             {\r
                 ListItemLayout layout = new ListItemLayout();\r
                 layout.Icon.SetBinding(ImageView.ResourceUrlProperty, "ThumbnailPath");\r
@@ -31,21 +30,40 @@ namespace MusicPlayer.Views
             collectionView.SelectionMode = ItemSelectionMode.Single;\r
             collectionView.SelectionChanged += OnTrackSelection;\r
 \r
-            trackCountLabel = new TextLabel()\r
+            trackCountLabel = new TextLabel("LabelText")\r
             {\r
+                ThemeChangeSensitive = true,\r
                 PixelSize = 28,\r
                 Text = "TRACK COUNT",\r
-                TextColor = UIColors.HEX001447,\r
                 VerticalAlignment = VerticalAlignment.Center,\r
                 FontFamily = "BreezeSans",\r
-                IsCreateByXaml = true,\r
             };\r
+            trackCountLabel.BindingContext = viewModel;\r
             titleView.Add(trackCountLabel);\r
             trackCountLabel.SetBinding(TextLabel.TextProperty, "TrackCount");\r
             RelativeLayout.SetLeftTarget(trackCountLabel, titleView);\r
             RelativeLayout.SetLeftRelativeOffset(trackCountLabel, 1.0f);\r
             RelativeLayout.SetRightRelativeOffset(trackCountLabel, 0.0f);\r
             RelativeLayout.SetFillHorizontal(trackCountLabel, true);\r
+\r
+            playAllIcon = new Button("PlayAll")\r
+            {\r
+                ThemeChangeSensitive = true,\r
+            };\r
+            titleView.Add(playAllIcon);\r
+            RelativeLayout.SetLeftRelativeOffset(playAllIcon, 1.0f);\r
+            RelativeLayout.SetRightRelativeOffset(playAllIcon, 1.0f);\r
+            RelativeLayout.SetHorizontalAlignment(playAllIcon, RelativeLayout.Alignment.End);\r
+\r
+            addToPlaylistIcon = new Button("PlaylistAdd")\r
+            {\r
+                ThemeChangeSensitive = true,\r
+                Margin = new Extents(32, 40, 0, 0),\r
+            };\r
+            titleView.Add(addToPlaylistIcon);\r
+            RelativeLayout.SetRightTarget(addToPlaylistIcon, playAllIcon);\r
+            RelativeLayout.SetRightRelativeOffset(addToPlaylistIcon, 0.0f);\r
+            RelativeLayout.SetHorizontalAlignment(addToPlaylistIcon, RelativeLayout.Alignment.End);\r
         }\r
 \r
         private void OnTrackSelection(object sender, SelectionChangedEventArgs e)\r
@@ -53,6 +71,10 @@ namespace MusicPlayer.Views
             //TODO\r
         }\r
 \r
+        protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e)\r
+        {\r
+            base.OnThemeChanged(sender, e);\r
+        }\r
         protected override void Dispose(DisposeTypes type)\r
         {\r
             if(Disposed)\r
@@ -66,13 +88,13 @@ namespace MusicPlayer.Views
                 trackCountLabel = null;\r
 \r
                 // TODO Uncomment after implementation is completed\r
-                //titleView.Remove(playAllIcon);\r
-                //playAllIcon.Dispose();\r
-                //playAllIcon = null;\r
+                titleView.Remove(playAllIcon);\r
+                playAllIcon.Dispose();\r
+                playAllIcon = null;\r
 \r
                 //titleView.Remove(addToPlaylistIcon);\r
-                //addToPlaylistIcon.Dispose();\r
-                //addToPlaylistIcon = null;\r
+                addToPlaylistIcon.Dispose();\r
+                addToPlaylistIcon = null;\r
             }\r
             base.Dispose(type);\r
         }\r