mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-14 11:27:43 +00:00
feat: add notifications button to profile page
This commit is contained in:
@ -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),
|
||||
|
@ -159,7 +159,7 @@ class _StreamPage extends State<StreamPage> 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)],
|
||||
|
@ -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<StatefulWidget> createState() => _NotificationsButtonWidget();
|
||||
@ -18,9 +17,7 @@ class _NotificationsButtonWidget extends State<NotificationsButtonWidget> {
|
||||
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<NotificationsButtonWidget> {
|
||||
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();
|
||||
},
|
||||
|
Reference in New Issue
Block a user