improving error handling
This commit is contained in:
@@ -13,7 +13,6 @@ import 'package:qpay/screens/accounts/account_provider.dart';
|
|||||||
import 'package:qpay/theme/app_theme.dart';
|
import 'package:qpay/theme/app_theme.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'firebase_options.dart';
|
import 'firebase_options.dart';
|
||||||
import 'config/app_config.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class ScaffoldWithNavBar extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ScaffoldWithNavBarState extends State<ScaffoldWithNavBar> {
|
class _ScaffoldWithNavBarState extends State<ScaffoldWithNavBar> {
|
||||||
bool _isLoggedIn = false;
|
|
||||||
late String initials;
|
late String initials;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,7 +28,6 @@ class _ScaffoldWithNavBarState extends State<ScaffoldWithNavBar> {
|
|||||||
|
|
||||||
if (prefs.getString("token") != null) {
|
if (prefs.getString("token") != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoggedIn = true;
|
|
||||||
initials = prefs.getString("initials")!;
|
initials = prefs.getString("initials")!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -56,7 +54,7 @@ class _ScaffoldWithNavBarState extends State<ScaffoldWithNavBar> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 12.0,
|
vertical: 12.0,
|
||||||
horizontal: 8
|
horizontal: 8,
|
||||||
),
|
),
|
||||||
child: Image(
|
child: Image(
|
||||||
image: AssetImage('assets/velocity.png'),
|
image: AssetImage('assets/velocity.png'),
|
||||||
@@ -186,7 +184,10 @@ class _ScaffoldWithNavBarState extends State<ScaffoldWithNavBar> {
|
|||||||
final String location = GoRouterState.of(context).uri.path;
|
final String location = GoRouterState.of(context).uri.path;
|
||||||
if (location.startsWith('/groups')) return 1;
|
if (location.startsWith('/groups')) return 1;
|
||||||
if (location.startsWith('/history')) return 2;
|
if (location.startsWith('/history')) return 2;
|
||||||
if (location.startsWith('/more') || location.startsWith('/users') || location.startsWith('/uptime')) return 3;
|
if (location.startsWith('/more') ||
|
||||||
|
location.startsWith('/users') ||
|
||||||
|
location.startsWith('/uptime'))
|
||||||
|
return 3;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:qpay/models/responsive_policy.dart';
|
import 'package:qpay/models/responsive_policy.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ContactScreen extends StatelessWidget {
|
class ContactScreen extends StatelessWidget {
|
||||||
const ContactScreen({super.key});
|
const ContactScreen({super.key});
|
||||||
@@ -186,7 +187,10 @@ class ContactScreen extends StatelessWidget {
|
|||||||
title: 'Instagram',
|
title: 'Instagram',
|
||||||
subtitle: 'Follow us for updates',
|
subtitle: 'Follow us for updates',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Instagram link will be added later
|
launchUrl(
|
||||||
|
Uri.parse('https://www.instagram.com/velocityafrica/'),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@@ -200,7 +204,10 @@ class ContactScreen extends StatelessWidget {
|
|||||||
title: 'WhatsApp',
|
title: 'WhatsApp',
|
||||||
subtitle: 'Chat with us directly',
|
subtitle: 'Chat with us directly',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// WhatsApp link will be added later
|
launchUrl(
|
||||||
|
Uri.parse('https://wa.me/263787770295'),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -293,4 +300,4 @@ class ContactScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,13 +170,28 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
|||||||
final apiResponse = await controller.doTransaction();
|
final apiResponse = await controller.doTransaction();
|
||||||
|
|
||||||
if (!apiResponse.isSuccess) {
|
if (!apiResponse.isSuccess) {
|
||||||
if (context.mounted) {
|
String errorMessage =
|
||||||
AppSnackBar.showError(
|
|
||||||
context,
|
|
||||||
controller.model.errorMessage ??
|
controller.model.errorMessage ??
|
||||||
apiResponse.error ??
|
apiResponse.error ??
|
||||||
"Transaction failed",
|
"Transaction failed";
|
||||||
);
|
if (context.mounted) {
|
||||||
|
if (errorMessage.contains(
|
||||||
|
"We can't process that transaction right now",
|
||||||
|
)) {
|
||||||
|
AppSnackBar.show(
|
||||||
|
context,
|
||||||
|
errorMessage,
|
||||||
|
action: SnackBarAction(
|
||||||
|
label: 'Check uptime',
|
||||||
|
textColor: Colors.yellow, // Optional custom styling
|
||||||
|
onPressed: () {
|
||||||
|
context.push('/uptime');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
AppSnackBar.showError(context, errorMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (controller.model.status == "SUCCESS" && context.mounted) {
|
} else if (controller.model.status == "SUCCESS" && context.mounted) {
|
||||||
context.push('/confirm');
|
context.push('/confirm');
|
||||||
|
|||||||
Reference in New Issue
Block a user