2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-11-14 15:50:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:stackwallet/notifications/notification_card.dart';
|
|
|
|
import 'package:stackwallet/providers/providers.dart';
|
2022-11-14 16:40:31 +00:00
|
|
|
import 'package:stackwallet/providers/ui/unread_notifications_provider.dart';
|
2023-05-09 21:57:40 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2022-11-14 15:50:58 +00:00
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
|
|
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|
|
|
|
|
|
|
class DesktopNotificationsView extends ConsumerStatefulWidget {
|
|
|
|
const DesktopNotificationsView({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/desktopNotifications";
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<DesktopNotificationsView> createState() =>
|
|
|
|
_DesktopNotificationsViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _DesktopNotificationsViewState
|
|
|
|
extends ConsumerState<DesktopNotificationsView> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final notifications =
|
|
|
|
ref.watch(notificationsProvider.select((value) => value.notifications));
|
|
|
|
|
|
|
|
return DesktopScaffold(
|
|
|
|
background: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: DesktopAppBar(
|
|
|
|
isCompactHeight: true,
|
|
|
|
leading: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 24),
|
|
|
|
child: Text(
|
|
|
|
"Notifications",
|
|
|
|
style: STextStyles.desktopH3(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: notifications.isEmpty
|
2022-11-16 17:23:42 +00:00
|
|
|
? Column(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
child: RoundedWhiteContainer(
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
"Notifications will appear here",
|
|
|
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-14 15:50:58 +00:00
|
|
|
),
|
2022-11-16 17:23:42 +00:00
|
|
|
],
|
2022-11-14 15:50:58 +00:00
|
|
|
)
|
|
|
|
: ListView.builder(
|
2022-11-14 16:40:31 +00:00
|
|
|
primary: false,
|
2022-11-14 15:50:58 +00:00
|
|
|
itemCount: notifications.length,
|
|
|
|
itemBuilder: (context, index) {
|
2022-11-14 16:40:31 +00:00
|
|
|
final notification = notifications[index];
|
|
|
|
if (notification.read == false) {
|
|
|
|
ref
|
|
|
|
.read(unreadNotificationsStateProvider.state)
|
|
|
|
.state
|
|
|
|
.add(notification.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 24,
|
|
|
|
vertical: 5,
|
|
|
|
),
|
|
|
|
child: NotificationCard(
|
|
|
|
notification: notification,
|
|
|
|
),
|
2022-11-14 15:50:58 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|