feat: add notifications button to profile page

This commit is contained in:
2025-05-30 13:51:07 +01:00
parent 428771462d
commit cd6c50f9bd
3 changed files with 15 additions and 10 deletions

View File

@ -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/button_follow.dart';
import 'package:zap_stream_flutter/widgets/header.dart'; import 'package:zap_stream_flutter/widgets/header.dart';
import 'package:zap_stream_flutter/widgets/nostr_text.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/profile.dart';
import 'package:zap_stream_flutter/widgets/stream_grid.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( Text(
t.profile.past_streams, t.profile.past_streams,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600), style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),

View File

@ -159,7 +159,7 @@ class _StreamPage extends State<StreamPage> with RouteAware {
ProfileWidget.pubkey( ProfileWidget.pubkey(
stream.info.host, stream.info.host,
children: [ children: [
NotificationsButtonWidget(stream: widget.stream), NotificationsButtonWidget(pubkey: widget.stream.info.host),
BasicButton( BasicButton(
Row( Row(
children: [Icon(Icons.bolt, size: 14), Text(t.zap.button_zap)], children: [Icon(Icons.bolt, size: 14), Text(t.zap.button_zap)],

View File

@ -1,12 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:zap_stream_flutter/notifications.dart'; import 'package:zap_stream_flutter/notifications.dart';
import 'package:zap_stream_flutter/theme.dart'; import 'package:zap_stream_flutter/theme.dart';
import 'package:zap_stream_flutter/utils.dart';
class NotificationsButtonWidget extends StatefulWidget { 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 @override
State<StatefulWidget> createState() => _NotificationsButtonWidget(); State<StatefulWidget> createState() => _NotificationsButtonWidget();
@ -18,9 +17,7 @@ class _NotificationsButtonWidget extends State<NotificationsButtonWidget> {
return ValueListenableBuilder( return ValueListenableBuilder(
valueListenable: notifications, valueListenable: notifications,
builder: (context, state, _) { builder: (context, state, _) {
final isNotified = (state?.notifyKeys ?? []).contains( final isNotified = (state?.notifyKeys ?? []).contains(widget.pubkey);
widget.stream.info.host,
);
return IconButton( return IconButton(
iconSize: 20, iconSize: 20,
onPressed: () async { onPressed: () async {
@ -28,9 +25,9 @@ class _NotificationsButtonWidget extends State<NotificationsButtonWidget> {
if (n == null) return; if (n == null) return;
if (isNotified) { if (isNotified) {
await n.removeWatchPubkey(widget.stream.info.host); await n.removeWatchPubkey(widget.pubkey);
} else { } else {
await n.watchPubkey(widget.stream.info.host, [30311]); await n.watchPubkey(widget.pubkey, [30311]);
} }
await notifications.reload(); await notifications.reload();
}, },