2023-01-12 05:08:47 +00:00
|
|
|
import 'package:collection/collection.dart';
|
2022-12-26 05:31:32 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-04-05 09:50:48 +00:00
|
|
|
import "package:photos/generated/l10n.dart";
|
2023-08-25 04:39:30 +00:00
|
|
|
import 'package:photos/models/collection/collection.dart';
|
2023-01-12 05:08:47 +00:00
|
|
|
import 'package:photos/services/collections_service.dart';
|
2023-01-17 08:20:17 +00:00
|
|
|
import 'package:photos/services/hidden_service.dart';
|
2023-01-12 05:22:50 +00:00
|
|
|
import 'package:photos/ui/viewer/gallery/uncategorized_page.dart';
|
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
2022-12-26 05:31:32 +00:00
|
|
|
|
2023-06-06 16:43:32 +00:00
|
|
|
class UnCategorizedCollections extends StatelessWidget {
|
2022-12-26 05:31:32 +00:00
|
|
|
final TextStyle textStyle;
|
|
|
|
|
2023-06-06 16:43:32 +00:00
|
|
|
const UnCategorizedCollections(
|
2022-12-26 05:31:32 +00:00
|
|
|
this.textStyle, {
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-12 05:08:47 +00:00
|
|
|
final Collection? collection = CollectionsService.instance
|
|
|
|
.getActiveCollections()
|
|
|
|
.firstWhereOrNull((e) => e.type == CollectionType.uncategorized);
|
2023-01-17 08:20:17 +00:00
|
|
|
if (collection == null) {
|
|
|
|
// create uncategorized collection if it's not already created
|
|
|
|
CollectionsService.instance.getUncategorizedCollection().ignore();
|
|
|
|
}
|
2022-12-26 05:31:32 +00:00
|
|
|
return OutlinedButton(
|
|
|
|
style: OutlinedButton.styleFrom(
|
2023-06-13 09:09:55 +00:00
|
|
|
backgroundColor: Theme.of(context).colorScheme.background,
|
2022-12-26 05:31:32 +00:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
side: BorderSide(
|
|
|
|
width: 0.5,
|
|
|
|
color: Theme.of(context).iconTheme.color!.withOpacity(0.24),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 48,
|
|
|
|
width: double.infinity,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.category_outlined,
|
|
|
|
color: Theme.of(context).iconTheme.color,
|
|
|
|
),
|
|
|
|
const Padding(padding: EdgeInsets.all(6)),
|
|
|
|
FutureBuilder<int>(
|
2023-01-12 05:08:47 +00:00
|
|
|
future: collection == null
|
|
|
|
? Future.value(0)
|
2023-07-06 07:59:31 +00:00
|
|
|
: CollectionsService.instance.getFileCount(collection),
|
2022-12-26 05:31:32 +00:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasData && snapshot.data! > 0) {
|
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: textStyle,
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
2023-04-05 09:50:48 +00:00
|
|
|
text: S.of(context).uncategorized,
|
2023-06-13 06:41:31 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
2022-12-26 05:31:32 +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).uncategorized,
|
2023-06-13 06:41:31 +00:00
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
2022-12-26 05:31:32 +00:00
|
|
|
),
|
|
|
|
//need to query in db and bring this value
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.chevron_right,
|
|
|
|
color: Theme.of(context).iconTheme.color,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-01-12 05:22:50 +00:00
|
|
|
onPressed: () async {
|
|
|
|
if (collection != null) {
|
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
UnCategorizedPage(collection),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2022-12-26 05:31:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|