refactor(shared): 공통 위젯 및 색상 정리

This commit is contained in:
JiWoong Sul
2026-01-12 16:17:29 +09:00
parent 448f500ca0
commit b1d02de656
6 changed files with 92 additions and 96 deletions

View File

@@ -248,49 +248,49 @@ class RetroColors {
/// 다크 모드 ColorScheme
static ColorScheme get darkColorScheme => ColorScheme.dark(
primary: _darkGold,
onPrimary: _darkBg,
primaryContainer: _darkGoldDark,
onPrimaryContainer: _darkTextPrimary,
secondary: _darkBorder,
onSecondary: _darkTextPrimary,
secondaryContainer: _darkPanelBg,
onSecondaryContainer: _darkTextPrimary,
tertiary: _darkMp,
onTertiary: _darkBg,
tertiaryContainer: _darkMpDark,
onTertiaryContainer: _darkTextPrimary,
error: _darkHp,
onError: _darkBg,
surface: _darkBg,
onSurface: _darkTextPrimary,
surfaceContainerHighest: _darkPanelBg,
outline: _darkBorder,
outlineVariant: _darkBorderLight,
);
primary: _darkGold,
onPrimary: _darkBg,
primaryContainer: _darkGoldDark,
onPrimaryContainer: _darkTextPrimary,
secondary: _darkBorder,
onSecondary: _darkTextPrimary,
secondaryContainer: _darkPanelBg,
onSecondaryContainer: _darkTextPrimary,
tertiary: _darkMp,
onTertiary: _darkBg,
tertiaryContainer: _darkMpDark,
onTertiaryContainer: _darkTextPrimary,
error: _darkHp,
onError: _darkBg,
surface: _darkBg,
onSurface: _darkTextPrimary,
surfaceContainerHighest: _darkPanelBg,
outline: _darkBorder,
outlineVariant: _darkBorderLight,
);
/// 라이트 모드 ColorScheme
static ColorScheme get lightColorScheme => ColorScheme.light(
primary: _lightGold,
onPrimary: _lightSurface,
primaryContainer: _lightGoldLight,
onPrimaryContainer: _lightTextPrimary,
secondary: _lightBorder,
onSecondary: _lightTextPrimary,
secondaryContainer: _lightPanelBg,
onSecondaryContainer: _lightTextPrimary,
tertiary: _lightMp,
onTertiary: _lightSurface,
tertiaryContainer: _lightMpDark,
onTertiaryContainer: _lightSurface,
error: _lightHp,
onError: _lightSurface,
surface: _lightBg,
onSurface: _lightTextPrimary,
surfaceContainerHighest: _lightPanelBg,
outline: _lightBorder,
outlineVariant: _lightBorderDark,
);
primary: _lightGold,
onPrimary: _lightSurface,
primaryContainer: _lightGoldLight,
onPrimaryContainer: _lightTextPrimary,
secondary: _lightBorder,
onSecondary: _lightTextPrimary,
secondaryContainer: _lightPanelBg,
onSecondaryContainer: _lightTextPrimary,
tertiary: _lightMp,
onTertiary: _lightSurface,
tertiaryContainer: _lightMpDark,
onTertiaryContainer: _lightSurface,
error: _lightHp,
onError: _lightSurface,
surface: _lightBg,
onSurface: _lightTextPrimary,
surfaceContainerHighest: _lightPanelBg,
outline: _lightBorder,
outlineVariant: _lightBorderDark,
);
/// @deprecated Use darkColorScheme or lightColorScheme instead
static ColorScheme get colorScheme => darkColorScheme;

View File

