-
Notifications
You must be signed in to change notification settings - Fork 848
fix: handle dust and gas sensor interactions #3143
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
Changes from 1 commit
00a788f
d775b51
7b09993
2897f00
e7b6035
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:pslab/l10n/app_localizations.dart'; | ||
| import 'package:pslab/providers/locator.dart'; | ||
| import 'package:pslab/view/widgets/common_scaffold_widget.dart'; | ||
|
|
||
| class DustSensorScreen extends StatefulWidget { | ||
| const DustSensorScreen({super.key}); | ||
|
|
||
| @override | ||
| State<DustSensorScreen> createState() => _DustSensorScreenState(); | ||
| } | ||
|
|
||
| class _DustSensorScreenState extends State<DustSensorScreen> { | ||
| AppLocalizations appLocalizations = getIt.get<AppLocalizations>(); | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| _setPortraitOrientation(); | ||
| SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||
| } | ||
|
|
||
| @override | ||
| void didChangeDependencies() { | ||
| _setPortraitOrientation(); | ||
| SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||
| super.didChangeDependencies(); | ||
| } | ||
|
|
||
| void _setPortraitOrientation() { | ||
| SystemChrome.setPreferredOrientations([ | ||
| DeviceOrientation.portraitUp, | ||
| DeviceOrientation.portraitDown, | ||
| ]); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return CommonScaffold( | ||
| title: appLocalizations.dustSensor, | ||
| body: Center( | ||
| child: Padding( | ||
| padding: const EdgeInsets.all(24.0), | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
|
||
| children: [ | ||
| Icon( | ||
| Icons.blur_on, | ||
| size: 120, | ||
| color: Colors.grey.shade400, | ||
| ), | ||
| const SizedBox(height: 32), | ||
| Text( | ||
| appLocalizations.dustSensor, | ||
| style: Theme.of(context).textTheme.headlineSmall?.copyWith( | ||
| fontWeight: FontWeight.bold, | ||
| color: Colors.black87, | ||
| ), | ||
| ), | ||
| const SizedBox(height: 16), | ||
| Text( | ||
| appLocalizations.screenNotImplemented, | ||
| textAlign: TextAlign.center, | ||
| style: Theme.of(context).textTheme.bodyLarge?.copyWith( | ||
| color: Colors.grey.shade600, | ||
| ), | ||
| ), | ||
| const SizedBox(height: 24), | ||
| Container( | ||
| padding: const EdgeInsets.all(16), | ||
| decoration: BoxDecoration( | ||
| color: Colors.orange.shade50, | ||
| borderRadius: BorderRadius.circular(8), | ||
| border: Border.all(color: Colors.orange.shade200), | ||
| ), | ||
| child: Column( | ||
| children: [ | ||
| Icon( | ||
| Icons.info_outline, | ||
| color: Colors.orange.shade700, | ||
| size: 32, | ||
| ), | ||
| const SizedBox(height: 8), | ||
| Text( | ||
| appLocalizations.dustSensorDesc, | ||
| textAlign: TextAlign.center, | ||
| style: TextStyle( | ||
| color: Colors.orange.shade900, | ||
| fontSize: 14, | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| const SizedBox(height: 32), | ||
| ElevatedButton.icon( | ||
| onPressed: () { | ||
| Navigator.pop(context); | ||
| }, | ||
| icon: const Icon(Icons.arrow_back), | ||
| label: Text(appLocalizations.back), | ||
| style: ElevatedButton.styleFrom( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: 24, | ||
| vertical: 12, | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,116 @@ | ||||||||||||||
| import 'package:flutter/material.dart'; | ||||||||||||||
| import 'package:flutter/services.dart'; | ||||||||||||||
| import 'package:pslab/l10n/app_localizations.dart'; | ||||||||||||||
| import 'package:pslab/providers/locator.dart'; | ||||||||||||||
| import 'package:pslab/view/widgets/common_scaffold_widget.dart'; | ||||||||||||||
|
|
||||||||||||||
| class GasSensorScreen extends StatefulWidget { | ||||||||||||||
| const GasSensorScreen({super.key}); | ||||||||||||||
|
|
||||||||||||||
| @override | ||||||||||||||
| State<GasSensorScreen> createState() => _GasSensorScreenState(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| class _GasSensorScreenState extends State<GasSensorScreen> { | ||||||||||||||
| AppLocalizations appLocalizations = getIt.get<AppLocalizations>(); | ||||||||||||||
|
|
||||||||||||||
| @override | ||||||||||||||
| void initState() { | ||||||||||||||
| super.initState(); | ||||||||||||||
| _setPortraitOrientation(); | ||||||||||||||
| SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| @override | ||||||||||||||
| void didChangeDependencies() { | ||||||||||||||
| _setPortraitOrientation(); | ||||||||||||||
| SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | ||||||||||||||
| super.didChangeDependencies(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| @override | |
| void didChangeDependencies() { | |
| _setPortraitOrientation(); | |
| SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); | |
| super.didChangeDependencies(); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_setPortraitOrientation()andSystemChrome.setEnabledSystemUIMode(...)are invoked in bothinitStateanddidChangeDependencies, which is redundant and makes lifecycle behavior harder to reason about. Consider keeping this logic in a single lifecycle method (typicallyinitStateor a post-frame callback) unless there is a specific dependency-change scenario you need to handle.