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