浏览代码

add animated_swither

lucky1213 4 年前
父节点
当前提交
4f6dffe8e8
共有 1 个文件被更改,包括 33 次插入4 次删除
  1. 33
    4
      lib/src/ui/page/photo_main_page.dart

+ 33
- 4
lib/src/ui/page/photo_main_page.dart 查看文件

@@ -99,6 +99,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
99 99
   void _closeGallerySelectDialog() {
100 100
     overlayEntry.remove();
101 101
     overlayEntry = null;
102
+    setState(() {});
102 103
   }
103 104
 
104 105
   void _showGallerySelectDialog() {
@@ -147,6 +148,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
147 148
       );
148 149
     });
149 150
     Overlay.of(context).insert(overlayEntry);
151
+    setState(() {});
150 152
   }
151 153
 
152 154
   @override
@@ -170,10 +172,37 @@ class _PhotoMainPageState extends State<PhotoMainPage>
170 172
               alignment: Alignment.center,
171 173
               height: 44.0,
172 174
               padding: EdgeInsets.zero.copyWith(right: kToolbarHeight),
173
-              child: Text(currentGalleryName, style: options.theme.textStyle.apply(
174
-                fontSizeDelta: 2.0,
175
-                fontWeightDelta: 1,
176
-              ),),
175
+              child: Row(
176
+                mainAxisAlignment: MainAxisAlignment.center,
177
+                children: [
178
+                  Text(currentGalleryName, style: options.theme.textStyle.apply(
179
+                    fontSizeDelta: 2.0,
180
+                    fontWeightDelta: 1,
181
+                  ),),
182
+                  Container(
183
+                    width: 18,
184
+                    height: 18,
185
+                    margin: EdgeInsets.only(left: 8),
186
+                    decoration: ShapeDecoration(shape: CircleBorder(
187
+                      side: BorderSide(
188
+                        color: options.theme.onSurfaceColor,
189
+                        width: 1.5
190
+                      ),
191
+                    )),
192
+                    child: AnimatedSwitcher(
193
+                      transitionBuilder: (child, animation){
194
+                        final Tween<double> tween = overlayEntry != null ? Tween(begin: -0.25, end: 0.25) : Tween(begin: 0.25, end: 0.75);
195
+                        //var tween = Tween(begin: -0.5, end: 0.0);
196
+                        return RotationTransition(child: child, turns: tween.animate(animation));
197
+                      },
198
+                      duration: Duration(milliseconds: 200),
199
+                      reverseDuration: Duration(milliseconds: 0),
200
+                      child: Icon(Icons.chevron_left, key: ValueKey(overlayEntry == null ? 0 : 1),  size: 14, color: options.theme.onSurfaceColor),
201
+                    ),
202
+                  ),
203
+                ],
204
+              )
205
+              
177 206
             ),
178 207
           ),
179 208
         ),