diff --git a/lib/pages/scan/scan.dart b/lib/pages/scan/scan.dart index 76f4312..1546eb7 100644 --- a/lib/pages/scan/scan.dart +++ b/lib/pages/scan/scan.dart @@ -12,6 +12,7 @@ import 'package:pola_flutter/pages/scan/scan_search_button.dart'; import 'package:pola_flutter/pages/scan/scan_state.dart'; import 'package:pola_flutter/i18n/strings.g.dart'; import 'package:pola_flutter/pages/scan/scan_vibration.dart'; +import 'package:pola_flutter/pages/scan/torch_button.dart'; import 'package:pola_flutter/pages/scan/torch_controller.dart'; import 'package:pola_flutter/theme/assets.gen.dart'; import 'package:pola_flutter/theme/colors.dart'; @@ -118,24 +119,16 @@ class _MainPageState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Expanded( - child: CompaniesList(state, listScrollController), - ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: GestureDetector( - onTap: () { - _scanBloc.add(ScanEvent.torchSwitched()); - cameraController.toggleTorch(); - }, - child: Container( - decoration: BoxDecoration( - boxShadow: [], - ), - child: state.isTorchOn - ? Assets.scan.flashlightOn.svg() - : Assets.scan.flashlightOff.svg(), - ), - ), + child: CompaniesList(state, listScrollController)), + Column( + children: [ + TorchButton( + isTorchOn: state.isTorchOn, + onTap: () { + _scanBloc.add(ScanEvent.torchSwitched()); + }, + ) + ], ) ], ); diff --git a/lib/pages/scan/torch_button.dart b/lib/pages/scan/torch_button.dart new file mode 100644 index 0000000..6b98832 --- /dev/null +++ b/lib/pages/scan/torch_button.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:pola_flutter/theme/assets.gen.dart'; + +class TorchButton extends StatelessWidget { + final bool isTorchOn; + final VoidCallback onTap; + + TorchButton({required this.isTorchOn, required this.onTap}); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + decoration: BoxDecoration( + boxShadow: [], + ), + child: isTorchOn + ? Assets.scan.flashlightOn.svg() + : Assets.scan.flashlightOff.svg(), + ), + ); + } +}