From 02cfe01ae0f30ea84c7973bcf6f300ede673834e Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 18 Mar 2025 21:30:13 +0100 Subject: [PATCH] Clean up main a little --- lib/main.dart | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d1f7a2b..d1f4555 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -115,7 +115,6 @@ class _ModManagerPageState extends State { bool _isLoading = false; String _statusMessage = ''; - int _totalModsFound = 0; bool _skipFileCount = false; bool _hasCycles = false; List? _cycleInfo; @@ -156,7 +155,6 @@ class _ModManagerPageState extends State { _activeMods = modManager.mods.values.where((m) => m.enabled).toList(); _isLoading = false; _statusMessage = 'Loaded ${_availableMods.length} mods'; - _totalModsFound = _availableMods.length; }); } @@ -341,7 +339,12 @@ class _ModManagerPageState extends State { margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( - color: Colors.red.shade900.withOpacity(0.3), + color: Color.fromRGBO( + Colors.red.shade900.red, + Colors.red.shade900.green, + Colors.red.shade900.blue, + 0.3 + ), borderRadius: BorderRadius.circular(4.0), border: Border.all(color: Colors.red.shade800), ), @@ -677,9 +680,7 @@ class _ModManagerPageState extends State { decoration: BoxDecoration( color: _searchQuery.isNotEmpty - ? Colors.blue.withOpacity( - 0.2, - ) + ? const Color.fromRGBO(0, 0, 255, 0.2) : null, borderRadius: BorderRadius.circular(4), @@ -823,7 +824,6 @@ class _ModManagerPageState extends State { if (mounted) { setState(() { _statusMessage = 'Loaded mod: ${mod.name}'; - _totalModsFound = modManager.mods.length; }); } } @@ -1093,14 +1093,16 @@ class _ModManagerPageState extends State { }); // Show success message - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Mod order saved to config. ${_activeMods.length} mods enabled.', + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Mod order saved to config. ${_activeMods.length} mods enabled.', + ), + backgroundColor: Colors.green, ), - backgroundColor: Colors.green, - ), - ); + ); + } } catch (e) { final logger = Logger.instance; logger.error('Error saving mod load order: $e'); @@ -1111,12 +1113,14 @@ class _ModManagerPageState extends State { }); // Show error message - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Error saving mod order: $e'), - backgroundColor: Colors.red, - ), - ); + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Error saving mod order: $e'), + backgroundColor: Colors.red, + ), + ); + } } }