Explorar o código

Merge pull request #356 from ente-io/largeMemories

Show memory counter for large number of memories
Manav %!s(int64=3) %!d(string=hai) anos
pai
achega
d3345b94e6
Modificáronse 1 ficheiros con 25 adicións e 13 borrados
  1. 25 13
      lib/ui/memories_widget.dart

+ 25 - 13
lib/ui/memories_widget.dart

@@ -207,6 +207,9 @@ class FullScreenMemory extends StatefulWidget {
 class _FullScreenMemoryState extends State<FullScreenMemory> {
 class _FullScreenMemoryState extends State<FullScreenMemory> {
   int _index = 0;
   int _index = 0;
   double _opacity = 1;
   double _opacity = 1;
+  // shows memory counter as index+1/totalFiles for large number of memories
+  // when the top step indicator isn't visible.
+  bool _showCounter = false;
   PageController _pageController;
   PageController _pageController;
   bool _shouldDisableScroll = false;
   bool _shouldDisableScroll = false;
   final GlobalKey shareButtonKey = GlobalKey();
   final GlobalKey shareButtonKey = GlobalKey();
@@ -219,6 +222,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
       if (mounted) {
       if (mounted) {
         setState(() {
         setState(() {
           _opacity = 0;
           _opacity = 0;
+          _showCounter = widget.memories.length > 60;
         });
         });
       }
       }
     });
     });
@@ -297,7 +301,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
           children: [
           children: [
             _buildSwiper(),
             _buildSwiper(),
             bottomGradient(),
             bottomGradient(),
-            _buildTitleText(),
+            _buildInfoText(),
             _buildBottomIcons(),
             _buildBottomIcons(),
           ],
           ],
         ),
         ),
@@ -305,23 +309,31 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
     );
     );
   }
   }
 
 
-  Hero _buildTitleText() {
+  Hero _buildInfoText() {
     return Hero(
     return Hero(
       tag: widget.title,
       tag: widget.title,
       child: Container(
       child: Container(
         alignment: Alignment.bottomCenter,
         alignment: Alignment.bottomCenter,
         padding: EdgeInsets.fromLTRB(0, 0, 0, 28),
         padding: EdgeInsets.fromLTRB(0, 0, 0, 28),
-        child: AnimatedOpacity(
-          opacity: _opacity,
-          duration: Duration(milliseconds: 500),
-          child: Text(
-            widget.title,
-            style: Theme.of(context)
-                .textTheme
-                .headline4
-                .copyWith(color: Colors.white),
-          ),
-        ),
+        child: _showCounter
+            ? Text(
+                '${_index + 1}/${widget.memories.length}',
+                style: Theme.of(context)
+                    .textTheme
+                    .bodyText1
+                    .copyWith(color: Colors.white.withOpacity(0.4)),
+              )
+            : AnimatedOpacity(
+                opacity: _opacity,
+                duration: Duration(milliseconds: 500),
+                child: Text(
+                  widget.title,
+                  style: Theme.of(context)
+                      .textTheme
+                      .headline4
+                      .copyWith(color: Colors.white),
+                ),
+              ),
       ),
       ),
     );
     );
   }
   }