From 5b7736a5423a7b90b5934bded8c3ce8991d4dccb Mon Sep 17 00:00:00 2001 From: Pratik Canopas <109139581+cp-pratik-k@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:41:00 +0530 Subject: [PATCH] Add privacy policy (#41) --- app/ios/Podfile.lock | 6 ++ app/lib/components/web_view_screen.dart | 83 +++++++++++++++++++ .../components/settings_action_list.dart | 5 +- app/pubspec.lock | 32 +++++++ app/pubspec.yaml | 1 + 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 app/lib/components/web_view_screen.dart diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index c3a80a5..61fd0a3 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -66,6 +66,8 @@ PODS: - video_player_avfoundation (0.0.1): - Flutter - FlutterMacOS + - webview_flutter_wkwebview (0.0.1): + - Flutter DEPENDENCIES: - firebase_core (from `.symlinks/plugins/firebase_core/ios`) @@ -81,6 +83,7 @@ DEPENDENCIES: - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: trunk: @@ -122,6 +125,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqflite/darwin" video_player_avfoundation: :path: ".symlinks/plugins/video_player_avfoundation/darwin" + webview_flutter_wkwebview: + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570 @@ -147,6 +152,7 @@ SPEC CHECKSUMS: sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec Toast: ec33c32b8688982cecc6348adeae667c1b9938da video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579 + webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 diff --git a/app/lib/components/web_view_screen.dart b/app/lib/components/web_view_screen.dart new file mode 100644 index 0000000..3b56ea5 --- /dev/null +++ b/app/lib/components/web_view_screen.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:style/buttons/action_button.dart'; +import 'package:style/extensions/context_extensions.dart'; +import 'package:style/indicators/circular_progress_indicator.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +import 'app_page.dart'; + +void showWebView(BuildContext context, String url) { + Navigator.of(context, rootNavigator: true).push( + MaterialPageRoute( + fullscreenDialog: true, + builder: (BuildContext context) => WebViewScreen(url: url), + ), + ); +} + +class WebViewScreen extends StatefulWidget { + final String url; + + const WebViewScreen({super.key, required this.url}); + + @override + State createState() => _WebViewScreenState(); +} + +class _WebViewScreenState extends State { + late WebViewController _controller; + + bool _loading = true; + + @override + void initState() { + _controller = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setNavigationDelegate( + NavigationDelegate( + onNavigationRequest: (request) { + if(request.url.startsWith("https://canopas.github.io/cloud-gallery/") + && request.url != "https://canopas.github.io/cloud-gallery/"){ + return NavigationDecision.navigate; + } + return NavigationDecision.prevent; + }, + onPageFinished: (_) => setState(() { + _loading = false; + }), + ), + ) + ..loadRequest(Uri.parse(widget.url)); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return AppPage( + title: '', + automaticallyImplyLeading: false, + leading: ActionButton( + onPressed: () => context.pop(), + icon: Icon( + Icons.close, + color: context.colorScheme.textSecondary, + ), + ), + body: Builder( + builder: (context) { + return Padding( + padding: context.systemPadding, + child: Stack( + children: [ + WebViewWidget(controller: _controller), + if (_loading) const Center(child: AppCircularProgressIndicator()), + ], + ), + ); + } + ), + ); + } +} diff --git a/app/lib/ui/flow/accounts/components/settings_action_list.dart b/app/lib/ui/flow/accounts/components/settings_action_list.dart index eaca3b6..da7fe31 100644 --- a/app/lib/ui/flow/accounts/components/settings_action_list.dart +++ b/app/lib/ui/flow/accounts/components/settings_action_list.dart @@ -1,3 +1,4 @@ +import 'package:cloud_gallery/components/web_view_screen.dart'; import 'package:cloud_gallery/domain/extensions/context_extensions.dart'; import 'package:data/storage/app_preferences.dart'; import 'package:flutter/cupertino.dart'; @@ -49,13 +50,13 @@ class SettingsActionList extends ConsumerWidget { ActionListButton( title: context.l10n.common_term_and_condition, onPressed: () { - ///TODO: Add term and condition screen + showWebView(context, "https://canopas.github.io/cloud-gallery/terms-and-conditions"); }, ), ActionListButton( title: context.l10n.common_privacy_policy, onPressed: () { - ///TODO: Add privacy policy screen + showWebView(context, "https://canopas.github.io/cloud-gallery/privacy-policy"); }), ]); } diff --git a/app/pubspec.lock b/app/pubspec.lock index ee563da..3038b2b 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1336,6 +1336,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.5" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932" + url: "https://pub.dev" + source: hosted + version: "4.7.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: f038ee2fae73b509dde1bc9d2c5a50ca92054282de17631a9a3d515883740934 + url: "https://pub.dev" + source: hosted + version: "3.16.0" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d + url: "https://pub.dev" + source: hosted + version: "2.10.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: f12f8d8a99784b863e8b85e4a9a5e3cf1839d6803d2c0c3e0533a8f3c5a992a7 + url: "https://pub.dev" + source: hosted + version: "3.13.0" win32: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 2c8d2a4..0d9428e 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: dio: ^5.4.3+1 flutter_local_notifications: ^17.0.1 share_plus: ^8.0.3 + webview_flutter: ^4.7.0 # storage shared_preferences: ^2.2.2