using Tizen.NUI.Binding;
using MusicPlayer.Common;
using MusicPlayer.ViewModels;
+using MusicPlayer.Views.Utils;
+using System.Collections.Generic;
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;
private ImageView thumb;
private Button listButton;
private Button playlistButton;
- private Button favouriteButton;
+ private MultiStateButton favouriteButton;
private PlayingListView currentListView;
private LyricsView lyricsView;
{
this.viewModel = viewModel;
BindingContext = viewModel.playerModel;
- BackgroundColor = Color.White;
+ StyleName = "AppBackground";
WidthResizePolicy = ResizePolicyType.FillToParent;
HeightResizePolicy = ResizePolicyType.FillToParent;
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()
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);
}
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,
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,
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) =>
{
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) =>
{
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) =>
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) =>
{
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) =>
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) =>
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);
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) =>
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);
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",
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,
};
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)
};
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);
}