101 lines
2.6 KiB
Dart
101 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:nearle/views/helpers/constants/Colorconstants.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
// ===== Controller =====
|
|
class TermsController extends GetxController {
|
|
WebViewController? webViewController;
|
|
var isLoading = true.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
initializeWebView();
|
|
}
|
|
|
|
void initializeWebView() {
|
|
webViewController = WebViewController()
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
..setBackgroundColor(const Color(0x00000000))
|
|
..setNavigationDelegate(
|
|
NavigationDelegate(
|
|
onPageStarted: (url) {
|
|
isLoading.value = true;
|
|
print('Started loading: $url');
|
|
},
|
|
onPageFinished: (url) {
|
|
isLoading.value = false;
|
|
print('Finished loading: $url');
|
|
},
|
|
onWebResourceError: (error) {
|
|
isLoading.value = false;
|
|
print('WebView error: ${error.description}');
|
|
},
|
|
),
|
|
);
|
|
loadTermsUrl();
|
|
}
|
|
|
|
Future<void> loadTermsUrl() async {
|
|
if (webViewController != null) {
|
|
try {
|
|
await webViewController!.loadRequest(
|
|
Uri.parse('https://nearle.in/terms'),
|
|
);
|
|
} catch (e) {
|
|
print('Error loading URL: $e');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// ===== Page =====
|
|
class TermsCondition extends StatelessWidget {
|
|
const TermsCondition({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final controller = Get.put(TermsController());
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: ColorConstants.primaryColor,
|
|
centerTitle: true,
|
|
toolbarHeight: 70,
|
|
leading: IconButton(
|
|
icon: const Icon(
|
|
Icons.arrow_back_ios,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
title: const Text(
|
|
'Terms & Conditions',
|
|
style: TextStyle(
|
|
fontSize: 26,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 1.2,
|
|
),
|
|
),
|
|
elevation: 4,
|
|
),
|
|
body: SafeArea(
|
|
child: Obx(() {
|
|
final wvc = controller.webViewController;
|
|
return Stack(
|
|
children: [
|
|
if (wvc != null) WebViewWidget(controller: wvc),
|
|
if (controller.isLoading.value)
|
|
const LinearProgressIndicator(minHeight: 2),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
}
|