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: lifecycle refactoring #995

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
66a4f82
Merge pull request #20 from openfoodfacts/develop
monsieurtanuki Jan 3, 2022
a6ed5fe
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 3, 2022
f1eb63f
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 3, 2022
dd4338a
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 4, 2022
1811829
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 4, 2022
8b14423
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 4, 2022
52b8ae3
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 5, 2022
96bb3f1
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 6, 2022
7840c45
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 6, 2022
241785b
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 6, 2022
edd46be
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 7, 2022
7e6f576
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 8, 2022
32c1433
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 9, 2022
6cc8541
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 10, 2022
d680373
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 10, 2022
c0ea17d
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 13, 2022
b257696
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 13, 2022
2555a12
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 13, 2022
077a938
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 14, 2022
c264e7f
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 14, 2022
f568686
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 17, 2022
07af801
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 18, 2022
f73efb3
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 19, 2022
d141a78
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 20, 2022
791e510
Merge branch 'openfoodfacts:develop' into develop
monsieurtanuki Jan 22, 2022
4b0d54b
fix: lifecycle refactoring
monsieurtanuki Jan 22, 2022
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
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ scan:
- packages/smooth_app/lib/pages/scan/continuous_scan_page.dart
- packages/smooth_app/lib/pages/scan/scan_page.dart
- packages/smooth_app/lib/pages/scan/scanner_overlay.dart
- packages/smooth_app/lib/pages/scan/scanner_state_manager.dart
- packages/smooth_app/lib/pages/scan/lifecycle_manager.dart

mlkit:
- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/scan/continuous_scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:smooth_app/data_models/continuous_scan_model.dart';
import 'package:smooth_app/pages/scan/scanner_state_manager.dart';
import 'package:smooth_app/pages/scan/lifecycle_manager.dart';

class ContinuousScanPage extends StatefulWidget {
const ContinuousScanPage();
Expand All @@ -27,7 +27,7 @@ class _ContinuousScanPageState extends State<ContinuousScanPage> {

return LifeCycleManager(
onResume: _resumeLiveFeed,
onStop: _stopLiveFeed,
onPause: _stopLiveFeed,
child: QRView(
overlay: QrScannerOverlayShape(
// We use [SmoothViewFinder] instead of the overlay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:visibility_detector/visibility_detector.dart';
class LifeCycleManager extends StatefulWidget {
const LifeCycleManager({
required this.onResume,
required this.onStop,
required this.onPause,
required this.child,
Key? key,
}) : super(key: key);

final Function() onResume;
final Function() onStop;
final Function() onPause;
final Widget child;

@override
Expand Down Expand Up @@ -41,7 +41,7 @@ class LifeCycleManagerState extends State<LifeCycleManager>
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.inactive) {
widget.onStop.call();
widget.onPause.call();
} else if (state == AppLifecycleState.resumed) {
widget.onResume.call();
}
Expand All @@ -53,7 +53,7 @@ class LifeCycleManagerState extends State<LifeCycleManager>
key: const ValueKey<String>('VisibilityDetector'),
onVisibilityChanged: (VisibilityInfo info) {
if (info.visibleFraction == 0.0) {
widget.onStop.call();
widget.onPause.call();
} else {
widget.onResume.call();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:google_ml_barcode_scanner/google_ml_barcode_scanner.dart';
import 'package:provider/provider.dart';
import 'package:smooth_app/data_models/continuous_scan_model.dart';
import 'package:smooth_app/main.dart';
import 'package:smooth_app/pages/scan/scanner_state_manager.dart';
import 'package:smooth_app/pages/scan/lifecycle_manager.dart';

class MLKitScannerPage extends StatefulWidget {
const MLKitScannerPage({Key? key}) : super(key: key);
Expand Down Expand Up @@ -71,7 +71,7 @@ class MLKitScannerPageState extends State<MLKitScannerPage> {

return LifeCycleManager(
onResume: _startLiveFeed,
onStop: _stopImageStream,
onPause: _stopImageStream,
child: _buildScannerWidget(),
);
}
Expand Down