2026-04-03 16:56:47 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../l10n/app_localizations.dart';
|
|
|
|
|
|
import '../../../../shared/theme/design_tokens.dart';
|
2026-04-06 01:28:10 +08:00
|
|
|
|
import '../../../../shared/widgets/app_modal_dialog.dart';
|
2026-04-07 12:30:12 +08:00
|
|
|
|
import '../../../../shared/widgets/gua_icon.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
import '../../../../shared/widgets/divination/divination_shared_widgets.dart';
|
|
|
|
|
|
import '../../../../shared/widgets/divination/divination_terms.dart';
|
|
|
|
|
|
import '../../../../shared/widgets/divination/yao_legend.dart';
|
|
|
|
|
|
import '../../../../shared/widgets/divination/yao_line_row.dart';
|
2026-04-03 18:18:55 +08:00
|
|
|
|
import '../../../../shared/widgets/date_time_picker/date_time_picker_bottom_sheet.dart';
|
2026-04-06 01:28:10 +08:00
|
|
|
|
import '../../../../shared/widgets/toast/toast.dart';
|
|
|
|
|
|
import '../../../../shared/widgets/toast/toast_type.dart';
|
|
|
|
|
|
import '../../data/models/divination_backend_models.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
import '../../data/models/divination_params.dart';
|
2026-04-06 01:28:10 +08:00
|
|
|
|
import '../../data/models/divination_result.dart';
|
2026-04-03 18:18:55 +08:00
|
|
|
|
import '../../data/services/divination_run_service.dart';
|
2026-04-03 19:04:46 +08:00
|
|
|
|
import 'divination_processing_screen.dart';
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
class ManualDivinationScreen extends StatefulWidget {
|
2026-04-03 18:18:55 +08:00
|
|
|
|
const ManualDivinationScreen({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.params,
|
|
|
|
|
|
required this.runService,
|
2026-04-06 01:28:10 +08:00
|
|
|
|
required this.onCompleted,
|
2026-04-03 18:18:55 +08:00
|
|
|
|
});
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
final DivinationParams params;
|
2026-04-03 18:18:55 +08:00
|
|
|
|
final DivinationRunService runService;
|
2026-04-06 01:28:10 +08:00
|
|
|
|
final Future<void> Function(DivinationResultData result) onCompleted;
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<ManualDivinationScreen> createState() => _ManualDivinationScreenState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _ManualDivinationScreenState extends State<ManualDivinationScreen>
|
|
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
|
|
late DateTime _selectedTime;
|
|
|
|
|
|
final List<YaoType?> _selectedYaos = List<YaoType?>.filled(6, null);
|
|
|
|
|
|
late final AnimationController _blinkController;
|
2026-04-03 18:18:55 +08:00
|
|
|
|
bool _submitting = false;
|
2026-04-03 16:56:47 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
_selectedTime = widget.params.divinationTime;
|
|
|
|
|
|
_blinkController = AnimationController(
|
|
|
|
|
|
vsync: this,
|
|
|
|
|
|
duration: const Duration(milliseconds: 500),
|
|
|
|
|
|
)..repeat(reverse: true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
_blinkController.dispose();
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool get _allSelected => _selectedYaos.every((v) => v != null);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
|
backgroundColor: colors.surface,
|
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
|
title: Text(l10n.manualScreenTitle),
|
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
|
backgroundColor: colors.surface,
|
|
|
|
|
|
surfaceTintColor: colors.surface,
|
|
|
|
|
|
),
|
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.xl),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
_buildInstruction(),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
_TimeCard(selectedTime: _selectedTime, onPickTime: _pickTime),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
_YaoSelectionCard(
|
|
|
|
|
|
selectedYaos: _selectedYaos,
|
|
|
|
|
|
blinkAnimation: _blinkController,
|
|
|
|
|
|
onSelect: _onSelectYao,
|
|
|
|
|
|
onNeedTip: _showOrderTip,
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.xl),
|
|
|
|
|
|
AnimatedBuilder(
|
|
|
|
|
|
animation: _blinkController,
|
|
|
|
|
|
builder: (context, _) {
|
|
|
|
|
|
final base = colors.primary;
|
|
|
|
|
|
return SizedBox(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
height: 50,
|
|
|
|
|
|
child: FilledButton(
|
2026-04-03 18:18:55 +08:00
|
|
|
|
onPressed: _allSelected && !_submitting ? _submitRun : null,
|
2026-04-03 16:56:47 +08:00
|
|
|
|
style: FilledButton.styleFrom(
|
|
|
|
|
|
backgroundColor: _allSelected
|
|
|
|
|
|
? base.withValues(
|
|
|
|
|
|
alpha: 0.6 + _blinkController.value * 0.4,
|
|
|
|
|
|
)
|
|
|
|
|
|
: base,
|
|
|
|
|
|
),
|
2026-04-03 18:18:55 +08:00
|
|
|
|
child: _submitting
|
|
|
|
|
|
? const SizedBox(
|
|
|
|
|
|
width: 18,
|
|
|
|
|
|
height: 18,
|
|
|
|
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
|
|
|
|
)
|
|
|
|
|
|
: Text(l10n.manualStartResolve),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildInstruction() {
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
return DivinationInstructionCard(
|
|
|
|
|
|
text: l10n.manualYaoInstruction,
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
showDialog<void>(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (_) {
|
|
|
|
|
|
return DivinationGuideDialog(
|
|
|
|
|
|
title: l10n.manualSelectYaoTitle,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
guideImages: const ['lc2.jpg', 'lc3.jpg', 'lc4.jpg', 'lc5.jpg'],
|
2026-04-03 16:56:47 +08:00
|
|
|
|
instructionText: l10n.manualYaoTipContent,
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _pickTime() async {
|
2026-04-03 18:18:55 +08:00
|
|
|
|
final result = await showDateTimePickerBottomSheet(
|
2026-04-03 16:56:47 +08:00
|
|
|
|
context: context,
|
2026-04-03 18:18:55 +08:00
|
|
|
|
initialDateTime: _selectedTime,
|
|
|
|
|
|
minDateTime: DateTime(2000),
|
|
|
|
|
|
maxDateTime: DateTime(2100),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
);
|
2026-04-03 18:18:55 +08:00
|
|
|
|
if (result == null || !mounted) return;
|
2026-04-03 16:56:47 +08:00
|
|
|
|
setState(() {
|
2026-04-03 18:18:55 +08:00
|
|
|
|
_selectedTime = result;
|
2026-04-03 16:56:47 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _onSelectYao(int index, YaoType type) {
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
_selectedYaos[index] = type;
|
|
|
|
|
|
});
|
|
|
|
|
|
HapticFeedback.selectionClick();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _showOrderTip() async {
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
await showDialog<void>(
|
|
|
|
|
|
context: context,
|
2026-04-06 01:28:10 +08:00
|
|
|
|
builder: (dialogContext) {
|
|
|
|
|
|
return AppModalDialog(
|
|
|
|
|
|
title: l10n.manualYaoTipTitle,
|
|
|
|
|
|
message: l10n.manualYaoTipContent,
|
2026-04-07 12:30:12 +08:00
|
|
|
|
iconWidget: const GuaIcon(),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
actions: [
|
2026-04-06 01:28:10 +08:00
|
|
|
|
AppModalDialogAction(
|
|
|
|
|
|
label: l10n.divinationIAcknowledge,
|
|
|
|
|
|
primary: true,
|
|
|
|
|
|
onPressed: () => Navigator.of(dialogContext).pop(),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-03 18:18:55 +08:00
|
|
|
|
Future<void> _submitRun() async {
|
2026-04-06 01:28:10 +08:00
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
PointsBalanceData points;
|
|
|
|
|
|
try {
|
|
|
|
|
|
points = await widget.runService.getPointsBalance();
|
|
|
|
|
|
} catch (_) {
|
|
|
|
|
|
if (!mounted) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Toast.show(context, l10n.errorRequestGeneric, type: ToastType.error);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!points.canRun || points.availableBalance < points.runCost) {
|
|
|
|
|
|
if (!mounted) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Toast.show(context, l10n.toastCoinInsufficient, type: ToastType.warning);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!mounted) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
final shouldStart = await showDialog<bool>(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (dialogContext) {
|
|
|
|
|
|
return AppModalDialog(
|
|
|
|
|
|
title: l10n.divinationCostDialogTitle,
|
|
|
|
|
|
message: l10n.divinationCostDialogBody(
|
|
|
|
|
|
points.runCost,
|
|
|
|
|
|
points.availableBalance,
|
|
|
|
|
|
),
|
2026-04-07 12:30:12 +08:00
|
|
|
|
iconWidget: const GuaIcon(),
|
2026-04-06 01:28:10 +08:00
|
|
|
|
actions: [
|
|
|
|
|
|
AppModalDialogAction(
|
|
|
|
|
|
label: l10n.cancel,
|
|
|
|
|
|
onPressed: () => Navigator.of(dialogContext).pop(false),
|
|
|
|
|
|
),
|
|
|
|
|
|
AppModalDialogAction(
|
|
|
|
|
|
label: l10n.divinationCostDialogConfirm,
|
|
|
|
|
|
primary: true,
|
|
|
|
|
|
onPressed: () => Navigator.of(dialogContext).pop(true),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
if (shouldStart != true) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-03 18:18:55 +08:00
|
|
|
|
setState(() {
|
|
|
|
|
|
_submitting = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (!mounted) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-04-03 19:04:46 +08:00
|
|
|
|
await Navigator.of(context).push<void>(
|
2026-04-03 18:18:55 +08:00
|
|
|
|
MaterialPageRoute<void>(
|
2026-04-03 19:04:46 +08:00
|
|
|
|
builder: (_) => DivinationProcessingScreen(
|
|
|
|
|
|
params: widget.params.copyWith(divinationTime: _selectedTime),
|
|
|
|
|
|
yaoStates: _selectedYaos.cast<YaoType>(),
|
|
|
|
|
|
runService: widget.runService,
|
2026-04-06 01:28:10 +08:00
|
|
|
|
onCompleted: widget.onCompleted,
|
2026-04-03 18:18:55 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
} finally {
|
2026-04-07 12:30:12 +08:00
|
|
|
|
if (mounted) {
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
_submitting = false;
|
|
|
|
|
|
});
|
2026-04-03 18:18:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-03 16:56:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _TimeCard extends StatelessWidget {
|
|
|
|
|
|
const _TimeCard({required this.selectedTime, required this.onPickTime});
|
|
|
|
|
|
|
|
|
|
|
|
final DateTime selectedTime;
|
|
|
|
|
|
final VoidCallback onPickTime;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
return Card(
|
|
|
|
|
|
margin: EdgeInsets.zero,
|
|
|
|
|
|
color: colors.surface,
|
|
|
|
|
|
elevation: 2,
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
l10n.manualSelectTime,
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
|
|
|
|
color: colors.primary,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text(
|
2026-04-03 18:18:55 +08:00
|
|
|
|
DateFormat.yMd(
|
|
|
|
|
|
Localizations.localeOf(context).toString(),
|
|
|
|
|
|
).add_Hm().format(selectedTime),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
OutlinedButton(
|
|
|
|
|
|
onPressed: onPickTime,
|
|
|
|
|
|
child: Text(l10n.divinationModify),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _YaoSelectionCard extends StatelessWidget {
|
|
|
|
|
|
const _YaoSelectionCard({
|
|
|
|
|
|
required this.selectedYaos,
|
|
|
|
|
|
required this.blinkAnimation,
|
|
|
|
|
|
required this.onSelect,
|
|
|
|
|
|
required this.onNeedTip,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
final List<YaoType?> selectedYaos;
|
|
|
|
|
|
final Animation<double> blinkAnimation;
|
|
|
|
|
|
final void Function(int, YaoType) onSelect;
|
|
|
|
|
|
final Future<void> Function() onNeedTip;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
|
|
final rowNames = DivinationTerms.yaoNames.reversed.toList();
|
|
|
|
|
|
return Card(
|
|
|
|
|
|
margin: EdgeInsets.zero,
|
|
|
|
|
|
color: colors.surface,
|
|
|
|
|
|
elevation: 2,
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
l10n.manualSpecifyYaoCombo,
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
|
|
|
|
color: colors.primary,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
...List.generate(rowNames.length, (i) {
|
|
|
|
|
|
final yaoIndex = 5 - i;
|
|
|
|
|
|
final current = selectedYaos[yaoIndex];
|
|
|
|
|
|
final enabled =
|
|
|
|
|
|
yaoIndex == 0 || selectedYaos[yaoIndex - 1] != null;
|
|
|
|
|
|
final shouldBlink = enabled && current == null;
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(bottom: AppSpacing.md),
|
|
|
|
|
|
child: AnimatedBuilder(
|
|
|
|
|
|
animation: blinkAnimation,
|
|
|
|
|
|
builder: (context, _) {
|
|
|
|
|
|
final borderColor = shouldBlink
|
|
|
|
|
|
? colors.primary.withValues(
|
|
|
|
|
|
alpha: 0.3 + blinkAnimation.value * 0.7,
|
|
|
|
|
|
)
|
|
|
|
|
|
: (enabled ? colors.primary : colors.outline);
|
|
|
|
|
|
return OutlinedButton(
|
|
|
|
|
|
style: OutlinedButton.styleFrom(
|
|
|
|
|
|
minimumSize: const Size.fromHeight(52),
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: AppSpacing.sm,
|
|
|
|
|
|
),
|
|
|
|
|
|
side: BorderSide(
|
|
|
|
|
|
color: borderColor,
|
|
|
|
|
|
width: shouldBlink ? 2 : 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
|
onNeedTip();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_showOptionsDialog(context, yaoIndex, onSelect);
|
|
|
|
|
|
},
|
|
|
|
|
|
child: YaoLineRow(
|
|
|
|
|
|
name: rowNames[i],
|
|
|
|
|
|
type: current ?? YaoType.undetermined,
|
|
|
|
|
|
showChangeMark: true,
|
|
|
|
|
|
enabled: enabled,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
const Align(alignment: Alignment.centerLeft, child: YaoLegend()),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _showOptionsDialog(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
int yaoIndex,
|
|
|
|
|
|
void Function(int, YaoType) onSelect,
|
|
|
|
|
|
) {
|
|
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
2026-04-03 19:04:46 +08:00
|
|
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
|
|
final options = <(String, YaoType, String)>[
|
2026-04-03 16:56:47 +08:00
|
|
|
|
(
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'${DivinationTerms.yaoTypeLabels[YaoTypeLabel.youngYang]}(${DivinationTerms.youngYangSymbol})',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
YaoType.youngYang,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'字字字',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
(
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'${DivinationTerms.yaoTypeLabels[YaoTypeLabel.youngYin]}(${DivinationTerms.youngYinSymbol})',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
YaoType.youngYin,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'花花花',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
(
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYang]}(${DivinationTerms.oldYangSymbol})',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
YaoType.oldYang,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'字字字',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
(
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYin]}(${DivinationTerms.oldYinSymbol})',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
YaoType.oldYin,
|
2026-04-03 19:04:46 +08:00
|
|
|
|
'花花花',
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
];
|
|
|
|
|
|
return showDialog<void>(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (context) {
|
2026-04-03 19:04:46 +08:00
|
|
|
|
return Dialog(
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
l10n.manualSelectYaoTitle,
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
|
|
|
|
color: colors.primary,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
2026-04-03 19:04:46 +08:00
|
|
|
|
IconButton(
|
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
|
icon: const Icon(Icons.close),
|
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
...options.map((option) {
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(bottom: AppSpacing.sm),
|
|
|
|
|
|
child: _YaoOptionCard(
|
|
|
|
|
|
label: option.$1,
|
|
|
|
|
|
pattern: option.$3,
|
|
|
|
|
|
isSelected: false,
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
onSelect(yaoIndex, option.$2);
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.md),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: colors.surfaceContainerHighest,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
l10n.coinFaceGuideTitle,
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleSmall
|
|
|
|
|
|
?.copyWith(
|
|
|
|
|
|
color: colors.onSurface,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
ClipRRect(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
|
'assets/images/qigua/zihua.jpg',
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
height: 120,
|
|
|
|
|
|
fit: BoxFit.contain,
|
2026-04-07 12:30:12 +08:00
|
|
|
|
errorBuilder: (context, error, stackTrace) =>
|
|
|
|
|
|
Container(
|
|
|
|
|
|
height: 120,
|
|
|
|
|
|
color: colors.errorContainer,
|
|
|
|
|
|
child: Center(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
l10n.divinationClose,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: colors.onErrorContainer,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-04-03 19:04:46 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
l10n.coinFaceGuideDescription,
|
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall
|
|
|
|
|
|
?.copyWith(color: colors.onSurfaceVariant),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-04-03 19:04:46 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-04-03 16:56:47 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-03 19:04:46 +08:00
|
|
|
|
|
|
|
|
|
|
class _YaoOptionCard extends StatelessWidget {
|
|
|
|
|
|
const _YaoOptionCard({
|
|
|
|
|
|
required this.label,
|
|
|
|
|
|
required this.pattern,
|
|
|
|
|
|
required this.isSelected,
|
|
|
|
|
|
required this.onTap,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
|
|
final String pattern;
|
|
|
|
|
|
final bool isSelected;
|
|
|
|
|
|
final VoidCallback onTap;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final colors = Theme.of(context).colorScheme;
|
|
|
|
|
|
return Material(
|
|
|
|
|
|
color: isSelected ? colors.primaryContainer : colors.surface,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: AppSpacing.md,
|
|
|
|
|
|
vertical: AppSpacing.sm + 4,
|
|
|
|
|
|
),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
border: Border.all(
|
|
|
|
|
|
color: isSelected ? colors.primary : colors.outlineVariant,
|
|
|
|
|
|
width: isSelected ? 2 : 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
label,
|
|
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
|
|
|
|
color: isSelected
|
|
|
|
|
|
? colors.onPrimaryContainer
|
|
|
|
|
|
: colors.onSurface,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 2),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
pattern,
|
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
|
|
|
|
color: isSelected
|
|
|
|
|
|
? colors.onPrimaryContainer.withValues(alpha: 0.7)
|
|
|
|
|
|
: colors.onSurfaceVariant,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
Icons.chevron_right,
|
|
|
|
|
|
color: isSelected
|
|
|
|
|
|
? colors.onPrimaryContainer
|
|
|
|
|
|
: colors.onSurfaceVariant,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|