Skip to content

Commit 9f83fd9

Browse files
authored
Merge pull request #168 from FmgLib/whats-new-net8
Whats new net8
2 parents 3a1b905 + aec2860 commit 9f83fd9

File tree

2 files changed

+148
-8
lines changed

2 files changed

+148
-8
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- master
7+
- release/*
88
- develop
99

1010
env:

src/FmgLib.MauiMarkup/Extensions/WebViewExtension.cs

Lines changed: 147 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,104 @@
33

44
public static partial class WebViewExtension
55
{
6+
public static T CanGoBack<T>(this T self,
7+
bool canGoBack)
8+
where T : WebView
9+
{
10+
self.SetValue(WebView.CanGoBackProperty, canGoBack);
11+
return self;
12+
}
13+
14+
public static T CanGoBack<T>(this T self,
15+
Func<bool> configure)
16+
where T : WebView
17+
{
18+
var canGoBack = configure();
19+
self.SetValue(WebView.CanGoBackProperty, canGoBack);
20+
return self;
21+
}
22+
23+
public static T CanGoBack<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
24+
where T : WebView
25+
{
26+
var context = new PropertyContext<bool>(self, WebView.CanGoBackProperty);
27+
configure(context).Build();
28+
return self;
29+
}
30+
31+
public static SettersContext<T> CanGoBack<T>(this SettersContext<T> self,
32+
bool canGoBack)
33+
where T : WebView
34+
{
35+
self.XamlSetters.Add(new Setter { Property = WebView.CanGoBackProperty, Value = canGoBack });
36+
return self;
37+
}
38+
39+
public static SettersContext<T> CanGoBack<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
40+
where T : WebView
41+
{
42+
var context = new PropertySettersContext<bool>(self.XamlSetters, WebView.CanGoBackProperty);
43+
configure(context).Build();
44+
return self;
45+
}
46+
47+
public static T CanGoForward<T>(this T self,
48+
bool canGoForward)
49+
where T : WebView
50+
{
51+
self.SetValue(WebView.CanGoForwardProperty, canGoForward);
52+
return self;
53+
}
54+
55+
public static T CanGoForward<T>(this T self,
56+
Func<bool> configure)
57+
where T : WebView
58+
{
59+
var canGoForward = configure();
60+
self.SetValue(WebView.CanGoForwardProperty, canGoForward);
61+
return self;
62+
}
63+
64+
public static T CanGoForward<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
65+
where T : WebView
66+
{
67+
var context = new PropertyContext<bool>(self, WebView.CanGoForwardProperty);
68+
configure(context).Build();
69+
return self;
70+
}
71+
72+
public static SettersContext<T> CanGoForward<T>(this SettersContext<T> self,
73+
bool canGoForward)
74+
where T : WebView
75+
{
76+
self.XamlSetters.Add(new Setter { Property = WebView.CanGoForwardProperty, Value = canGoForward });
77+
return self;
78+
}
79+
80+
public static SettersContext<T> CanGoForward<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
81+
where T : WebView
82+
{
83+
var context = new PropertySettersContext<bool>(self.XamlSetters, WebView.CanGoForwardProperty);
84+
configure(context).Build();
85+
return self;
86+
}
87+
688
public static T Cookies<T>(this T self,
789
System.Net.CookieContainer cookies)
890
where T : WebView
991
{
1092
self.SetValue(WebView.CookiesProperty, cookies);
1193
return self;
1294
}
95+
96+
public static T Cookies<T>(this T self,
97+
Func<System.Net.CookieContainer> configure)
98+
where T : WebView
99+
{
100+
var cookies = configure();
101+
self.SetValue(WebView.CookiesProperty, cookies);
102+
return self;
103+
}
13104

14105
public static T Cookies<T>(this T self, Func<PropertyContext<System.Net.CookieContainer>, IPropertyBuilder<System.Net.CookieContainer>> configure)
15106
where T : WebView
@@ -42,6 +133,15 @@ public static T Source<T>(this T self,
42133
self.SetValue(WebView.SourceProperty, source);
43134
return self;
44135
}
136+
137+
public static T Source<T>(this T self,
138+
Func<WebViewSource> configure)
139+
where T : WebView
140+
{
141+
var source = configure();
142+
self.SetValue(WebView.SourceProperty, source);
143+
return self;
144+
}
45145

46146
public static T Source<T>(this T self, Func<PropertyContext<WebViewSource>, IPropertyBuilder<WebViewSource>> configure)
47147
where T : WebView
@@ -67,33 +167,73 @@ public static SettersContext<T> Source<T>(this SettersContext<T> self, Func<Prop
67167
return self;
68168
}
69169

70-
public static T OnNavigated<T>(this T self, EventHandler<WebNavigatedEventArgs> handler)
170+
public static T UserAgent<T>(this T self,
171+
string userAgent)
172+
where T : WebView
173+
{
174+
self.SetValue(WebView.UserAgentProperty, userAgent);
175+
return self;
176+
}
177+
178+
public static T UserAgent<T>(this T self,
179+
Func<string> configure)
180+
where T : WebView
181+
{
182+
var userAgent = configure();
183+
self.SetValue(WebView.UserAgentProperty, userAgent);
184+
return self;
185+
}
186+
187+
public static T UserAgent<T>(this T self, Func<PropertyContext<string>, IPropertyBuilder<string>> configure)
188+
where T : WebView
189+
{
190+
var context = new PropertyContext<string>(self, WebView.UserAgentProperty);
191+
configure(context).Build();
192+
return self;
193+
}
194+
195+
public static SettersContext<T> UserAgent<T>(this SettersContext<T> self,
196+
string userAgent)
197+
where T : WebView
198+
{
199+
self.XamlSetters.Add(new Setter { Property = WebView.UserAgentProperty, Value = userAgent });
200+
return self;
201+
}
202+
203+
public static SettersContext<T> UserAgent<T>(this SettersContext<T> self, Func<PropertySettersContext<string>, IPropertySettersBuilder<string>> configure)
204+
where T : WebView
205+
{
206+
var context = new PropertySettersContext<string>(self.XamlSetters, WebView.UserAgentProperty);
207+
configure(context).Build();
208+
return self;
209+
}
210+
211+
public static T OnNavigated<T>(this T self, System.EventHandler<WebNavigatedEventArgs> handler)
71212
where T : WebView
72213
{
73214
self.Navigated += handler;
74215
return self;
75216
}
76217

77-
public static T OnNavigated<T>(this T self, Action<T> action)
218+
public static T OnNavigated<T>(this T self, System.Action<T> action)
78219
where T : WebView
79220
{
80221
self.Navigated += (o, arg) => action(self);
81222
return self;
82223
}
83-
84-
public static T OnNavigating<T>(this T self, EventHandler<WebNavigatingEventArgs> handler)
224+
225+
public static T OnNavigating<T>(this T self, System.EventHandler<WebNavigatingEventArgs> handler)
85226
where T : WebView
86227
{
87228
self.Navigating += handler;
88229
return self;
89230
}
90231

91-
public static T OnNavigating<T>(this T self, Action<T> action)
232+
public static T OnNavigating<T>(this T self, System.Action<T> action)
92233
where T : WebView
93234
{
94235
self.Navigating += (o, arg) => action(self);
95236
return self;
96237
}
97-
238+
98239
}
99-

0 commit comments

Comments
 (0)