This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 471
/
TouchEffectPage.xaml
151 lines (126 loc) · 7.21 KB
/
TouchEffectPage.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="UTF-8"?>
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Effects.TouchEffectPage"
x:Name="Page">
<pages:BasePage.Resources>
<Style x:Key="GridRowContentStyle" TargetType="StackLayout">
<Setter Property="HorizontalOptions" Value="CenterAndExpand" />
<Setter Property="VerticalOptions" Value="CenterAndExpand" />
<Setter Property="Spacing" Value="10" />
</Style>
</pages:BasePage.Resources>
<ScrollView>
<StackLayout Padding="{StaticResource ContentPadding}"
Spacing="10">
<StackLayout
Orientation="Horizontal">
<Label
HorizontalOptions="FillAndExpand"
FontSize="Title"
TextColor="Black"
Text="NativeAnimationBorderless"/>
<Switch
IsToggled="{Binding NativeAnimationBorderless, Source={x:Reference Page}}"/>
</StackLayout>
<Label
HorizontalOptions="CenterAndExpand"
FontSize="Title"
TextColor="Black"
Text="{Binding TouchCount, StringFormat='Touches: {0}', Source={x:Reference Page}}" />
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Image | Toggle" />
<Image xct:TouchEffect.NormalBackgroundImageSource="{xct:ImageResource Id=Xamarin.CommunityToolkit.Sample.Images.button.png}"
xct:TouchEffect.PressedBackgroundImageSource="{xct:ImageResource Id=Xamarin.CommunityToolkit.Sample.Images.button_pressed.png}"
xct:TouchEffect.IsToggled="False"
xct:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}"/>
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Scale | Fade | Animated" />
<StackLayout Orientation="Horizontal"
HorizontalOptions="CenterAndExpand"
xct:TouchEffect.AnimationDuration="250"
xct:TouchEffect.AnimationEasing="{x:Static Easing.CubicInOut}"
xct:TouchEffect.PressedScale="0.8"
xct:TouchEffect.PressedOpacity="0.6"
xct:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}">
<BoxView Color="Gold" />
<Label Text="The entire layout receives touches" />
<BoxView Color="Gold"/>
</StackLayout>
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Native | Long Press | Hover" />
<Label HorizontalOptions="CenterAndExpand"
FontSize="Body"
TextColor="Black"
Text="{Binding LongPressCount, StringFormat='Long press count: {0}', Source={x:Reference Page}}" />
<StackLayout Orientation="Horizontal"
HorizontalOptions="CenterAndExpand"
BackgroundColor="Black"
Padding="20"
xct:TouchEffect.HoveredScale="1.2"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.NativeAnimationBorderless="{Binding NativeAnimationBorderless, Source={x:Reference Page}}"
xct:TouchEffect.LongPressCommand="{Binding LongPressCommand, Source={x:Reference Page}}"
xct:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}">
<Label Text="TITLE"
TextColor="White"
FontSize="Large"/>
</StackLayout>
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Color | Rotation | Pulse | Animated" />
<StackLayout Orientation="Horizontal"
HorizontalOptions="CenterAndExpand"
Padding="20"
xct:TouchEffect.AnimationDuration="500"
xct:TouchEffect.PulseCount="2"
xct:TouchEffect.NormalBackgroundColor="Gold"
xct:TouchEffect.PressedBackgroundColor="Orange"
xct:TouchEffect.PressedRotation="15"
xct:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}">
<Label Text="TITLE"
TextColor="White"
FontSize="Large"/>
</StackLayout>
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Image | Native" />
<Image Source="{xct:ImageResource Id=Xamarin.CommunityToolkit.Sample.Images.button.png}"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.NativeAnimationBorderless="{Binding NativeAnimationBorderless, Source={x:Reference Page}}"
xct:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}"/>
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Button | ImageButton" />
<Button
Text="Button"
xct:TouchEffect.Command="{Binding Command, Mode=OneWay, Source={x:Reference Page}}" />
<ImageButton
HeightRequest="150"
Source="xamarinstore.jpg"
xct:TouchEffect.Command="{Binding Command, Mode=OneWay, Source={x:Reference Page}}" />
</StackLayout>
<StackLayout Style="{StaticResource GridRowContentStyle}">
<Label Text="Nested effect" />
<ContentView
HorizontalOptions="CenterAndExpand"
BackgroundColor="Purple"
Padding="50"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.NativeAnimationBorderless="{Binding NativeAnimationBorderless, Source={x:Reference Page}}"
xct:TouchEffect.Command="{Binding ParentCommand, Source={x:Reference Page}}">
<BoxView Color="Gold"
WidthRequest="100"
HeightRequest="100"
xct:TouchEffect.NativeAnimation="True"
xct:TouchEffect.NativeAnimationBorderless="{Binding NativeAnimationBorderless, Source={x:Reference Page}}"
xct:TouchEffect.Command="{Binding ChildCommand, Source={x:Reference Page}}" />
</ContentView>
</StackLayout>
</StackLayout>
</ScrollView>
</pages:BasePage>