mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 07:50:42 +00:00
Fixed equipment profiles sections collapsing
This commit is contained in:
parent
bf3c8aa7c7
commit
a976fcdaff
1 changed files with 9 additions and 9 deletions
|
@ -19,15 +19,15 @@ class EquipmentProfilesScreen extends StatefulWidget {
|
||||||
class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
static const maxProfiles = 5 + 1; // replace with a constant from iap
|
static const maxProfiles = 5 + 1; // replace with a constant from iap
|
||||||
|
|
||||||
late List<GlobalKey<EquipmentProfileContainerState>> profileContainersKeys = [];
|
final Map<String, GlobalKey<EquipmentProfileContainerState>> keysMap = {};
|
||||||
int get profilesCount => EquipmentProfiles.of(context).length;
|
int get profilesCount => keysMap.length;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
profileContainersKeys = EquipmentProfiles.of(context)
|
EquipmentProfiles.of(context).forEach((profile) {
|
||||||
.map((e) => GlobalKey<EquipmentProfileContainerState>(debugLabel: e.id))
|
keysMap[profile.id] ??= GlobalKey<EquipmentProfileContainerState>(debugLabel: profile.id);
|
||||||
.toList();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -64,7 +64,7 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
Dimens.paddingM,
|
Dimens.paddingM,
|
||||||
),
|
),
|
||||||
child: EquipmentProfileContainer(
|
child: EquipmentProfileContainer(
|
||||||
key: profileContainersKeys[index],
|
key: keysMap.values.toList()[index],
|
||||||
data: EquipmentProfiles.of(context)[index],
|
data: EquipmentProfiles.of(context)[index],
|
||||||
onExpand: () => _keepExpandedAt(index),
|
onExpand: () => _keepExpandedAt(index),
|
||||||
onUpdate: (profileData) => _updateProfileAt(profileData, index),
|
onUpdate: (profileData) => _updateProfileAt(profileData, index),
|
||||||
|
@ -72,7 +72,7 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
childCount: profilesCount,
|
childCount: keysMap.length,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(child: SizedBox(height: MediaQuery.paddingOf(context).bottom)),
|
SliverToBoxAdapter(child: SizedBox(height: MediaQuery.paddingOf(context).bottom)),
|
||||||
|
@ -100,10 +100,10 @@ class _EquipmentProfilesScreenState extends State<EquipmentProfilesScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _keepExpandedAt(int index) {
|
void _keepExpandedAt(int index) {
|
||||||
profileContainersKeys.getRange(0, index).forEach((element) {
|
keysMap.values.toList().getRange(0, index).forEach((element) {
|
||||||
element.currentState?.collapse();
|
element.currentState?.collapse();
|
||||||
});
|
});
|
||||||
profileContainersKeys.getRange(index + 1, profilesCount).forEach((element) {
|
keysMap.values.toList().getRange(index + 1, profilesCount).forEach((element) {
|
||||||
element.currentState?.collapse();
|
element.currentState?.collapse();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue