diff --git a/lib/pages/scan/scan.dart b/lib/pages/scan/scan.dart index 3f74821..e108020 100644 --- a/lib/pages/scan/scan.dart +++ b/lib/pages/scan/scan.dart @@ -11,6 +11,7 @@ import 'package:pola_flutter/pages/scan/scan_event.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'; @@ -125,18 +126,11 @@ class _MainPageState extends State { child: CompaniesList(state, listScrollController)), Column( children: [ - GestureDetector( + TorchButton( + isTorchOn: state.isTorchOn, onTap: () { _scanBloc.add(ScanEvent.torchSwitched()); }, - child: Container( - decoration: BoxDecoration( - boxShadow: [], - ), - child: state.isTorchOn - ? Assets.scan.flashlightOn.svg() - : Assets.scan.flashlightOff.svg(), - ), ) ], ) diff --git a/lib/pages/scan/torch_button.dart b/lib/pages/scan/torch_button.dart new file mode 100644 index 0000000..bf088fa --- /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(), + ), + ); + } +}