mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-17 04:18:50 +00:00
feat: zaps / profiles
This commit is contained in:
@ -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)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user