mock add/delete

This commit is contained in:
Vadim 2023-03-20 22:39:07 +03:00
parent 5e814184f0
commit 2ef59d9eb6
3 changed files with 30 additions and 6 deletions

View file

@ -45,11 +45,27 @@ class EquipmentProfileProviderState extends State<EquipmentProfileProvider> {
});
}
void addProfile(EquipmentProfileData data) {}
/// Creates a default equipment profile
void addProfile() {
_profiles.add(const EquipmentProfileData(
id: 'default',
name: '',
apertureValues: apertureValues,
ndValues: ndValues,
shutterSpeedValues: shutterSpeedValues,
isoValues: isoValues,
));
setState(() {});
}
void updateProdile(EquipmentProfileData data) {}
void updateProdile(EquipmentProfileData data) {
//
}
void deleteProfile(EquipmentProfileData data) {}
void deleteProfile(EquipmentProfileData data) {
_profiles.remove(data);
setState(() {});
}
}
class EquipmentProfiles extends InheritedWidget {

View file

@ -1,14 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'components/equipment_list_tiles/widget_list_tiles_equipments.dart';
class EquipmentListTilesSection extends StatefulWidget {
final EquipmentProfileData data;
final VoidCallback onDelete;
const EquipmentListTilesSection({required this.data, super.key});
const EquipmentListTilesSection({
required this.data,
required this.onDelete,
super.key,
});
@override
State<EquipmentListTilesSection> createState() => _EquipmentListTilesSectionState();
@ -63,7 +67,7 @@ class _EquipmentListTilesSectionState extends State<EquipmentListTilesSection> {
children: [
_collapseButton(),
IconButton(
onPressed: () {},
onPressed: widget.onDelete,
icon: const Icon(Icons.delete),
),
],

View file

@ -37,6 +37,10 @@ class _EquipmentProfileScreenState extends State<EquipmentProfileScreen> {
itemCount: EquipmentProfiles.of(context)?.length ?? 0,
itemBuilder: (_, index) => EquipmentListTilesSection(
data: EquipmentProfiles.of(context)![index],
onDelete: () {
EquipmentProfileProvider.of(context)
.deleteProfile(EquipmentProfiles.of(context)![index]);
},
),
),
),