docs: 更新协议文档,删除废弃计划文档
- 更新 http-error-codes, user-points-chat-data-protocol - 更新 divination-run-protocol, profile-protocol - 删除废弃的后端和前端设计计划文档
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../theme/design_tokens.dart';
|
||||
|
||||
class DivinationSummaryTagData {
|
||||
const DivinationSummaryTagData({
|
||||
required this.label,
|
||||
required this.background,
|
||||
required this.foreground,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Color background;
|
||||
final Color foreground;
|
||||
}
|
||||
|
||||
class DivinationSummaryCard extends StatelessWidget {
|
||||
const DivinationSummaryCard({
|
||||
super.key,
|
||||
required this.question,
|
||||
required this.leading,
|
||||
required this.tags,
|
||||
this.leadingBackgroundColor,
|
||||
this.onTap,
|
||||
this.questionMaxLines = 1,
|
||||
});
|
||||
|
||||
final String question;
|
||||
final Widget leading;
|
||||
final List<DivinationSummaryTagData> tags;
|
||||
final Color? leadingBackgroundColor;
|
||||
final VoidCallback? onTap;
|
||||
final int questionMaxLines;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final card = 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: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
leadingBackgroundColor ??
|
||||
colors.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Center(child: leading),
|
||||
),
|
||||
const SizedBox(width: AppSpacing.md),
|
||||
Expanded(
|
||||
child: Text(
|
||||
question,
|
||||
maxLines: questionMaxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (tags.isNotEmpty) ...[
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
Wrap(
|
||||
spacing: AppSpacing.sm,
|
||||
runSpacing: AppSpacing.sm,
|
||||
children: tags
|
||||
.map(
|
||||
(tag) => _DivinationSummaryTag(
|
||||
label: tag.label,
|
||||
background: tag.background,
|
||||
foreground: tag.foreground,
|
||||
),
|
||||
)
|
||||
.toList(growable: false),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (onTap == null) {
|
||||
return SizedBox(width: double.infinity, child: card);
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Material(
|
||||
color: colors.surface.withValues(alpha: 0),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
onTap: onTap,
|
||||
child: card,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DivinationSummaryTag extends StatelessWidget {
|
||||
const _DivinationSummaryTag({
|
||||
required this.label,
|
||||
required this.background,
|
||||
required this.foreground,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Color background;
|
||||
final Color foreground;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppSpacing.sm,
|
||||
vertical: AppSpacing.xs,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: foreground),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../features/divination/data/models/divination_params.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
abstract final class DivinationTerms {
|
||||
static const yaoNames = ['初爻', '二爻', '三爻', '四爻', '五爻', '上爻'];
|
||||
@@ -45,6 +46,32 @@ abstract final class DivinationTerms {
|
||||
static const yaoXiang = '爻象';
|
||||
static const qiGua = '起卦';
|
||||
static const jieGua = '解卦';
|
||||
|
||||
static String yaoName(AppLocalizations l10n, int index) {
|
||||
return switch (index) {
|
||||
0 => l10n.yaoNameFirst,
|
||||
1 => l10n.yaoNameSecond,
|
||||
2 => l10n.yaoNameThird,
|
||||
3 => l10n.yaoNameFourth,
|
||||
4 => l10n.yaoNameFifth,
|
||||
5 => l10n.yaoNameTop,
|
||||
_ => '',
|
||||
};
|
||||
}
|
||||
|
||||
static String yinYangLabel(AppLocalizations l10n, bool isYang) {
|
||||
return isYang ? l10n.yaoYang : l10n.yaoYin;
|
||||
}
|
||||
|
||||
static String yaoTypeLabel(AppLocalizations l10n, YaoType type) {
|
||||
return switch (type) {
|
||||
YaoType.youngYang => l10n.yaoYoungYang,
|
||||
YaoType.youngYin => l10n.yaoYoungYin,
|
||||
YaoType.oldYang => l10n.yaoOldYang,
|
||||
YaoType.oldYin => l10n.yaoOldYin,
|
||||
YaoType.undetermined => '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
enum YaoTypeLabel { youngYang, youngYin, oldYang, oldYin }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../features/divination/data/models/divination_params.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../theme/design_tokens.dart';
|
||||
import 'divination_terms.dart';
|
||||
|
||||
@@ -8,6 +10,7 @@ class YaoLegend extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final style = Theme.of(context).textTheme.bodySmall;
|
||||
final mutedTextColor = Theme.of(
|
||||
context,
|
||||
@@ -17,19 +20,19 @@ class YaoLegend extends StatelessWidget {
|
||||
runSpacing: AppSpacing.xs,
|
||||
children: [
|
||||
Text(
|
||||
'\u2014 ${DivinationTerms.yinYang[true]}',
|
||||
'\u2014 ${DivinationTerms.yinYangLabel(l10n, true)}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'-- ${DivinationTerms.yinYang[false]}',
|
||||
'-- ${DivinationTerms.yinYangLabel(l10n, false)}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'${DivinationTerms.changeMarkOldYang} ${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYang]}(变)',
|
||||
'${DivinationTerms.changeMarkOldYang} ${DivinationTerms.yaoTypeLabel(l10n, YaoType.oldYang)}${l10n.yaoMovingSuffix}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
Text(
|
||||
'${DivinationTerms.changeMarkOldYin} ${DivinationTerms.yaoTypeLabels[YaoTypeLabel.oldYin]}(变)',
|
||||
'${DivinationTerms.changeMarkOldYin} ${DivinationTerms.yaoTypeLabel(l10n, YaoType.oldYin)}${l10n.yaoMovingSuffix}',
|
||||
style: style?.copyWith(color: mutedTextColor),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user