2024-10-07 13:08:27 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:lightmeter/generated/l10n.dart';
|
2024-10-21 09:40:11 +00:00
|
|
|
import 'package:lightmeter/providers/films_provider.dart';
|
2024-10-24 10:09:27 +00:00
|
|
|
import 'package:lightmeter/res/dimens.dart';
|
2024-10-07 13:08:27 +00:00
|
|
|
import 'package:lightmeter/screens/settings/components/shared/expandable_section_list/widget_expandable_section_list.dart';
|
|
|
|
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
|
|
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|
|
|
|
|
|
|
class FilmsScreen extends StatefulWidget {
|
|
|
|
const FilmsScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<FilmsScreen> createState() => _FilmsScreenState();
|
|
|
|
}
|
|
|
|
|
2024-10-24 10:09:27 +00:00
|
|
|
class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStateMixin {
|
|
|
|
late final tabController = TabController(length: 2, vsync: this);
|
|
|
|
|
2024-10-07 13:08:27 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SliverScreen(
|
2024-10-24 10:09:27 +00:00
|
|
|
title: Text(S.of(context).films),
|
|
|
|
bottom: TabBar(
|
|
|
|
controller: tabController,
|
|
|
|
tabs: [
|
|
|
|
Tab(text: S.of(context).filmsInUse),
|
|
|
|
Tab(text: S.of(context).filmsCustom),
|
|
|
|
],
|
|
|
|
),
|
2024-10-07 13:08:27 +00:00
|
|
|
appBarActions: [
|
|
|
|
IconButton(
|
2024-10-21 09:40:11 +00:00
|
|
|
onPressed: _addFilm,
|
2024-10-07 13:08:27 +00:00
|
|
|
icon: const Icon(Icons.add_outlined),
|
|
|
|
tooltip: S.of(context).tooltipAdd,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
slivers: [
|
2024-10-24 10:09:27 +00:00
|
|
|
SliverFillRemaining(
|
|
|
|
// The inner (body) scroll view must use this scroll controller so that
|
|
|
|
// the independent scroll positions can be kept in sync.
|
|
|
|
child: TabBarView(
|
|
|
|
controller: tabController,
|
|
|
|
children: [
|
|
|
|
_FilmsListBuilder(
|
|
|
|
films: Films.of(context).skip(1).toList(),
|
|
|
|
onFilmSelected: (film, value) {},
|
|
|
|
),
|
|
|
|
_FilmsListBuilder(
|
|
|
|
films: Films.of(context).skip(1).toList(),
|
|
|
|
onFilmSelected: (film, value) {},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-10-07 13:08:27 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2024-10-21 09:40:11 +00:00
|
|
|
|
2024-10-24 10:09:27 +00:00
|
|
|
void _addFilm([EquipmentProfile? copyFrom]) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FilmsListBuilder extends StatelessWidget {
|
|
|
|
final List<Film> films;
|
|
|
|
final void Function(Film film, bool value) onFilmSelected;
|
|
|
|
final void Function()? onFilmEdit;
|
|
|
|
|
|
|
|
const _FilmsListBuilder({
|
|
|
|
required this.films,
|
|
|
|
required this.onFilmSelected,
|
|
|
|
this.onFilmEdit,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListView.builder(
|
|
|
|
padding: const EdgeInsets.all(Dimens.paddingM).add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom)),
|
|
|
|
itemCount: films.length,
|
|
|
|
itemBuilder: (_, index) => Card(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: index == 0 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
|
|
|
topRight: index == 0 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
|
|
|
bottomLeft: index == films.length - 1 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
|
|
|
bottomRight: index == films.length - 1 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: index == 0 ? Dimens.paddingM : 0.0,
|
|
|
|
bottom: index == films.length - 1 ? Dimens.paddingM : 0.0,
|
|
|
|
),
|
|
|
|
child: CheckboxListTile(
|
|
|
|
controlAffinity: ListTileControlAffinity.leading,
|
|
|
|
value: Films.inUseOf(context).contains(films[index]),
|
|
|
|
title: Text(films[index].name),
|
|
|
|
onChanged: (value) {
|
|
|
|
onFilmSelected(films[index], value ?? false);
|
|
|
|
},
|
|
|
|
secondary: onFilmEdit != null
|
|
|
|
? IconButton(
|
|
|
|
onPressed: onFilmEdit,
|
|
|
|
icon: const Icon(Icons.edit),
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2024-10-21 09:40:11 +00:00
|
|
|
}
|
2024-10-07 13:08:27 +00:00
|
|
|
}
|