Skip to content

Commit a6c75fd

Browse files
committed
[Common]<PP_TC> Add loader in web view.
Signed-off-by: Tushar Sharma <[email protected]>
1 parent 6ffae10 commit a6c75fd

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

lib/src/pp_tc/fa_policy_tc.dart

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:webview_flutter/webview_flutter.dart';
33

4-
class FaPrivacyPoliciesAndTC extends StatelessWidget {
4+
class FaPrivacyPoliciesAndTC extends StatefulWidget {
55
const FaPrivacyPoliciesAndTC({
66
this.onResult,
77
this.url,
@@ -10,41 +10,64 @@ class FaPrivacyPoliciesAndTC extends StatelessWidget {
1010
final Function(bool)? onResult;
1111
final String? url;
1212

13+
@override
14+
State<FaPrivacyPoliciesAndTC> createState() => _FaPrivacyPoliciesAndTCState();
15+
}
16+
17+
class _FaPrivacyPoliciesAndTCState extends State<FaPrivacyPoliciesAndTC> {
18+
bool _pageLoaded = false;
19+
1320
@override
1421
Widget build(BuildContext context) {
1522
return Scaffold(
16-
body: WebView(
17-
initialUrl: url ?? 'https://www.fieldassist.in/privacy-policy/',
18-
javascriptMode: JavascriptMode.unrestricted,
19-
),
20-
bottomNavigationBar: Row(
23+
body: Stack(
2124
children: [
22-
Expanded(
23-
child: MaterialButton(
24-
color: Colors.red.shade300,
25-
child: Text(
26-
"Reject",
27-
style: TextStyle(color: Colors.white),
28-
),
29-
onPressed: () {
30-
onResult?.call(false);
31-
Navigator.pop(context);
32-
}),
33-
),
34-
Expanded(
35-
child: MaterialButton(
36-
color: Colors.blue.shade300,
37-
child: Text(
38-
"Accept",
39-
style: TextStyle(color: Colors.white),
40-
),
41-
onPressed: () {
42-
onResult?.call(true);
43-
Navigator.pop(context);
44-
}),
25+
WebView(
26+
initialUrl:
27+
widget.url ?? 'https://www.fieldassist.in/privacy-policy/',
28+
javascriptMode: JavascriptMode.unrestricted,
29+
onPageFinished: (_) {
30+
setState(() {
31+
_pageLoaded = true;
32+
});
33+
},
4534
),
35+
if (_pageLoaded)
36+
Center(
37+
child: CircularProgressIndicator(),
38+
),
4639
],
4740
),
41+
bottomNavigationBar: !_pageLoaded
42+
? null
43+
: Row(
44+
children: [
45+
Expanded(
46+
child: MaterialButton(
47+
color: Colors.red.shade300,
48+
child: Text(
49+
"Reject",
50+
style: TextStyle(color: Colors.white),
51+
),
52+
onPressed: () {
53+
widget.onResult?.call(false);
54+
Navigator.pop(context);
55+
}),
56+
),
57+
Expanded(
58+
child: MaterialButton(
59+
color: Colors.blue.shade300,
60+
child: Text(
61+
"Accept",
62+
style: TextStyle(color: Colors.white),
63+
),
64+
onPressed: () {
65+
widget.onResult?.call(true);
66+
Navigator.pop(context);
67+
}),
68+
),
69+
],
70+
),
4871
);
4972
}
5073
}

0 commit comments

Comments
 (0)