101 lines
2.9 KiB
Dart
101 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../Controller/More/Notification/Notificationcontroller.dart';
|
|
import '../../../Helper/Constants/Assetconstants.dart';
|
|
import '../../../Helper/Constants/Colorconstants.dart';
|
|
|
|
class NotificationView extends StatelessWidget {
|
|
NotificationView({super.key});
|
|
|
|
final NotificationController controller =
|
|
Get.put(NotificationController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: ColorConstants.lightColor,
|
|
appBar: AppBar(
|
|
leading: Row(
|
|
children: [
|
|
IconButton(onPressed: (){
|
|
Navigator.pop(context);
|
|
|
|
}, icon: Icon(Icons.arrow_back,color: Colors.black,)),
|
|
Text(
|
|
"Notification",
|
|
style: TextStyle(color: Colors.black,fontSize: 20),
|
|
),
|
|
],
|
|
),
|
|
leadingWidth: 400,
|
|
elevation: 0,
|
|
backgroundColor:ColorConstants.lightColor,
|
|
automaticallyImplyLeading: true,
|
|
),
|
|
|
|
body: Obx(() {
|
|
// Loading state
|
|
if (controller.isLoading.value) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
// Empty state
|
|
if (controller.notifications.isEmpty) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Image(
|
|
height: 160,
|
|
width: 160,
|
|
image: AssetImage(AssetConstants.NoRecords),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
"No notification at this moment",
|
|
style: TextStyle(color: Colors.grey[600], fontSize: 18),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// Notification List
|
|
return ListView.builder(
|
|
padding: const EdgeInsets.all(12),
|
|
itemCount: controller.notifications.length,
|
|
itemBuilder: (context, index) {
|
|
final NotificationModel item =
|
|
controller.notifications[index];
|
|
|
|
return Card(
|
|
elevation: 2,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: ListTile(
|
|
title: Text(
|
|
item.title,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
subtitle: Text(
|
|
item.message,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
trailing: Text(
|
|
item.notificationdate.split("T")[0], // YYYY-MM-DD
|
|
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
}
|