-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:lyric/data/cue/slide.dart'; | ||
import 'package:lyric/services/cue/from_id.dart'; | ||
import 'package:lyric/ui/common/error.dart'; | ||
|
||
class CuePage extends ConsumerStatefulWidget { | ||
const CuePage(this.cueId, {super.key}); | ||
|
||
final int cueId; | ||
|
||
@override | ||
ConsumerState<CuePage> createState() => _CuePageState(); | ||
} | ||
|
||
class _CuePageState extends ConsumerState<CuePage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
final cue = ref.watch(revivedCueFromIdProvider(widget.cueId)); | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(cue.value?.title ?? ''), | ||
), | ||
body: switch (cue) { | ||
AsyncError(:final error, :final stackTrace) => LErrorCard( | ||
type: LErrorType.error, | ||
title: 'Nem sikerült betölteni a listát!', | ||
icon: Icons.error, | ||
message: error.toString(), | ||
stack: stackTrace.toString(), | ||
), | ||
AsyncLoading() => Center( | ||
child: CircularProgressIndicator(), | ||
), | ||
AsyncValue(:final value!) => ListView( | ||
children: value.slides!.map((e) => CueSlideTile(e)).toList(), | ||
) | ||
}); | ||
} | ||
} | ||
|
||
class CueSlideTile extends StatelessWidget { | ||
const CueSlideTile(this.slide, {super.key}); | ||
|
||
final Slide slide; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ListTile( | ||
title: Text(slide.getPreview()), | ||
); | ||
} | ||
} |