Skip to content

Commit

Permalink
fix: hide "Play video" button for unsupported platforms (#235)
Browse files Browse the repository at this point in the history
Changed to hide the "Play video" button in `PostFormAttaches` if
`video_player` is not supported for the platform.
  • Loading branch information
poppingmoon authored Jun 22, 2024
1 parent 7e5534b commit 703134f
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions lib/view/widget/post_form_attaches.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -208,23 +208,27 @@ class PostFormAttaches extends ConsumerWidget {
),
),
if (files[index].type?.startsWith('video/') ?? false)
ListTile(
leading: const Icon(Icons.play_arrow),
title: Text(t.aria.playVideo),
onTap: () => showDialog<void>(
context: context,
builder: (context) => VideoDialog(
url: switch (files[index]) {
DrivePostFile(:final file) => file.url,
_ => null,
},
file: switch (files[index]) {
LocalPostFile(:final file) => file,
_ => null,
},
if (defaultTargetPlatform
case TargetPlatform.android ||
TargetPlatform.iOS ||
TargetPlatform.macOS)
ListTile(
leading: const Icon(Icons.play_arrow),
title: Text(t.aria.playVideo),
onTap: () => showDialog<void>(
context: context,
builder: (context) => VideoDialog(
url: switch (files[index]) {
DrivePostFile(:final file) => file.url,
_ => null,
},
file: switch (files[index]) {
LocalPostFile(:final file) => file,
_ => null,
},
),
),
),
),
if (files[index].type?.startsWith('audio/') ?? false)
if (files[index] case DrivePostFile(:final file))
ListTile(
Expand Down

0 comments on commit 703134f

Please sign in to comment.