@@ -40,23 +40,21 @@ class PixelBorderPainter extends CustomPainter {
..color = fillColor!
..style = PaintingStyle.fill;
canvas.drawRect(
Rect.fromLTWH(borderWidth, borderWidth,
size.width - borderWidth * 2, size.height - borderWidth * 2),
Rect.fromLTWH(
borderWidth,
borderWidth,
size.width - borderWidth * 2,
size.height - borderWidth * 2,
),
bgPaint,
);
}
// 외곽 테두리 (상단, 좌측 - 어두운 색으로 깊이감)
// 상단
canvas.drawRect(
Rect.fromLTWH(0, 0, size.width, borderWidth),
outerPaint,
);
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, borderWidth), outerPaint);
// 좌측
canvas.drawRect(
Rect.fromLTWH(0, 0, borderWidth, size.height),
outerPaint,
);
canvas.drawRect(Rect.fromLTWH(0, 0, borderWidth, size.height), outerPaint);
// 외곽 테두리 (하단, 우측 - 어두운 색)
// 하단
@@ -73,14 +71,22 @@ class PixelBorderPainter extends CustomPainter {
// 내곽 하이라이트 (상단, 좌측 내부 - 밝은 색으로 입체감)
// 상단 내부
canvas.drawRect(
Rect.fromLTWH(borderWidth, borderWidth,
size.width - borderWidth * 2, borderWidth * 0.5),
Rect.fromLTWH(
borderWidth,
borderWidth,
size.width - borderWidth * 2,
borderWidth * 0.5,
),
innerPaint,
);
// 좌측 내부
canvas.drawRect(
Rect.fromLTWH(borderWidth, borderWidth,
borderWidth * 0.5, size.height - borderWidth * 2),
Rect.fromLTWH(
borderWidth,
borderWidth,
borderWidth * 0.5,
size.height - borderWidth * 2,
),
innerPaint,
);
}
@@ -96,11 +102,9 @@ class PixelBorderPainter extends CustomPainter {
/// 골드 테두리 스타일 (타이틀, 중요 패널용)
class GoldBorderPainter extends PixelBorderPainter {
const GoldBorderPainter({
super.borderWidth = 3.0,
super.fillColor,
}) : super(
outerColor: RetroColors.goldDark,
innerColor: RetroColors.goldLight,
);
const GoldBorderPainter({super.borderWidth = 3.0, super.fillColor})
: super(
outerColor: RetroColors.goldDark,
innerColor: RetroColors.goldLight,
);
}

View File

@@ -76,7 +76,9 @@ class _RetroButtonState extends State<RetroButton> {
child: GestureDetector(
onTapDown: _isEnabled ? (_) => setState(() => _isPressed = true) : null,
onTapUp: _isEnabled ? (_) => setState(() => _isPressed = false) : null,
onTapCancel: _isEnabled ? () => setState(() => _isPressed = false) : null,
onTapCancel: _isEnabled
? () => setState(() => _isPressed = false)
: null,
onTap: widget.onPressed,
child: AnimatedContainer(
duration: const Duration(milliseconds: 100),

View File

@@ -71,17 +71,12 @@ class RetroDialog extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
color: accent.withValues(alpha: 0.2),
border: Border(
bottom: BorderSide(color: accent, width: 2),
),
border: Border(bottom: BorderSide(color: accent, width: 2)),
),
child: Row(
children: [
if (titleIcon != null) ...[
Text(
titleIcon!,
style: TextStyle(fontSize: 14, color: accent),
),
Text(titleIcon!, style: TextStyle(fontSize: 14, color: accent)),
const SizedBox(width: 8),
],
Expanded(
@@ -140,25 +135,18 @@ class RetroTabBar extends StatelessWidget {
return Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: borderColor, width: 2),
),
border: Border(bottom: BorderSide(color: borderColor, width: 2)),
),
child: TabBar(
controller: controller,
isScrollable: tabs.length > 3,
indicator: BoxDecoration(
color: accent.withValues(alpha: 0.3),
border: Border(
bottom: BorderSide(color: accent, width: 2),
),
border: Border(bottom: BorderSide(color: accent, width: 2)),
),
labelColor: accent,
unselectedLabelColor: mutedColor,
labelStyle: const TextStyle(
fontFamily: 'PressStart2P',
fontSize: 9,
),
labelStyle: const TextStyle(fontFamily: 'PressStart2P', fontSize: 9),
unselectedLabelStyle: const TextStyle(
fontFamily: 'PressStart2P',
fontSize: 9,
@@ -193,10 +181,7 @@ class RetroSectionHeader extends StatelessWidget {
child: Row(
children: [
if (icon != null) ...[
Text(
icon!,
style: TextStyle(fontSize: 12, color: accent),
),
Text(icon!, style: TextStyle(fontSize: 12, color: accent)),
const SizedBox(width: 6),
],
Text(
@@ -231,11 +216,7 @@ class RetroSectionHeader extends StatelessWidget {
/// 레트로 스타일 정보 박스
/// 라이트/다크 모드 자동 지원
class RetroInfoBox extends StatelessWidget {
const RetroInfoBox({
super.key,
required this.content,
this.backgroundColor,
});
const RetroInfoBox({super.key, required this.content, this.backgroundColor});
final String content;
final Color? backgroundColor;

View File

@@ -37,8 +37,14 @@ class RetroPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
final painter = useGoldBorder
? GoldBorderPainter(borderWidth: borderWidth, fillColor: backgroundColor)
: PixelBorderPainter(borderWidth: borderWidth, fillColor: backgroundColor);
? GoldBorderPainter(
borderWidth: borderWidth,
fillColor: backgroundColor,
)
: PixelBorderPainter(
borderWidth: borderWidth,
fillColor: backgroundColor,
);
return CustomPaint(
painter: painter,
@@ -77,7 +83,9 @@ class _PanelTitle extends StatelessWidget {
: RetroColors.panelBorderOuter.withValues(alpha: 0.5),
border: Border(
bottom: BorderSide(
color: useGoldBorder ? RetroColors.gold : RetroColors.panelBorderInner,
color: useGoldBorder
? RetroColors.gold
: RetroColors.panelBorderInner,
width: 1,
),
),

View File

@@ -45,7 +45,8 @@ class RetroProgressBar extends StatelessWidget {
/// 퍼센트 표시 여부
final bool showPercentage;
double get _percentage => maxValue > 0 ? (value / maxValue).clamp(0.0, 1.0) : 0;
double get _percentage =>
maxValue > 0 ? (value / maxValue).clamp(0.0, 1.0) : 0;
@override
Widget build(BuildContext context) {
@@ -69,9 +70,7 @@ class RetroProgressBar extends StatelessWidget {
color: emptyColor,
border: Border.all(color: RetroColors.panelBorderOuter, width: 2),
),
child: showSegments
? _buildSegmentedBar()
: _buildSolidBar(),
child: showSegments ? _buildSegmentedBar() : _buildSolidBar(),
),
),
if (showPercentage) ...[
@@ -108,7 +107,9 @@ class RetroProgressBar extends StatelessWidget {
border: Border(
right: index < segmentCount - 1
? BorderSide(
color: RetroColors.panelBorderOuter.withValues(alpha: 0.5),
color: RetroColors.panelBorderOuter.withValues(
alpha: 0.5,
),
width: 1,
)
: BorderSide.none,