fixed photo animation

This commit is contained in:
Myzel394 2022-08-16 10:57:33 +02:00
parent e884527d85
commit 171633c907
2 changed files with 21 additions and 43 deletions

View File

@ -192,6 +192,7 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
} finally { } finally {
setState(() { setState(() {
lockCamera = false; lockCamera = false;
uploadingPhotoAnimation = null;
}); });
} }
@ -257,39 +258,29 @@ class _MainScreenState extends AuthRequiredState<MainScreen> with Loadable {
color: Colors.black, color: Colors.black,
child: ExpandableBottomSheet( child: ExpandableBottomSheet(
background: SafeArea( background: SafeArea(
child: SizedBox( child: Align(
width: MediaQuery.of(context).size.width, alignment: Alignment.topCenter,
height: MediaQuery.of(context).size.height, child: AnimateInBuilder(
child: Stack( builder: (showPreview) => AnimatedOpacity(
alignment: Alignment.center, opacity: showPreview ? 1.0 : 0.0,
children: <Widget>[ duration: const Duration(milliseconds: 1100),
Align( curve: Curves.easeOutQuad,
alignment: Alignment.topCenter, child: ClipRRect(
child: AnimateInBuilder( borderRadius: BorderRadius.circular(SMALL_SPACE),
builder: (showPreview) => AnimatedOpacity( child: AspectRatio(
opacity: showPreview ? 1.0 : 0.0, aspectRatio: 1 / controller!.value.aspectRatio,
duration: const Duration(milliseconds: 1100), child: Stack(
curve: Curves.easeOutQuad, children: <Widget>[
child: ClipRRect( controller!.buildPreview(),
borderRadius: BorderRadius.circular(SMALL_SPACE), if (uploadingPhotoAnimation != null)
child: AspectRatio( UploadingPhoto(
aspectRatio: 1 / controller!.value.aspectRatio, data: uploadingPhotoAnimation!,
child: controller!.buildPreview(), ),
), ],
),
), ),
), ),
), ),
if (uploadingPhotoAnimation != null) ),
UploadingPhoto(
data: uploadingPhotoAnimation!,
onDone: () {
setState(() {
uploadingPhotoAnimation = null;
});
},
),
],
), ),
), ),
), ),

View File

@ -2,16 +2,13 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:share_location/constants/spacing.dart'; import 'package:share_location/constants/spacing.dart';
import 'package:share_location/constants/values.dart';
class UploadingPhoto extends StatefulWidget { class UploadingPhoto extends StatefulWidget {
final Uint8List data; final Uint8List data;
final VoidCallback onDone;
const UploadingPhoto({ const UploadingPhoto({
Key? key, Key? key,
required this.data, required this.data,
required this.onDone,
}) : super(key: key); }) : super(key: key);
@override @override
@ -38,16 +35,6 @@ class _UploadingPhotoState extends State<UploadingPhoto>
), ),
); );
controller.addStatusListener((status) {
if (status == AnimationStatus.completed) {
Future.delayed(PHOTO_SHOW_AFTER_CREATION_DURATION, () {
if (mounted) {
widget.onDone();
}
});
}
});
controller.forward(); controller.forward();
} }