Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Make 'add new' in location search section functional

ashilkn4a84836dd9bc
diff --git a/lib/models/search/search_types.dart b/lib/models/search/search_types.dart
index ee1310c0fb..2ba8c5718f 100644
--- a/lib/models/search/search_types.dart
+++ b/lib/models/search/search_types.dart
@@ -1,7 +1,10 @@
import "package:flutter/material.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/search/search_result.dart";
+import "package:photos/models/typedefs.dart";
import "package:photos/services/search_service.dart";
+import "package:photos/ui/viewer/location/add_location_sheet.dart";
+import "package:photos/ui/viewer/location/pick_center_point_widget.dart";
enum ResultType {
collection,
@@ -161,6 +164,22 @@ extension SectionTypeExtensions on SectionType {
}
}
+ FutureVoidCallback ctaOnTap(BuildContext context) {
+ switch (this) {
+ case SectionType.location:
+ return () async {
+ final centerPoint = await showPickCenterPointSheet(context);
+ if (centerPoint != null) {
+ showAddLocationSheet(context, centerPoint);
+ }
+ };
+ default:
+ {
+ return () async {};
+ }
+ }
+ }
+
Future<List<SearchResult>> getData({int? limit, BuildContext? context}) {
if (this == SectionType.moment && context == null) {
AssertionError("context cannot be null for SectionType.moment");
diff --git a/lib/ui/viewer/location/edit_center_point_tile_widget.dart b/lib/ui/viewer/location/edit_center_point_tile_widget.dart
index 25d202114b..9891bd02e2 100644
--- a/lib/ui/viewer/location/edit_center_point_tile_widget.dart
+++ b/lib/ui/viewer/location/edit_center_point_tile_widget.dart
@@ -52,7 +52,10 @@ class EditCenterPointTileWidget extends StatelessWidget {
onTap: () async {
final Location? centerPoint = await showPickCenterPointSheet(
context,
- InheritedLocationTagData.of(context).locationTagEntity!.item.name,
+ locationTagName: InheritedLocationTagData.of(context)
+ .locationTagEntity!
+ .item
+ .name,
);
if (centerPoint != null) {
InheritedLocationTagData.of(context)
diff --git a/lib/ui/viewer/location/pick_center_point_widget.dart b/lib/ui/viewer/location/pick_center_point_widget.dart
index ddde018ec7..e3fac6fcca 100644
--- a/lib/ui/viewer/location/pick_center_point_widget.dart
+++ b/lib/ui/viewer/location/pick_center_point_widget.dart
@@ -21,9 +21,9 @@ import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
Future<Location?> showPickCenterPointSheet(
- BuildContext context,
+ BuildContext context, {
String? locationTagName,
-) async {
+}) async {
return await showBarModalBottomSheet(
context: context,
builder: (context) {
@@ -79,7 +79,7 @@ class PickCenterPointWidget extends StatelessWidget {
title: TitleBarTitleWidget(
title: S.of(context).pickCenterPoint,
),
- caption: locationTagName,
+ caption: locationTagName ?? "New location",
),
Expanded(
child: Gallery(
diff --git a/lib/ui/viewer/search/search_section_cta.dart b/lib/ui/viewer/search/search_section_cta.dart
index 1e8d912443..b8a74f0574 100644
--- a/lib/ui/viewer/search/search_section_cta.dart
+++ b/lib/ui/viewer/search/search_section_cta.dart
@@ -15,40 +15,43 @@ class SearchSectionCTAIcon extends StatelessWidget {
}
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
- return SizedBox(
- width: 84,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- DottedBorder(
- color: colorScheme.strokeFaint,
- dashPattern: const [3.875, 3.875],
- borderType: BorderType.Circle,
- strokeWidth: 1.5,
- radius: const Radius.circular(33.25),
- child: SizedBox(
- width: 62.5,
- height: 62.5,
- child: Icon(
- sectionType.getCTAIcon() ?? Icons.add,
- color: colorScheme.strokeFaint,
- size: 20,
+ return GestureDetector(
+ onTap: sectionType.ctaOnTap(context),
+ child: SizedBox(
+ width: 84,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ DottedBorder(
+ color: colorScheme.strokeFaint,
+ dashPattern: const [3.875, 3.875],
+ borderType: BorderType.Circle,
+ strokeWidth: 1.5,
+ radius: const Radius.circular(33.25),
+ child: SizedBox(
+ width: 62.5,
+ height: 62.5,
+ child: Icon(
+ sectionType.getCTAIcon() ?? Icons.add,
+ color: colorScheme.strokeFaint,
+ size: 20,
+ ),
),
),
- ),
- const SizedBox(
- height: 9.25,
- ),
- Text(
- sectionType.getCTAText(context),
- maxLines: 2,
- textAlign: TextAlign.center,
- overflow: TextOverflow.ellipsis,
- style: textTheme.miniFaint,
- ),
- ],
+ const SizedBox(
+ height: 9.25,
+ ),
+ Text(
+ sectionType.getCTAText(context),
+ maxLines: 2,
+ textAlign: TextAlign.center,
+ overflow: TextOverflow.ellipsis,
+ style: textTheme.miniFaint,
+ ),
+ ],
+ ),
),
),
);