
Implements automatic synchronization of unsynced local reception data (move line quantities) to the backend before fetching new receptions. This ensures local changes are pushed when connectivity is available. Adds a pull-to-refresh mechanism on the reception page, allowing users to manually refresh the list of receptions. Integrates an offline indicator in the main app bar, providing immediate visual feedback on the application's network connectivity status.
86 lines
2.5 KiB
Dart
86 lines
2.5 KiB
Dart
import 'package:e_scan/services/connectivity_service.dart';
|
|
import 'package:e_scan/themes/app_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
class MainAppbarComponent extends StatelessWidget
|
|
implements PreferredSizeWidget {
|
|
const MainAppbarComponent({
|
|
super.key,
|
|
this.title,
|
|
this.subTitle,
|
|
this.scaffoledKey,
|
|
this.leading,
|
|
this.actions,
|
|
});
|
|
final GlobalKey<ScaffoldState>? scaffoledKey;
|
|
final String? title;
|
|
final String? subTitle;
|
|
final Widget? leading;
|
|
final List<Widget>? actions;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
leading:
|
|
leading ??
|
|
IconButton(
|
|
icon: Icon(Icons.menu, color: AppTheme.of(context).white),
|
|
onPressed: () {
|
|
scaffoledKey?.currentState?.openDrawer();
|
|
},
|
|
),
|
|
title: title == null || subTitle == null
|
|
? null
|
|
: Row(
|
|
children: [
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title ?? '',
|
|
style: AppTheme.of(
|
|
context,
|
|
).titleMedium.copyWith(color: AppTheme.of(context).white),
|
|
),
|
|
Text(
|
|
subTitle ?? '',
|
|
style: AppTheme.of(
|
|
context,
|
|
).bodyMedium.copyWith(color: AppTheme.of(context).white),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
actions: [
|
|
...actions ?? [],
|
|
Consumer(
|
|
builder: (context, ref, _) {
|
|
final isConnected = ref.watch(isConnectedProvider);
|
|
if (isConnected) {
|
|
return SizedBox.shrink();
|
|
} else {
|
|
return Row(
|
|
spacing: 5,
|
|
children: [
|
|
Icon(Icons.cloud_off, color: Colors.white),
|
|
Text('Hors ligne', style: TextStyle(color: Colors.white)),
|
|
SizedBox(width: 10),
|
|
],
|
|
);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
toolbarHeight: 60,
|
|
backgroundColor: AppTheme.of(context).primary,
|
|
elevation: 4,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => Size.fromHeight(kToolbarHeight);
|
|
}
|