Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an "About" page and add build number info #56

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 11 additions & 0 deletions lib/package_info_helper.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
6 changes: 6 additions & 0 deletions lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.dart';

class AnyFluroRouter {
static FluroRouter router = FluroRouter();
Expand Down Expand Up @@ -95,6 +96,11 @@ class AnyFluroRouter {
handler: newHandler(() => Addresses(), []),
transitionType: TransitionType.inFromBottom,
);
router.define(
'settings/about',
handler: newHandler(() => About(), []),
transitionType: TransitionType.inFromBottom,
);
router.define(
'payments',
handler: newHandler(() => Payments(), []),
Expand Down
86 changes: 86 additions & 0 deletions lib/routes/about.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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';

import '../app_controller.dart';

class About extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SingleChildScrollView(
child: SafeArea(
child:
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Image(
width: 300,
image: AssetImage(AppController.logoImagePath())
),
SizedBox(
height: 10,
),
Text("[email protected]"),
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,
),
),
],
));
}
}
23 changes: 23 additions & 0 deletions lib/routes/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class _SettingsPageState extends State<SettingsPage> {
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',
Expand Down Expand Up @@ -136,6 +137,28 @@ class _SettingsPageState extends State<SettingsPage> {
);
}

Widget _BuildAboutUs(context) {
return Container(
margin: EdgeInsets.all(10.0),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(AppController.scale(20.0)),
child: Text("About",
style: TextStyle(
fontSize: 22,
))),
],
),
onTap: () {
Navigator.pushNamed(context, 'settings/about');
}),
);
}

Widget _SelectCurrencyLink(context) {
return Container(
margin: EdgeInsets.all(10.0),
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down