|
@@ -8,11 +8,43 @@ import 'package:photos/models/file.dart';
|
|
|
import 'package:photos/ui/thumbnail_widget.dart';
|
|
|
import 'package:photos/utils/data_util.dart';
|
|
|
|
|
|
-class DeduplicatePage extends StatelessWidget {
|
|
|
+class DeduplicatePage extends StatefulWidget {
|
|
|
final List<DuplicateFiles> duplicates;
|
|
|
|
|
|
DeduplicatePage(this.duplicates, {Key key}) : super(key: key);
|
|
|
|
|
|
+ @override
|
|
|
+ _DeduplicatePageState createState() => _DeduplicatePageState();
|
|
|
+}
|
|
|
+
|
|
|
+class _DeduplicatePageState extends State<DeduplicatePage> {
|
|
|
+ final kDeleteIconOverlay = Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ gradient: LinearGradient(
|
|
|
+ begin: Alignment.topCenter,
|
|
|
+ end: Alignment.bottomCenter,
|
|
|
+ colors: [
|
|
|
+ Colors.transparent,
|
|
|
+ Colors.black.withOpacity(0.6),
|
|
|
+ ],
|
|
|
+ stops: const [0.75, 1],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ child: Align(
|
|
|
+ alignment: Alignment.bottomRight,
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.only(right: 8, bottom: 4),
|
|
|
+ child: Icon(
|
|
|
+ Icons.delete_forever,
|
|
|
+ size: 18,
|
|
|
+ color: Colors.red[700],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ final Set<File> selectedFiles = <File>{};
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
@@ -70,10 +102,10 @@ class DeduplicatePage extends StatelessWidget {
|
|
|
}
|
|
|
return Padding(
|
|
|
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
|
|
- child: _getGridView(duplicates[index - 1]),
|
|
|
+ child: _getGridView(widget.duplicates[index - 1]),
|
|
|
);
|
|
|
},
|
|
|
- itemCount: duplicates.length,
|
|
|
+ itemCount: widget.duplicates.length,
|
|
|
shrinkWrap: true,
|
|
|
),
|
|
|
),
|
|
@@ -127,7 +159,12 @@ class DeduplicatePage extends StatelessWidget {
|
|
|
Widget _buildFile(BuildContext context, File file, int index) {
|
|
|
return GestureDetector(
|
|
|
onTap: () {
|
|
|
- // TODO
|
|
|
+ if (selectedFiles.contains(file)) {
|
|
|
+ selectedFiles.remove(file);
|
|
|
+ } else {
|
|
|
+ selectedFiles.add(file);
|
|
|
+ }
|
|
|
+ setState(() {});
|
|
|
},
|
|
|
onLongPress: () {
|
|
|
HapticFeedback.lightImpact();
|
|
@@ -135,23 +172,26 @@ class DeduplicatePage extends StatelessWidget {
|
|
|
child: Container(
|
|
|
margin: const EdgeInsets.all(2.0),
|
|
|
decoration: BoxDecoration(
|
|
|
- border: index == 0
|
|
|
- ? null
|
|
|
- : Border.all(
|
|
|
- width: 0,
|
|
|
- color: Colors.red,
|
|
|
- ),
|
|
|
+ border: selectedFiles.contains(file)
|
|
|
+ ? Border.all(
|
|
|
+ width: 3,
|
|
|
+ color: Colors.red[700],
|
|
|
+ )
|
|
|
+ : null,
|
|
|
),
|
|
|
- child: Hero(
|
|
|
- tag: "deduplicate_" + file.tag(),
|
|
|
- child: ThumbnailWidget(
|
|
|
- file,
|
|
|
- diskLoadDeferDuration: kThumbnailDiskLoadDeferDuration,
|
|
|
- serverLoadDeferDuration: kThumbnailServerLoadDeferDuration,
|
|
|
- shouldShowLivePhotoOverlay: true,
|
|
|
- key: Key("deduplicate_" + file.tag()),
|
|
|
+ child: Stack(children: [
|
|
|
+ Hero(
|
|
|
+ tag: "deduplicate_" + file.tag(),
|
|
|
+ child: ThumbnailWidget(
|
|
|
+ file,
|
|
|
+ diskLoadDeferDuration: kThumbnailDiskLoadDeferDuration,
|
|
|
+ serverLoadDeferDuration: kThumbnailServerLoadDeferDuration,
|
|
|
+ shouldShowLivePhotoOverlay: true,
|
|
|
+ key: Key("deduplicate_" + file.tag()),
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
+ selectedFiles.contains(file) ? kDeleteIconOverlay : Container(),
|
|
|
+ ]),
|
|
|
),
|
|
|
);
|
|
|
}
|