Skip to content

Commit 47a3c1e

Browse files
committed
feat: show appbar while loading when coming from link
1 parent eeb6cd4 commit 47a3c1e

File tree

7 files changed

+176
-114
lines changed

7 files changed

+176
-114
lines changed

lib/Screens/circuit.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,14 @@ class CircuitScreen extends StatelessWidget {
240240
isFromRaceHub: true,
241241
),
242242
builder: (context, snapshot) => snapshot.hasError
243-
? RequestErrorWidget(
244-
snapshot.error.toString(),
243+
? Scaffold(
244+
appBar: AppBar(
245+
backgroundColor:
246+
Theme.of(context).colorScheme.onPrimary,
247+
),
248+
body: RequestErrorWidget(
249+
snapshot.error.toString(),
250+
),
245251
)
246252
: snapshot.hasData
247253
? NestedScrollView(
@@ -372,7 +378,13 @@ class CircuitScreen extends StatelessWidget {
372378
),
373379
),
374380
)
375-
: LoadingIndicatorUtil(),
381+
: Scaffold(
382+
appBar: AppBar(
383+
backgroundColor:
384+
Theme.of(context).colorScheme.onPrimary,
385+
),
386+
body: LoadingIndicatorUtil(),
387+
),
376388
),
377389
);
378390
}

