diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index 8b66ed0..bb44f49 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -308,6 +308,7 @@ class _MainScreenState extends AuthRequiredState with Loadable { opacityDuration: DEFAULT_OPACITY_DURATION * SECONDARY_BUTTONS_DURATION_MULTIPLIER, child: ChangeCameraButton( + disabled: lockCamera, onChangeCamera: () { final currentCameraIndex = GlobalValuesManager .cameras @@ -348,12 +349,18 @@ class _MainScreenState extends AuthRequiredState with Loadable { SECONDARY_BUTTONS_DURATION_MULTIPLIER, opacityDuration: DEFAULT_OPACITY_DURATION * SECONDARY_BUTTONS_DURATION_MULTIPLIER, - child: lastPhoto == null - ? const TodayPhotoButton() - : TodayPhotoButton( - data: lastPhoto![0], - type: lastPhoto![1], - ), + child: TodayPhotoButton( + data: lastPhoto == null ? null : lastPhoto![0], + type: lastPhoto == null ? null : lastPhoto![1], + onLeave: () { + controller!.setFlashMode(FlashMode.off); + }, + onComeBack: () { + if (isTorchEnabled) { + controller!.setFlashMode(FlashMode.torch); + } + }, + ), ), ], ), @@ -362,7 +369,11 @@ class _MainScreenState extends AuthRequiredState with Loadable { ), ), expandableContent: Padding( - padding: const EdgeInsets.all(LARGE_SPACE), + padding: const EdgeInsets.only( + left: LARGE_SPACE, + right: LARGE_SPACE, + bottom: MEDIUM_SPACE, + ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -403,8 +414,7 @@ class _MainScreenState extends AuthRequiredState with Loadable { : () { final newZoomLevelIndex = ((currentZoomLevelIndex + 1) % - zoomLevels!.length) - .toInt(); + zoomLevels!.length); controller! .setZoomLevel(zoomLevels![newZoomLevelIndex]); diff --git a/lib/widgets/change_camera_button.dart b/lib/widgets/change_camera_button.dart index 7beeaf1..f2513b0 100644 --- a/lib/widgets/change_camera_button.dart +++ b/lib/widgets/change_camera_button.dart @@ -3,10 +3,12 @@ import 'package:flutter/services.dart'; class ChangeCameraButton extends StatelessWidget { final VoidCallback onChangeCamera; + final bool disabled; const ChangeCameraButton({ Key? key, required this.onChangeCamera, + this.disabled = false, }) : super(key: key); @override @@ -15,23 +17,30 @@ class ChangeCameraButton extends StatelessWidget { enableFeedback: false, highlightColor: Colors.transparent, onTap: () { + if (disabled) { + return; + } + HapticFeedback.heavyImpact(); onChangeCamera(); }, - child: Stack( - alignment: Alignment.center, - children: [ - Icon( - Icons.circle, - size: 60, - color: Colors.white.withOpacity(.2), - ), - Icon( - Icons.camera_alt, - size: 30, - color: Colors.white, - ), - ], + child: Opacity( + opacity: disabled ? 0.5 : 1.0, + child: Stack( + alignment: Alignment.center, + children: [ + Icon( + Icons.circle, + size: 60, + color: Colors.white.withOpacity(.2), + ), + const Icon( + Icons.camera_alt, + size: 30, + color: Colors.white, + ), + ], + ), ), ); } diff --git a/lib/widgets/today_photo_button.dart b/lib/widgets/today_photo_button.dart index 3b1fa59..2da88e1 100644 --- a/lib/widgets/today_photo_button.dart +++ b/lib/widgets/today_photo_button.dart @@ -10,9 +10,13 @@ import 'raw_memory_display.dart'; class TodayPhotoButton extends StatelessWidget { final Uint8List? data; final MemoryType? type; + final VoidCallback onLeave; + final VoidCallback onComeBack; const TodayPhotoButton({ Key? key, + required this.onLeave, + required this.onComeBack, this.data, this.type, }) : super(key: key); @@ -20,8 +24,12 @@ class TodayPhotoButton extends StatelessWidget { @override Widget build(BuildContext context) { return InkWell( - onTap: () { - Navigator.pushNamed(context, TimelineScreen.ID); + onTap: () async { + onLeave(); + + await Navigator.pushNamed(context, TimelineScreen.ID); + + onComeBack(); }, child: Container( width: 45,