feat: zaps / profiles

This commit is contained in:
2025-05-09 12:23:39 +01:00
parent ab5bdcca69
commit 0ba0839863
25 changed files with 778 additions and 79 deletions

View File

@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter/widgets.dart';
import 'package:ndk/ndk.dart';
import 'package:zap_stream_flutter/theme.dart';
@ -6,13 +7,35 @@ import 'package:zap_stream_flutter/widgets/stream_tile.dart';
class StreamGrid extends StatelessWidget {
final List<Nip01Event> events;
const StreamGrid({super.key, required this.events});
final bool showEnded;
final bool showLive;
final bool showPlanned;
const StreamGrid({
super.key,
required this.events,
this.showLive = true,
this.showEnded = false,
this.showPlanned = false,
});
@override
Widget build(BuildContext context) {
final streams = events.map((e) => StreamEvent(e));
final streams = events
.map((e) => StreamEvent(e))
.where((e) => e.info.stream?.isNotEmpty ?? false)
.sortedBy((a) => a.info.starts ?? a.event.createdAt);
final live = streams.where((s) => s.info.status == StreamStatus.live);
return Column(children: [_streamGroup("Live", live)]);
final ended = streams.where((s) => s.info.status == StreamStatus.ended);
final planned = streams.where((s) => s.info.status == StreamStatus.planned);
return Column(
spacing: 16,
children: [
if (showLive && live.isNotEmpty) _streamGroup("Live", live),
if (showPlanned && planned.isNotEmpty) _streamGroup("Planned", planned),
if (showEnded && ended.isNotEmpty) _streamGroup("Ended", ended),
],
);
}
Widget _streamGroup(String title, Iterable<StreamEvent> events) {
@ -30,7 +53,7 @@ class StreamGrid extends StatelessWidget {
child: Container(
height: 1,
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: LAYER_1)),
border: Border(bottom: BorderSide(color: LAYER_2)),
),
),
),