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-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../notifications/notification_card.dart';
|
|
|
|
import '../../providers/providers.dart';
|
|
|
|
import '../../providers/ui/unread_notifications_provider.dart';
|
|
|
|
import '../../themes/stack_colors.dart';
|
|
|
|
import '../../utilities/text_styles.dart';
|
|
|
|
import '../../widgets/background.dart';
|
|
|
|
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import '../../widgets/rounded_white_container.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class NotificationsView extends ConsumerStatefulWidget {
|
|
|
|
const NotificationsView({
|
2024-05-27 23:56:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
this.walletId,
|
2024-05-27 23:56:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final String? walletId;
|
|
|
|
|
|
|
|
static const routeName = "/notifications";
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<NotificationsView> createState() => _NotificationsViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _NotificationsViewState extends ConsumerState<NotificationsView> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final notifications = widget.walletId == null
|
|
|
|
? ref
|
|
|
|
.watch(notificationsProvider.select((value) => value.notifications))
|
|
|
|
: ref
|
|
|
|
.watch(notificationsProvider.select((value) => value.notifications))
|
|
|
|
.where((element) => element.walletId == widget.walletId)
|
|
|
|
.toList(growable: false);
|
|
|
|
|
2022-11-25 19:24:01 +00:00
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(
|
|
|
|
"Notifications",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
body: Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: notifications.isNotEmpty
|
|
|
|
? Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemCount: notifications.length,
|
|
|
|
itemBuilder: (builderContext, index) {
|
|
|
|
final notification = notifications[index];
|
|
|
|
if (notification.read == false) {
|
|
|
|
ref
|
|
|
|
.read(unreadNotificationsStateProvider.state)
|
|
|
|
.state
|
|
|
|
.add(notification.id);
|
|
|
|
}
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: NotificationCard(
|
|
|
|
notification: notifications[index],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: RoundedWhiteContainer(
|
|
|
|
child: Center(
|
|
|
|
child: FittedBox(
|
|
|
|
fit: BoxFit.scaleDown,
|
|
|
|
child: Text(
|
|
|
|
"Notifications will appear here",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-05-27 23:56:22 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|