Neda/admin_panel/lib/services/mock/mock_notification_service.dart

54 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import '../../models/notification_model.dart';
import '../interfaces/notification_service.dart';
import '../api/api_client.dart';
class MockNotificationService implements NotificationService {
final List<NotificationModel> _items = [
const NotificationModel(
id: 'n-0001',
title: 'به‌روزرسانی سامانه',
description: 'ساعت ۲۲ سرویس برای ۱۵ دقیقه در دسترس نیست.',
type: NotificationType.public,
isAccepted: null,
receiverId: 'all',
senderId: 'admin',
groupId: null,
),
const NotificationModel(
id: 'n-0002',
title: 'درخواست عضویت',
description: 'کاربر ali_karimi درخواست عضویت ارسال کرده است.',
type: NotificationType.joinRequest,
isAccepted: null,
receiverId: 'admin',
senderId: 'u-0002',
groupId: 'g-0001',
),
];
@override
Future<NotificationList> getNotifications() async {
await Future.delayed(const Duration(milliseconds: 350));
return List.unmodifiable(_items);
}
@override
Future<void> sendPublicNotification(String title, String description) async {
await Future.delayed(const Duration(milliseconds: 300));
if (title.trim().isEmpty) {
throw const ApiException(statusCode: 400, message: 'عنوان الزامی است');
}
final item = NotificationModel(
id: 'n-${_items.length + 1}',
title: title,
description: description,
type: NotificationType.public,
isAccepted: null,
receiverId: 'all',
senderId: 'admin',
groupId: null,
);
_items.insert(0, item);
}
}