This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathImageButtonCoreGalleryPage.cs
135 lines (112 loc) · 4.06 KB
/
ImageButtonCoreGalleryPage.cs
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
using System;
using Xamarin.Forms.CustomAttributes;
namespace Xamarin.Forms.Controls
{
internal class ImageButtonCoreGalleryPage : CoreGalleryPage<ImageButton>
{
protected override bool SupportsFocus => false;
protected override bool SupportsTapGestureRecognizer => false;
protected override void InitializeElement(ImageButton element)
{
element.Source = "oasissmall.jpg";
}
protected override void Build(StackLayout stackLayout)
{
base.Build(stackLayout);
IsEnabledStateViewContainer.View.Clicked += (sender, args) =>
{
IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";
};
var aspectFillContainer = new ViewContainer<ImageButton>(Test.ImageButton.AspectFill, new ImageButton { Aspect = Aspect.AspectFill });
var aspectFitContainer = new ViewContainer<ImageButton>(Test.ImageButton.AspectFit, new ImageButton { Aspect = Aspect.AspectFit });
var fillContainer = new ViewContainer<ImageButton>(Test.ImageButton.Fill, new ImageButton { Aspect = Aspect.Fill });
var isLoadingContainer = new StateViewContainer<ImageButton>(Test.ImageButton.IsLoading, new ImageButton());
var isOpaqueContainer = new StateViewContainer<ImageButton>(Test.ImageButton.IsOpaque, new ImageButton());
var borderButtonContainer = new ViewContainer<ImageButton>(Test.ImageButton.BorderColor,
new ImageButton
{
BackgroundColor = Color.Transparent,
BorderColor = Color.Red,
BorderWidth = 1,
Source = "oasissmall.jpg"
}
);
var corderRadiusContainer = new ViewContainer<ImageButton>(Test.ImageButton.CornerRadius,
new ImageButton
{
Source = "oasissmall.jpg",
BackgroundColor = Color.Transparent,
BorderColor = Color.Red,
CornerRadius = 20,
BorderWidth = 1,
}
);
var borderWidthContainer = new ViewContainer<ImageButton>(Test.ImageButton.BorderWidth,
new ImageButton
{
Source = "oasissmall.jpg",
BackgroundColor = Color.Transparent,
BorderColor = Color.Red,
BorderWidth = 15,
}
);
var clickedContainer = new EventViewContainer<ImageButton>(Test.ImageButton.Clicked,
new ImageButton
{
Source = "oasissmall.jpg"
}
);
clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired();
var pressedContainer = new EventViewContainer<ImageButton>(Test.ImageButton.Pressed,
new ImageButton
{
Source = "oasissmall.jpg"
}
);
pressedContainer.View.Pressed += (sender, args) => pressedContainer.EventFired();
var commandContainer = new ViewContainer<ImageButton>(Test.ImageButton.Command,
new ImageButton
{
Command = new Command(() => DisplayActionSheet("Hello Command", "Cancel", "Destroy")),
Source = "oasissmall.jpg"
}
);
var imageContainer = new ViewContainer<ImageButton>(Test.ImageButton.Image,
new ImageButton
{
Source = new FileImageSource { File = "bank.png" }
}
);
var paddingContainer = new ViewContainer<ImageButton>(Test.ImageButton.Padding,
new ImageButton
{
Source = "oasissmall.jpg",
BackgroundColor = Color.Red,
Padding = new Thickness(20, 30, 60, 15)
}
);
InitializeElement(aspectFillContainer.View);
InitializeElement(aspectFitContainer.View);
InitializeElement(fillContainer.View);
InitializeElement(isLoadingContainer.View);
InitializeElement(isOpaqueContainer.View);
var sourceContainer = new ViewContainer<ImageButton>(Test.ImageButton.Source, new ImageButton { Source = "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Xamarin.Forms.Controls/coffee.png" });
var gifContainer = new ViewContainer<ImageButton>(Test.ImageButton.Source, new ImageButton { Source = "GifTwo.gif" });
Add(aspectFillContainer);
Add(aspectFitContainer);
Add(fillContainer);
Add(isLoadingContainer);
Add(isOpaqueContainer);
Add(sourceContainer);
Add(gifContainer);
Add(borderButtonContainer);
Add(borderWidthContainer);
Add(clickedContainer);
Add(commandContainer);
Add(corderRadiusContainer);
Add(imageContainer);
Add(pressedContainer);
Add(paddingContainer);
}
}
}