Skip to content

Commit e743e9f

Browse files
Merge pull request #256 from Jahnavi-SF4672/main
Added property to change close button icon color in Popup
2 parents 0e3d341 + fbc28ed commit e743e9f

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

maui/src/Popup/PopupCloseButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ protected override void OnDraw(ICanvas canvas, RectF rectF)
229229
_closeButtonImage.IsVisible = false;
230230
}
231231

232-
canvas.StrokeColor = _popupView._popup.PopupStyle.GetCloseButtonIconStroke();
232+
canvas.StrokeColor = _popupView._popup.PopupStyle.GetCloseIconColor();
233233
canvas.StrokeSize = (float)_popupView._popup.PopupStyle.GetCloseButtonIconStrokeThickness();
234234
PointF firstLine = new Point(0, 0);
235235
PointF secondLine = new Point(0, 0);

maui/src/Popup/Style/PopupStyle.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ public class PopupStyle : Element, IThemeElement
190190
BindableProperty.Create(nameof(CloseButtonIcon), typeof(ImageSource), typeof(PopupStyle), null);
191191

192192
/// <summary>
193-
/// Identifies the <see cref="CloseButtonIconStroke"/> <see cref="BindableProperty"/>.
193+
/// Identifies the <see cref="CloseIconColor"/> <see cref="BindableProperty"/>.
194194
/// </summary>
195-
internal static BindableProperty CloseButtonIconStrokeProperty =
196-
BindableProperty.Create(nameof(CloseButtonIconStroke), typeof(Color), typeof(PopupStyle), defaultValue: Color.FromArgb("#49454F"));
195+
public static BindableProperty CloseIconColorProperty =
196+
BindableProperty.Create(nameof(CloseIconColor), typeof(Color), typeof(PopupStyle), defaultValue: Color.FromArgb("#49454F"));
197197

198198
/// <summary>
199199
/// Identifies the <see cref="CloseButtonIconStrokeThickness"/> <see cref="BindableProperty"/>.
@@ -924,19 +924,32 @@ public ImageSource CloseButtonIcon
924924
set => SetValue(CloseButtonIconProperty, value);
925925
}
926926

927-
#endregion
928-
929-
#region Internal Properties
930-
931927
/// <summary>
932-
/// Gets or sets the icon color for close button.
928+
/// Gets or sets the color of the close icon displayed in the <see cref="SfPopup"/>.
933929
/// </summary>
934-
internal Color CloseButtonIconStroke
930+
/// <example>
931+
/// <para>The following code example demonstrates how to set <see cref="CloseIconColor"/> for the <see cref="SfPopup"/> control.</para>
932+
/// <code lang="XAML">
933+
/// <![CDATA[
934+
/// <popup:SfPopup x:Name="popup">
935+
/// <popup:SfPopup.PopupStyle>
936+
/// <popup:PopupStyle CloseIconColor="Red" />
937+
/// </popup:SfPopup.PopupStyle>
938+
/// </popup:SfPopup>
939+
/// ]]>
940+
/// </code>
941+
/// </example>
942+
/// <seealso cref="SfPopup.ShowCloseButton"/>
943+
public Color CloseIconColor
935944
{
936-
get => (Color)GetValue(CloseButtonIconStrokeProperty);
937-
set => SetValue(CloseButtonIconStrokeProperty, value);
945+
get => (Color)GetValue(CloseIconColorProperty);
946+
set => SetValue(CloseIconColorProperty, value);
938947
}
939948

949+
#endregion
950+
951+
#region Internal Properties
952+
940953
/// <summary>
941954
/// Gets or sets the icon stroke thickness for close button.
942955
/// </summary>
@@ -1113,7 +1126,7 @@ void IThemeElement.OnCommonThemeChanged(string oldTheme, string newTheme)
11131126
/// Gets the icon color for close button.
11141127
/// </summary>
11151128
/// <returns> icon color for close button.</returns>
1116-
internal Color GetCloseButtonIconStroke() => CloseButtonIconStroke;
1129+
internal Color GetCloseIconColor() => CloseIconColor;
11171130

11181131
/// <summary>
11191132
/// Gets the icon stroke thickness for close button.
@@ -1160,7 +1173,7 @@ internal void SetThemeProperties(SfPopup popup)
11601173
ApplyDynamicResource(HeaderFontSizeProperty, "SfPopupNormalHeaderFontSize");
11611174
ApplyDynamicResource(MessageFontSizeProperty, "SfPopupNormalMessageFontSize");
11621175
ApplyDynamicResource(FooterFontSizeProperty, "SfPopupNormalFooterFontSize");
1163-
ApplyDynamicResource(CloseButtonIconStrokeProperty, "SfPopupNormalCloseButtonIconStroke");
1176+
ApplyDynamicResource(CloseIconColorProperty, "SfPopupNormalCloseButtonIconStroke");
11641177
ApplyDynamicResource(CloseButtonIconStrokeThicknessProperty, "SfPopupNormalCloseButtonIconStrokeThickness");
11651178
ApplyDynamicResource(HoveredCloseButtonIconBackgroundProperty, "SfPopupHoverCloseButtonIconBackground");
11661179
ApplyDynamicResource(PressedCloseButtonIconBackgroundProperty, "SfPopupPressedCloseButtonIconBackground");

0 commit comments

Comments
 (0)