|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/notifications_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
@ -10,44 +11,59 @@ import 'package:test_sa/views/widgets/notifications/notification_item.dart';
|
|
|
|
|
class RecentActivitiesFragment extends StatelessWidget {
|
|
|
|
|
RecentActivitiesFragment({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
NotificationsProvider _notificationsProvider;
|
|
|
|
|
//NotificationsProvider _notificationsProvider;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
_notificationsProvider ??= Provider.of<NotificationsProvider>(context, listen: false);
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: AppColor.background(context),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
|
|
|
|
shadows: [boxShadowR14],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.recentActivities.heading5(context).paddingOnly(top: 16, start: 16, end: 16),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: _notificationsProvider.notifications.length,
|
|
|
|
|
separatorBuilder: (context, itemIndex) => const Divider().defaultStyle(context).paddingOnly(top: 16, bottom: 16),
|
|
|
|
|
itemBuilder: (context, itemIndex) {
|
|
|
|
|
// todo add priority & progress tag to show chip
|
|
|
|
|
return NotificationItem(
|
|
|
|
|
notification: _notificationsProvider.notifications[itemIndex],
|
|
|
|
|
onPressed: (notification) {
|
|
|
|
|
// todo @sikander, check notifications payload, because notification model is different to need to check from backend
|
|
|
|
|
//Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId);
|
|
|
|
|
//_notificationsProvider ??= Provider.of<NotificationsProvider>(context, listen: false);
|
|
|
|
|
return Consumer<NotificationsProvider>(builder: (context, _notificationsProvider, _) {
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
Provider.of<AllRequestsProvider>(context, listen: false).getRequests();
|
|
|
|
|
_notificationsProvider.getSystemNotifications();
|
|
|
|
|
return Future.delayed(const Duration(microseconds: 250));
|
|
|
|
|
},
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: ShapeDecoration(
|
|
|
|
|
color: AppColor.background(context),
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
|
|
|
|
shadows: [boxShadowR14],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.recentActivities
|
|
|
|
|
.heading5(context)
|
|
|
|
|
.toShimmer(
|
|
|
|
|
isShow: _notificationsProvider.isLoading,
|
|
|
|
|
)
|
|
|
|
|
.paddingOnly(top: 16, start: 16, end: 16),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemCount: _notificationsProvider.notifications.length,
|
|
|
|
|
separatorBuilder: (context, itemIndex) => const Divider().defaultStyle(context).paddingOnly(top: 16, bottom: 16),
|
|
|
|
|
itemBuilder: (context, itemIndex) {
|
|
|
|
|
// todo add priority & progress tag to show chip
|
|
|
|
|
return NotificationItem(
|
|
|
|
|
isLoading: _notificationsProvider.isLoading,
|
|
|
|
|
notification: _notificationsProvider.notifications[itemIndex],
|
|
|
|
|
onPressed: (notification) {
|
|
|
|
|
// todo @sikander, check notifications payload, because notification model is different to need to check from backend
|
|
|
|
|
//Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|