feat(divination): 重构手动起卦教程,支持三硬币交互选择
This commit is contained in:
@@ -5,15 +5,24 @@ import '../../theme/app_color_palette.dart';
|
||||
import '../../theme/design_tokens.dart';
|
||||
|
||||
class DivinationGuideImage extends StatelessWidget {
|
||||
const DivinationGuideImage({super.key, required this.path});
|
||||
const DivinationGuideImage({super.key, required this.paths});
|
||||
|
||||
final String path;
|
||||
final List<String> paths;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg),
|
||||
child: Image.asset(path, fit: BoxFit.contain),
|
||||
child: paths.length == 1
|
||||
? Image.asset(paths.first, fit: BoxFit.contain)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Expanded(child: Image.asset(paths[0], fit: BoxFit.contain)),
|
||||
const SizedBox(width: AppSpacing.md),
|
||||
Expanded(child: Image.asset(paths[1], fit: BoxFit.contain)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -67,17 +76,31 @@ class DivinationInstructionCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class DivinationGuideDialog extends StatelessWidget {
|
||||
class DivinationGuideDialog extends StatefulWidget {
|
||||
const DivinationGuideDialog({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.guideImages,
|
||||
required this.instructionText,
|
||||
required this.instructions,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final List<String> guideImages;
|
||||
final String instructionText;
|
||||
final List<List<String>> guideImages;
|
||||
final List<String> instructions;
|
||||
|
||||
@override
|
||||
State<DivinationGuideDialog> createState() => _DivinationGuideDialogState();
|
||||
}
|
||||
|
||||
class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
final PageController _pageController = PageController();
|
||||
int _currentPage = 0;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -90,7 +113,7 @@ class DivinationGuideDialog extends StatelessWidget {
|
||||
children: [
|
||||
const SizedBox(height: AppSpacing.lg),
|
||||
Text(
|
||||
title,
|
||||
widget.title,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -98,15 +121,25 @@ class DivinationGuideDialog extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
Expanded(
|
||||
child: PageView(
|
||||
children: guideImages
|
||||
.map((path) => DivinationGuideImage(path: path))
|
||||
.toList(),
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
_currentPage = index;
|
||||
});
|
||||
},
|
||||
itemCount: widget.guideImages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return DivinationGuideImage(paths: widget.guideImages[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(AppSpacing.lg),
|
||||
child: Text(instructionText),
|
||||
child: Text(
|
||||
widget.instructions[_currentPage],
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(
|
||||
|
||||
Reference in New Issue
Block a user