- Fix gamification endpoints to use Node.js server (app.eventifyplus.com) - Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit) - Add booking models, service, payment service (Razorpay), checkout provider - Add 3-step CheckoutScreen with Razorpay native modal integration - Add Google OAuth login (Flutter + Django backend) - Add full notifications system (Django model + 3 endpoints + Flutter UI) - Register CheckoutProvider, NotificationProvider in main.dart MultiProvider - Wire notification bell in HomeScreen app bar - Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
95 lines
3.0 KiB
Dart
95 lines
3.0 KiB
Dart
// lib/features/notifications/widgets/notification_tile.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import '../models/notification_model.dart';
|
|
|
|
class NotificationTile extends StatelessWidget {
|
|
final NotificationModel notification;
|
|
final VoidCallback? onTap;
|
|
|
|
const NotificationTile({Key? key, required this.notification, this.onTap}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Container(
|
|
color: notification.isRead ? Colors.transparent : const Color(0xFFF0F4FF),
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildIcon(),
|
|
const SizedBox(width: 14),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
notification.title,
|
|
style: TextStyle(
|
|
fontWeight: notification.isRead ? FontWeight.w400 : FontWeight.w600,
|
|
fontSize: 14,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
notification.message,
|
|
style: TextStyle(color: Colors.grey.shade600, fontSize: 13),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
_timeAgo(notification.createdAt),
|
|
style: TextStyle(color: Colors.grey.shade400, fontSize: 12),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildIcon() {
|
|
final config = _typeConfig(notification.type);
|
|
return Container(
|
|
width: 40,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color: config.color.withOpacity(0.15),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(config.icon, color: config.color, size: 20),
|
|
);
|
|
}
|
|
|
|
static _TypeConfig _typeConfig(String type) {
|
|
switch (type) {
|
|
case 'event': return _TypeConfig(Colors.blue, Icons.event);
|
|
case 'promo': return _TypeConfig(Colors.green, Icons.local_offer);
|
|
case 'booking': return _TypeConfig(Colors.orange, Icons.confirmation_number);
|
|
default: return _TypeConfig(Colors.grey, Icons.info_outline);
|
|
}
|
|
}
|
|
|
|
static String _timeAgo(DateTime dt) {
|
|
final diff = DateTime.now().difference(dt);
|
|
if (diff.inMinutes < 1) return 'Just now';
|
|
if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';
|
|
if (diff.inHours < 24) return '${diff.inHours}h ago';
|
|
if (diff.inDays < 7) return '${diff.inDays}d ago';
|
|
return '${dt.day}/${dt.month}/${dt.year}';
|
|
}
|
|
}
|
|
|
|
class _TypeConfig {
|
|
final Color color;
|
|
final IconData icon;
|
|
const _TypeConfig(this.color, this.icon);
|
|
}
|