Fladder/lib/screens/dashboard/top_posters_row.dart
PartyDonut d572884e61
feature: Add new home carousel (#58)
## Pull Request Description

This adds a new home carousel better suited for mobile
The old one is still available

## Checklist

- [x] If a new package was added, did you ensure it works for all
supported platforms? Is the package also well maintained?
- [x] Did you add localization for any text? If yes, did you sort the
.arb file using ```arb_utils sort <INPUT_FILE>```?
- [x] Check that any changes are related to the issue at hand.

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
2024-10-21 22:24:59 +02:00

36 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fladder/models/item_base_model.dart';
import 'package:fladder/models/settings/client_settings_model.dart';
import 'package:fladder/providers/settings/client_settings_provider.dart';
import 'package:fladder/screens/shared/media/carousel_banner.dart';
import 'package:fladder/screens/shared/media/media_banner.dart';
class TopPostersRow extends ConsumerWidget {
final List<ItemBaseModel> posters;
const TopPostersRow({required this.posters, super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final bannerType = ref.watch(clientSettingsProvider.select((value) => value.homeBanner));
final maxHeight = (MediaQuery.sizeOf(context).shortestSide * 0.6).clamp(125.0, 350.0);
return switch (bannerType) {
HomeBanner.carousel => Column(
mainAxisSize: MainAxisSize.min,
children: [
CarouselBanner(
items: posters,
maxHeight: maxHeight,
),
const SizedBox(height: 8)
],
),
HomeBanner.banner => MediaBanner(
items: posters,
maxHeight: maxHeight,
)
};
}
}