feat: deploy infrastructure + disk/drive, calendar, presentation, workspaces, onboarding, demo user
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../providers/notification_provider.dart';
|
||||
import '../../widgets/loading_indicator.dart';
|
||||
import '../../widgets/empty_state.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
|
||||
class NotificationsScreen extends ConsumerStatefulWidget {
|
||||
const NotificationsScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<NotificationsScreen> createState() =>
|
||||
_NotificationsScreenState();
|
||||
}
|
||||
|
||||
class _NotificationsScreenState extends ConsumerState<NotificationsScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(
|
||||
() => ref.read(notificationProvider.notifier).loadNotifications());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = ref.watch(notificationProvider);
|
||||
final notifier = ref.read(notificationProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Уведомления'),
|
||||
actions: [
|
||||
if (state.unreadCount > 0)
|
||||
TextButton(
|
||||
onPressed: notifier.markAllAsRead,
|
||||
child: const Text('Прочитать все'),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: state.isLoading
|
||||
? const LoadingIndicator()
|
||||
: state.notifications.isEmpty
|
||||
? const EmptyState(
|
||||
icon: Icons.notifications_none,
|
||||
title: 'Нет уведомлений',
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: notifier.loadNotifications,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: state.notifications.length,
|
||||
itemBuilder: (_, i) {
|
||||
final n = state.notifications[i];
|
||||
return Dismissible(
|
||||
key: Key(n.id),
|
||||
direction: DismissDirection.endToStart,
|
||||
onDismissed: (_) => notifier.markAsRead(n.id),
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
color: VoIdeaColors.primary,
|
||||
child: const Icon(Icons.check, color: Colors.white),
|
||||
),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
color: n.isRead ? null : VoIdeaColors.primary.withOpacity(0.03),
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 18,
|
||||
backgroundColor: n.isRead
|
||||
? VoIdeaColors.muted.withOpacity(0.1)
|
||||
: VoIdeaColors.primary.withOpacity(0.1),
|
||||
child: Icon(
|
||||
n.isRead
|
||||
? Icons.notifications_none
|
||||
: Icons.notifications_active,
|
||||
size: 20,
|
||||
color: n.isRead
|
||||
? VoIdeaColors.muted
|
||||
: VoIdeaColors.primary,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
n.title,
|
||||
style: TextStyle(
|
||||
fontWeight: n.isRead
|
||||
? FontWeight.normal
|
||||
: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(n.body,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
DateFormat('d MMM HH:mm')
|
||||
.format(n.createdAt),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: VoIdeaColors.muted,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
if (!n.isRead) notifier.markAsRead(n.id);
|
||||
if (n.ideaId != null) {
|
||||
context.push('/ideas/${n.ideaId}');
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user