Skip to content

Commit

Permalink
Added bounce to settings circular buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Programming-With-Chris committed Aug 21, 2022
1 parent 9edbd74 commit 1454595
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 0 additions & 4 deletions ShoppingList/Controls/CircularButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ static void OnImageChanged(BindableObject bindable, object oldValue, object newV
static void OnIsVisibleChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (CircularButton)bindable;
var thisDrawable = control.Drawable as CircularButtonDrawable;

//thisDrawable.SetInvisible = !(bool)newValue;
//control.Invalidate();

var newValueAsBool = (bool)newValue;

Expand Down
2 changes: 1 addition & 1 deletion ShoppingList/ShoppingList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-android;</TargetFrameworks>
<!-- <TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>-->
<!--<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>-->
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->

Expand Down
17 changes: 9 additions & 8 deletions ShoppingList/View/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
x:Name="Nautical">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Nautical"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -102,7 +102,8 @@
x:Name="Neon">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer
Tapped="ThemeButtonPressed"
CommandParameter="Neon"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -115,7 +116,7 @@
x:Name="Striking">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Striking"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -128,7 +129,7 @@
x:Name="Muted">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Muted"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -141,7 +142,7 @@
x:Name="Pretty">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Pretty"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -166,7 +167,7 @@
x:Name="Royalty">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Royalty"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -179,7 +180,7 @@
x:Name="DeepRed">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="DeepRed"/>
</control:CircularButton.GestureRecognizers>

Expand All @@ -192,7 +193,7 @@
x:Name="Depression">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
<TapGestureRecognizer Tapped="ThemeButtonPressed"
CommandParameter="Depression"/>
</control:CircularButton.GestureRecognizers>

Expand Down
12 changes: 12 additions & 0 deletions ShoppingList/View/SettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ namespace ShoppingList;
public partial class SettingsView : ContentPage
{

SettingsViewModel _svm;

public SettingsView(SettingsViewModel settingsViewModel)
{
InitializeComponent();
BindingContext = settingsViewModel;
_svm = settingsViewModel;

}

private async void ThemeButtonPressed(object sender, EventArgs e)
{
var circularButton = sender as CircularButton;
var themeName = ((TappedEventArgs)e).Parameter.ToString();

await circularButton.BounceOnPressAsync();

_svm.UpdatePrimaryColorPressed(themeName);

}
}

0 comments on commit 1454595

Please sign in to comment.