mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-15 11:48:21 +00:00
@ -143,6 +143,7 @@ class ZapStreamApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateDefaultStreamInfo({
|
Future<void> updateDefaultStreamInfo({
|
||||||
|
String? id,
|
||||||
String? title,
|
String? title,
|
||||||
String? summary,
|
String? summary,
|
||||||
String? image,
|
String? image,
|
||||||
@ -154,6 +155,7 @@ class ZapStreamApi {
|
|||||||
await _sendPatchRequest(
|
await _sendPatchRequest(
|
||||||
url,
|
url,
|
||||||
body: {
|
body: {
|
||||||
|
"id": id,
|
||||||
"title": title,
|
"title": title,
|
||||||
"summary": summary,
|
"summary": summary,
|
||||||
"image": image,
|
"image": image,
|
||||||
|
@ -177,6 +177,7 @@ class _LivePage extends State<LivePage>
|
|||||||
builder: (context, streamState) {
|
builder: (context, streamState) {
|
||||||
final ev = streamState
|
final ev = streamState
|
||||||
?.sortedBy((e) => e.createdAt)
|
?.sortedBy((e) => e.createdAt)
|
||||||
|
.reversed
|
||||||
.firstWhereOrNull((e) => e.getFirstTag("status") == "live");
|
.firstWhereOrNull((e) => e.getFirstTag("status") == "live");
|
||||||
|
|
||||||
final stream = ev != null ? StreamEvent(ev) : null;
|
final stream = ev != null ? StreamEvent(ev) : null;
|
||||||
@ -337,6 +338,7 @@ class _LivePage extends State<LivePage>
|
|||||||
api: _api,
|
api: _api,
|
||||||
account: _account!,
|
account: _account!,
|
||||||
hideEndpointConfig: _streaming,
|
hideEndpointConfig: _streaming,
|
||||||
|
currentStream: ev,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).then((_) {
|
).then((_) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:ndk/entities.dart';
|
||||||
import 'package:zap_stream_flutter/api.dart';
|
import 'package:zap_stream_flutter/api.dart';
|
||||||
import 'package:zap_stream_flutter/const.dart';
|
import 'package:zap_stream_flutter/const.dart';
|
||||||
import 'package:zap_stream_flutter/i18n/strings.g.dart';
|
import 'package:zap_stream_flutter/i18n/strings.g.dart';
|
||||||
@ -12,12 +13,14 @@ class StreamConfigWidget extends StatefulWidget {
|
|||||||
final ZapStreamApi api;
|
final ZapStreamApi api;
|
||||||
final AccountInfo account;
|
final AccountInfo account;
|
||||||
final bool? hideEndpointConfig;
|
final bool? hideEndpointConfig;
|
||||||
|
final Nip01Event? currentStream;
|
||||||
|
|
||||||
const StreamConfigWidget({
|
const StreamConfigWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.api,
|
required this.api,
|
||||||
required this.account,
|
required this.account,
|
||||||
this.hideEndpointConfig,
|
this.hideEndpointConfig,
|
||||||
|
this.currentStream,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -41,6 +44,19 @@ class _StreamConfigWidget extends State<StreamConfigWidget> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _variantWidget(String cap) {
|
||||||
|
if (cap.startsWith("variant:")) {
|
||||||
|
final caps = cap.split(":");
|
||||||
|
return PillWidget(
|
||||||
|
color: LAYER_3,
|
||||||
|
child: Text(caps[1].replaceAll("h", "p")),
|
||||||
|
);
|
||||||
|
} else if (cap.startsWith("dvr:")) {
|
||||||
|
return PillWidget(color: LAYER_3, child: Text("Recording"));
|
||||||
|
}
|
||||||
|
return PillWidget(color: LAYER_3, child: Text(cap));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ValueListenableBuilder(
|
return ValueListenableBuilder(
|
||||||
@ -88,15 +104,16 @@ class _StreamConfigWidget extends State<StreamConfigWidget> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (endpoint != null && !(widget.hideEndpointConfig ?? false))
|
if (endpoint != null && !(widget.hideEndpointConfig ?? false))
|
||||||
Row(
|
SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children:
|
children:
|
||||||
endpoint.capabilities
|
endpoint.capabilities
|
||||||
.map(
|
.map((e) => _variantWidget(e))
|
||||||
(e) => PillWidget(color: LAYER_3, child: Text(e)),
|
|
||||||
)
|
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: _title,
|
controller: _title,
|
||||||
@ -155,6 +172,7 @@ class _StreamConfigWidget extends State<StreamConfigWidget> {
|
|||||||
t.button.save,
|
t.button.save,
|
||||||
onTap: (context) async {
|
onTap: (context) async {
|
||||||
await widget.api.updateDefaultStreamInfo(
|
await widget.api.updateDefaultStreamInfo(
|
||||||
|
id: widget.currentStream?.getFirstTag("d"),
|
||||||
title: _title.text,
|
title: _title.text,
|
||||||
summary: _summary.text,
|
summary: _summary.text,
|
||||||
contentWarning: _nsfw ? "nsfw" : null,
|
contentWarning: _nsfw ? "nsfw" : null,
|
||||||
|
Reference in New Issue
Block a user