Explorar el Código

Refactoring step 1: Remove use of variable to check if swiping has happened after opening a photo

ashilkn hace 1 año
padre
commit
fe7570e83e
Se han modificado 2 ficheros con 2 adiciones y 5 borrados
  1. 1 4
      lib/ui/viewer/file/detail_page.dart
  2. 1 1
      lib/ui/viewer/file/file_widget.dart

+ 1 - 4
lib/ui/viewer/file/detail_page.dart

@@ -72,7 +72,6 @@ class _DetailPageState extends State<DetailPage> {
   List<File>? _files;
   late PageController _pageController;
   int _selectedIndex = 0;
-  bool _hasPageChanged = false;
   bool _hasLoadedTillStart = false;
   bool _hasLoadedTillEnd = false;
   final _enableFullScreenNotifier = ValueNotifier(false);
@@ -152,7 +151,6 @@ class _DetailPageState extends State<DetailPage> {
           },
           child: FileWidget(
             file,
-            autoPlay: !_hasPageChanged,
             tagPrefix: widget.config.tagPrefix,
             shouldDisableScroll: (value) {
               if (_shouldDisableScroll != value) {
@@ -178,10 +176,9 @@ class _DetailPageState extends State<DetailPage> {
       onPageChanged: (index) {
         setState(() {
           _selectedIndex = index;
-          _hasPageChanged = true;
         });
         _preloadEntries();
-        _preloadFiles(index);
+        // _preloadFiles(index);
       },
       physics: _shouldDisableScroll
           ? const NeverScrollableScrollPhysics()

+ 1 - 1
lib/ui/viewer/file/file_widget.dart

@@ -36,7 +36,7 @@ class FileWidget extends StatelessWidget {
     } else if (file.fileType == FileType.video) {
       return VideoWidget(
         file,
-        autoPlay: autoPlay, // Autoplay if it was opened directly
+        autoPlay: autoPlay ?? false, // Autoplay if it was opened directly
         tagPrefix: tagPrefix,
         playbackCallback: playbackCallback,
       );