mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-17 12:28:49 +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/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),
|
||||||
|
@ -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)],
|
||||||
|
@ -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();
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user