Ocideck/lib/widgets/editors/video_slide_editor.dart
Brenno de Winter dd2e91d61b Initial commit: OciDeck Marp presentation builder
Flutter desktop app for building Marp presentations via structured
slide editors, with live preview, fullscreen presenter, and PDF/PPTX
export. Includes Makefile quality gate, CI workflow, and full test suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 23:28:39 +02:00

123 lines
3.3 KiB
Dart

import 'package:flutter/material.dart';
import '../../models/slide.dart';
import '../../services/image_service.dart';
import '_editor_field.dart';
import 'audio_attachment_editor.dart';
class VideoSlideEditor extends StatefulWidget {
final Slide slide;
final ValueChanged<Slide> onUpdate;
final ImageService imageService;
const VideoSlideEditor({
super.key,
required this.slide,
required this.onUpdate,
required this.imageService,
});
@override
State<VideoSlideEditor> createState() => _VideoSlideEditorState();
}
class _VideoSlideEditorState extends State<VideoSlideEditor> {
late final TextEditingController _title;
@override
void initState() {
super.initState();
_title = TextEditingController(text: widget.slide.title);
_title.addListener(_emit);
}
void _emit() {
widget.onUpdate(widget.slide.copyWith(title: _title.text));
}
Future<void> _pickVideo() async {
final path = await widget.imageService.pickVideo();
if (path != null) widget.onUpdate(widget.slide.copyWith(videoPath: path));
}
@override
void dispose() {
_title.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.all(16),
children: [
EditorField(
label: 'Titel (optioneel)',
controller: _title,
hint: 'Titel boven de video',
maxLines: 2,
),
const SizedBox(height: 16),
const SectionLabel('Video'),
Row(
children: [
Expanded(child: _PathBox(path: widget.slide.videoPath)),
const SizedBox(width: 8),
ElevatedButton.icon(
onPressed: _pickVideo,
icon: const Icon(Icons.movie_outlined, size: 16),
label: const Text('Kiezen'),
),
],
),
const SizedBox(height: 8),
Material(
color: Colors.transparent,
child: CheckboxListTile(
value: widget.slide.videoAutoplay,
onChanged: (value) => widget.onUpdate(
widget.slide.copyWith(videoAutoplay: value ?? false),
),
title: const Text('Video automatisch afspelen'),
dense: true,
contentPadding: EdgeInsets.zero,
controlAffinity: ListTileControlAffinity.leading,
),
),
const SizedBox(height: 16),
AudioAttachmentEditor(
slide: widget.slide,
imageService: widget.imageService,
onUpdate: widget.onUpdate,
),
],
);
}
}
class _PathBox extends StatelessWidget {
final String path;
const _PathBox({required this.path});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFFCBD5E1)),
borderRadius: BorderRadius.circular(6),
color: Colors.white,
),
child: Text(
path.isEmpty ? 'Geen video gekozen' : path,
style: TextStyle(
fontSize: 12,
color: path.isEmpty
? const Color(0xFF94A3B8)
: const Color(0xFF334155),
),
overflow: TextOverflow.ellipsis,
),
);
}
}