From cc2ab3b68a4e6c1bf009656784fbe4f59ca6d92d Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:40:11 +0200 Subject: [PATCH] made `SliverScreen` title a widget --- lib/screens/films/screen_films.dart | 35 ++++++++++--------- .../lightmeter_pro/screen_lightmeter_pro.dart | 2 +- .../screen_equipment_profile.dart | 2 +- lib/screens/settings/screen_settings.dart | 2 +- .../shared/sliver_screen/screen_sliver.dart | 6 ++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/screens/films/screen_films.dart b/lib/screens/films/screen_films.dart index 41f6e23..c5e5d7b 100644 --- a/lib/screens/films/screen_films.dart +++ b/lib/screens/films/screen_films.dart @@ -1,15 +1,9 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; -import 'package:lightmeter/screens/settings/components/about/widget_settings_section_about.dart'; -import 'package:lightmeter/screens/settings/components/general/widget_settings_section_general.dart'; -import 'package:lightmeter/screens/settings/components/lightmeter_pro/widget_settings_section_lightmeter_pro.dart'; -import 'package:lightmeter/screens/settings/components/metering/widget_settings_section_metering.dart'; -import 'package:lightmeter/screens/settings/components/shared/expandable_section_list/components/expandable_section_list_item/widget_expandable_section_list_item.dart'; +import 'package:lightmeter/providers/films_provider.dart'; +import 'package:lightmeter/screens/films/components/film_formula_input/widget_film_formula_input.dart'; import 'package:lightmeter/screens/settings/components/shared/expandable_section_list/widget_expandable_section_list.dart'; -import 'package:lightmeter/screens/settings/components/theme/widget_settings_section_theme.dart'; -import 'package:lightmeter/screens/settings/flow_settings.dart'; import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart'; -import 'package:lightmeter/utils/context_utils.dart'; import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; @@ -24,31 +18,29 @@ class _FilmsScreenState extends State { @override Widget build(BuildContext context) { return SliverScreen( - title: 'Films', + title: Text('Films'), appBarActions: [ IconButton( - onPressed: () {}, + onPressed: _addFilm, icon: const Icon(Icons.add_outlined), tooltip: S.of(context).tooltipAdd, ), ], slivers: [ - ExpandableSectionList( - values: films, + ExpandableSectionList( + values: [], onSectionTitleTap: () {}, contentBuilder: (context, value) => [ ListTile( leading: const Icon(Icons.iso), title: Text(S.of(context).iso), trailing: Text(value.iso.toString()), - onTap: () { - - }, + onTap: () {}, ), ListTile( leading: const Icon(Icons.equalizer), title: Text('Formula'), - trailing: Text('x^1.34'), + trailing: Text(value.exponent.toString()), ), ], actionsBuilder: (context, value) => [ @@ -68,4 +60,15 @@ class _FilmsScreenState extends State { ], ); } + + void _addFilm([EquipmentProfile? copyFrom]) { + showDialog( + context: context, + builder: (_) => const FilmFormulaDialog(), + ).then((name) { + if (name != null) { + FilmsProvider.of(context).addFilm(name); + } + }); + } } diff --git a/lib/screens/lightmeter_pro/screen_lightmeter_pro.dart b/lib/screens/lightmeter_pro/screen_lightmeter_pro.dart index 35bdf83..c527f76 100644 --- a/lib/screens/lightmeter_pro/screen_lightmeter_pro.dart +++ b/lib/screens/lightmeter_pro/screen_lightmeter_pro.dart @@ -21,7 +21,7 @@ class LightmeterProScreen extends StatelessWidget { children: [ Expanded( child: SliverScreen( - title: S.of(context).proFeaturesTitle, + title: Text(S.of(context).proFeaturesTitle), slivers: [ SliverToBoxAdapter( child: Padding( diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart index b07b767..2496977 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart @@ -28,7 +28,7 @@ class _EquipmentProfilesScreenState extends State { @override Widget build(BuildContext context) { return SliverScreen( - title: S.of(context).equipmentProfiles, + title: Text(S.of(context).equipmentProfiles), appBarActions: [ IconButton( onPressed: _addProfile, diff --git a/lib/screens/settings/screen_settings.dart b/lib/screens/settings/screen_settings.dart index 295e01c..b153428 100644 --- a/lib/screens/settings/screen_settings.dart +++ b/lib/screens/settings/screen_settings.dart @@ -33,7 +33,7 @@ class _SettingsScreenState extends State { Widget build(BuildContext context) { return ScaffoldMessenger( child: SliverScreen( - title: S.of(context).settings, + title: Text(S.of(context).settings), slivers: [ SliverList( delegate: SliverChildListDelegate( diff --git a/lib/screens/shared/sliver_screen/screen_sliver.dart b/lib/screens/shared/sliver_screen/screen_sliver.dart index 4c69457..f9fc4e6 100644 --- a/lib/screens/shared/sliver_screen/screen_sliver.dart +++ b/lib/screens/shared/sliver_screen/screen_sliver.dart @@ -3,7 +3,7 @@ import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; class SliverScreen extends StatelessWidget { - final String title; + final Widget title; final List appBarActions; final List slivers; @@ -29,12 +29,12 @@ class SliverScreen extends StatelessWidget { flexibleSpace: FlexibleSpaceBar( centerTitle: false, titlePadding: const EdgeInsets.all(Dimens.paddingM), - title: Text( - title, + title: DefaultTextStyle( style: TextStyle( color: Theme.of(context).colorScheme.onSurface, fontSize: Dimens.grid24, ), + child: title, ), ), actions: [