bug fix on batches for zesa
This commit is contained in:
@@ -50,6 +50,7 @@ class GroupBatchItem {
|
||||
final String? groupBatchId;
|
||||
final String? recipientName;
|
||||
final String? recipientPhone;
|
||||
final String? recipientAccount;
|
||||
final double? amount;
|
||||
final String? status;
|
||||
final String? transactionId;
|
||||
@@ -65,6 +66,7 @@ class GroupBatchItem {
|
||||
this.groupBatchId,
|
||||
this.recipientName,
|
||||
this.recipientPhone,
|
||||
this.recipientAccount,
|
||||
this.amount,
|
||||
this.status,
|
||||
this.transactionId,
|
||||
@@ -146,4 +148,4 @@ class GroupBatchUpdateRequest {
|
||||
_$GroupBatchUpdateRequestFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$GroupBatchUpdateRequestToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ GroupBatchItem _$GroupBatchItemFromJson(Map<String, dynamic> json) =>
|
||||
groupBatchId: json['groupBatchId'] as String?,
|
||||
recipientName: json['recipientName'] as String?,
|
||||
recipientPhone: json['recipientPhone'] as String?,
|
||||
recipientAccount: json['recipientAccount'] as String?,
|
||||
amount: (json['amount'] as num?)?.toDouble(),
|
||||
status: json['status'] as String?,
|
||||
transactionId: json['transactionId'] as String?,
|
||||
@@ -66,6 +67,7 @@ Map<String, dynamic> _$GroupBatchItemToJson(GroupBatchItem instance) =>
|
||||
'groupBatchId': instance.groupBatchId,
|
||||
'recipientName': instance.recipientName,
|
||||
'recipientPhone': instance.recipientPhone,
|
||||
'recipientAccount': instance.recipientAccount,
|
||||
'amount': instance.amount,
|
||||
'status': instance.status,
|
||||
'transactionId': instance.transactionId,
|
||||
|
||||
@@ -2388,19 +2388,13 @@ class _BatchDetailScreenState extends State<BatchDetailScreen>
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
item.recipientPhone ?? '',
|
||||
item.recipientAccount ?? '',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
|
||||
),
|
||||
if (item.billName != null || item.billProductName != null)
|
||||
const SizedBox(height: 4),
|
||||
if (item.billName != null || item.billProductName != null)
|
||||
_buildBillInfoRow(item, isDark),
|
||||
if (item.providerLabel != null &&
|
||||
item.providerLabel!.isNotEmpty)
|
||||
const SizedBox(height: 3),
|
||||
if (item.providerLabel != null &&
|
||||
item.providerLabel!.isNotEmpty)
|
||||
_buildProviderBadge(item, isDark),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -2429,14 +2423,6 @@ class _BatchDetailScreenState extends State<BatchDetailScreen>
|
||||
final parts = <InlineSpan>[];
|
||||
if (item.billName != null && item.billName!.isNotEmpty) {
|
||||
parts.addAll([
|
||||
WidgetSpan(
|
||||
child: Icon(
|
||||
Icons.receipt_rounded,
|
||||
size: 12,
|
||||
color: Colors.grey.shade500,
|
||||
),
|
||||
),
|
||||
const WidgetSpan(child: SizedBox(width: 3)),
|
||||
TextSpan(
|
||||
text: item.billName,
|
||||
style: TextStyle(
|
||||
|
||||
@@ -49,12 +49,13 @@ class _GroupCreateScreenState extends State<GroupCreateScreen> {
|
||||
if (parts.length >= 2) {
|
||||
final name = parts[0].trim();
|
||||
final account = parts[1].trim();
|
||||
final phone = parts[2].trim();
|
||||
if (name.isNotEmpty && account.isNotEmpty) {
|
||||
members.add(
|
||||
Recipient(
|
||||
name: name,
|
||||
account: account,
|
||||
phoneNumber: account,
|
||||
phoneNumber: phone,
|
||||
latestProviderLabel: '',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gif_view/gif_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:qpay/providers/splash_provider.dart';
|
||||
import 'package:qpay/routes.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
@@ -16,6 +20,8 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
late Animation<double> _fadeAnimation;
|
||||
late Animation<double> _scaleAnimation;
|
||||
|
||||
bool _bottomSheetShown = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -40,8 +46,28 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
CurvedAnimation(parent: _scaleController, curve: Curves.elasticOut),
|
||||
);
|
||||
|
||||
// Start animations
|
||||
// Start animations and version check
|
||||
_startAnimations();
|
||||
|
||||
// Kick off the version check via the provider (mounted-checked
|
||||
// inside a post-frame callback so the widget is in the tree).
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.read<SplashProvider>().addListener(_onStatusChanged);
|
||||
context.read<SplashProvider>().checkVersion();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _onStatusChanged() {
|
||||
if (!mounted) return;
|
||||
final provider = context.read<SplashProvider>();
|
||||
|
||||
if (provider.status == SplashCheckStatus.updateAvailable) {
|
||||
_showUpdateBottomSheet();
|
||||
}
|
||||
// For noUpdate we do nothing here — the animation will call
|
||||
// splashState.finish() when it completes naturally.
|
||||
}
|
||||
|
||||
void _startAnimations() async {
|
||||
@@ -50,16 +76,20 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
_fadeController.forward();
|
||||
_scaleController.forward();
|
||||
|
||||
// Wait for 3 seconds (adjust as needed)
|
||||
// Let the splash branding play for at least 1.25 s.
|
||||
await Future.delayed(const Duration(milliseconds: 1250));
|
||||
|
||||
// Start fade out animation
|
||||
await _fadeController.reverse();
|
||||
|
||||
// Mark splash complete so GoRouter redirect releases navigation
|
||||
// to the originally intended route (e.g. /poll/:id).
|
||||
// After the animation completes, release navigation to the
|
||||
// originally intended route UNLESS an update is available
|
||||
// (in which case the bottom sheet keeps the user on splash).
|
||||
if (mounted) {
|
||||
splashState.finish();
|
||||
final provider = context.read<SplashProvider>();
|
||||
if (provider.status != SplashCheckStatus.updateAvailable) {
|
||||
splashState.finish();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// If there's an error, still complete the splash screen
|
||||
@@ -69,8 +99,208 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
}
|
||||
}
|
||||
|
||||
void _showUpdateBottomSheet() {
|
||||
// Prevent showing the sheet more than once.
|
||||
if (_bottomSheetShown) return;
|
||||
_bottomSheetShown = true;
|
||||
|
||||
final provider = context.read<SplashProvider>();
|
||||
final payload = provider.updatePayload;
|
||||
final version = payload?['version']?.toString() ?? 'a newer';
|
||||
|
||||
if (kIsWeb) {
|
||||
_showWebUpdateSheet(provider, version);
|
||||
} else {
|
||||
_showMobileUpdateSheet(provider, version);
|
||||
}
|
||||
}
|
||||
|
||||
/// Web: clear Cloudflare cache, wait 5 s, then hard-refresh the page
|
||||
/// so the browser picks up the new deployment.
|
||||
void _showWebUpdateSheet(SplashProvider provider, String version) {
|
||||
final message =
|
||||
'A new version of the app is available. Please refresh to get the latest update.';
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isDismissible: false,
|
||||
enableDrag: false,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
builder: (sheetContext) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Icon
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange.shade50,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.system_update_rounded,
|
||||
color: Colors.orange.shade700,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Title
|
||||
Text(
|
||||
'Update Available',
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Message
|
||||
Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.copyWith(color: Colors.grey.shade600),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
|
||||
// Refresh button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
provider.clearCacheAndRefresh();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.orange.shade700,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Refresh to Update',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Mobile (Android / iOS): open the app store / download URL so the
|
||||
/// user can install the latest version. No cache clearing needed.
|
||||
void _showMobileUpdateSheet(SplashProvider provider, String version) {
|
||||
final message =
|
||||
provider.updatePayload?['message']?.toString() ??
|
||||
'A new version of the app is available. Please download the latest version from the store.';
|
||||
final downloadUrl = provider.downloadUrl;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isDismissible: false,
|
||||
enableDrag: false,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
builder: (sheetContext) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Icon
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orange.shade50,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.system_update_rounded,
|
||||
color: Colors.orange.shade700,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Title
|
||||
Text(
|
||||
'Update Available',
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Message
|
||||
Text(
|
||||
'Version $version is now available. $message',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.copyWith(color: Colors.grey.shade600),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
|
||||
// Download button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
if (downloadUrl != null && downloadUrl.isNotEmpty) {
|
||||
launchUrl(
|
||||
Uri.parse(downloadUrl),
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.orange.shade700,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Download Update',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
try {
|
||||
context.read<SplashProvider>().removeListener(_onStatusChanged);
|
||||
} catch (_) {}
|
||||
_fadeController.dispose();
|
||||
_scaleController.dispose();
|
||||
super.dispose();
|
||||
@@ -108,4 +338,4 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user