mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-16 10:46:00 -07:00
feat: Android TV support (#503)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
7ab8c015b9
commit
c299492d6d
168 changed files with 12019 additions and 3073 deletions
|
|
@ -3,53 +3,56 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
import 'package:fladder/providers/arguments_provider.dart';
|
||||
import 'package:fladder/screens/shared/media/poster_widget.dart';
|
||||
import 'package:fladder/util/focus_provider.dart';
|
||||
import 'package:fladder/util/item_base_model/item_base_model_extensions.dart';
|
||||
import 'package:fladder/widgets/shared/ensure_visible.dart';
|
||||
import 'package:fladder/widgets/shared/horizontal_list.dart';
|
||||
|
||||
class PosterRow extends ConsumerStatefulWidget {
|
||||
class PosterRow extends ConsumerWidget {
|
||||
final List<ItemBaseModel> posters;
|
||||
final String label;
|
||||
final double? collectionAspectRatio;
|
||||
final Function()? onLabelClick;
|
||||
final EdgeInsets contentPadding;
|
||||
final Function(ItemBaseModel focused)? onFocused;
|
||||
final bool primaryPosters;
|
||||
const PosterRow({
|
||||
required this.posters,
|
||||
this.contentPadding = const EdgeInsets.symmetric(horizontal: 16),
|
||||
required this.label,
|
||||
this.collectionAspectRatio,
|
||||
this.onLabelClick,
|
||||
this.onFocused,
|
||||
this.primaryPosters = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() => _PosterRowState();
|
||||
}
|
||||
|
||||
class _PosterRowState extends ConsumerState<PosterRow> {
|
||||
late final controller = ScrollController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dominantRatio = widget.collectionAspectRatio ?? widget.posters.getMostCommonType.aspectRatio;
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final dominantRatio = primaryPosters ? 1.2 : collectionAspectRatio ?? posters.getMostCommonType.aspectRatio;
|
||||
return HorizontalList(
|
||||
contentPadding: widget.contentPadding,
|
||||
label: widget.label,
|
||||
onLabelClick: widget.onLabelClick,
|
||||
contentPadding: contentPadding,
|
||||
label: label,
|
||||
autoFocus: ref.read(argumentsStateProvider).htpcMode ? FocusProvider.autoFocusOf(context) : false,
|
||||
onLabelClick: onLabelClick,
|
||||
dominantRatio: dominantRatio,
|
||||
items: widget.posters,
|
||||
itemBuilder: (context, index) {
|
||||
final poster = widget.posters[index];
|
||||
items: posters,
|
||||
onFocused: (index) {
|
||||
if (onFocused != null) {
|
||||
onFocused?.call(posters[index]);
|
||||
} else {
|
||||
context.ensureVisible();
|
||||
}
|
||||
},
|
||||
itemBuilder: (context, index, selected) {
|
||||
final poster = posters[index];
|
||||
return PosterWidget(
|
||||
key: Key(poster.id),
|
||||
poster: poster,
|
||||
aspectRatio: dominantRatio,
|
||||
key: Key(poster.id),
|
||||
primaryPosters: primaryPosters,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue