added films screen to navigation

This commit is contained in:
Vadim 2024-10-24 12:33:37 +02:00
parent ba5bbb78d7
commit 0243598553
6 changed files with 63 additions and 208 deletions

View file

@ -5,11 +5,16 @@ import 'package:lightmeter/data/models/supported_locale.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/platform_config.dart';
import 'package:lightmeter/providers/user_preferences_provider.dart';
import 'package:lightmeter/screens/film_edit/flow_film_edit.dart';
import 'package:lightmeter/screens/film_edit/screen_film_edit.dart';
import 'package:lightmeter/screens/films/screen_films.dart';
import 'package:lightmeter/screens/lightmeter_pro/screen_lightmeter_pro.dart';
import 'package:lightmeter/screens/metering/flow_metering.dart';
import 'package:lightmeter/screens/settings/flow_settings.dart';
import 'package:lightmeter/screens/shared/release_notes_dialog/flow_dialog_release_notes.dart';
import 'package:lightmeter/screens/timer/flow_timer.dart';
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class Application extends StatelessWidget {
const Application({super.key});
@ -45,6 +50,8 @@ class Application extends StatelessWidget {
routes: {
"metering": (_) => const ReleaseNotesFlow(child: MeteringFlow()),
"settings": (_) => const SettingsFlow(),
"films": (_) => const FilmsScreen(),
"filmEdit": (context) => FilmEditFlow(args: ModalRoute.of(context)!.settings.arguments! as FilmEditArgs),
"lightmeterPro": (_) => LightmeterProScreen(),
"timer": (context) => TimerFlow(args: ModalRoute.of(context)!.settings.arguments! as TimerFlowArgs),
},

View file

@ -67,8 +67,6 @@
"equipmentProfile": "Equipment profile",
"equipmentProfiles": "Equipment profiles",
"tapToAdd": "Tap to add",
"filmsInUse": "Films in use",
"filmsInUseDescription": "Select films which you use.",
"general": "General",
"keepScreenOn": "Keep screen on",
"haptics": "Haptics",
@ -151,6 +149,10 @@
}
},
"close": "Close",
"films": "Films",
"filmsInUse": "Films in use",
"filmsInUseDescription": "Select films which you use.",
"filmsCustom": "Custom films",
"addFilmTitle": "Add film",
"editFilmTitle": "Edit film",
"filmFormula": "Formula",

View file

