From 3df71100a82829759177608363c87bcb57a9cf9b Mon Sep 17 00:00:00 2001 From: emmanueltech Date: Sun, 25 Feb 2024 21:44:41 +0500 Subject: [PATCH 1/2] about us feature --- lib/main.dart | 2 + lib/package_info_helper.dart | 11 +++++ lib/router.dart | 6 +++ lib/routes/about_us.dart | 84 ++++++++++++++++++++++++++++++++++++ lib/routes/settings.dart | 23 ++++++++++ pubspec.yaml | 1 + 6 files changed, 127 insertions(+) create mode 100644 lib/package_info_helper.dart create mode 100644 lib/routes/about_us.dart diff --git a/lib/main.dart b/lib/main.dart index e4ce9f8b..397f192d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,10 +6,12 @@ import 'package:app/app_controller.dart'; import 'package:app/router.dart'; import 'client.dart'; import 'native_storage.dart'; +import 'package_info_helper.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); setDefaultUrl(); + PackageInfoPlusHelper.init(); Authentication.checkForAuth().then((isAuthenticated) { AnyFluroRouter.setupRouter(); runApp(Anypay(isAuthenticated)); diff --git a/lib/package_info_helper.dart b/lib/package_info_helper.dart new file mode 100644 index 00000000..92174bf1 --- /dev/null +++ b/lib/package_info_helper.dart @@ -0,0 +1,11 @@ +import 'package:package_info_plus/package_info_plus.dart'; + +class PackageInfoPlusHelper { + static String version = ""; + static String build = ""; + static Future init() async { + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + version = packageInfo.version; + build = packageInfo.buildNumber; + } +} diff --git a/lib/router.dart b/lib/router.dart index f6099805..31965c69 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -15,6 +15,7 @@ import 'package:app/routes/payments.dart'; import 'package:app/routes/payment.dart'; import 'package:app/routes/invoice.dart'; import 'package:app/routes/login.dart'; +import 'routes/about_us.dart'; class AnyFluroRouter { static FluroRouter router = FluroRouter(); @@ -95,6 +96,11 @@ class AnyFluroRouter { handler: newHandler(() => Addresses(), []), transitionType: TransitionType.inFromBottom, ); + router.define( + 'settings/about_us', + handler: newHandler(() => AboutUs(), []), + transitionType: TransitionType.inFromBottom, + ); router.define( 'payments', handler: newHandler(() => Payments(), []), diff --git a/lib/routes/about_us.dart b/lib/routes/about_us.dart new file mode 100644 index 00000000..d5b41fbf --- /dev/null +++ b/lib/routes/about_us.dart @@ -0,0 +1,84 @@ +import 'package:app/package_info_helper.dart'; +import 'package:flutter/material.dart'; +import 'package:app/back_button.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class AboutUs extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SingleChildScrollView( + child: SafeArea( + child: + Column(mainAxisAlignment: MainAxisAlignment.center, children: [ + Text( + "AnyPay", + style: TextStyle(fontSize: 40, fontWeight: FontWeight.w500), + ), + SizedBox( + height: 10, + ), + Text("support@anypayx.com"), + SizedBox( + height: 10, + ), + _clickable( + url: "https://docs.anypayx.com/terms", + title: "Terms of Service"), + SizedBox( + height: 10, + ), + _clickable( + url: "https://docs.anypayx.com/privacy", + title: "Privacy Policy"), + SizedBox( + height: 10, + ), + _clickable( + url: "https://docs.anypayx.com/", title: "Documentation"), + SizedBox( + height: 10, + ), + Text( + "${PackageInfoPlusHelper.version} [Build ${PackageInfoPlusHelper.build}]", + style: TextStyle(fontStyle: FontStyle.italic), + ), + SizedBox( + height: 10, + ), + Text( + "2024", + style: TextStyle(fontStyle: FontStyle.italic), + ), + SizedBox( + height: 10, + ), + CircleBackButton( + margin: EdgeInsets.only(top: 20.0), + backPath: '/settings', + ), + ]), + ), + ), + ), + ); + } + Widget _clickable({required String title, required String url}) { + return GestureDetector( + onTap: () async { + await launchUrl(Uri.parse(url)); + }, + child: Column( + children: [ + Text( + title, + style: TextStyle( + decoration: TextDecoration.underline, + decorationColor: Colors.blue, + ), + ), + ], + )); + } +} diff --git a/lib/routes/settings.dart b/lib/routes/settings.dart index abbdc30d..119cc048 100644 --- a/lib/routes/settings.dart +++ b/lib/routes/settings.dart @@ -60,6 +60,7 @@ class _SettingsPageState extends State { if (isUserLoggedIn == true) _SelectCurrencyLink(context), if (isUserLoggedIn == true) _BusinessInfoLink(context), if (isUserLoggedIn == true) _AddressesLink(context), + _BuildAboutUs(context), CircleBackButton( margin: EdgeInsets.only(top: 20.0), backPath: 'navigation', @@ -136,6 +137,28 @@ class _SettingsPageState extends State { ); } + Widget _BuildAboutUs(context) { + return Container( + margin: EdgeInsets.all(10.0), + child: GestureDetector( + behavior: HitTestBehavior.translucent, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.all(AppController.scale(20.0)), + child: Text("About Us", + style: TextStyle( + fontSize: 22, + ))), + ], + ), + onTap: () { + Navigator.pushNamed(context, 'settings/about_us'); + }), + ); + } + Widget _SelectCurrencyLink(context) { return Container( margin: EdgeInsets.all(10.0), diff --git a/pubspec.yaml b/pubspec.yaml index ca233789..17b5bb01 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: fluro: ^2.0.4 http: ^1.2.0 intl: ^0.19.0 + package_info_plus: ^5.0.1 flutter: sdk: flutter From c608429947fc6507b16d80c20c3d574515b4f652 Mon Sep 17 00:00:00 2001 From: emmanueltech Date: Mon, 26 Feb 2024 20:39:23 +0500 Subject: [PATCH 2/2] fixes --- lib/router.dart | 6 +++--- lib/routes/{about_us.dart => about.dart} | 10 ++++++---- lib/routes/settings.dart | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) rename lib/routes/{about_us.dart => about.dart} (89%) diff --git a/lib/router.dart b/lib/router.dart index 31965c69..8ad7a9a2 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -15,7 +15,7 @@ import 'package:app/routes/payments.dart'; import 'package:app/routes/payment.dart'; import 'package:app/routes/invoice.dart'; import 'package:app/routes/login.dart'; -import 'routes/about_us.dart'; +import 'routes/about.dart'; class AnyFluroRouter { static FluroRouter router = FluroRouter(); @@ -97,8 +97,8 @@ class AnyFluroRouter { transitionType: TransitionType.inFromBottom, ); router.define( - 'settings/about_us', - handler: newHandler(() => AboutUs(), []), + 'settings/about', + handler: newHandler(() => About(), []), transitionType: TransitionType.inFromBottom, ); router.define( diff --git a/lib/routes/about_us.dart b/lib/routes/about.dart similarity index 89% rename from lib/routes/about_us.dart rename to lib/routes/about.dart index d5b41fbf..8fa2292d 100644 --- a/lib/routes/about_us.dart +++ b/lib/routes/about.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; import 'package:app/back_button.dart'; import 'package:url_launcher/url_launcher.dart'; -class AboutUs extends StatelessWidget { +import '../app_controller.dart'; + +class About extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( @@ -12,9 +14,9 @@ class AboutUs extends StatelessWidget { child: SafeArea( child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - "AnyPay", - style: TextStyle(fontSize: 40, fontWeight: FontWeight.w500), + Image( + width: 300, + image: AssetImage(AppController.logoImagePath()) ), SizedBox( height: 10, diff --git a/lib/routes/settings.dart b/lib/routes/settings.dart index 119cc048..90df6b88 100644 --- a/lib/routes/settings.dart +++ b/lib/routes/settings.dart @@ -147,14 +147,14 @@ class _SettingsPageState extends State { children: [ Container( margin: EdgeInsets.all(AppController.scale(20.0)), - child: Text("About Us", + child: Text("About", style: TextStyle( fontSize: 22, ))), ], ), onTap: () { - Navigator.pushNamed(context, 'settings/about_us'); + Navigator.pushNamed(context, 'settings/about'); }), ); }