Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix torchlight button #148

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions lib/pages/scan/scan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -118,24 +119,16 @@ class _MainPageState extends State<MainPage> {
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());
},
)
],
)
],
);
Expand Down
24 changes: 24 additions & 0 deletions lib/pages/scan/torch_button.dart
Original file line number Diff line number Diff line change
@@ -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(),
),
);
}
}