Merge pull request 'added_unread_allread_notification' (#157) from added_unread_allread_notification into main
Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/157
This commit is contained in:
@@ -4,12 +4,13 @@ import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/notification_view_model.dart';
|
||||
import 'package:tm_app/views/notification/strings/notification_strings.dart';
|
||||
import 'package:tm_app/views/shared/page_selection_dialog.dart';
|
||||
import 'package:tm_app/views/shared/desktop_navigation_widget.dart';
|
||||
import 'package:tm_app/views/shared/page_selection_dialog.dart';
|
||||
|
||||
import '../../shared/main_tab_bar.dart';
|
||||
import '../widgets/notification_all_tab.dart';
|
||||
import '../widgets/notification_important_tab.dart';
|
||||
import '../widgets/notification_unread_tab.dart';
|
||||
import '../../shared/main_tab_bar.dart';
|
||||
|
||||
class DesktopNotificationPage extends StatefulWidget {
|
||||
const DesktopNotificationPage({super.key});
|
||||
@@ -65,7 +66,9 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
onTap: viewModel.markAllAsRead,
|
||||
onTap: () {
|
||||
viewModel.markAllAsRead(context);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
child: Container(
|
||||
width: 132.0.w(),
|
||||
@@ -89,16 +92,27 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: const [
|
||||
NotificationAllTab(),
|
||||
NotificationUnreadTab(),
|
||||
NotificationImportantTab(),
|
||||
],
|
||||
viewModel.isLoading
|
||||
? Container()
|
||||
: Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: const [
|
||||
NotificationAllTab(),
|
||||
NotificationUnreadTab(),
|
||||
NotificationImportantTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (viewModel.isLoading) ...[
|
||||
const Spacer(),
|
||||
const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
SizedBox(height: 10.0.h()),
|
||||
Row(
|
||||
children: [
|
||||
@@ -116,8 +130,10 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => PageSelectionDialog(
|
||||
totalPages: viewModel.totalPages),
|
||||
builder:
|
||||
(context) => PageSelectionDialog(
|
||||
totalPages: viewModel.totalPages,
|
||||
),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
viewModel.hasMoreData) {
|
||||
viewModel.getNotifications(
|
||||
page: viewModel.currentPage + 1,
|
||||
isMobile: true,
|
||||
isMobile: true,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -51,7 +51,7 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>(); // ✅ وصل به ویومدل
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
@@ -72,7 +72,9 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
onTap: viewModel.markAllAsRead, // ✅ مثل دسکتاپ/تبلت
|
||||
onTap: () {
|
||||
viewModel.markAllAsRead(context);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
child: Container(
|
||||
width: 132.0.w(),
|
||||
@@ -96,20 +98,26 @@ class _MobileNotificationPageState extends State<MobileNotificationPage>
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: [
|
||||
NotificationAllTab(scrollController: _scrollController),
|
||||
NotificationUnreadTab(scrollController: _scrollController),
|
||||
NotificationImportantTab(scrollController: _scrollController),
|
||||
],
|
||||
),
|
||||
),
|
||||
viewModel.isLoading
|
||||
? Container()
|
||||
: Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: [
|
||||
NotificationAllTab(scrollController: _scrollController),
|
||||
NotificationUnreadTab(scrollController: _scrollController),
|
||||
NotificationImportantTab(
|
||||
scrollController: _scrollController,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (viewModel.isLoading) ...[
|
||||
SizedBox(height: 10.0.h()),
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
SizedBox(height: 10.0.h()),
|
||||
const Spacer(),
|
||||
const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.secondary50),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
@@ -70,7 +70,9 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: InkWell(
|
||||
onTap: viewModel.markAllAsRead,
|
||||
onTap: () {
|
||||
viewModel.markAllAsRead(context);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
child: Container(
|
||||
width: 132.0.w(),
|
||||
@@ -94,16 +96,27 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12.0.h()),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: const [
|
||||
NotificationAllTab(),
|
||||
NotificationUnreadTab(),
|
||||
NotificationImportantTab(),
|
||||
],
|
||||
viewModel.isLoading
|
||||
? Container()
|
||||
: Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: const [
|
||||
NotificationAllTab(),
|
||||
NotificationUnreadTab(),
|
||||
NotificationImportantTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (viewModel.isLoading) ...[
|
||||
const Spacer(),
|
||||
const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
SizedBox(height: 10.0.h()),
|
||||
Row(
|
||||
children: [
|
||||
@@ -121,9 +134,10 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => PageSelectionDialog(
|
||||
totalPages: viewModel.totalPages,
|
||||
),
|
||||
builder:
|
||||
(context) => PageSelectionDialog(
|
||||
totalPages: viewModel.totalPages,
|
||||
),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
|
||||
@@ -12,9 +12,20 @@ class NotificationUnreadTab extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
|
||||
if (viewModel.isUnreadLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final notifications =
|
||||
viewModel.notificationResponse?.data?.notifications ?? [];
|
||||
viewModel.unreadNotificationResponse?.data?.notifications ?? [];
|
||||
|
||||
if (notifications.isEmpty) {
|
||||
return const Center(child: Text('No unread notifications'));
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: notifications.length,
|
||||
itemBuilder: (context, index) {
|
||||
final notification = notifications[index];
|
||||
|
||||
Reference in New Issue
Block a user