chore: Follow up VideoPlayer in ImageViewer
This commit is contained in:
parent
d3330c8bdf
commit
92d3e7f1c3
2 changed files with 31 additions and 22 deletions
|
|
@ -75,6 +75,7 @@ class ImageViewerView extends StatelessWidget {
|
||||||
focusNode: controller.focusNode,
|
focusNode: controller.focusNode,
|
||||||
onKeyEvent: controller.onKeyEvent,
|
onKeyEvent: controller.onKeyEvent,
|
||||||
child: PageView.builder(
|
child: PageView.builder(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
controller: controller.pageController,
|
controller: controller.pageController,
|
||||||
itemCount: controller.allEvents.length,
|
itemCount: controller.allEvents.length,
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
|
|
@ -119,30 +120,33 @@ class ImageViewerView extends StatelessWidget {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (hovered && controller.canGoBack)
|
if (hovered)
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12.0),
|
|
||||||
child: IconButton(
|
|
||||||
style: iconButtonStyle,
|
|
||||||
tooltip: L10n.of(context).previous,
|
|
||||||
icon: const Icon(Icons.chevron_left_outlined),
|
|
||||||
onPressed: controller.prevImage,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (hovered && controller.canGoNext)
|
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.all(12.0),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: IconButton(
|
children: [
|
||||||
style: iconButtonStyle,
|
if (controller.canGoBack)
|
||||||
tooltip: L10n.of(context).next,
|
Padding(
|
||||||
icon: const Icon(Icons.chevron_right_outlined),
|
padding: const EdgeInsets.all(12.0),
|
||||||
onPressed: controller.nextImage,
|
child: IconButton(
|
||||||
),
|
style: iconButtonStyle,
|
||||||
|
tooltip: L10n.of(context).previous,
|
||||||
|
icon: const Icon(Icons.arrow_upward_outlined),
|
||||||
|
onPressed: controller.prevImage,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (controller.canGoNext)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(12.0),
|
||||||
|
child: IconButton(
|
||||||
|
style: iconButtonStyle,
|
||||||
|
tooltip: L10n.of(context).next,
|
||||||
|
icon: const Icon(Icons.arrow_downward_outlined),
|
||||||
|
onPressed: controller.nextImage,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,10 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
|
||||||
|
|
||||||
await videoPlayerController.initialize();
|
await videoPlayerController.initialize();
|
||||||
|
|
||||||
|
final infoMap = widget.event.content.tryGetMap<String, Object?>('info');
|
||||||
|
final videoWidth = infoMap?.tryGet<int>('w') ?? 400;
|
||||||
|
final videoHeight = infoMap?.tryGet<int>('h') ?? 300;
|
||||||
|
|
||||||
// Create a ChewieController on top.
|
// Create a ChewieController on top.
|
||||||
setState(() {
|
setState(() {
|
||||||
_chewieController = ChewieController(
|
_chewieController = ChewieController(
|
||||||
|
|
@ -77,6 +81,7 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
|
||||||
autoPlay: true,
|
autoPlay: true,
|
||||||
autoInitialize: true,
|
autoInitialize: true,
|
||||||
looping: true,
|
looping: true,
|
||||||
|
aspectRatio: videoHeight == 0 ? null : videoWidth / videoHeight,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} on IOException catch (e) {
|
} on IOException catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue