Skip to content

Commit 355baca

Browse files
committed
refactor(settings/status/tools): unify app-bar status widget and standardize nav icons
- Replace per-screen custom app-bar controls with a single SystemStatusWidget in Settings, Status and Tools screens. - Use WiFiProvider.disconnect() (with mounted check) for the disconnect flow instead of calling the WiFi screen's state directly. - Replace legacy Icons in Settings/Tools bottom navigation with Phosphor icons, add activeIcon variants styled with theme primary color, and relabel "WiFi" to "Network". - Remove now-unused about/license/markdown UI bits from Settings (moved to simplified About flow).
1 parent 6259d1f commit 355baca

File tree

3 files changed

+54
-119
lines changed

3 files changed

+54
-119
lines changed

lib/settings/settings_screen.dart

Lines changed: 38 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@ import 'package:flutter/material.dart';
2222
import 'package:flutter/services.dart';
2323

2424
import 'package:logging/logging.dart';
25+
import 'package:orion/util/widgets/system_status_widget.dart';
2526
import 'package:path/path.dart' as path;
27+
import 'package:provider/provider.dart';
2628

2729
import 'package:orion/glasser/glasser.dart';
28-
import 'package:orion/pubspec.dart';
29-
import 'package:orion/settings/about_dialog.dart';
3030
import 'package:orion/settings/about_screen.dart';
3131
import 'package:orion/settings/debug_screen.dart';
32-
import 'package:orion/settings/fancy_license_screen.dart';
3332
import 'package:orion/settings/general_screen.dart';
3433
import 'package:orion/settings/update_screen.dart';
3534
import 'package:orion/settings/wifi_screen.dart';
36-
import 'package:orion/util/markdown_screen.dart';
3735
import 'package:orion/util/orion_config.dart';
36+
import 'package:orion/util/providers/wifi_provider.dart';
3837

3938
import 'package:phosphor_flutter/phosphor_flutter.dart';
4039

@@ -187,8 +186,8 @@ class SettingsScreenState extends State<SettingsScreen> {
187186
},
188187
);
189188

190-
if (shouldDisconnect) {
191-
await _wifiScreenKey.currentState?.disconnect();
189+
if (shouldDisconnect && mounted) {
190+
await context.read<WiFiProvider>().disconnect();
192191
}
193192
}
194193

