A framework for building convergent cross-platform Nextcloud clients using Flutter.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

part of '../neon_spreed.dart';
class SpreedScreenPreview extends StatefulWidget {
const SpreedScreenPreview({
required this.source,
super.key,
});
final DesktopCapturerSource source;
@override
State<SpreedScreenPreview> createState() => _SpreedScreenPreviewState();
}
class _SpreedScreenPreviewState extends State<SpreedScreenPreview> {
late final List<StreamSubscription<dynamic>> subscriptions = [];
@override
void initState() {
super.initState();
subscriptions.addAll([
widget.source.onThumbnailChanged.stream.listen((final _) => setState(() {})),
widget.source.onNameChanged.stream.listen((final _) => setState(() {})),
]);
}
@override
void dispose() {
for (final subscription in subscriptions) {
unawaited(subscription.cancel());
}
super.dispose();
}
@override
Widget build(final BuildContext context) => Column(
children: [
if (widget.source.thumbnail != null) ...[
AspectRatio(
aspectRatio: 3 / 2,
child: Image.memory(
widget.source.thumbnail!,
gaplessPlayback: true,
fit: BoxFit.contain,
),
),
],
Text(
widget.source.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
],
);
}