Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
feat: send only selected pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
Aline Bonnet committed Aug 19, 2024
1 parent 5d3b2c7 commit 29b03ae
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions lib/page/collection_creation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class CollectionCreationPageState extends State<CollectionCreationPage> {
]);
}

final Map<File, bool> _selectedFiles = {};

@override
void initState() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
Expand All @@ -31,12 +33,19 @@ class CollectionCreationPageState extends State<CollectionCreationPage> {
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
for (var file in widget.imgList) {
_selectedFiles[file] = true;
}
super.initState();
}

void goToInstancePage() {
final list = _selectedFiles.entries
.where((entry) => entry.value)
.map((entry) => entry.key)
.toList();
GetIt.instance<NavigationService>()
.pushTo(Routes.instance, arguments: widget.imgList);
.pushTo(Routes.instance, arguments: list);
}

@override
Expand Down Expand Up @@ -66,14 +75,8 @@ class CollectionCreationPageState extends State<CollectionCreationPage> {
spacing: 8,
runSpacing: 8,
children: [
...widget.imgList
.map((item) => Container(
height: 100,
child: Image.file(
item,
fit: BoxFit.cover,
)))
.toList()
for (var file in _selectedFiles.keys)
PictureItem(file),
],
)))),
Padding(
Expand All @@ -91,4 +94,30 @@ class CollectionCreationPageState extends State<CollectionCreationPage> {
),
));
}

Widget PictureItem(File file) {
return Stack(
alignment: Alignment.bottomRight,
children: [
Container(
height: 80,
child: Image.file(
file,
fit: BoxFit.cover,
)),
SizedBox(
height: 24.0,
width: 24.0,
child: Checkbox(
value: _selectedFiles[file],
onChanged: (value) {
setState(() {
_selectedFiles[file] = value!;
});
},
),
)
],
);
}
}

0 comments on commit 29b03ae

Please sign in to comment.