150 lines
4.0 KiB
Dart
150 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
// import '../../../theme/app_colors.dart';
|
|
|
|
/// 통화 선택 위젯
|
|
/// KRW(원화), USD(달러), JPY(엔화), CNY(위안화) 중 선택할 수 있습니다.
|
|
class CurrencySelector extends StatelessWidget {
|
|
final String currency;
|
|
final ValueChanged<String> onChanged;
|
|
final bool isGlassmorphism; // deprecated: ignored
|
|
|
|
const CurrencySelector({
|
|
super.key,
|
|
required this.currency,
|
|
required this.onChanged,
|
|
this.isGlassmorphism = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
_CurrencyOption(
|
|
label: '₩',
|
|
value: 'KRW',
|
|
isSelected: currency == 'KRW',
|
|
onTap: () => onChanged('KRW'),
|
|
isGlassmorphism: isGlassmorphism,
|
|
),
|
|
const SizedBox(width: 8),
|
|
_CurrencyOption(
|
|
label: '\$',
|
|
value: 'USD',
|
|
isSelected: currency == 'USD',
|
|
onTap: () => onChanged('USD'),
|
|
isGlassmorphism: isGlassmorphism,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
children: [
|
|
_CurrencyOption(
|
|
label: '¥',
|
|
value: 'JPY',
|
|
subtitle: 'JPY',
|
|
isSelected: currency == 'JPY',
|
|
onTap: () => onChanged('JPY'),
|
|
isGlassmorphism: isGlassmorphism,
|
|
),
|
|
const SizedBox(width: 8),
|
|
_CurrencyOption(
|
|
label: '¥',
|
|
value: 'CNY',
|
|
subtitle: 'CNY',
|
|
isSelected: currency == 'CNY',
|
|
onTap: () => onChanged('CNY'),
|
|
isGlassmorphism: isGlassmorphism,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 통화 옵션 버튼
|
|
class _CurrencyOption extends StatelessWidget {
|
|
final String label;
|
|
final String value;
|
|
final String? subtitle;
|
|
final bool isSelected;
|
|
final VoidCallback onTap;
|
|
final bool isGlassmorphism; // deprecated: ignored
|
|
|
|
const _CurrencyOption({
|
|
required this.label,
|
|
required this.value,
|
|
this.subtitle,
|
|
required this.isSelected,
|
|
required this.onTap,
|
|
required this.isGlassmorphism,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return Expanded(
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(12),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
decoration: BoxDecoration(
|
|
color: _getBackgroundColor(theme),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: _getBorder(theme),
|
|
),
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
color: _getTextColor(theme),
|
|
),
|
|
),
|
|
if (subtitle != null) ...[
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
subtitle!,
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w500,
|
|
color: _getTextColor(theme).withValues(alpha: 0.8),
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Color _getBackgroundColor(ThemeData theme) {
|
|
final scheme = theme.colorScheme;
|
|
return isSelected ? scheme.primary : scheme.surface;
|
|
}
|
|
|
|
Border? _getBorder(ThemeData theme) {
|
|
if (isSelected) return null;
|
|
return Border.all(
|
|
color: theme.colorScheme.outline.withValues(alpha: 0.6),
|
|
width: 1,
|
|
);
|
|
}
|
|
|
|
Color _getTextColor(ThemeData theme) {
|
|
final scheme = theme.colorScheme;
|
|
return isSelected ? scheme.onPrimary : scheme.onSurface;
|
|
}
|
|
}
|