Skip to content

Commit

Permalink
cue page
Browse files Browse the repository at this point in the history
  • Loading branch information
RedyAu committed Nov 23, 2024
1 parent 375510b commit 199fde3
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions lib/ui/cue/page.dart
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()),
);
}
}

0 comments on commit 199fde3

Please sign in to comment.