feat: 实现起卦、设置与积分系统
This commit is contained in:
@@ -78,7 +78,7 @@ class _NavItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final iconColor = selected ? colors.primary : colors.outline;
|
||||
final iconColor = colors.primary;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
@@ -91,9 +91,10 @@ class _NavItem extends StatelessWidget {
|
||||
const SizedBox(height: AppSpacing.xs),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: iconColor),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: iconColor,
|
||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../theme/app_color_palette.dart';
|
||||
import '../../theme/design_tokens.dart';
|
||||
|
||||
class DivinationGuideImage extends StatelessWidget {
|
||||
const DivinationGuideImage({super.key, required this.path});
|
||||
|
||||
final String path;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg),
|
||||
child: Image.asset(path, fit: BoxFit.contain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DivinationInstructionCard extends StatelessWidget {
|
||||
const DivinationInstructionCard({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final palette = Theme.of(context).extension<AppColorPalette>()!;
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(AppSpacing.md),
|
||||
decoration: BoxDecoration(
|
||||
color: palette.warningContainer,
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: palette.warning,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Text(
|
||||
'▶',
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: palette.warning,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DivinationGuideDialog extends StatelessWidget {
|
||||
const DivinationGuideDialog({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.guideImages,
|
||||
required this.instructionText,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final List<String> guideImages;
|
||||
final String instructionText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Dialog(
|
||||
child: SizedBox(
|
||||
width: 360,
|
||||
height: 560,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: AppSpacing.lg),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
Expanded(
|
||||
child: PageView(
|
||||
children: guideImages
|
||||
.map((path) => DivinationGuideImage(path: path))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(AppSpacing.lg),
|
||||
child: Text(instructionText),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
AppSpacing.lg,
|
||||
0,
|
||||
AppSpacing.lg,
|
||||
AppSpacing.lg,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(l10n.divinationIAcknowledge),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import '../../../features/divination/data/models/divination_params.dart';
|
||||
|
||||
abstract final class DivinationTerms {
|
||||
static const yaoNames = ['初爻', '二爻', '三爻', '四爻', '五爻', '上爻'];
|
||||
|
||||
static const yaoTypeLabels = {
|
||||
YaoTypeLabel.youngYang: '少阳',
|
||||
YaoTypeLabel.youngYin: '少阴',
|
||||
YaoTypeLabel.oldYang: '老阳',
|
||||
YaoTypeLabel.oldYin: '老阴',
|
||||
};
|
||||
|
||||
static const yinYang = {true: '阳', false: '阴'};
|
||||
|
||||
static const wuXing = ['木', '火', '土', '金', '水'];
|
||||
|
||||
static const yuanZhi = '元';
|
||||
|
||||
static const changeMarkOldYang = '○';
|
||||
static const changeMarkOldYin = '×';
|
||||
|
||||
static const signBest = '上上签';
|
||||
static const signGood = '中上签';
|
||||
static const signNormal = '中下签';
|
||||
|
||||
static const ganZhi = '干支';
|
||||
static const ganZhiInfo = '干支信息';
|
||||
static const ganZhiKongWang = '干支空亡';
|
||||
static const yueJian = '月建';
|
||||
static const riChen = '日辰';
|
||||
static const yuePo = '月破';
|
||||
static const riChong = '日冲';
|
||||
static const wuXingWangShuai = '五行旺衰';
|
||||
|
||||
static const guaXiang = '卦象';
|
||||
static const yaoXiang = '爻象';
|
||||
static const qiGua = '起卦';
|
||||
static const jieGua = '解卦';
|
||||
}
|
||||
|
||||
enum YaoTypeLabel { youngYang, youngYin, oldYang, oldYin }
|
||||
|
||||
extension YaoTypeLabelX on YaoType {
|
||||
String get label {
|
||||
return switch (this) {
|
||||
YaoType.youngYang =>
|
||||
DivinationTerms.yaoTypeLabels[YaoTypeLabel.youngYang]!,
|
||||
YaoType.youngYin => DivinationTerms.yaoTypeLabels[YaoTypeLabel.youngYin]!,
|
||||
YaoType.oldYang => DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYang]!,
|
||||
YaoType.oldYin => DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYin]!,
|
||||
YaoType.undetermined => '',
|
||||
};
|
||||
}
|
||||
|
||||
String get changeMark {
|
||||
return switch (this) {
|
||||
YaoType.oldYang => DivinationTerms.changeMarkOldYang,
|
||||
YaoType.oldYin => DivinationTerms.changeMarkOldYin,
|
||||
_ => '',
|
||||
};
|
||||
}
|
||||
|
||||
bool get isYang {
|
||||
return switch (this) {
|
||||
YaoType.youngYang || YaoType.oldYang => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../features/divination/data/models/divination_params.dart';
|
||||
import '../../theme/design_tokens.dart';
|
||||
|
||||
class YaoGlyph extends StatelessWidget {
|
||||
const YaoGlyph({super.key, required this.type, this.height = 6});
|
||||
|
||||
final YaoType type;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final lineColor = type == YaoType.undetermined
|
||||
? colors.outline
|
||||
: colors.primary;
|
||||
final isYin = type == YaoType.youngYin || type == YaoType.oldYin;
|
||||
if (!isYin) {
|
||||
return Container(
|
||||
key: const Key('yao_glyph_solid'),
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: lineColor,
|
||||
borderRadius: BorderRadius.circular(height),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
key: const Key('yao_glyph_split_left'),
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: lineColor,
|
||||
borderRadius: BorderRadius.circular(height),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Expanded(
|
||||
child: Container(
|
||||
key: const Key('yao_glyph_split_right'),
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: lineColor,
|
||||
borderRadius: BorderRadius.circular(height),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../theme/design_tokens.dart';
|
||||
import 'divination_terms.dart';
|
||||
|
||||
class YaoLegend extends StatelessWidget {
|
||||
const YaoLegend({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = Theme.of(context).textTheme.bodySmall;
|
||||
final mutedTextColor = Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withValues(alpha: 0.8);
|
||||
return Wrap(
|
||||
spacing: AppSpacing.md,
|
||||
runSpacing: AppSpacing.xs,
|
||||
children: [
|
||||
Text(
|
||||
'\u2014 ${DivinationTerms.yinYang[true]}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'-- ${DivinationTerms.yinYang[false]}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'${DivinationTerms.changeMarkOldYang} ${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYang]}(变)',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'${DivinationTerms.changeMarkOldYin} ${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYin]}(变)',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../features/divination/data/models/divination_params.dart';
|
||||
import '../../theme/design_tokens.dart';
|
||||
import 'divination_terms.dart';
|
||||
import 'yao_glyph.dart';
|
||||
|
||||
class YaoLineRow extends StatelessWidget {
|
||||
const YaoLineRow({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.type,
|
||||
this.showChangeMark = true,
|
||||
this.showName = true,
|
||||
this.onTap,
|
||||
this.enabled = true,
|
||||
this.lineHeight = 6,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final YaoType type;
|
||||
final bool showChangeMark;
|
||||
final bool showName;
|
||||
final VoidCallback? onTap;
|
||||
final bool enabled;
|
||||
final double lineHeight;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mark = showChangeMark ? _changeMark(type) : '';
|
||||
|
||||
return InkWell(
|
||||
onTap: enabled ? onTap : null,
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
child: SizedBox(
|
||||
height: 38,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 48,
|
||||
child: Text(showName ? name : '', textAlign: TextAlign.center),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Expanded(
|
||||
child: YaoGlyph(type: type, height: lineHeight),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20,
|
||||
child: Text(
|
||||
mark,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _changeMark(YaoType type) {
|
||||
return type.changeMark;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user