update container behaviour
This commit is contained in:
@@ -39,6 +39,63 @@ class ContainerListScreen extends HookConsumerWidget {
|
|||||||
final container = containers[index];
|
final container = containers[index];
|
||||||
return Slidable(
|
return Slidable(
|
||||||
key: ValueKey(container.id),
|
key: ValueKey(container.id),
|
||||||
|
startActionPane: ActionPane(
|
||||||
|
motion: const ScrollMotion(),
|
||||||
|
children: [
|
||||||
|
if (container.id != selectedContainer)
|
||||||
|
SlidableAction(
|
||||||
|
onPressed: (context) async {
|
||||||
|
final result = await ref
|
||||||
|
.read(
|
||||||
|
selectedContainerProvider.notifier,
|
||||||
|
)
|
||||||
|
.setContainerId(container.id);
|
||||||
|
|
||||||
|
if (context.mounted &&
|
||||||
|
result ==
|
||||||
|
SetContainerResult
|
||||||
|
.successHasProxy) {
|
||||||
|
await ref
|
||||||
|
.read(
|
||||||
|
startProxyControllerProvider
|
||||||
|
.notifier,
|
||||||
|
)
|
||||||
|
.maybeStartProxy(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onPrimaryContainer,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.primaryContainer,
|
||||||
|
icon: Icons.check,
|
||||||
|
label: 'Select',
|
||||||
|
)
|
||||||
|
else
|
||||||
|
SlidableAction(
|
||||||
|
onPressed: (context) {
|
||||||
|
ref
|
||||||
|
.read(
|
||||||
|
selectedContainerProvider.notifier,
|
||||||
|
)
|
||||||
|
.clearContainer();
|
||||||
|
},
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onPrimaryContainer,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.primaryContainer,
|
||||||
|
icon: Icons.close,
|
||||||
|
label: 'Unselect',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
endActionPane: ActionPane(
|
endActionPane: ActionPane(
|
||||||
motion: const ScrollMotion(),
|
motion: const ScrollMotion(),
|
||||||
children: [
|
children: [
|
||||||
@@ -66,27 +123,6 @@ class ContainerListScreen extends HookConsumerWidget {
|
|||||||
child: ContainerListTile(
|
child: ContainerListTile(
|
||||||
container,
|
container,
|
||||||
isSelected: container.id == selectedContainer,
|
isSelected: container.id == selectedContainer,
|
||||||
onTap: () async {
|
|
||||||
if (container.id == selectedContainer) {
|
|
||||||
ref
|
|
||||||
.read(selectedContainerProvider.notifier)
|
|
||||||
.clearContainer();
|
|
||||||
} else {
|
|
||||||
final result = await ref
|
|
||||||
.read(selectedContainerProvider.notifier)
|
|
||||||
.setContainerId(container.id);
|
|
||||||
|
|
||||||
if (context.mounted &&
|
|
||||||
result ==
|
|
||||||
SetContainerResult.successHasProxy) {
|
|
||||||
await ref
|
|
||||||
.read(
|
|
||||||
startProxyControllerProvider.notifier,
|
|
||||||
)
|
|
||||||
.maybeStartProxy(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -107,7 +143,7 @@ class ContainerListScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final initialColor =
|
final initialColor =
|
||||||
await ref
|
await ref
|
||||||
@@ -126,7 +162,8 @@ class ContainerListScreen extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Icon(Icons.add),
|
label: const Text('Container'),
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-10
@@ -7,12 +7,9 @@ class ContainerListTile extends HookWidget {
|
|||||||
final ContainerData container;
|
final ContainerData container;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
|
|
||||||
final void Function()? onTap;
|
|
||||||
|
|
||||||
const ContainerListTile(
|
const ContainerListTile(
|
||||||
this.container, {
|
this.container, {
|
||||||
required this.isSelected,
|
required this.isSelected,
|
||||||
this.onTap,
|
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -25,13 +22,10 @@ class ContainerListTile extends HookWidget {
|
|||||||
selected: isSelected,
|
selected: isSelected,
|
||||||
leading: CircleAvatar(backgroundColor: container.color),
|
leading: CircleAvatar(backgroundColor: container.color),
|
||||||
title: Text(container.name ?? 'New Container'),
|
title: Text(container.name ?? 'New Container'),
|
||||||
trailing: IconButton(
|
onTap: () async {
|
||||||
onPressed: () async {
|
await ContainerEditRoute(container).push(context);
|
||||||
await ContainerEditRoute(container).push(context);
|
},
|
||||||
},
|
trailing: const Icon(Icons.chevron_right),
|
||||||
icon: const Icon(Icons.chevron_right),
|
|
||||||
),
|
|
||||||
onTap: onTap,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user