@@ -257,81 +256,7 @@ class SettingsScreenState extends State<SettingsScreen> {
257256
appBar: AppBar(
258257
title: const Text('Settings'),
259258
actions: <Widget>[
260-
Padding(
261-
padding: const EdgeInsets.only(right: 16.0),
262-
child: _selectedIndex == 2
263-
? IconButton(
264-
icon: PhosphorIcon(PhosphorIcons.info(), size: 40),
265-
iconSize: 40,
266-
onPressed: () {
267-
showOrionAboutDialog(
268-
context: context,
269-
applicationName: 'Orion',
270-
applicationVersion:
271-
'Version ${Pubspec.version} - ${Pubspec.versionFull.toString().split('+')[1] == 'SELFCOMPILED' ? 'Local Build' : 'Commit ${Pubspec.versionFull.toString().split('+')[1]}'}',
272-
applicationLegalese:
273-
'Apache License 2.0 - Copyright © ${DateTime.now().year} Open Resin Alliance',
274-
applicationIcon: const FlutterLogo(size: 100),
275-
children: <Widget>[
276-
Padding(
277-
padding:
278-
const EdgeInsets.only(left: 10, right: 10),
279-
child: GlassCard(
280-
child: ListTile(
281-
leading: const Icon(Icons.list, size: 30),
282-
title: const Text('Changelog'),
283-
onTap: () {
284-
Navigator.push(
285-
context,
286-
MaterialPageRoute(
287-
builder: (context) =>
288-
const MarkdownScreen(
289-
filename: 'CHANGELOG.md'),
290-
),
291-
);
292-
},
293-
),
294-
),
295-
),
296-
Padding(
297-
padding: const EdgeInsets.all(10),
298-
child: GlassCard(
299-
child: ListTile(
300-
title: const Text('Open-Source Licenses'),
301-
leading:
302-
const Icon(Icons.favorite, size: 30),
303-
onTap: () {
304-
showFancyLicensePage(
305-
context: context,
306-
applicationName: 'Orion',
307-
applicationVersion: Pubspec.version,
308-
);
309-
},
310-
),
311-
),
312-
),
313-
],
314-
);
315-
},
316-
)
317-
: _selectedIndex == 1
318-
? ValueListenableBuilder<bool>(
319-
valueListenable: isConnected,
320-
builder: (context, value, child) {
321-
return value
322-
? IconButton(
323-
onPressed: () {
324-
launchDisconnectDialog();
325-
},
326-
icon: PhosphorIcon(
327-
PhosphorIcons.xCircle(),
328-
size: 40),
329-
)
330-
: const SizedBox.shrink();
331-
},
332-
)
333-
: const SizedBox.shrink(),
334-
),
259+
SystemStatusWidget(),
335260
],
336261
),
337262
body: _selectedIndex == 0
@@ -360,23 +285,44 @@ class SettingsScreenState extends State<SettingsScreen> {
360285
bottomNavigationBar: GlassBottomNavigationBar(
361286
type: BottomNavigationBarType.fixed,
362287
items: <BottomNavigationBarItem>[
363-
const BottomNavigationBarItem(
364-
icon: Icon(Icons.settings),
288+
BottomNavigationBarItem(
289+
icon: PhosphorIcon(PhosphorIcons.gear()),
290+
activeIcon: PhosphorIcon(
291+
PhosphorIconsFill.gear,
292+
color: Theme.of(context).colorScheme.primary,
293+
),
365294
label: 'General',
366295
),
367-
const BottomNavigationBarItem(
368-
icon: Icon(Icons.network_wifi),
369-
label: 'WiFi',
296+
BottomNavigationBarItem(
297+
icon: PhosphorIcon(PhosphorIcons.network()),
298+
activeIcon: PhosphorIcon(
299+
PhosphorIconsFill.network,
300+
color: Theme.of(context).colorScheme.primary,
301+
),
302+
label: 'Network',
370303
),
371-
const BottomNavigationBarItem(
372-
icon: Icon(Icons.info),
304+
BottomNavigationBarItem(
305+
icon: PhosphorIcon(PhosphorIcons.info()),
306+
activeIcon: PhosphorIcon(
307+
PhosphorIconsFill.info,
308+
color: Theme.of(context).colorScheme.primary,
309+
),
373310
label: 'About',
374311
),
375-
const BottomNavigationBarItem(
376-
icon: Icon(Icons.update), label: 'Updates'),
312+
BottomNavigationBarItem(
313+
icon: PhosphorIcon(PhosphorIcons.download()),
314+
activeIcon: PhosphorIcon(
315+
PhosphorIconsFill.download,
316+
color: Theme.of(context).colorScheme.primary,
317+
),
318+
label: 'Updates'),
377319
if (config.getFlag('developerMode', category: 'advanced'))
378-
const BottomNavigationBarItem(
379-
icon: Icon(Icons.bug_report),
320+
BottomNavigationBarItem(
321+
icon: PhosphorIcon(PhosphorIcons.bug()),
322+
activeIcon: PhosphorIcon(
323+
PhosphorIconsFill.bug,
324+
color: Theme.of(context).colorScheme.primary,
325+
),
380326
label: 'Debug',
381327
),
382328
],

lib/status/status_screen.dart

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import 'package:orion/backend_service/providers/status_provider.dart';
3434
import 'package:orion/backend_service/odyssey/models/status_models.dart';
3535
import 'package:orion/backend_service/backend_service.dart';
3636
import 'package:orion/util/layer_preview_cache.dart';
37+
import 'package:orion/util/widgets/system_status_widget.dart';
3738

3839
class StatusScreen extends StatefulWidget {
3940
final bool newPrint;
@@ -284,33 +285,7 @@ class StatusScreenState extends State<StatusScreen> {
284285
appBar: AppBar(
285286
automaticallyImplyLeading: false,
286287
centerTitle: true,
287-
actions: [
288-
Padding(
289-
padding: const EdgeInsets.only(right: 16),
290-
child: Builder(builder: (context) {
291-
final provider = Provider.of<StatusProvider>(context);
292-
final int? temp = provider.resinTemperature;
293-
return GlassCard(
294-
child: Padding(
295-
padding: const EdgeInsets.symmetric(
296-
horizontal: 8, vertical: 6),
297-
child: Row(
298-
children: [
299-
Icon(Icons.thermostat,
300-
size: 20,
301-
color:
302-
Theme.of(context).colorScheme.primary),
303-
const SizedBox(width: 6),
304-
Text(
305-
'$temp\u00B0C',
306-
style: TextStyle(fontSize: 18),
307-
),
308-
const SizedBox(width: 8),
309-
],
310-
)));
311-
}),
312-
),
313-
],
288+
actions: const [SystemStatusWidget()],
314289
title: Builder(builder: (context) {
315290
final deviceMsg = provider.deviceStatusMessage;
316291
final statusText =

lib/tools/tools_screen.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:orion/glasser/glasser.dart';
2323
import 'package:orion/tools/move_z_screen.dart';
2424
import 'package:orion/tools/exposure_screen.dart';
2525
import 'package:orion/tools/force_screen.dart';
26+
import 'package:orion/util/widgets/system_status_widget.dart';
2627

2728
class ToolsScreen extends StatefulWidget {
2829
const ToolsScreen({super.key});
@@ -51,6 +52,7 @@ class ToolsScreenState extends State<ToolsScreen> {
5152
child: Scaffold(
5253
appBar: AppBar(
5354
title: const Text('Tools'),
55+
actions: const [SystemStatusWidget()],
5456
),
5557
body: _selectedIndex == 0
5658
? const MoveZScreen()
@@ -64,14 +66,26 @@ class ToolsScreenState extends State<ToolsScreen> {
6466
items: <BottomNavigationBarItem>[
6567
BottomNavigationBarItem(
6668
icon: PhosphorIcon(PhosphorIcons.arrowsDownUp()),
69+
activeIcon: PhosphorIcon(
70+
PhosphorIconsFill.arrowsDownUp,
71+
color: Theme.of(context).colorScheme.primary,
72+
),
6773
label: 'Move Z',
6874
),
6975
BottomNavigationBarItem(
7076
icon: PhosphorIcon(PhosphorIcons.lightbulbFilament()),
77+
activeIcon: PhosphorIcon(
78+
PhosphorIconsFill.lightbulbFilament,
79+
color: Theme.of(context).colorScheme.primary,
80+
),
7181
label: 'Exposure',
7282
),
7383
BottomNavigationBarItem(
7484
icon: PhosphorIcon(PhosphorIcons.chartLineUp()),
85+
activeIcon: PhosphorIcon(
86+
PhosphorIconsFill.chartLineUp,
87+
color: Theme.of(context).colorScheme.primary,
88+
),
7589
label: 'Force Sensor',
7690
),
7791
// TODO: Implement Self Test

0 commit comments

Comments
 (0)