@ -23,6 +23,7 @@ import 'package:flutter/cupertino.dart';
import ' package:flutter/material.dart ' ;
import ' package:flutter_html/flutter_html.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:url_launcher/url_launcher.dart ' ;
import ' package:webview_flutter/webview_flutter.dart ' ;
class UserLoginAgreementPage extends StatefulWidget {
@ -52,31 +53,31 @@ class _UserLoginAgreementPageState extends State<UserLoginAgreementPage> {
@ override
void initState ( ) {
super . initState ( ) ;
_controller = WebViewController ( )
. . setJavaScriptMode ( JavaScriptMode . unrestricted )
. . setNavigationDelegate (
NavigationDelegate (
onProgress: ( int progress ) {
/ / Update loading bar .
print ( " Progress: $ progress " ) ;
} ,
onPageStarted: ( String url ) { } ,
onPageFinished: ( String url ) {
setState ( ( ) {
isPageLoaded = true ;
} ) ;
} ,
onHttpError: ( HttpResponseError error ) { } ,
onWebResourceError: ( WebResourceError error ) { } ,
onNavigationRequest: ( NavigationRequest request ) {
if ( request . url . startsWith ( ' https://www.youtube.com/ ' ) ) {
return NavigationDecision . prevent ;
}
return NavigationDecision . navigate ;
} ,
) ,
)
. . loadRequest ( Uri . parse ( widget . isArabic ? " https://hmg.com/ar/Pages/Privacy.aspx " : " https://hmg.com/en/Pages/Privacy.aspx " ) ) ;
/ / _controller = WebViewController ( )
/ / . . setJavaScriptMode ( JavaScriptMode . unrestricted )
/ / . . setNavigationDelegate (
/ / NavigationDelegate (
/ / onProgress: ( int progress ) {
/ / / / Update loading bar .
/ / print ( " Progress: $ progress " ) ;
/ / } ,
/ / onPageStarted: ( String url ) { } ,
/ / onPageFinished: ( String url ) {
/ / setState ( ( ) {
/ / isPageLoaded = true ;
/ / } ) ;
/ / } ,
/ / onHttpError: ( HttpResponseError error ) { } ,
/ / onWebResourceError: ( WebResourceError error ) { } ,
/ / onNavigationRequest: ( NavigationRequest request ) {
/ / if ( request . url . startsWith ( ' https://www.youtube.com/ ' ) ) {
/ / return NavigationDecision . prevent ;
/ / }
/ / return NavigationDecision . navigate ;
/ / } ,
/ / ) ,
/ / )
/ / . . loadRequest ( Uri . parse ( widget . isArabic ? " https://hmg.com/ar/Pages/Privacy.aspx " : " https://hmg.com/en/Pages/Privacy.aspx " ) ) ;
}
@ override
@ -90,17 +91,19 @@ class _UserLoginAgreementPageState extends State<UserLoginAgreementPage> {
showNewAppBar: true ,
isShowDecPage: false ,
appBarTitle: TranslationBase . of ( context ) . userAgreement ,
body: isTermsAndConditionsPage
? getTermsAndConditionsContent ( )
: isPageLoaded
? WebViewWidget ( controller: _controller )
: Container (
child: Center (
child: GifLoaderContainer (
barrierDismissible: false ,
) ,
) ,
) ,
body:
/ / isTermsAndConditionsPage
/ / ?
getTermsAndConditionsContent ( ) ,
/ / : isPageLoaded
/ / ? WebViewWidget ( controller: _controller )
/ / : Container (
/ / child: Center (
/ / child: GifLoaderContainer (
/ / barrierDismissible: false ,
/ / ) ,
/ / ) ,
/ / ) ,
/ / Padding (
/ / padding: const EdgeInsets . all ( 8.0 ) ,
/ / child: SingleChildScrollView ( child: WebViewWidget ( controller: _controller )
@ -153,21 +156,24 @@ class _UserLoginAgreementPageState extends State<UserLoginAgreementPage> {
child: CustomTextButton (
backgroundColor: CustomColors . green ,
elevation: 0 ,
onPressed: isPageLoaded
? ( ) {
if ( isTermsAndConditionsPage ) {
if ( acceptTerms ) {
setState ( ( ) {
isTermsAndConditionsPage = false ;
} ) ;
} else {
AppToast . showErrorToast ( message: TranslationBase . of ( context ) . pleaseAcceptTerms ) ;
}
} else {
addUsageAgreement ( ) ;
}
}
: null ,
onPressed:
/ / isPageLoaded
/ / ?
( ) {
/ / if ( isTermsAndConditionsPage ) {
if ( acceptTerms ) {
addUsageAgreement ( ) ;
/ / setState ( ( ) {
/ / isTermsAndConditionsPage = false ;
/ / } ) ;
} else {
AppToast . showErrorToast ( message: TranslationBase . of ( context ) . pleaseAcceptTerms ) ;
}
/ / } else {
/ / addUsageAgreement ( ) ;
/ / }
} ,
/ / : null ,
child: Text ( TranslationBase . of ( context ) . acceptLbl . toUpperCase ( ) ,
style: TextStyle (
fontSize: 18.0 ,
@ -238,6 +244,23 @@ class _UserLoginAgreementPageState extends State<UserLoginAgreementPage> {
style: TextStyle ( fontSize: 16 , fontFamily: ( projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) , color: Color ( 0xff2B353E ) , letterSpacing: - 1.44 , height: 35 / 24 ) ,
) ,
mHeight ( 12.0 ) ,
InkWell (
onTap: ( ) async {
await launchUrl ( Uri . parse ( widget . isArabic ? " https://hmg.com/ar/Pages/Privacy.aspx " : " https://hmg.com/en/Pages/Privacy.aspx " ) ) ;
} ,
child: Text (
TranslationBase . of ( context ) . clickPrivacyPolicy ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . bold ,
fontFamily: ( projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) ,
color: Colors . blue ,
letterSpacing: - 1.44 ,
height: 35 / 24 ,
decoration: TextDecoration . underline ) ,
) ,
) ,
mHeight ( 12.0 ) ,
Text (
TranslationBase . of ( context ) . termsConditions4 ,
style: TextStyle ( fontSize: 16 , fontFamily: ( projectViewModel . isArabic ? ' Cairo ' : ' Poppins ' ) , color: Color ( 0xff2B353E ) , letterSpacing: - 1.44 , height: 35 / 24 ) ,