Skip to content

Commit

Permalink
[Common]<PP_TC> Add loader in web view.
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Sharma <[email protected]>
  • Loading branch information
TusharFA committed Jul 11, 2022
1 parent 6ffae10 commit 1ec03f2
Showing 1 changed file with 52 additions and 29 deletions.
81 changes: 52 additions & 29 deletions lib/src/pp_tc/fa_policy_tc.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class FaPrivacyPoliciesAndTC extends StatelessWidget {
class FaPrivacyPoliciesAndTC extends StatefulWidget {
const FaPrivacyPoliciesAndTC({
this.onResult,
this.url,
Expand All @@ -10,41 +10,64 @@ class FaPrivacyPoliciesAndTC extends StatelessWidget {
final Function(bool)? onResult;
final String? url;

@override
State<FaPrivacyPoliciesAndTC> createState() => _FaPrivacyPoliciesAndTCState();
}

class _FaPrivacyPoliciesAndTCState extends State<FaPrivacyPoliciesAndTC> {
bool _pageLoaded = false;

@override
Widget build(BuildContext context) {
return Scaffold(
body: WebView(
initialUrl: url ?? 'https://www.fieldassist.in/privacy-policy/',
javascriptMode: JavascriptMode.unrestricted,
),
bottomNavigationBar: Row(
body: Stack(
children: [
Expanded(
child: MaterialButton(
color: Colors.red.shade300,
child: Text(
"Reject",
style: TextStyle(color: Colors.white),
),
onPressed: () {
onResult?.call(false);
Navigator.pop(context);
}),
),
Expanded(
child: MaterialButton(
color: Colors.blue.shade300,
child: Text(
"Accept",
style: TextStyle(color: Colors.white),
),
onPressed: () {
onResult?.call(true);
Navigator.pop(context);
}),
WebView(
initialUrl:
widget.url ?? 'https://www.fieldassist.in/privacy-policy/',
javascriptMode: JavascriptMode.unrestricted,
onPageFinished: (_) {
setState(() {
_pageLoaded = true;
});
},
),
if (!_pageLoaded)
Center(
child: CircularProgressIndicator(),
),
],
),
bottomNavigationBar: !_pageLoaded
? null
: Row(
children: [
Expanded(
child: MaterialButton(
color: Colors.red.shade300,
child: Text(
"Reject",
style: TextStyle(color: Colors.white),
),
onPressed: () {
widget.onResult?.call(false);
Navigator.pop(context);
}),
),
Expanded(
child: MaterialButton(
color: Colors.blue.shade300,
child: Text(
"Accept",
style: TextStyle(color: Colors.white),
),
onPressed: () {
widget.onResult?.call(true);
Navigator.pop(context);
}),
),
],
),
);
}
}

0 comments on commit 1ec03f2

Please sign in to comment.