From 326d05057fb451ea6062b7f71df3be06a6c00403 Mon Sep 17 00:00:00 2001 From: Ahmadreza Zibaei Date: Fri, 12 Oct 2018 13:39:51 +0330 Subject: [PATCH] update capture page , model is now a global variable --- .../org.eclipse.buildship.core.prefs | 1 + lib/pages/capture.dart | 72 +++++-------------- 2 files changed, 20 insertions(+), 53 deletions(-) create mode 100644 android/.settings/org.eclipse.buildship.core.prefs diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b3c7fde --- /dev/null +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1 @@ +eclipse.preferences.version=1 diff --git a/lib/pages/capture.dart b/lib/pages/capture.dart index 0581449..ede4a82 100644 --- a/lib/pages/capture.dart +++ b/lib/pages/capture.dart @@ -34,13 +34,11 @@ class Choice { enum Options { video, videoRecording, photo, audio, audioRecording } -class _CaptureRoute extends State with TickerProviderStateMixin { +class _CaptureRoute extends State { final GlobalKey _scaffoldKey = GlobalKey(); - AnimationController _animationController; - Animation _animation; - CameraController controller; + CaptureModel model; var _state = Options.photo; bool _initializing = false; @@ -66,18 +64,6 @@ class _CaptureRoute extends State with TickerProviderStateMixin { @override void initState() { - _animationController = AnimationController( - vsync: this, - duration: Duration(seconds: 5), - ); - - _animation = Tween(begin: 0.0, end: 500.0).animate( - CurvedAnimation( - parent: _animationController, - curve: Curves.fastOutSlowIn, - ), - ); - _prepare(); super.initState(); } @@ -93,11 +79,10 @@ class _CaptureRoute extends State with TickerProviderStateMixin { _loading = false; }); if (filePath != null) { - CaptureModel audio = CaptureModel( + model = CaptureModel( filePath: filePath, seriesUUID: uuid, captureMode: CaptureMode.audio); - CaptureModel.updateItem(audio); } } }); @@ -106,6 +91,7 @@ class _CaptureRoute extends State with TickerProviderStateMixin { void onAudioStopButtonPressed() { stopAudioRecording().then((_) { _state = Options.audio; + CaptureModel.updateItem(model); if (mounted) setState(() {}); }); } @@ -135,42 +121,35 @@ class _CaptureRoute extends State with TickerProviderStateMixin { } void onTakePictureButtonPressed() { - setState(() { - _loading = true; - }); + _loading = true; takePicture().then((String filePath) { if (mounted) { - setState(() { - _loading = false; - }); + _loading = false; if (filePath != null) { - CaptureModel image = CaptureModel( + model = CaptureModel( filePath: filePath, seriesUUID: uuid, captureMode: CaptureMode.picture); - CaptureModel.updateItem(image); + CaptureModel.updateItem(model); } + setState(() {}); } }); } void onVideoRecordButtonPressed() { - setState(() { - _loading = true; - }); + _loading = true; startVideoRecording().then((String filePath) { - _state = Options.videoRecording; if (mounted) { - setState(() { - _loading = false; - }); + _state = Options.videoRecording; + _loading = false; if (filePath != null) { - CaptureModel video = CaptureModel( + model = CaptureModel( filePath: filePath, seriesUUID: uuid, captureMode: CaptureMode.video); - CaptureModel.updateItem(video); } + setState(() {}); } }); } @@ -178,6 +157,7 @@ class _CaptureRoute extends State with TickerProviderStateMixin { void onVideoStopButtonPressed() { stopVideoRecording().then((_) { _state = Options.video; + CaptureModel.updateItem(model); if (mounted) setState(() {}); }); } @@ -327,7 +307,6 @@ class _CaptureRoute extends State with TickerProviderStateMixin { if (_state == Options.photo) { onTakePictureButtonPressed(); } else if (_state == Options.video) { - _animationController.repeat(); onVideoRecordButtonPressed(); } else if (_state == Options.videoRecording) { onVideoStopButtonPressed(); @@ -368,23 +347,10 @@ class _CaptureRoute extends State with TickerProviderStateMixin { ); } if (_state == Options.audioRecording || _state == Options.videoRecording) { - return AnimatedBuilder( - animation: _animationController, - builder: (BuildContext context, Widget child) { - int value = (_animation.value as double).toInt(); - if (value > 250) { - value = 500 - value; - } - double size = value / 5.0; - if (size < 30.0) { - size = 30.0; - } - return Icon( - Icons.stop, - size: size, - color: Colors.black.withRed(value), - ); - }, + return Icon( + Icons.stop, + size: 50.0, + color: Colors.black.withRed(50), ); } return Icon(Icons.archive);