chat support
This commit is contained in:
34
lib/providers/chat_unread_provider.dart
Normal file
34
lib/providers/chat_unread_provider.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChatUnreadProvider extends ChangeNotifier {
|
||||
int _unreadCount = 0;
|
||||
bool _chatOpen = false;
|
||||
|
||||
int get unreadCount => _unreadCount;
|
||||
bool get isChatOpen => _chatOpen;
|
||||
|
||||
/// 📩 Called when ADMIN sends message
|
||||
void increment() {
|
||||
if (!_chatOpen) {
|
||||
_unreadCount++;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/// 👁 Called when chat screen is opened
|
||||
void setChatOpen(bool open) {
|
||||
_chatOpen = open;
|
||||
|
||||
if (open) {
|
||||
_unreadCount = 0; // reset badge when user opens chat
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 🔁 Manual reset (optional)
|
||||
void reset() {
|
||||
_unreadCount = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user