Skip to content

Commit 808f458

Browse files
authored
Merge pull request #99 from FmgLib/98-navigationpage-attached-prop-added
98 navigationpage attached prop added
2 parents 55406c2 + 757f79a commit 808f458

File tree

3 files changed

+195
-3
lines changed

3 files changed

+195
-3
lines changed

libs/FmgLib.MauiMarkup/Extensions/NavigationPageExtension.cs

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,135 @@ public static Task<bool> AnimateBarTextColorTo<T>(this T self, Color value, uint
117117
var callback = (Color actValue) => { self.BarTextColor = actValue; };
118118
return Transformations.AnimateAsync<Color>(self, "AnimateBarTextColorTo", transform, callback, length, easing);
119119
}
120-
120+
121+
public static T HasBackButton<T>(this T self,
122+
bool hasBackButton)
123+
where T : Microsoft.Maui.Controls.NavigationPage
124+
{
125+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.HasBackButtonProperty, hasBackButton);
126+
return self;
127+
}
128+
129+
public static T HasBackButton<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
130+
where T : Microsoft.Maui.Controls.NavigationPage
131+
{
132+
var context = new PropertyContext<bool>(self, Microsoft.Maui.Controls.NavigationPage.HasBackButtonProperty);
133+
configure(context).Build();
134+
return self;
135+
}
136+
137+
public static SettersContext<T> HasBackButton<T>(this SettersContext<T> self,
138+
bool hasBackButton)
139+
where T : Microsoft.Maui.Controls.NavigationPage
140+
{
141+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.HasBackButtonProperty, Value = hasBackButton });
142+
return self;
143+
}
144+
145+
public static SettersContext<T> HasBackButton<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
146+
where T : Microsoft.Maui.Controls.NavigationPage
147+
{
148+
var context = new PropertySettersContext<bool>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.HasBackButtonProperty);
149+
configure(context).Build();
150+
return self;
151+
}
152+
153+
public static T TitleIconImageSource<T>(this T self,
154+
Microsoft.Maui.Controls.ImageSource titleIconImageSource)
155+
where T : Microsoft.Maui.Controls.NavigationPage
156+
{
157+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.TitleIconImageSourceProperty, titleIconImageSource);
158+
return self;
159+
}
160+
161+
public static T TitleIconImageSource<T>(this T self, Func<PropertyContext<Microsoft.Maui.Controls.ImageSource>, IPropertyBuilder<Microsoft.Maui.Controls.ImageSource>> configure)
162+
where T : Microsoft.Maui.Controls.NavigationPage
163+
{
164+
var context = new PropertyContext<Microsoft.Maui.Controls.ImageSource>(self, Microsoft.Maui.Controls.NavigationPage.TitleIconImageSourceProperty);
165+
configure(context).Build();
166+
return self;
167+
}
168+
169+
public static SettersContext<T> TitleIconImageSource<T>(this SettersContext<T> self,
170+
Microsoft.Maui.Controls.ImageSource titleIconImageSource)
171+
where T : Microsoft.Maui.Controls.NavigationPage
172+
{
173+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.TitleIconImageSourceProperty, Value = titleIconImageSource });
174+
return self;
175+
}
176+
177+
public static SettersContext<T> TitleIconImageSource<T>(this SettersContext<T> self, Func<PropertySettersContext<Microsoft.Maui.Controls.ImageSource>, IPropertySettersBuilder<Microsoft.Maui.Controls.ImageSource>> configure)
178+
where T : Microsoft.Maui.Controls.NavigationPage
179+
{
180+
var context = new PropertySettersContext<Microsoft.Maui.Controls.ImageSource>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.TitleIconImageSourceProperty);
181+
configure(context).Build();
182+
return self;
183+
}
184+
185+
public static T IconColor<T>(this T self,
186+
Microsoft.Maui.Graphics.Color iconColor)
187+
where T : Microsoft.Maui.Controls.NavigationPage
188+
{
189+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.IconColorProperty, iconColor);
190+
return self;
191+
}
192+
193+
public static T IconColor<T>(this T self, Func<PropertyContext<Microsoft.Maui.Graphics.Color>, IPropertyBuilder<Microsoft.Maui.Graphics.Color>> configure)
194+
where T : Microsoft.Maui.Controls.NavigationPage
195+
{
196+
var context = new PropertyContext<Microsoft.Maui.Graphics.Color>(self, Microsoft.Maui.Controls.NavigationPage.IconColorProperty);
197+
configure(context).Build();
198+
return self;
199+
}
200+
201+
public static SettersContext<T> IconColor<T>(this SettersContext<T> self,
202+
Microsoft.Maui.Graphics.Color iconColor)
203+
where T : Microsoft.Maui.Controls.NavigationPage
204+
{
205+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.IconColorProperty, Value = iconColor });
206+
return self;
207+
}
208+
209+
public static SettersContext<T> IconColor<T>(this SettersContext<T> self, Func<PropertySettersContext<Microsoft.Maui.Graphics.Color>, IPropertySettersBuilder<Microsoft.Maui.Graphics.Color>> configure)
210+
where T : Microsoft.Maui.Controls.NavigationPage
211+
{
212+
var context = new PropertySettersContext<Microsoft.Maui.Graphics.Color>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.IconColorProperty);
213+
configure(context).Build();
214+
return self;
215+
}
216+
217+
public static T TitleView<T>(this T self,
218+
Microsoft.Maui.Controls.View titleView)
219+
where T : Microsoft.Maui.Controls.NavigationPage
220+
{
221+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.TitleViewProperty, titleView);
222+
return self;
223+
}
224+
225+
public static T TitleView<T>(this T self, Func<PropertyContext<Microsoft.Maui.Controls.View>, IPropertyBuilder<Microsoft.Maui.Controls.View>> configure)
226+
where T : Microsoft.Maui.Controls.NavigationPage
227+
{
228+
var context = new PropertyContext<Microsoft.Maui.Controls.View>(self, Microsoft.Maui.Controls.NavigationPage.TitleViewProperty);
229+
configure(context).Build();
230+
return self;
231+
}
232+
233+
public static SettersContext<T> TitleView<T>(this SettersContext<T> self,
234+
Microsoft.Maui.Controls.View titleView)
235+
where T : Microsoft.Maui.Controls.NavigationPage
236+
{
237+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.TitleViewProperty, Value = titleView });
238+
return self;
239+
}
240+
241+
public static SettersContext<T> TitleView<T>(this SettersContext<T> self, Func<PropertySettersContext<Microsoft.Maui.Controls.View>, IPropertySettersBuilder<Microsoft.Maui.Controls.View>> configure)
242+
where T : Microsoft.Maui.Controls.NavigationPage
243+
{
244+
var context = new PropertySettersContext<Microsoft.Maui.Controls.View>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.TitleViewProperty);
245+
configure(context).Build();
246+
return self;
247+
}
248+
121249
public static T OnPopped<T>(this T self, EventHandler<NavigationEventArgs> handler)
122250
where T : NavigationPage
123251
{

libs/FmgLib.MauiMarkup/Extensions/PageExtension.cs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,5 +859,69 @@ public static Color GetShellTabBarUnselectedColorValue<T>(this T self)
859859
{
860860
return (Color)self.GetValue(Shell.TabBarUnselectedColorProperty);
861861
}
862-
862+
863+
864+
public static T HasNavigationBar<T>(this T self,
865+
bool hasNavigationBar)
866+
where T : Microsoft.Maui.Controls.Page
867+
{
868+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.HasNavigationBarProperty, hasNavigationBar);
869+
return self;
870+
}
871+
872+
public static T HasNavigationBar<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
873+
where T : Microsoft.Maui.Controls.Page
874+
{
875+
var context = new PropertyContext<bool>(self, Microsoft.Maui.Controls.NavigationPage.HasNavigationBarProperty);
876+
configure(context).Build();
877+
return self;
878+
}
879+
880+
public static SettersContext<T> HasNavigationBar<T>(this SettersContext<T> self,
881+
bool hasNavigationBar)
882+
where T : Microsoft.Maui.Controls.Page
883+
{
884+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.HasNavigationBarProperty, Value = hasNavigationBar });
885+
return self;
886+
}
887+
888+
public static SettersContext<T> HasNavigationBar<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
889+
where T : Microsoft.Maui.Controls.Page
890+
{
891+
var context = new PropertySettersContext<bool>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.HasNavigationBarProperty);
892+
configure(context).Build();
893+
return self;
894+
}
895+
896+
public static T BackButtonTitle<T>(this T self,
897+
string backButtonTitle)
898+
where T : Microsoft.Maui.Controls.Page
899+
{
900+
self.SetValue(Microsoft.Maui.Controls.NavigationPage.BackButtonTitleProperty, backButtonTitle);
901+
return self;
902+
}
903+
904+
public static T BackButtonTitle<T>(this T self, Func<PropertyContext<string>, IPropertyBuilder<string>> configure)
905+
where T : Microsoft.Maui.Controls.Page
906+
{
907+
var context = new PropertyContext<string>(self, Microsoft.Maui.Controls.NavigationPage.BackButtonTitleProperty);
908+
configure(context).Build();
909+
return self;
910+
}
911+
912+
public static SettersContext<T> BackButtonTitle<T>(this SettersContext<T> self,
913+
string backButtonTitle)
914+
where T : Microsoft.Maui.Controls.Page
915+
{
916+
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.NavigationPage.BackButtonTitleProperty, Value = backButtonTitle });
917+
return self;
918+
}
919+
920+
public static SettersContext<T> BackButtonTitle<T>(this SettersContext<T> self, Func<PropertySettersContext<string>, IPropertySettersBuilder<string>> configure)
921+
where T : Microsoft.Maui.Controls.Page
922+
{
923+
var context = new PropertySettersContext<string>(self.XamlSetters, Microsoft.Maui.Controls.NavigationPage.BackButtonTitleProperty);
924+
configure(context).Build();
925+
return self;
926+
}
863927
}

libs/FmgLib.MauiMarkup/FmgLib.MauiMarkup.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageId>FmgLib.MauiMarkup</PackageId>
1212
<Summary>FmgLib.MauiMarkup with C# Markup classes and fluent helper methods</Summary>
1313
<Title>FmgLib.MauiMarkup</Title>
14-
<Version>8.6.1</Version>
14+
<Version>8.6.2</Version>
1515
<Authors>FmgYazılım</Authors>
1616
<Company>Fmg Yazılım</Company>
1717
<Copyright>©2024</Copyright>

0 commit comments

Comments
 (0)