@@ -22,9 +22,23 @@ import 'package:lichess_mobile/src/widgets/buttons.dart';
2222import 'package:lichess_mobile/src/widgets/filter.dart' ;
2323import 'package:lichess_mobile/src/widgets/list.dart' ;
2424import 'package:lichess_mobile/src/widgets/platform.dart' ;
25+ import 'package:lichess_mobile/src/widgets/platform_scaffold.dart' ;
2526import 'package:lichess_mobile/src/widgets/settings.dart' ;
2627
27- enum BroadcastRoundTab { overview, boards, players }
28+ enum BroadcastRoundTab {
29+ overview,
30+ boards,
31+ players;
32+
33+ static BroadcastRoundTab ? tabOrNullFromString (String tab) {
34+ return switch (tab) {
35+ 'overview' => BroadcastRoundTab .overview,
36+ 'boards' => BroadcastRoundTab .boards,
37+ 'players' => BroadcastRoundTab .players,
38+ _ => null ,
39+ };
40+ }
41+ }
2842
2943enum _BroadcastGameFilter {
3044 all,
@@ -41,6 +55,49 @@ enum _BroadcastGameFilter {
4155 }
4256}
4357
58+ class BroadcastRoundScreenLoading extends ConsumerWidget {
59+ final BroadcastRoundId roundId;
60+ final BroadcastRoundTab ? initialTab;
61+
62+ const BroadcastRoundScreenLoading ({super .key, required this .roundId, this .initialTab});
63+
64+ static Route <dynamic > buildRoute (
65+ BuildContext context,
66+ BroadcastRoundId roundId, {
67+ BroadcastRoundTab ? initialTab,
68+ }) {
69+ return buildScreenRoute (
70+ context,
71+ screen: BroadcastRoundScreenLoading (roundId: roundId, initialTab: initialTab),
72+ );
73+ }
74+
75+ @override
76+ Widget build (BuildContext context, WidgetRef ref) {
77+ final round = ref.watch (broadcastRoundProvider (roundId));
78+
79+ return switch (round) {
80+ AsyncData (: final value) => BroadcastRoundScreen (
81+ broadcast: Broadcast (
82+ tour: value.tournament,
83+ round: value.round,
84+ group: value.groupName,
85+ roundToLinkId: roundId,
86+ ),
87+ initialTab: initialTab,
88+ ),
89+ AsyncError (: final error) => PlatformScaffold (
90+ appBarTitle: const Text ('' ),
91+ body: Center (child: Text ('Cannot load round data: $error ' )),
92+ ),
93+ _ => const PlatformScaffold (
94+ appBarTitle: Text ('' ),
95+ body: Center (child: CircularProgressIndicator .adaptive ()),
96+ ),
97+ };
98+ }
99+ }
100+
44101class BroadcastRoundScreen extends ConsumerStatefulWidget {
45102 final Broadcast broadcast;
46103 final BroadcastRoundTab ? initialTab;
0 commit comments