mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-17 12:28:49 +00:00
@ -374,6 +374,14 @@ Map<String, TopZaps> topZapReceiver(Iterable<ZapReceipt> zaps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String formatSecondsToHHMMSS(int seconds) {
|
||||||
|
int hours = seconds ~/ 3600;
|
||||||
|
int minutes = (seconds % 3600) ~/ 60;
|
||||||
|
int remainingSeconds = seconds % 60;
|
||||||
|
|
||||||
|
return '${hours.toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}';
|
||||||
|
}
|
||||||
|
|
||||||
String bech32ToHex(String bech32) {
|
String bech32ToHex(String bech32) {
|
||||||
final decoder = Bech32Decoder();
|
final decoder = Bech32Decoder();
|
||||||
final data = decoder.convert(bech32, 10_000);
|
final data = decoder.convert(bech32, 10_000);
|
||||||
|
49
lib/widgets/live_timer.dart
Normal file
49
lib/widgets/live_timer.dart
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:zap_stream_flutter/theme.dart';
|
||||||
|
import 'package:zap_stream_flutter/utils.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/pill.dart';
|
||||||
|
|
||||||
|
class LiveTimerWidget extends StatefulWidget {
|
||||||
|
final DateTime started;
|
||||||
|
|
||||||
|
const LiveTimerWidget({super.key, required this.started});
|
||||||
|
|
||||||
|
@override
|
||||||
|
createState() => _LiveTimerWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LiveTimerWidget extends State<LiveTimerWidget> {
|
||||||
|
late Timer _timer;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
|
setState(() {
|
||||||
|
// tick
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_timer.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return PillWidget(
|
||||||
|
color: LAYER_2,
|
||||||
|
child: Text(
|
||||||
|
formatSecondsToHHMMSS(
|
||||||
|
((DateTime.now().millisecondsSinceEpoch -
|
||||||
|
widget.started.millisecondsSinceEpoch) /
|
||||||
|
1000)
|
||||||
|
.toInt(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ import 'package:zap_stream_flutter/theme.dart';
|
|||||||
import 'package:zap_stream_flutter/utils.dart';
|
import 'package:zap_stream_flutter/utils.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/game_info.dart';
|
import 'package:zap_stream_flutter/widgets/game_info.dart';
|
||||||
|
import 'package:zap_stream_flutter/widgets/live_timer.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/pill.dart';
|
import 'package:zap_stream_flutter/widgets/pill.dart';
|
||||||
import 'package:zap_stream_flutter/widgets/profile.dart';
|
import 'package:zap_stream_flutter/widgets/profile.dart';
|
||||||
@ -39,6 +40,9 @@ class StreamInfoWidget extends StatelessWidget {
|
|||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
if (startedDate != null)
|
if (startedDate != null)
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
RichText(
|
RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
style: TextStyle(color: LAYER_5, fontSize: 14),
|
style: TextStyle(color: LAYER_5, fontSize: 14),
|
||||||
@ -48,6 +52,9 @@ class StreamInfoWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
LiveTimerWidget(started: startedDate),
|
||||||
|
],
|
||||||
|
),
|
||||||
if (stream.info.summary?.isNotEmpty ?? false)
|
if (stream.info.summary?.isNotEmpty ?? false)
|
||||||
Text.rich(
|
Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
|
Reference in New Issue
Block a user