From 22a524cfd1bc0d9a6c6574283382aaf4966e9bed Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Tue, 3 Dec 2019 15:51:16 -0800 Subject: [PATCH] Icons finally working with pngs (SVGs later maybe) --- Aurora.gtk/Aurora.gtk.csproj | 18 ++- Aurora/Aurora.csproj | 1 + .../Components/ImageButton/ImageButton.xaml | 11 ++ .../ImageButton/ImageButton.xaml.cs | 105 ++++++++++++++++++ .../Design/Components/MediaPlayer/Player.css | 8 ++ .../Design/Components/MediaPlayer/Player.xaml | 21 ++-- .../Components/MediaPlayer/Player.xaml.cs | 12 +- Aurora/Design/Views/MainView/MainView.css | 5 + Aurora/Design/Views/MainView/MainView.xaml | 2 +- 9 files changed, 158 insertions(+), 25 deletions(-) create mode 100644 Aurora/Design/Components/ImageButton/ImageButton.xaml create mode 100644 Aurora/Design/Components/ImageButton/ImageButton.xaml.cs diff --git a/Aurora.gtk/Aurora.gtk.csproj b/Aurora.gtk/Aurora.gtk.csproj index bd0e220..8635ae6 100644 --- a/Aurora.gtk/Aurora.gtk.csproj +++ b/Aurora.gtk/Aurora.gtk.csproj @@ -169,10 +169,6 @@ Always - - - - @@ -509,6 +505,20 @@ Aurora + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + diff --git a/Aurora/Aurora.csproj b/Aurora/Aurora.csproj index e0a58ce..1083c4b 100644 --- a/Aurora/Aurora.csproj +++ b/Aurora/Aurora.csproj @@ -44,6 +44,7 @@ + diff --git a/Aurora/Design/Components/ImageButton/ImageButton.xaml b/Aurora/Design/Components/ImageButton/ImageButton.xaml new file mode 100644 index 0000000..0ad022c --- /dev/null +++ b/Aurora/Design/Components/ImageButton/ImageButton.xaml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Aurora/Design/Components/ImageButton/ImageButton.xaml.cs b/Aurora/Design/Components/ImageButton/ImageButton.xaml.cs new file mode 100644 index 0000000..cf5d90a --- /dev/null +++ b/Aurora/Design/Components/ImageButton/ImageButton.xaml.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using Xamarin.Forms; + +namespace Aurora.Design.Components.ImageButton +{ + public partial class ImageButton : ContentView + { + public ImageButton() + { + InitializeComponent(); + } + + public static readonly BindableProperty SourceProperty = + BindableProperty.Create( + "Source", + typeof(ImageSource), + typeof(ImageButton), + null, + BindingMode.TwoWay, + propertyChanged: (bindable, oldValue, newValue) => + { + ImageButton control = (ImageButton)bindable; + + control.imgButton.Source = (ImageSource)newValue; + }); + + public static readonly BindableProperty CommandProperty = BindableProperty.Create( + "Command", + typeof(Command), + typeof(ImageButton), + null, + propertyChanged: (bindable, oldValue, newValue) => + { + ImageButton control = (ImageButton)bindable; + var command = (Command)newValue; + + CanExecute(command, control); + + command.CanExecuteChanged += (sender, e) => + { + CanExecute(sender, control); + }; + }); + + public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create( + "CommandParameter", + typeof(object), + typeof(ImageButton), + null); + + private static void CanExecute(object sender, ImageButton control) + { + var cmd = (Command)sender; + control.imgButton.IsEnabled = cmd.CanExecute(null); + } + + public ImageSource Source + { + get { return (ImageSource)GetValue(SourceProperty); } + set { SetValue(SourceProperty, value); } + } + + + public event EventHandler Tapped; + + public Command Command + { + get { return (Command)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + + public object CommandParameter + { + get { return GetValue(CommandParameterProperty); } + set { SetValue(CommandParameterProperty, value); } + } + + protected void OnButtonTapped(object sender, EventArgs args) + { + object resolvedParameter; + + if (CommandParameter != null) + { + resolvedParameter = CommandParameter; + } + else + { + resolvedParameter = args; + } + + if (Command?.CanExecute(resolvedParameter) ?? true) + { + this.AbortAnimation("imgButtonAnim"); + new Animation(v => imgButton.Scale = v, 1, 0.5).Commit(imgButton, "imgButtonAnim", 16, 150, Easing.SinOut, + (v, c) => + { + imgButton.Scale = 1; + Tapped?.Invoke(this, args); + Command?.Execute(resolvedParameter); + }); + } + } + } +} diff --git a/Aurora/Design/Components/MediaPlayer/Player.css b/Aurora/Design/Components/MediaPlayer/Player.css index 6648058..5fc79aa 100644 --- a/Aurora/Design/Components/MediaPlayer/Player.css +++ b/Aurora/Design/Components/MediaPlayer/Player.css @@ -8,3 +8,11 @@ #MediaInfoLayout label { margin-left: 20; } + +ImageButton { + margin-top: 10; + margin-left: 20; + margin-right: 20; + margin-bottom: 10; + width: 40; +} diff --git a/Aurora/Design/Components/MediaPlayer/Player.xaml b/Aurora/Design/Components/MediaPlayer/Player.xaml index 7d15ab6..ea51ed1 100644 --- a/Aurora/Design/Components/MediaPlayer/Player.xaml +++ b/Aurora/Design/Components/MediaPlayer/Player.xaml @@ -2,7 +2,7 @@ - - - + - + + Source="Resources/forwards.png"/> diff --git a/Aurora/Design/Components/MediaPlayer/Player.xaml.cs b/Aurora/Design/Components/MediaPlayer/Player.xaml.cs index 35947b4..f00fbe1 100644 --- a/Aurora/Design/Components/MediaPlayer/Player.xaml.cs +++ b/Aurora/Design/Components/MediaPlayer/Player.xaml.cs @@ -107,14 +107,14 @@ namespace Aurora.Design.Components.MediaPlayer if (newValue is Command) { Command cmd = newValue as Command; - component.PreviousButton.Clicked += component.OnPreviousButtonClicked; + component.PreviousButton.Tapped += component.OnPreviousButtonClicked; cmd.CanExecuteChanged += (sender, e) => OnPreviousButtonCanExecuteChanged(sender, e, component, cmd); } if (oldValue is Command && oldValue != null) { Command cmd = newValue as Command; - component.PreviousButton.Clicked -= component.OnPreviousButtonClicked; + component.PreviousButton.Tapped -= component.OnPreviousButtonClicked; cmd.CanExecuteChanged -= (sender, e) => OnPreviousButtonCanExecuteChanged(sender, e, component, cmd); } } @@ -177,14 +177,14 @@ namespace Aurora.Design.Components.MediaPlayer if (newValue is Command) { Command cmd = newValue as Command; - component.PlayButton.Clicked += component.OnPlayButtonClicked; + component.PlayButton.Tapped += component.OnPlayButtonClicked; cmd.CanExecuteChanged += (sender, e) => OnPlayButtonCanExecuteChanged(sender, e, component, cmd); } if (oldValue is Command && oldValue != null) { Command cmd = newValue as Command; - component.PlayButton.Clicked -= component.OnPlayButtonClicked; + component.PlayButton.Tapped -= component.OnPlayButtonClicked; cmd.CanExecuteChanged -= (sender, e) => OnPlayButtonCanExecuteChanged(sender, e, component, cmd); } } @@ -247,14 +247,14 @@ namespace Aurora.Design.Components.MediaPlayer if (newValue is Command) { Command cmd = newValue as Command; - component.NextButton.Clicked += component.OnNextButtonClicked; + component.NextButton.Tapped += component.OnNextButtonClicked; cmd.CanExecuteChanged += (sender, e) => OnNextButtonCanExecuteChanged(sender, e, component, cmd); } if (oldValue is Command && oldValue != null) { Command cmd = oldValue as Command; - component.NextButton.Clicked -= component.OnNextButtonClicked; + component.NextButton.Tapped -= component.OnNextButtonClicked; cmd.CanExecuteChanged -= (sender, e) => OnNextButtonCanExecuteChanged(sender, e, component, cmd); } } diff --git a/Aurora/Design/Views/MainView/MainView.css b/Aurora/Design/Views/MainView/MainView.css index d6d97f2..77cbc0e 100644 --- a/Aurora/Design/Views/MainView/MainView.css +++ b/Aurora/Design/Views/MainView/MainView.css @@ -14,6 +14,7 @@ #TitleContainer { margin-top: 10; + background-color: #3a3a3a; } #TitleContainer Label { @@ -22,3 +23,7 @@ font-size: 18; vertical-align: bottom; } + +#Player { + background-color: #626363; +} diff --git a/Aurora/Design/Views/MainView/MainView.xaml b/Aurora/Design/Views/MainView/MainView.xaml index 328efd9..c0a1c47 100644 --- a/Aurora/Design/Views/MainView/MainView.xaml +++ b/Aurora/Design/Views/MainView/MainView.xaml @@ -15,7 +15,7 @@ - +