8fb82d473d
Lets multiple stacked HorizontalScrollRow instances render under a single visible heading by passing title: "" to the second-row-onward instances. Combined with the existing shared-controller support, this gives us multi-row scrollers without a new widget. Used in the next commit's home rewrite for Recently added (2 rows) and Most played (3 rows). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../theme/theme_extension.dart';
|
|
|
|
/// Mirrors the web HorizontalScrollRow: a labeled section that scrolls
|
|
/// horizontally. Multi-row sections share one [controller] so they
|
|
/// scroll together.
|
|
class HorizontalScrollRow extends StatelessWidget {
|
|
const HorizontalScrollRow({
|
|
required this.title,
|
|
required this.children,
|
|
this.height = 200,
|
|
this.controller,
|
|
super.key,
|
|
});
|
|
|
|
final String title;
|
|
final List<Widget> children;
|
|
final double height;
|
|
final ScrollController? controller;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final fs = Theme.of(context).extension<FabledSwordTheme>()!;
|
|
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
if (title.isNotEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
|
child: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontFamily: fs.display.fontFamily,
|
|
fontSize: 18,
|
|
color: fs.parchment,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: height,
|
|
child: ListView(
|
|
controller: controller,
|
|
scrollDirection: Axis.horizontal,
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
children: children,
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
}
|