@ -4,15 +4,21 @@ import 'package:lightmeter/screens/film_edit/bloc_film_edit.dart';
import 'package:lightmeter/screens/film_edit/screen_film_edit.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class FilmEditFlow extends StatelessWidget {
final FilmExponential? film;
class FilmEditArgs {
final FilmExponential film;
const FilmEditFlow({this.film, super.key});
const FilmEditArgs({required this.film});
}
class FilmEditFlow extends StatelessWidget {
final FilmEditArgs args;
const FilmEditFlow({required this.args, super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => FilmEditBloc(film),
create: (_) => FilmEditBloc(args.film),
child: const FilmEditScreen(),
);
}

View file

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/films_provider.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:lightmeter/screens/settings/components/shared/expandable_section_list/widget_expandable_section_list.dart';
import 'package:lightmeter/screens/film_edit/flow_film_edit.dart';
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
@ -16,6 +16,12 @@ class FilmsScreen extends StatefulWidget {
class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStateMixin {
late final tabController = TabController(length: 2, vsync: this);
@override
void dispose() {
tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SliverScreen(
@ -28,16 +34,22 @@ class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStat
],
),
appBarActions: [
IconButton(
onPressed: _addFilm,
icon: const Icon(Icons.add_outlined),
tooltip: S.of(context).tooltipAdd,
AnimatedBuilder(
animation: tabController,
builder: (context, _) => AnimatedSwitcher(
duration: Dimens.switchDuration,
child: tabController.index == 0
? const SizedBox.shrink()
: IconButton(
onPressed: _addFilm,
icon: const Icon(Icons.add_outlined),
tooltip: S.of(context).tooltipAdd,
),
),
),
],
slivers: [
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: [
@ -45,9 +57,10 @@ class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStat
films: Films.of(context).skip(1).toList(),
onFilmSelected: (film, value) {},
),
_FilmsListBuilder(
films: Films.of(context).skip(1).toList(),
_FilmsListBuilder<FilmExponential>(
films: Films.of(context).skip(1).whereType<FilmExponential>().toList(),
onFilmSelected: (film, value) {},
onFilmEdit: _editFilm,
),
],
),
@ -56,13 +69,25 @@ class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStat
);
}
void _addFilm([EquipmentProfile? copyFrom]) {}
void _addFilm() {
Navigator.of(context).pushNamed(
'filmEdit',
arguments: const FilmEditArgs(film: FilmExponential(name: '', iso: 100, exponent: 1.3)),
);
}
void _editFilm(FilmExponential film) {
Navigator.of(context).pushNamed(
'filmEdit',
arguments: FilmEditArgs(film: film),
);
}
}
class _FilmsListBuilder extends StatelessWidget {
final List<Film> films;
final void Function(Film film, bool value) onFilmSelected;
final void Function()? onFilmEdit;
class _FilmsListBuilder<T extends Film> extends StatelessWidget {
final List<T> films;
final void Function(T film, bool value) onFilmSelected;
final void Function(T film)? onFilmEdit;
const _FilmsListBuilder({
required this.films,
@ -98,7 +123,7 @@ class _FilmsListBuilder extends StatelessWidget {
},
secondary: onFilmEdit != null
? IconButton(
onPressed: onFilmEdit,
onPressed: () => onFilmEdit!(films[index]),
icon: const Icon(Icons.edit),
)
: null,

View file

@ -1,166 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lightmeter/res/dimens.dart';
class FormulaInput extends StatefulWidget {
const FormulaInput({super.key});
@override
State<FormulaInput> createState() => _FormulaInputState();
}
class _FormulaInputState extends State<FormulaInput> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
TextFormField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('x')),
],
),
const Spacer(),
Row(
children: [
_Button(
title: '()',
onTap: () {},
),
_buttonsDivider,
_Button(
title: 'ln',
onTap: () {},
),
_buttonsDivider,
_Button(
title: 'lg',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '^',
onTap: () {},
),
],
),
Row(
children: [
_Button(
title: '7',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '8',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '9',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '^',
onTap: () {},
),
],
),
Row(
children: [
_Button(
title: '4',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '5',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '6',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '^',
onTap: () {},
),
],
),
Row(
children: [
_Button(
title: '1',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '2',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '3',
onTap: () {},
),
_buttonsDivider,
_Button(
title: '^',
onTap: () {},
),
],
),
Row(
children: [
_Button(
title: '0',
onTap: () {},
),
_Button(
title: '.',
onTap: () {},
),
_Button(
title: '<',
onTap: () {},
),
_Button(
title: '^',
onTap: () {},
),
],
)
],
),
),
);
}
}
class _Button extends StatelessWidget {
final String title;
final VoidCallback onTap;
const _Button({super.key, required this.title, required this.onTap});
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
alignment: Alignment.center,
height: Dimens.grid48,
decoration: ShapeDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
shape: const StadiumBorder(),
),
child: Text(title),
),
);
}
}
const _buttonsDivider = SizedBox(width: Dimens.grid8, height: Dimens.grid8);

View file

@ -1,9 +1,6 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/films_provider.dart';
import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart';
import 'package:lightmeter/screens/settings/components/shared/iap_list_tile/widget_list_tile_iap.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class FilmsListTile extends StatelessWidget {
const FilmsListTile({super.key});
@ -12,24 +9,8 @@ class FilmsListTile extends StatelessWidget {
Widget build(BuildContext context) {
return IAPListTile(
leading: const Icon(Icons.camera_roll_outlined),
title: Text(S.of(context).filmsInUse),
onTap: () {
showDialog<List<Film>>(
context: context,
builder: (_) => DialogFilter<Film>(
icon: const Icon(Icons.camera_roll_outlined),
title: S.of(context).filmsInUse,
description: S.of(context).filmsInUseDescription,
values: Films.of(context).sublist(1),
selectedValues: Films.inUseOf(context),
titleAdapter: (_, value) => value.name,
),
).then((values) {
if (values != null) {
FilmsProvider.of(context).saveFilms(values);
}
});
},
title: Text(S.of(context).films),
onTap: () => Navigator.of(context).pushNamed('films'),
);
}
}