Browse Source

Merge branch 'master' into collaboration_view

Neeraj Gupta 2 years ago
parent
commit
6e904a4d46

+ 3 - 0
.gitignore

@@ -15,6 +15,9 @@
 *.iws
 .idea/
 
+#Visual Studio Code related
+.vscode/settings.json
+
 # The .vscode folder contains launch configuration and tasks you configure in
 # VS Code which you may wish to be included in version control, so this line
 # is commented out by default.

+ 0 - 7
.vscode/settings.json

@@ -1,7 +0,0 @@
-{
-    "workbench.colorCustomizations": {
-        "activityBar.background": "#123046",
-        "titleBar.activeBackground": "#194363",
-        "titleBar.activeForeground": "#F9FBFD"
-    }
-}

+ 1 - 1
lib/db/device_files_db.dart

@@ -392,7 +392,7 @@ extension DeviceFiles on FilesDB {
     final db = await database;
     final fileRows = await db.rawQuery(
       '''SELECT * FROM FILES  f JOIN device_files df on f.local_id = df.id 
-      and df.path_id= ? order by f.modification_time DESC limit 1;
+      and df.path_id= ? order by f.creation_time DESC limit 1;
           ''',
       [pathID],
     );

+ 2 - 2
lib/services/sync_service.dart

@@ -93,7 +93,7 @@ class SyncService {
     } on WiFiUnavailableError {
       _logger.warning("Not uploading over mobile data");
       Bus.instance.fire(
-        SyncStatusUpdate(SyncStatus.paused, reason: "waiting for WiFi..."),
+        SyncStatusUpdate(SyncStatus.paused, reason: "Waiting for WiFi..."),
       );
     } on SyncStopRequestedError {
       _syncStopRequested = false;
@@ -127,7 +127,7 @@ class SyncService {
           Bus.instance.fire(
             SyncStatusUpdate(
               SyncStatus.paused,
-              reason: "waiting for network...",
+              reason: "Waiting for network...",
             ),
           );
           _logger.severe("unable to connect", e, StackTrace.current);

+ 2 - 1
lib/ui/collections/collection_item_widget.dart

@@ -30,7 +30,7 @@ class CollectionItem extends StatelessWidget {
           Stack(
             children: [
               ClipRRect(
-                borderRadius: BorderRadius.circular(4),
+                borderRadius: BorderRadius.circular(1),
                 child: SizedBox(
                   height: sideOfThumbnail,
                   width: sideOfThumbnail,
@@ -52,6 +52,7 @@ class CollectionItem extends StatelessWidget {
           Column(
             crossAxisAlignment: CrossAxisAlignment.start,
             children: [
+              const SizedBox(height: 2),
               Text(
                 c.collection.name ?? "Unnamed",
                 style: enteTextTheme.small,

+ 10 - 12
lib/ui/collections/device_folder_icon_widget.dart

@@ -1,6 +1,7 @@
 // @dart=2.9
 
 import 'package:flutter/material.dart';
+import 'package:photos/ente_theme_data.dart';
 import 'package:photos/models/device_collection.dart';
 import 'package:photos/ui/viewer/file/file_icons_widget.dart';
 import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
@@ -27,7 +28,7 @@ class DeviceFolderIcon extends StatelessWidget {
             crossAxisAlignment: CrossAxisAlignment.start,
             children: <Widget>[
               ClipRRect(
-                borderRadius: BorderRadius.circular(4),
+                borderRadius: BorderRadius.circular(1),
                 child: SizedBox(
                   height: 120,
                   width: 120,
@@ -52,17 +53,14 @@ class DeviceFolderIcon extends StatelessWidget {
                   ),
                 ),
               ),
-              Padding(
-                padding: const EdgeInsets.only(top: 10),
-                child: Text(
-                  deviceCollection.name,
-                  textAlign: TextAlign.left,
-                  style: Theme.of(context)
-                      .textTheme
-                      .subtitle1
-                      .copyWith(fontSize: 12),
-                  overflow: TextOverflow.ellipsis,
-                ),
+              const SizedBox(
+                height: 2,
+              ),
+              Text(
+                deviceCollection.name,
+                textAlign: TextAlign.left,
+                style: Theme.of(context).colorScheme.enteTheme.textTheme.small,
+                overflow: TextOverflow.ellipsis,
               ),
             ],
           ),

+ 1 - 1
lib/ui/collections/remote_collections_grid_view_widget.dart

@@ -56,7 +56,7 @@ class RemoteCollectionsGridViewWidget extends StatelessWidget {
         // To include the + button
         gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
           crossAxisCount: albumsCountInOneRow,
-          mainAxisSpacing: 6,
+          mainAxisSpacing: 14,
           crossAxisSpacing: gapBetweenAlbums,
           childAspectRatio: sideOfThumbnail / (sideOfThumbnail + 50),
         ), //24 is height of album title

+ 5 - 1
lib/ui/collections_gallery_widget.dart

@@ -102,7 +102,11 @@ class _CollectionsGalleryWidgetState extends State<CollectionsGalleryWidget>
         }
       },
     );
-    result.matched.removeWhere((element) => element.thumbnail == null);
+    result.matched.removeWhere(
+      (element) =>
+          element.thumbnail == null ||
+          (element.collection.publicURLs?.isNotEmpty ?? false),
+    );
     return result.matched + result.unmatched;
   }
 

+ 93 - 92
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -33,7 +33,6 @@ class LazyLoadingGallery extends StatefulWidget {
   final String tag;
   final String logTag;
   final Stream<int> currentIndexStream;
-  final bool smallerTodayFont;
 
   LazyLoadingGallery(
     this.files,
@@ -44,7 +43,6 @@ class LazyLoadingGallery extends StatefulWidget {
     this.selectedFiles,
     this.tag,
     this.currentIndexStream, {
-    this.smallerTodayFont,
     this.logTag = "",
     Key key,
   }) : super(key: key ?? UniqueKey());
@@ -64,8 +62,9 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
   StreamSubscription<FilesUpdatedEvent> _reloadEventSubscription;
   StreamSubscription<int> _currentIndexSubscription;
   bool _shouldRender;
-  final ValueNotifier<bool> _shouldSelectAll = ValueNotifier(false);
+  final ValueNotifier<bool> _toggleSelectAllFromDay = ValueNotifier(false);
   final ValueNotifier<bool> _showSelectAllButton = ValueNotifier(false);
+  final ValueNotifier<bool> _areAllFromDaySelected = ValueNotifier(false);
 
   @override
   void initState() {
@@ -163,6 +162,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
     _reloadEventSubscription.cancel();
     _currentIndexSubscription.cancel();
     widget.selectedFiles.removeListener(_selectedFilesListener);
+
     super.dispose();
   }
 
@@ -182,24 +182,28 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
     }
     return Column(
       children: [
-        Padding(
-          padding: const EdgeInsets.fromLTRB(4, 14, 12, 8),
-          child: Row(
-            mainAxisAlignment: MainAxisAlignment.spaceBetween,
-            children: [
-              getDayWidget(
+        Row(
+          mainAxisAlignment: MainAxisAlignment.spaceBetween,
+          children: [
+            Padding(
+              padding: const EdgeInsets.all(12),
+              child: getDayWidget(
                 context,
                 _files[0].creationTime,
-                widget.smallerTodayFont,
               ),
-              ValueListenableBuilder(
-                valueListenable: _showSelectAllButton,
-                builder: (context, value, _) {
-                  return widget.selectedFiles.files.isEmpty
-                      ? const SizedBox.shrink()
-                      : GestureDetector(
+            ),
+            ValueListenableBuilder(
+              valueListenable: _showSelectAllButton,
+              builder: (context, value, _) {
+                return !value
+                    ? const SizedBox.shrink()
+                    : GestureDetector(
+                        behavior: HitTestBehavior.translucent,
+                        child: SizedBox(
+                          width: 48,
+                          height: 44,
                           child: ValueListenableBuilder(
-                            valueListenable: _shouldSelectAll,
+                            valueListenable: _areAllFromDaySelected,
                             builder: (context, value, _) {
                               return value
                                   ? const Icon(
@@ -214,14 +218,17 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
                                     );
                             },
                           ),
-                          onTap: () {
-                            _shouldSelectAll.value = !_shouldSelectAll.value;
-                          },
-                        );
-                },
-              )
-            ],
-          ),
+                        ),
+                        onTap: () {
+                          //this value has no significance
+                          //changing only to notify the listeners
+                          _toggleSelectAllFromDay.value =
+                              !_toggleSelectAllFromDay.value;
+                        },
+                      );
+              },
+            )
+          ],
         ),
         _shouldRender ? _getGallery() : PlaceHolderWidget(_files.length),
       ],
@@ -242,7 +249,8 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
           widget.selectedFiles,
           index == 0,
           _files.length > kRecycleLimit,
-          _shouldSelectAll,
+          _toggleSelectAllFromDay,
+          _areAllFromDaySelected,
         ),
       );
     }
@@ -253,13 +261,6 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
   }
 
   void _selectedFilesListener() {
-    final filesOfGirdAsSet = widget.files.toSet();
-    //to disable the 'all selected' state of the icon when every file is
-    //unselected one by one after selecting all using the icon
-    if (!widget.selectedFiles.files
-        .any((element) => filesOfGirdAsSet.contains(element))) {
-      _shouldSelectAll.value = false;
-    }
     if (widget.selectedFiles.files.isEmpty) {
       _showSelectAllButton.value = false;
     } else {
@@ -270,21 +271,23 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
 
 class LazyLoadingGridView extends StatefulWidget {
   final String tag;
-  final List<File> files;
+  final List<File> filesInDay;
   final GalleryLoader asyncLoader;
   final SelectedFiles selectedFiles;
   final bool shouldRender;
   final bool shouldRecycle;
-  final ValueNotifier shouldSelectAll;
+  final ValueNotifier toggleSelectAllFromDay;
+  final ValueNotifier areAllFilesSelected;
 
   LazyLoadingGridView(
     this.tag,
-    this.files,
+    this.filesInDay,
     this.asyncLoader,
     this.selectedFiles,
     this.shouldRender,
     this.shouldRecycle,
-    this.shouldSelectAll, {
+    this.toggleSelectAllFromDay,
+    this.areAllFilesSelected, {
     Key key,
   }) : super(key: key ?? UniqueKey());
 
@@ -299,7 +302,6 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
   @override
   void initState() {
     _shouldRender = widget.shouldRender;
-    widget.shouldSelectAll.addListener(_shouldSelectAllListener);
     widget.selectedFiles.addListener(_selectedFilesListener);
     _clearSelectionsEvent =
         Bus.instance.on<ClearSelectionsEvent>().listen((event) {
@@ -307,21 +309,23 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
         setState(() {});
       }
     });
+    widget.toggleSelectAllFromDay.addListener(_toggleSelectAllFromDayListener);
     super.initState();
   }
 
   @override
   void dispose() {
     widget.selectedFiles.removeListener(_selectedFilesListener);
-    widget.shouldSelectAll.removeListener(_shouldSelectAllListener);
     _clearSelectionsEvent.cancel();
+    widget.toggleSelectAllFromDay
+        .removeListener(_toggleSelectAllFromDayListener);
     super.dispose();
   }
 
   @override
   void didUpdateWidget(LazyLoadingGridView oldWidget) {
     super.didUpdateWidget(oldWidget);
-    if (!listEquals(widget.files, oldWidget.files)) {
+    if (!listEquals(widget.filesInDay, oldWidget.filesInDay)) {
       _shouldRender = widget.shouldRender;
     }
   }
@@ -348,7 +352,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
       },
       child: _shouldRender
           ? _getGridView()
-          : PlaceHolderWidget(widget.files.length),
+          : PlaceHolderWidget(widget.filesInDay.length),
     );
   }
 
@@ -363,7 +367,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
             });
           }
         },
-        child: PlaceHolderWidget(widget.files.length),
+        child: PlaceHolderWidget(widget.filesInDay.length),
       );
     } else {
       return _getGridView();
@@ -376,10 +380,12 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
       physics:
           const NeverScrollableScrollPhysics(), // to disable GridView's scrolling
       itemBuilder: (context, index) {
-        return _buildFile(context, widget.files[index]);
+        return _buildFile(context, widget.filesInDay[index]);
       },
-      itemCount: widget.files.length,
+      itemCount: widget.filesInDay.length,
       gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
+        crossAxisSpacing: 2,
+        mainAxisSpacing: 2,
         crossAxisCount: 4,
       ),
       padding: const EdgeInsets.all(0),
@@ -399,47 +405,41 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
         HapticFeedback.lightImpact();
         _selectFile(file);
       },
-      child: Container(
-        margin: const EdgeInsets.all(1.5),
-        decoration: BoxDecoration(
-          borderRadius: BorderRadius.circular(3),
-        ),
-        child: ClipRRect(
-          borderRadius: BorderRadius.circular(3),
-          child: Stack(
-            children: [
-              Hero(
-                tag: widget.tag + file.tag,
-                child: ColorFiltered(
-                  colorFilter: ColorFilter.mode(
-                    Colors.black.withOpacity(
-                      widget.selectedFiles.isFileSelected(file) ? 0.4 : 0,
-                    ),
-                    BlendMode.darken,
-                  ),
-                  child: ThumbnailWidget(
-                    file,
-                    diskLoadDeferDuration: thumbnailDiskLoadDeferDuration,
-                    serverLoadDeferDuration: thumbnailServerLoadDeferDuration,
-                    shouldShowLivePhotoOverlay: true,
-                    key: Key(widget.tag + file.tag),
+      child: ClipRRect(
+        borderRadius: BorderRadius.circular(1),
+        child: Stack(
+          children: [
+            Hero(
+              tag: widget.tag + file.tag,
+              child: ColorFiltered(
+                colorFilter: ColorFilter.mode(
+                  Colors.black.withOpacity(
+                    widget.selectedFiles.isFileSelected(file) ? 0.4 : 0,
                   ),
+                  BlendMode.darken,
+                ),
+                child: ThumbnailWidget(
+                  file,
+                  diskLoadDeferDuration: thumbnailDiskLoadDeferDuration,
+                  serverLoadDeferDuration: thumbnailServerLoadDeferDuration,
+                  shouldShowLivePhotoOverlay: true,
+                  key: Key(widget.tag + file.tag),
                 ),
               ),
-              Visibility(
-                visible: widget.selectedFiles.isFileSelected(file),
-                child: const Positioned(
-                  right: 4,
-                  top: 4,
-                  child: Icon(
-                    Icons.check_circle_rounded,
-                    size: 20,
-                    color: Colors.white, //same for both themes
-                  ),
+            ),
+            Visibility(
+              visible: widget.selectedFiles.isFileSelected(file),
+              child: const Positioned(
+                right: 4,
+                top: 4,
+                child: Icon(
+                  Icons.check_circle_rounded,
+                  size: 20,
+                  color: Colors.white, //same for both themes
                 ),
-              )
-            ],
-          ),
+              ),
+            )
+          ],
         ),
       ),
     );
@@ -452,9 +452,9 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
   void _routeToDetailPage(File file, BuildContext context) {
     final page = DetailPage(
       DetailPageConfiguration(
-        List.unmodifiable(widget.files),
+        List.unmodifiable(widget.filesInDay),
         widget.asyncLoader,
-        widget.files.indexOf(file),
+        widget.filesInDay.indexOf(file),
         widget.tag,
       ),
     );
@@ -462,8 +462,13 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
   }
 
   void _selectedFilesListener() {
+    if (widget.selectedFiles.files.containsAll(widget.filesInDay.toSet())) {
+      widget.areAllFilesSelected.value = true;
+    } else {
+      widget.areAllFilesSelected.value = false;
+    }
     bool shouldRefresh = false;
-    for (final file in widget.files) {
+    for (final file in widget.filesInDay) {
       if (widget.selectedFiles.isPartOfLastSelected(file)) {
         shouldRefresh = true;
       }
@@ -473,17 +478,13 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
     }
   }
 
-  void _shouldSelectAllListener() {
-    if (widget.shouldSelectAll.value && mounted) {
+  void _toggleSelectAllFromDayListener() {
+    if (widget.selectedFiles.files.containsAll(widget.filesInDay.toSet())) {
       setState(() {
-        widget.selectedFiles.selectAll(widget.files.toSet());
+        widget.selectedFiles.unSelectAll(widget.filesInDay.toSet());
       });
     } else {
-      if (mounted) {
-        setState(() {
-          widget.selectedFiles.unSelectAll(widget.files.toSet());
-        });
-      }
+      widget.selectedFiles.selectAll(widget.filesInDay.toSet());
     }
   }
 }

+ 1 - 1
lib/ui/settings/storage_card_widget.dart

@@ -126,7 +126,7 @@ class _StorageCardWidgetState extends State<StorageCardWidget> {
     final totalStorageInBytes = userDetails.getTotalStorage();
     final freeStorageInBytes = totalStorageInBytes - usedStorageInBytes;
 
-    final isMobileScreenSmall = MediaQuery.of(context).size.width <= 360;
+    final isMobileScreenSmall = MediaQuery.of(context).size.width <= 336;
     final shouldShowFreeSpaceInMBs = freeStorageInBytes < hundredMBinBytes;
     final shouldShowFreeSpaceInTBs = freeStorageInBytes >= oneTBinBytes;
     final shouldShowUsedStorageInTBs = usedStorageInBytes >= oneTBinBytes;

+ 2 - 2
lib/ui/shared_collections_gallery.dart

@@ -288,7 +288,7 @@ class OutgoingCollectionItem extends StatelessWidget {
         child: Row(
           children: <Widget>[
             ClipRRect(
-              borderRadius: BorderRadius.circular(3),
+              borderRadius: BorderRadius.circular(1),
               child: SizedBox(
                 height: 60,
                 width: 60,
@@ -377,7 +377,7 @@ class IncomingCollectionItem extends StatelessWidget {
         crossAxisAlignment: CrossAxisAlignment.start,
         children: <Widget>[
           ClipRRect(
-            borderRadius: BorderRadius.circular(4),
+            borderRadius: BorderRadius.circular(1),
             child: SizedBox(
               height: sideOfThumbnail,
               width: sideOfThumbnail,

+ 0 - 1
lib/ui/viewer/gallery/collection_page.dart

@@ -66,7 +66,6 @@ class CollectionPage extends StatelessWidget {
       tagPrefix: tagPrefix,
       selectedFiles: _selectedFiles,
       initialFiles: initialFiles,
-      smallerTodayFont: true,
       albumName: c.collection.name,
     );
     return Scaffold(

+ 1 - 1
lib/ui/viewer/gallery/device_folder_page.dart

@@ -112,7 +112,7 @@ class _BackupConfigurationHeaderWidgetState
                         .withOpacity(0.7),
                   ),
                 ),
-          Switch(
+          Switch.adaptive(
             value: _isBackedUp,
             onChanged: (value) async {
               await RemoteSyncService.instance.updateDeviceFolderSyncStatus(

+ 0 - 3
lib/ui/viewer/gallery/gallery.dart

@@ -39,7 +39,6 @@ class Gallery extends StatefulWidget {
   final Widget header;
   final Widget footer;
   final Widget emptyState;
-  final bool smallerTodayFont;
   final String albumName;
   final double scrollBottomSafeArea;
 
@@ -55,7 +54,6 @@ class Gallery extends StatefulWidget {
     this.footer = const SizedBox(height: 120),
     this.emptyState = const EmptyState(),
     this.scrollBottomSafeArea = 120.0,
-    this.smallerTodayFont = false,
     this.albumName = '',
     Key key,
   }) : super(key: key);
@@ -247,7 +245,6 @@ class _GalleryState extends State<Gallery> {
               .on<GalleryIndexUpdatedEvent>()
               .where((event) => event.tag == widget.tagPrefix)
               .map((event) => event.index),
-          smallerTodayFont: widget.smallerTodayFont,
           logTag: _logTag,
         );
         if (widget.header != null && index == 0) {

+ 6 - 8
lib/utils/date_time_util.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:intl/intl.dart';
+import 'package:photos/theme/ente_theme.dart';
 
 const Set<int> monthWith31Days = {1, 3, 5, 7, 8, 10, 12};
 const Set<int> monthWith30Days = {4, 6, 9, 11};
@@ -194,19 +195,16 @@ bool isLeapYear(DateTime dateTime) {
 Widget getDayWidget(
   BuildContext context,
   int timestamp,
-  bool smallerTodayFont,
 ) {
+  final colorScheme = getEnteColorScheme(context);
+  final textTheme = getEnteTextTheme(context);
   return Container(
     alignment: Alignment.centerLeft,
     child: Text(
       getDayTitle(timestamp),
-      style: (getDayTitle(timestamp) == "Today" && !smallerTodayFont)
-          ? Theme.of(context).textTheme.headline5
-          : Theme.of(context).textTheme.caption?.copyWith(
-                fontSize: 16,
-                fontWeight: FontWeight.w600,
-                fontFamily: 'Inter-SemiBold',
-              ),
+      style: (getDayTitle(timestamp) == "Today")
+          ? textTheme.body
+          : textTheme.body.copyWith(color: colorScheme.textMuted),
     ),
   );
 }