Skip to content

Commit d9c24df

Browse files
Merge pull request #45 from Choza-rajan/SfButtonControl
Implementation of the SfButton Control in MAUI Toolkit
2 parents d94f5a5 + 966670e commit d9c24df

File tree

11 files changed

+3537
-1655
lines changed

11 files changed

+3537
-1655
lines changed

maui/src/Button/SfButton.Methods.cs

Lines changed: 909 additions & 0 deletions
Large diffs are not rendered by default.

maui/src/Button/SfButton.Properties.cs

Lines changed: 683 additions & 0 deletions
Large diffs are not rendered by default.

maui/src/Button/SfButton.cs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
using Syncfusion.Maui.Toolkit.EffectsView;
2+
using Syncfusion.Maui.Toolkit.Graphics.Internals;
3+
using Syncfusion.Maui.Toolkit.Themes;
4+
5+
namespace Syncfusion.Maui.Toolkit.Buttons
6+
{
7+
/// <summary>
8+
/// The <see cref="SfButton"/> class provides a way for users to interact with the application
9+
/// by clicking or tapping. It can display text, an icon, or both, and supports various customization options.
10+
/// </summary>
11+
/// <example>
12+
/// The below example shows how to initialize the <see cref="SfButton"/>
13+
/// # [XAML](#tab/tabid-1)
14+
/// <code Lang="XAML"><![CDATA[
15+
/// <toolkit:SfButton
16+
/// x:Name="button"
17+
/// Text="Button"
18+
/// HeightRequest="50"
19+
/// WidthRequest="200"/>
20+
/// ]]></code>
21+
/// # [C#](#tab/tabid-2)
22+
/// <code Lang="C#"><![CDATA[
23+
/// SfButton button = new SfButton();
24+
/// button.Text = "Button";
25+
/// button.WidthRequest = 200;
26+
/// button.HeightRequest = 50;
27+
/// ]]></code>
28+
/// ***
29+
/// </example>
30+
[ContentProperty("Content")]
31+
public partial class SfButton : ButtonBase, ITextElement, IParentThemeElement
32+
{
33+
34+
#region Fields
35+
36+
/// <summary>
37+
/// Represents the number of lines used for text content in the button.
38+
/// </summary>
39+
double _numberOfLines = 1;
40+
41+
/// <summary>
42+
/// Holds a custom view that is optionally added to the button's content.
43+
/// </summary>
44+
View? _customView;
45+
46+
/// <summary>
47+
/// Defines the rectangular bounds for the icon within the button.
48+
/// </summary>
49+
RectF _iconRectF = new();
50+
51+
/// <summary>
52+
/// A reference to the effects view used to add visual effects to the button.
53+
/// </summary>
54+
SfEffectsView? _effectsView;
55+
56+
/// <summary>
57+
/// The size used for semantic purposes to describe the button's layout to assistive technologies.
58+
/// </summary>
59+
Size _buttonSemanticsSize = Size.Zero;
60+
61+
/// <summary>
62+
/// Stores semantic nodes used for accessibility features of the button.
63+
/// </summary>
64+
readonly List<SemanticsNode> _buttonSemanticsNodes = [];
65+
66+
/// <summary>
67+
/// Indicates whether the flow direction of the text is right-to-left.
68+
/// </summary>
69+
bool _isRightToLeft => ((this as IVisualElementController).EffectiveFlowDirection & EffectiveFlowDirection.RightToLeft) == EffectiveFlowDirection.RightToLeft;
70+
71+
/// <summary>
72+
/// Indicates whether the button is currently being pressed.
73+
/// </summary>
74+
bool _isPressed = false;
75+
76+
#if WINDOWS || MACCATALYST
77+
/// <summary>
78+
/// Tracks whether the mouse is hovering over the button.
79+
/// </summary>
80+
bool _isMouseHover = false;
81+
82+
#if WINDOWS
83+
/// <summary>
84+
/// Tracks whether a press action has been invoked.
85+
/// </summary>
86+
bool _isPressInvoked = false;
87+
#endif
88+
#endif
89+
90+
#if IOS || MACCATALYST
91+
/// <summary>
92+
/// Captures the point where a touch-down interaction occurred.
93+
/// </summary>
94+
Point _touchDownPoint;
95+
96+
/// <summary>
97+
/// This constant used to detect whether the interaction is touch or scroll.
98+
/// </summary>
99+
const double ScrollThreshold = 5.0;
100+
#endif
101+
102+
#endregion
103+
104+
#region Constructor
105+
106+
/// <summary>
107+
/// Initializes a new instance of the <see cref="SfButton"/> class.
108+
/// </summary>
109+
public SfButton()
110+
{
111+
InitializeElement();
112+
}
113+
114+
#endregion
115+
116+
#region Destructor
117+
118+
/// <summary>
119+
/// Destructor of the <see cref="SfButton"/> class
120+
/// </summary>
121+
~SfButton()
122+
{
123+
UnhookEvents();
124+
}
125+
126+
#endregion
127+
}
128+
}

maui/src/Chip/Helpers/ChipCollection.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
namespace Syncfusion.Maui.Toolkit.Chips
44
{
5-
/// <summary>
6-
/// Defines the type for adding collection of SfChip.
7-
/// </summary>
8-
public class ChipCollection : ObservableCollection<SfChip>
9-
{
10-
#region Constructor
5+
/// <summary>
6+
/// Defines the type for adding collection of SfChip.
7+
/// </summary>
8+
public partial class ChipCollection : ObservableCollection<SfChip>
9+
{
10+
#region Constructor
1111

12-
/// <summary>
13-
/// Initializes a new instance of the <see cref="ChipCollection"/> class.
14-
/// </summary>
15-
/// <param name="group">Chip group.</param>
16-
public ChipCollection(SfChipGroup group)
17-
{
18-
if (group != null)
19-
{
20-
CollectionChanged += group.ItemsCollectionChanged;
21-
}
22-
}
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="ChipCollection"/> class.
14+
/// </summary>
15+
/// <param name="group">Chip group.</param>
16+
public ChipCollection(SfChipGroup group)
17+
{
18+
if (group != null)
19+
{
20+
CollectionChanged += group.ItemsCollectionChanged;
21+
}
22+
}
2323

24-
#endregion
25-
}
24+
#endregion
25+
}
2626
}

0 commit comments

Comments
 (0)