refactor(divination): 优化占卜界面和组件
- 更新占卜处理和结果页面 - 优化占卜共享组件
This commit is contained in:
@@ -149,7 +149,7 @@ class _DivinationProcessingScreenState extends State<DivinationProcessingScreen>
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pushReplacement(
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => DivinationResultScreen(
|
||||
data: data,
|
||||
@@ -157,6 +157,7 @@ class _DivinationProcessingScreenState extends State<DivinationProcessingScreen>
|
||||
enableIntroTransition: true,
|
||||
),
|
||||
),
|
||||
(route) => route.isFirst,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,12 +170,7 @@ class _DivinationResultScreenState extends State<DivinationResultScreen> {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return PopScope<void>(
|
||||
canPop: true,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) {
|
||||
return;
|
||||
}
|
||||
_backToHome();
|
||||
},
|
||||
onPopInvokedWithResult: (didPop, result) {},
|
||||
child: Scaffold(
|
||||
backgroundColor: colors.surface,
|
||||
appBar: AppBar(
|
||||
|
||||
@@ -96,6 +96,8 @@ class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
final PageController _pageController = PageController();
|
||||
int _currentPage = 0;
|
||||
|
||||
bool get _isLastPage => _currentPage == widget.guideImages.length - 1;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController.dispose();
|
||||
@@ -105,6 +107,8 @@ class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final swipeHint = _guideSwipeHint(Localizations.localeOf(context));
|
||||
return Dialog(
|
||||
child: SizedBox(
|
||||
width: 360,
|
||||
@@ -139,6 +143,10 @@ class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
child: Text(
|
||||
widget.instructions[_currentPage],
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colors.onSurfaceVariant,
|
||||
height: 1.45,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
@@ -151,8 +159,14 @@ class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(l10n.divinationIAcknowledge),
|
||||
onPressed: _isLastPage
|
||||
? () => Navigator.of(context).pop()
|
||||
: null,
|
||||
child: Text(
|
||||
_isLastPage
|
||||
? l10n.divinationIAcknowledge
|
||||
: '${_currentPage + 1} / ${widget.guideImages.length} · $swipeHint',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -161,4 +175,11 @@ class _DivinationGuideDialogState extends State<DivinationGuideDialog> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _guideSwipeHint(Locale locale) {
|
||||
if (locale.languageCode == 'en') {
|
||||
return 'Swipe left for the next step';
|
||||
}
|
||||
return '左滑查看下一步';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user