From cd6c50f9bd053e8cbf55182baf47035d218cace0 Mon Sep 17 00:00:00 2001 From: Kieran Date: Fri, 30 May 2025 13:51:07 +0100 Subject: [PATCH] feat: add notifications button to profile page --- lib/pages/profile.dart | 10 +++++++++- lib/pages/stream.dart | 2 +- lib/widgets/notifications_button.dart | 13 +++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/pages/profile.dart b/lib/pages/profile.dart index f970e2d..0a838dc 100644 --- a/lib/pages/profile.dart +++ b/lib/pages/profile.dart @@ -12,6 +12,7 @@ import 'package:zap_stream_flutter/widgets/button.dart'; import 'package:zap_stream_flutter/widgets/button_follow.dart'; import 'package:zap_stream_flutter/widgets/header.dart'; import 'package:zap_stream_flutter/widgets/nostr_text.dart'; +import 'package:zap_stream_flutter/widgets/notifications_button.dart'; import 'package:zap_stream_flutter/widgets/profile.dart'; import 'package:zap_stream_flutter/widgets/stream_grid.dart'; @@ -91,7 +92,14 @@ class ProfilePage extends StatelessWidget { ), ], ), - if (!isMe) FollowButton(pubkey: hexPubkey), + if (!isMe) + Row( + spacing: 8, + children: [ + FollowButton(pubkey: hexPubkey), + NotificationsButtonWidget(pubkey: hexPubkey), + ], + ), Text( t.profile.past_streams, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600), diff --git a/lib/pages/stream.dart b/lib/pages/stream.dart index 18f843d..df0269b 100644 --- a/lib/pages/stream.dart +++ b/lib/pages/stream.dart @@ -159,7 +159,7 @@ class _StreamPage extends State with RouteAware { ProfileWidget.pubkey( stream.info.host, children: [ - NotificationsButtonWidget(stream: widget.stream), + NotificationsButtonWidget(pubkey: widget.stream.info.host), BasicButton( Row( children: [Icon(Icons.bolt, size: 14), Text(t.zap.button_zap)], diff --git a/lib/widgets/notifications_button.dart b/lib/widgets/notifications_button.dart index 848b7bc..7c7f055 100644 --- a/lib/widgets/notifications_button.dart +++ b/lib/widgets/notifications_button.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; import 'package:zap_stream_flutter/notifications.dart'; import 'package:zap_stream_flutter/theme.dart'; -import 'package:zap_stream_flutter/utils.dart'; class NotificationsButtonWidget extends StatefulWidget { - final StreamEvent stream; + final String pubkey; - const NotificationsButtonWidget({super.key, required this.stream}); + const NotificationsButtonWidget({super.key, required this.pubkey}); @override State createState() => _NotificationsButtonWidget(); @@ -18,9 +17,7 @@ class _NotificationsButtonWidget extends State { return ValueListenableBuilder( valueListenable: notifications, builder: (context, state, _) { - final isNotified = (state?.notifyKeys ?? []).contains( - widget.stream.info.host, - ); + final isNotified = (state?.notifyKeys ?? []).contains(widget.pubkey); return IconButton( iconSize: 20, onPressed: () async { @@ -28,9 +25,9 @@ class _NotificationsButtonWidget extends State { if (n == null) return; if (isNotified) { - await n.removeWatchPubkey(widget.stream.info.host); + await n.removeWatchPubkey(widget.pubkey); } else { - await n.watchPubkey(widget.stream.info.host, [30311]); + await n.watchPubkey(widget.pubkey, [30311]); } await notifications.reload(); },