67 lines
1.9 KiB
Dart
67 lines
1.9 KiB
Dart
/// Host that swaps practice stages from [ValuesSortController].
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../providers/values_sort_provider.dart';
|
|
import 'card_sorting_screen.dart';
|
|
import 'pile_review_screen.dart';
|
|
import 'practice_hub_screen.dart';
|
|
import 'rank_order_screen.dart';
|
|
import 'reflection_screen.dart';
|
|
import 'sorted_overview_screen.dart';
|
|
import 'welcome_screen.dart';
|
|
|
|
class PracticeFlowScreen extends StatelessWidget {
|
|
const PracticeFlowScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final sort = context.watch<ValuesSortController>();
|
|
|
|
if (sort.loading) {
|
|
return const Scaffold(
|
|
body: Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
|
|
if (sort.error != null) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text('Could not load the values deck.\n${sort.error}'),
|
|
const SizedBox(height: 12),
|
|
FilledButton(
|
|
onPressed: sort.load,
|
|
child: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
return AnimatedSwitcher(
|
|
duration: const Duration(milliseconds: 320),
|
|
child: KeyedSubtree(
|
|
key: ValueKey(sort.stage),
|
|
child: switch (sort.stage) {
|
|
SortStage.welcome => const WelcomeScreen(),
|
|
SortStage.sorting => const CardSortingScreen(),
|
|
SortStage.hub => const PracticeHubScreen(),
|
|
SortStage.overview => const SortedOverviewScreen(),
|
|
SortStage.pileReview => const PileReviewScreen(),
|
|
SortStage.ranking => const RankOrderScreen(),
|
|
SortStage.reflection => const ReflectionScreen(),
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|