mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-16 20:08:50 +00:00
@ -17,51 +17,91 @@ class ChatWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final hostMuteList = ndk.lists.getSingleNip51List(
|
||||||
|
Nip51List.kMute,
|
||||||
|
Bip340EventSigner(privateKey: null, publicKey: stream.info.host),
|
||||||
|
forceRefresh: true,
|
||||||
|
);
|
||||||
|
final signer = ndk.accounts.getLoggedAccount()?.signer;
|
||||||
|
final myMuteList =
|
||||||
|
signer != null
|
||||||
|
? ndk.lists.getSingleNip51List(
|
||||||
|
Nip51List.kMute,
|
||||||
|
signer,
|
||||||
|
forceRefresh: true,
|
||||||
|
)
|
||||||
|
: Future.value(null);
|
||||||
|
|
||||||
return RxFilter<Nip01Event>(
|
return RxFilter<Nip01Event>(
|
||||||
filters: [
|
filters: [
|
||||||
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
Filter(kinds: [1311, 9735], limit: 200, aTags: [stream.aTag]),
|
||||||
],
|
],
|
||||||
builder: (ctx, state) {
|
builder: (ctx, state) {
|
||||||
return Column(
|
return FutureBuilder(
|
||||||
spacing: 8,
|
future: Future.wait([hostMuteList, myMuteList]),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
builder: (ctx, muteState) {
|
||||||
children: [
|
final mutedPubkeys =
|
||||||
_TopZappersWidget(events: state ?? []),
|
muteState.data
|
||||||
Expanded(
|
?.map((e) => e?.pubKeys)
|
||||||
child: SingleChildScrollView(
|
.where((e) => e != null)
|
||||||
reverse: true,
|
.expand((e) => e!)
|
||||||
child: Column(
|
.map((e) => e.value)
|
||||||
spacing: 8,
|
.toSet() ??
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
<String>{};
|
||||||
children:
|
|
||||||
(state ?? [])
|
final filteredChat =
|
||||||
.sortedBy((c) => c.createdAt)
|
(state ?? [])
|
||||||
.map(
|
.where((e) => !mutedPubkeys.contains(e.pubKey))
|
||||||
(c) => switch (c.kind) {
|
.toList();
|
||||||
1311 => ChatMessageWidget(stream: stream, msg: c),
|
|
||||||
9735 => _ChatZapWidget(stream: stream, zap: c),
|
return Column(
|
||||||
_ => SizedBox.shrink(),
|
spacing: 8,
|
||||||
},
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
)
|
children: [
|
||||||
.toList(),
|
_TopZappersWidget(events: filteredChat),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
reverse: true,
|
||||||
|
child: Column(
|
||||||
|
spacing: 8,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children:
|
||||||
|
filteredChat
|
||||||
|
.sortedBy((c) => c.createdAt)
|
||||||
|
.map(
|
||||||
|
(c) => switch (c.kind) {
|
||||||
|
1311 => ChatMessageWidget(
|
||||||
|
stream: stream,
|
||||||
|
msg: c,
|
||||||
|
),
|
||||||
|
9735 => _ChatZapWidget(
|
||||||
|
stream: stream,
|
||||||
|
zap: c,
|
||||||
|
),
|
||||||
|
_ => SizedBox.shrink(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
if (stream.info.status == StreamStatus.live)
|
||||||
),
|
WriteMessageWidget(stream: stream),
|
||||||
if (stream.info.status == StreamStatus.live)
|
if (stream.info.status == StreamStatus.ended)
|
||||||
WriteMessageWidget(stream: stream),
|
Container(
|
||||||
if (stream.info.status == StreamStatus.ended)
|
padding: EdgeInsets.all(8),
|
||||||
Container(
|
margin: EdgeInsets.symmetric(vertical: 8),
|
||||||
padding: EdgeInsets.all(8),
|
width: double.maxFinite,
|
||||||
margin: EdgeInsets.symmetric(vertical: 8),
|
alignment: Alignment.center,
|
||||||
width: double.maxFinite,
|
decoration: BoxDecoration(borderRadius: DEFAULT_BR),
|
||||||
alignment: Alignment.center,
|
child: Text(
|
||||||
decoration: BoxDecoration(borderRadius: DEFAULT_BR),
|
"STREAM ENDED",
|
||||||
child: Text(
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
"STREAM ENDED",
|
),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user