lib/Screens/driver_details.dart

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -498,49 +498,57 @@ class DriverDetailsFromIdScreen extends StatelessWidget {
498498

499499
@override
500500
Widget build(BuildContext context) {
501-
return Scaffold(
502-
body: FutureBuilder(
503-
future: FormulaOneScraper().scrapeDriversDetails('', detailsPath),
504-
builder: (context, snapshot) {
505-
if (snapshot.hasError) {
506-
return RequestErrorWidget(
501+
return FutureBuilder(
502+
future: FormulaOneScraper().scrapeDriversDetails('', detailsPath),
503+
builder: (context, snapshot) {
504+
if (snapshot.hasError) {
505+
return Scaffold(
506+
appBar: AppBar(
507+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
508+
),
509+
body: RequestErrorWidget(
507510
snapshot.error.toString(),
508-
);
509-
} else if (snapshot.hasData) {
510-
List driverName = snapshot.data![4][0].split(' ');
511-
driverName.last = driverName.last.toString().toUpperCase();
512-
return Scaffold(
513-
appBar: AppBar(
514-
title: Text(
515-
driverName.join(' '),
516-
style: const TextStyle(
517-
fontWeight: FontWeight.w600,
518-
),
511+
),
512+
);
513+
} else if (snapshot.hasData) {
514+
List driverName = snapshot.data![4][0].split(' ');
515+
driverName.last = driverName.last.toString().toUpperCase();
516+
return Scaffold(
517+
appBar: AppBar(
518+
title: Text(
519+
driverName.join(' '),
520+
style: const TextStyle(
521+
fontWeight: FontWeight.w600,
519522
),
520-
backgroundColor: Theme.of(context).colorScheme.onPrimary,
521523
),
522-
body: SingleChildScrollView(
523-
child: Column(
524-
crossAxisAlignment: CrossAxisAlignment.center,
525-
mainAxisAlignment: MainAxisAlignment.center,
526-
children: [
527-
Center(
528-
child: DriverImageProvider(detailsPath, 'driver'),
529-
),
530-
DriverDetailsFragment(
531-
snapshot.data!,
532-
)
533-
],
534-
),
524+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
525+
),
526+
body: SingleChildScrollView(
527+
child: Column(
528+
crossAxisAlignment: CrossAxisAlignment.center,
529+
mainAxisAlignment: MainAxisAlignment.center,
530+
children: [
531+
Center(
532+
child: DriverImageProvider(detailsPath, 'driver'),
533+
),
534+
DriverDetailsFragment(
535+
snapshot.data!,
536+
)
537+
],
535538
),
536-
);
537-
} else {
538-
return const Center(
539+
),
540+
);
541+
} else {
542+
return Scaffold(
543+
appBar: AppBar(
544+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
545+
),
546+
body: Center(
539547
child: LoadingIndicatorUtil(),
540-
);
541-
}
542-
},
543-
),
548+
),
549+
);
550+
}
551+
},
544552
);
545553
}
546554
}

lib/Screens/free_practice_screen.dart

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -465,25 +465,33 @@ class FreePracticeFromMeetingKeyScreen extends StatelessWidget {
465465
AppLocalizations.of(context)!.freePracticeThree,
466466
];
467467

468-
return Scaffold(
469-
body: FutureBuilder(
470-
future: EventTracker().getCircuitDetails(
471-
meetingKey,
472-
isFromRaceHub: true,
473-
),
474-
builder: (context, snapshot) => snapshot.hasError
475-
? RequestErrorWidget(snapshot.error.toString())
476-
: snapshot.hasData
477-
? FreePracticeScreen(
478-
sessionsTitle[sessionIndex - 1],
479-
sessionIndex,
480-
'',
481-
meetingKey,
482-
int.parse(snapshot.data!['meetingContext']['season']),
483-
snapshot.data!['race']['meetingOfficialName'],
484-
)
485-
: LoadingIndicatorUtil(),
468+
return FutureBuilder(
469+
future: EventTracker().getCircuitDetails(
470+
meetingKey,
471+
isFromRaceHub: true,
486472
),
473+
builder: (context, snapshot) => snapshot.hasError
474+
? Scaffold(
475+
appBar: AppBar(
476+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
477+
),
478+
body: RequestErrorWidget(snapshot.error.toString()),
479+
)
480+
: snapshot.hasData
481+
? FreePracticeScreen(
482+
sessionsTitle[sessionIndex - 1],
483+
sessionIndex,
484+
'',
485+
meetingKey,
486+
int.parse(snapshot.data!['meetingContext']['season']),
487+
snapshot.data!['race']['meetingOfficialName'],
488+
)
489+
: Scaffold(
490+
appBar: AppBar(
491+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
492+
),
493+
body: LoadingIndicatorUtil(),
494+
),
487495
);
488496
}
489497
}

lib/Screens/race_details.dart

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -349,23 +349,31 @@ class RaceDetailsFromIdScreen extends StatelessWidget {
349349

350350
@override
351351
Widget build(BuildContext context) {
352-
return Scaffold(
353-
body: FutureBuilder(
354-
future: EventTracker().getCircuitDetails(
355-
meetingId,
356-
isFromRaceHub: true,
357-
),
358-
builder: (context, snapshot) => snapshot.hasError
359-
? RequestErrorWidget(snapshot.error.toString())
360-
: snapshot.hasData
361-
? RaceDetailsScreen(
362-
snapshot.data!['raceCustomBBParameter'],
363-
snapshot.data!['meetingContext']['timetables'][2]
364-
['session'] ==
365-
's',
366-
)
367-
: LoadingIndicatorUtil(),
352+
return FutureBuilder(
353+
future: EventTracker().getCircuitDetails(
354+
meetingId,
355+
isFromRaceHub: true,
368356
),
357+
builder: (context, snapshot) => snapshot.hasError
358+
? Scaffold(
359+
appBar: AppBar(
360+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
361+
),
362+
body: RequestErrorWidget(snapshot.error.toString()),
363+
)
364+
: snapshot.hasData
365+
? RaceDetailsScreen(
366+
snapshot.data!['raceCustomBBParameter'],
367+
snapshot.data!['meetingContext']['timetables'][2]
368+
['session'] ==
369+
's',
370+
)
371+
: Scaffold(
372+
appBar: AppBar(
373+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
374+
),
375+
body: LoadingIndicatorUtil(),
376+
),
369377
);
370378
}
371379
}

lib/Screens/racehub.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,23 @@ class RaceHubWithoutEventScreen extends StatelessWidget {
176176

177177
@override
178178
Widget build(BuildContext context) {
179-
return Scaffold(
180-
body: FutureBuilder(
181-
future: EventTracker().parseEvent(),
182-
builder: (context, snapshot) => snapshot.hasError
183-
? RequestErrorWidget(snapshot.error.toString())
184-
: snapshot.hasData
185-
? RaceHubScreen(snapshot.data!)
186-
: LoadingIndicatorUtil(),
187-
),
179+
return FutureBuilder(
180+
future: EventTracker().parseEvent(),
181+
builder: (context, snapshot) => snapshot.hasError
182+
? Scaffold(
183+
appBar: AppBar(
184+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
185+
),
186+
body: RequestErrorWidget(snapshot.error.toString()),
187+
)
188+
: snapshot.hasData
189+
? RaceHubScreen(snapshot.data!)
190+
: Scaffold(
191+
appBar: AppBar(
192+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
193+
),
194+
body: LoadingIndicatorUtil(),
195+
),
188196
);
189197
}
190198
}

lib/Screens/team_details.dart

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -539,30 +539,38 @@ class TeamDetailsFromIdScreen extends StatelessWidget {
539539

540540
@override
541541
Widget build(BuildContext context) {
542-
return Scaffold(
543-
body: FutureBuilder(
544-
future: FormulaOneScraper().scrapeTeamDetails('', detailsPath),
545-
builder: (context, snapshot) => snapshot.hasError
546-
? RequestErrorWidget(
542+
return FutureBuilder(
543+
future: FormulaOneScraper().scrapeTeamDetails('', detailsPath),
544+
builder: (context, snapshot) => snapshot.hasError
545+
? Scaffold(
546+
appBar: AppBar(
547+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
548+
),
549+
body: RequestErrorWidget(
547550
snapshot.error.toString(),
548-
)
549-
: snapshot.hasData
550-
? Scaffold(
551-
appBar: AppBar(
552-
title: Text(
553-
snapshot.data!["teamName"],
554-
style: const TextStyle(
555-
fontWeight: FontWeight.w600,
556-
),
551+
),
552+
)
553+
: snapshot.hasData
554+
? Scaffold(
555+
appBar: AppBar(
556+
title: Text(
557+
snapshot.data!["teamName"],
558+
style: const TextStyle(
559+
fontWeight: FontWeight.w600,
557560
),
558-
backgroundColor: Theme.of(context).colorScheme.onPrimary,
559561
),
560-
body: TeamDetailsFragment(snapshot.data!),
561-
)
562-
: const Center(
562+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
563+
),
564+
body: TeamDetailsFragment(snapshot.data!),
565+
)
566+
: Scaffold(
567+
appBar: AppBar(
568+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
569+
),
570+
body: Center(
563571
child: LoadingIndicatorUtil(),
564572
),
565-
),
573+
),
566574
);
567575
}
568576
}

lib/Screens/video.dart

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,29 @@ class VideoScreenFromId extends StatefulWidget {
304304
class _VideoScreenFromIdState extends State<VideoScreenFromId> {
305305
@override
306306
Widget build(BuildContext context) {
307-
return Scaffold(
308-
body: FutureBuilder<Video>(
309-
future: F1VideosFetcher().getVideoDetails(widget.videoId),
310-
builder: (context, snapshot) => snapshot.hasError
311-
? RequestErrorWidget(
312-
snapshot.error.toString(),
313-
)
314-
: snapshot.hasData
315-
? VideoScreen(snapshot.data!)
316-
: const Center(
307+
return FutureBuilder<Video>(
308+
future: F1VideosFetcher().getVideoDetails(widget.videoId),
309+
builder: (context, snapshot) => snapshot.hasError
310+
? Scaffold(
311+
appBar: AppBar(
312+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
313+
),
314+
body: Center(
315+
child: RequestErrorWidget(
316+
snapshot.error.toString(),
317+
),
318+
),
319+
)
320+
: snapshot.hasData
321+
? VideoScreen(snapshot.data!)
322+
: Scaffold(
323+
appBar: AppBar(
324+
backgroundColor: Theme.of(context).colorScheme.onPrimary,
325+
),
326+
body: Center(
317327
child: LoadingIndicatorUtil(),
318328
),
319-
),
329+
),
320330
);
321331
}
322332
}

0 commit comments

Comments
 (0)