2022-10-27 07:23:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/core/configuration.dart';
|
|
|
|
import 'package:photos/db/files_db.dart';
|
2023-04-05 09:50:48 +00:00
|
|
|
import "package:photos/generated/l10n.dart";
|
2023-05-25 05:51:56 +00:00
|
|
|
import "package:photos/models/metadata/common_keys.dart";
|
2023-02-23 07:53:41 +00:00
|
|
|
import "package:photos/services/collections_service.dart";
|
2022-10-27 07:23:45 +00:00
|
|
|
import 'package:photos/ui/viewer/gallery/archive_page.dart';
|
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
|
|
|
|
2023-06-06 16:43:32 +00:00
|
|
|
class ArchivedCollectionsButton extends StatelessWidget {
|
2022-10-27 07:23:45 +00:00
|
|
|
final TextStyle textStyle;
|
|
|
|
|
2023-06-06 16:43:32 +00:00
|
|
|
const ArchivedCollectionsButton(
|
2022-10-27 07:23:45 +00:00
|
|
|
this.textStyle, {
|
2022-12-27 16:46:59 +00:00
|
|
|
Key? key,
|
2022-10-27 07:23:45 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-23 07:53:41 +00:00
|
|
|
final Set<int> hiddenCollectionId =
|
|
|
|
CollectionsService.instance.getHiddenCollections();
|
2022-10-27 07:23:45 +00:00
|
|
|
return OutlinedButton(
|
|
|
|
style: OutlinedButton.styleFrom(
|
|
|
|
backgroundColor: Theme.of(context).backgroundColor,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
side: BorderSide(
|
|
|
|
width: 0.5,
|
2022-12-27 16:46:59 +00:00
|
|
|
color: Theme.of(context).iconTheme.color!.withOpacity(0.24),
|
2022-10-27 07:23:45 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 48,
|
|
|
|
width: double.infinity,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
2022-10-31 09:56:59 +00:00
|
|
|
Icons.archive_outlined,
|
2022-10-27 07:23:45 +00:00
|
|
|
color: Theme.of(context).iconTheme.color,
|
|
|
|
),
|
|
|
|
const Padding(padding: EdgeInsets.all(6)),
|
|
|
|
FutureBuilder<int>(
|
2023-02-23 07:53:41 +00:00
|
|
|
future: FilesDB.instance.archivedFilesCount(
|
2023-05-25 05:51:56 +00:00
|
|
|
archiveVisibility,
|
2022-12-30 03:29:48 +00:00
|
|
|
Configuration.instance.getUserID()!,
|
2023-02-23 07:53:41 +00:00
|
|
|
hiddenCollectionId,
|
2022-10-27 07:23:45 +00:00
|
|
|
),
|
|
|
|
builder: (context, snapshot) {
|
2022-12-27 16:46:59 +00:00
|
|
|
if (snapshot.hasData && snapshot.data! > 0) {
|
2022-10-27 07:23:45 +00:00
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: textStyle,
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
2023-04-05 09:50:48 +00:00
|
|
|
text: S.of(context).archive,
|
2023-06-13 06:41:31 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
2022-10-27 07:23:45 +00:00
|
|
|
),
|
|
|
|
const TextSpan(text: " \u2022 "),
|
|
|
|
TextSpan(
|
|
|
|
text: snapshot.data.toString(),
|
|
|
|
),
|
|
|
|
//need to query in db and bring this value
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: textStyle,
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
2023-04-05 09:50:48 +00:00
|
|
|
text: S.of(context).archive,
|
2023-06-13 06:41:31 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
2022-10-27 07:23:45 +00:00
|
|
|
),
|
|
|
|
//need to query in db and bring this value
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.chevron_right,
|
|
|
|
color: Theme.of(context).iconTheme.color,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
ArchivePage(),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|