feat: Refactor color handling in NoGameDataScreen to utilize centralized color palette from WolfMenuPalette
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -53,35 +53,6 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
/// Currently selected ready version.
|
||||
final GameVersion? selectedReadyVersion;
|
||||
|
||||
static final Color _backgroundColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.backgroundIndex),
|
||||
);
|
||||
static final Color _panelColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.panelIndex),
|
||||
);
|
||||
static final Color _borderColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.borderIndex),
|
||||
);
|
||||
static final Color _titleColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(
|
||||
WolfMenuPalette.headerTextIndex,
|
||||
),
|
||||
);
|
||||
static final Color _bodyColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(
|
||||
WolfMenuPalette.unselectedTextIndex,
|
||||
),
|
||||
);
|
||||
static final Color _emphasisColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.emphasisIndex),
|
||||
);
|
||||
static final Color _warningColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.warningIndex),
|
||||
);
|
||||
static final Color _mutedColor = Color(
|
||||
ColorPalette.argbFromVgaIndex(WolfMenuPalette.mutedIndex),
|
||||
);
|
||||
|
||||
static String _stateLabel(GameDataVersionState state) {
|
||||
switch (state) {
|
||||
case GameDataVersionState.incomplete:
|
||||
@@ -96,22 +67,22 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
static Color _stateColor(GameDataVersionState state) {
|
||||
switch (state) {
|
||||
case GameDataVersionState.ready:
|
||||
return _emphasisColor;
|
||||
return Color(WolfMenuPalette.emphasisColor);
|
||||
case GameDataVersionState.checksumWarning:
|
||||
return _warningColor;
|
||||
return Color(WolfMenuPalette.warningColor);
|
||||
case GameDataVersionState.incomplete:
|
||||
return _mutedColor;
|
||||
return Color(WolfMenuPalette.mutedColor);
|
||||
}
|
||||
}
|
||||
|
||||
static Color _fileStateColor(GameDataFileState state) {
|
||||
switch (state) {
|
||||
case GameDataFileState.ready:
|
||||
return _emphasisColor;
|
||||
return Color(WolfMenuPalette.emphasisColor);
|
||||
case GameDataFileState.warning:
|
||||
return _warningColor;
|
||||
return Color(WolfMenuPalette.warningColor);
|
||||
case GameDataFileState.missing:
|
||||
return _mutedColor;
|
||||
return Color(WolfMenuPalette.mutedColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +92,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
scanResult?.readyVersions ?? <GameDataVersionAnalysis>[];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: _backgroundColor,
|
||||
backgroundColor: Color(WolfMenuPalette.backgroundColor),
|
||||
body: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||
return SingleChildScrollView(
|
||||
@@ -135,8 +106,11 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: _panelColor,
|
||||
border: Border.all(color: _borderColor, width: 2),
|
||||
color: Color(WolfMenuPalette.panelColor),
|
||||
border: Border.all(
|
||||
color: Color(WolfMenuPalette.borderColor),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
@@ -147,7 +121,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
Text(
|
||||
'WOLF3D DATA NOT FOUND',
|
||||
style: TextStyle(
|
||||
color: _titleColor,
|
||||
color: Color(WolfMenuPalette.titleColor),
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -157,7 +131,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
'No game files were discovered.\n\n'
|
||||
'Select a game-data directory, or select one or more game-data files.',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
color: Color(WolfMenuPalette.bodyColor),
|
||||
fontSize: 15,
|
||||
height: 1.4,
|
||||
),
|
||||
@@ -166,7 +140,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
Text(
|
||||
'A complete version can be loaded directly or imported into the app config folder.',
|
||||
style: TextStyle(
|
||||
color: _emphasisColor,
|
||||
color: Color(WolfMenuPalette.emphasisColor),
|
||||
fontSize: 14,
|
||||
height: 1.35,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -205,7 +179,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
child: Text(
|
||||
'Scanning selected locations...',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
color: Color(WolfMenuPalette.bodyColor),
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
),
|
||||
@@ -214,8 +188,8 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
if (scanResult != null) ...[
|
||||
const SizedBox(height: 18),
|
||||
_ScanSummary(
|
||||
bodyColor: _bodyColor,
|
||||
mutedColor: _mutedColor,
|
||||
bodyColor: Color(WolfMenuPalette.bodyColor),
|
||||
mutedColor: Color(WolfMenuPalette.mutedColor),
|
||||
scanResult: scanResult!,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -223,11 +197,15 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
(GameDataVersionAnalysis analysis) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _VersionCard(
|
||||
panelColor: _backgroundColor,
|
||||
borderColor: _borderColor,
|
||||
titleColor: _titleColor,
|
||||
bodyColor: _bodyColor,
|
||||
mutedColor: _mutedColor,
|
||||
panelColor: Color(
|
||||
WolfMenuPalette.backgroundColor,
|
||||
),
|
||||
borderColor: Color(
|
||||
WolfMenuPalette.borderColor,
|
||||
),
|
||||
titleColor: Color(WolfMenuPalette.titleColor),
|
||||
bodyColor: Color(WolfMenuPalette.bodyColor),
|
||||
mutedColor: Color(WolfMenuPalette.mutedColor),
|
||||
analysis: analysis,
|
||||
),
|
||||
),
|
||||
@@ -239,13 +217,19 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
initialValue:
|
||||
selectedReadyVersion ??
|
||||
readyVersions.first.version,
|
||||
dropdownColor: _panelColor,
|
||||
style: TextStyle(color: _bodyColor),
|
||||
dropdownColor: Color(WolfMenuPalette.panelColor),
|
||||
style: TextStyle(
|
||||
color: Color(WolfMenuPalette.bodyColor),
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Complete version',
|
||||
labelStyle: TextStyle(color: _bodyColor),
|
||||
labelStyle: TextStyle(
|
||||
color: Color(WolfMenuPalette.bodyColor),
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: _borderColor),
|
||||
borderSide: BorderSide(
|
||||
color: Color(WolfMenuPalette.borderColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
items: readyVersions
|
||||
@@ -291,7 +275,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
child: Text(
|
||||
pickerError!.trim(),
|
||||
style: TextStyle(
|
||||
color: _emphasisColor,
|
||||
color: Color(WolfMenuPalette.emphasisColor),
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -305,7 +289,7 @@ class NoGameDataScreen extends StatelessWidget {
|
||||
child: Text(
|
||||
'Configured data directory: ${configuredDataDirectory!.trim()}',
|
||||
style: TextStyle(
|
||||
color: _bodyColor,
|
||||
color: Color(WolfMenuPalette.bodyColor),
|
||||
fontSize: 13,
|
||||
height: 1.3,
|
||||
),
|
||||
|
||||
@@ -66,6 +66,25 @@ abstract class WolfMenuPalette {
|
||||
static int get headerTextIndex => _cachedHeaderTextIndex ??=
|
||||
ColorPalette.findClosestPaletteIndex(_headerTargetRgb);
|
||||
|
||||
/// Standard ARGB colors (`0xAARRGGBB`) for UI consumers.
|
||||
static int get backgroundColor =>
|
||||
ColorPalette.argbFromVgaIndex(backgroundIndex);
|
||||
|
||||
static int get panelColor => ColorPalette.argbFromVgaIndex(panelIndex);
|
||||
|
||||
static int get borderColor => ColorPalette.argbFromVgaIndex(borderIndex);
|
||||
|
||||
static int get titleColor => ColorPalette.argbFromVgaIndex(headerTextIndex);
|
||||
|
||||
static int get bodyColor =>
|
||||
ColorPalette.argbFromVgaIndex(unselectedTextIndex);
|
||||
|
||||
static int get emphasisColor => ColorPalette.argbFromVgaIndex(emphasisIndex);
|
||||
|
||||
static int get warningColor => ColorPalette.argbFromVgaIndex(warningIndex);
|
||||
|
||||
static int get mutedColor => ColorPalette.argbFromVgaIndex(mutedIndex);
|
||||
|
||||
static int get selectedTextColor => ColorPalette.vga32Bit[selectedTextIndex];
|
||||
|
||||
static int get unselectedTextColor =>
|
||||
|
||||
Reference in New Issue
Block a user