mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
added equipment profiles screens to navigation
This commit is contained in:
parent
1d0d901218
commit
4d02e71736
4 changed files with 109 additions and 3 deletions
|
@ -7,10 +7,12 @@ import 'package:lightmeter/navigation/modal_route_args_parser.dart';
|
|||
import 'package:lightmeter/navigation/routes.dart';
|
||||
import 'package:lightmeter/platform_config.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:lightmeter/screens/equipment_profile_edit/flow_equipment_profile_edit.dart';
|
||||
import 'package:lightmeter/screens/film_edit/flow_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/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.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';
|
||||
|
@ -49,8 +51,10 @@ class Application extends StatelessWidget {
|
|||
routes: {
|
||||
NavigationRoutes.meteringScreen.name: (_) => const ReleaseNotesFlow(child: MeteringFlow()),
|
||||
NavigationRoutes.settingsScreen.name: (_) => const SettingsFlow(),
|
||||
NavigationRoutes.equipmentProfilesListScreen.name: (_) => const EquipmentProfilesScreen(),
|
||||
NavigationRoutes.equipmentProfileEditScreen.name: (context) =>
|
||||
EquipmentProfileEditFlow(args: context.routeArgs<EquipmentProfileEditArgs>()),
|
||||
NavigationRoutes.filmsListScreen.name: (_) => const FilmsScreen(),
|
||||
NavigationRoutes.filmAddScreen.name: (_) => const FilmEditFlow(args: FilmEditArgs()),
|
||||
NavigationRoutes.filmEditScreen.name: (context) => FilmEditFlow(args: context.routeArgs<FilmEditArgs>()),
|
||||
NavigationRoutes.proFeaturesScreen.name: (_) => LightmeterProScreen(),
|
||||
NavigationRoutes.timerScreen.name: (context) => TimerFlow(args: context.routeArgs<TimerFlowArgs>()),
|
||||
|
|
|
@ -2,8 +2,9 @@ enum NavigationRoutes {
|
|||
meteringScreen,
|
||||
settingsScreen,
|
||||
filmsListScreen,
|
||||
filmAddScreen,
|
||||
filmEditScreen,
|
||||
equipmentProfilesListScreen,
|
||||
equipmentProfileEditScreen,
|
||||
proFeaturesScreen,
|
||||
timerScreen,
|
||||
}
|
||||
|
|
101
lib/screens/equipment_profiles/screen_equipment_profiles.dart
Normal file
101
lib/screens/equipment_profiles/screen_equipment_profiles.dart
Normal file
|
@ -0,0 +1,101 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/navigation/routes.dart';
|
||||
import 'package:lightmeter/providers/equipment_profile_provider.dart';
|
||||
import 'package:lightmeter/res/dimens.dart';
|
||||
import 'package:lightmeter/screens/equipment_profile_edit/flow_equipment_profile_edit.dart';
|
||||
import 'package:lightmeter/screens/shared/sliver_placeholder/widget_sliver_placeholder.dart';
|
||||
import 'package:lightmeter/screens/shared/sliver_screen/screen_sliver.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
||||
class EquipmentProfilesScreen extends StatefulWidget {
|
||||
const EquipmentProfilesScreen({super.key});
|
||||
|
||||
@override
|
||||
State<EquipmentProfilesScreen> createState() => _EquipmentProfilesScreenState();
|
||||
}
|
||||
|
||||
class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> with SingleTickerProviderStateMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverScreen(
|
||||
title: Text(S.of(context).films),
|
||||
appBarActions: [
|
||||
IconButton(
|
||||
onPressed: _addProfile,
|
||||
icon: const Icon(Icons.add_outlined),
|
||||
tooltip: S.of(context).tooltipAdd,
|
||||
),
|
||||
],
|
||||
slivers: [
|
||||
if (EquipmentProfiles.of(context).isNotEmpty)
|
||||
_EquipmentProfilesListBuilder(
|
||||
values: EquipmentProfiles.of(context).toList(),
|
||||
onEdit: _editProfile,
|
||||
)
|
||||
else
|
||||
SliverPlaceholder(onTap: _addProfile),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _addProfile() {
|
||||
Navigator.of(context).pushNamed(
|
||||
NavigationRoutes.equipmentProfileEditScreen.name,
|
||||
arguments: const EquipmentProfileEditArgs(),
|
||||
);
|
||||
}
|
||||
|
||||
void _editProfile(EquipmentProfile profile) {
|
||||
Navigator.of(context).pushNamed(
|
||||
NavigationRoutes.equipmentProfileEditScreen.name,
|
||||
arguments: EquipmentProfileEditArgs(profile: profile),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EquipmentProfilesListBuilder extends StatelessWidget {
|
||||
final List<EquipmentProfile> values;
|
||||
final void Function(EquipmentProfile film) onEdit;
|
||||
|
||||
const _EquipmentProfilesListBuilder({
|
||||
required this.values,
|
||||
required this.onEdit,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverList.builder(
|
||||
itemCount: values.length,
|
||||
itemBuilder: (_, index) => Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
Dimens.paddingM,
|
||||
index == 0 ? Dimens.paddingM : 0,
|
||||
Dimens.paddingM,
|
||||
index == values.length - 1 ? Dimens.paddingM + MediaQuery.paddingOf(context).bottom : 0.0,
|
||||
),
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: index == 0 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
||||
bottom: index == values.length - 1 ? const Radius.circular(Dimens.borderRadiusL) : Radius.zero,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: index == 0 ? Dimens.paddingM : 0.0,
|
||||
bottom: index == values.length - 1 ? Dimens.paddingM : 0.0,
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(values[index].name),
|
||||
trailing: IconButton(
|
||||
onPressed: () => onEdit(values[index]),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@ class _FilmsScreenState extends State<FilmsScreen> with SingleTickerProviderStat
|
|||
|
||||
void _addFilm() {
|
||||
Navigator.of(context).pushNamed(
|
||||
NavigationRoutes.filmAddScreen.name,
|
||||
NavigationRoutes.filmEditScreen.name,
|
||||
arguments: const FilmEditArgs(),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue