π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refactor LocationTagsWidget to enhance UI and improve location tag handling
aman-pilot448d74ec6fab
diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/location_tags_widget.dart b/mobile/apps/photos/lib/ui/viewer/file_details/location_tags_widget.dartindex 62f2f41a96..176914295b 100644--- a/mobile/apps/photos/lib/ui/viewer/file_details/location_tags_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file_details/location_tags_widget.dart@@ -1,6 +1,7 @@import "dart:async";import "dart:ui";+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:flutter_animate/flutter_animate.dart";@@ -15,8 +16,6 @@ import "package:photos/service_locator.dart";import "package:photos/services/search_service.dart";import "package:photos/states/location_screen_state.dart";import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/components/buttons/chip_button_widget.dart";-import "package:photos/ui/components/info_item_widget.dart";import "package:photos/ui/map/image_marker.dart";import "package:photos/ui/map/map_screen.dart";import "package:photos/ui/map/map_view.dart";@@ -35,24 +34,19 @@ class LocationTagsWidget extends StatefulWidget {}class _LocationTagsWidgetState extends State<LocationTagsWidget> {- String? title;late Future<List<Widget>> locationTagChips;late StreamSubscription<LocationTagUpdatedEvent> _locTagUpdateListener;- VoidCallback? onTap;- bool _loadedLocationTags = false;@overridevoid initState() {- locationTagChips = _getLocationTags().then((value) {- _loadedLocationTags = true;- return value;- });+ locationTagChips = _getLocationTags();_locTagUpdateListener = Bus.instance.on<LocationTagUpdatedEvent>().listen((event,) {- locationTagChips = _getLocationTags();+ setState(() {+ locationTagChips = _getLocationTags();+ });});-super.initState();}@@ -64,96 +58,60 @@ class _LocationTagsWidgetState extends State<LocationTagsWidget> {@overrideWidget build(BuildContext context) {- return AnimatedSwitcher(- duration: const Duration(milliseconds: 500),- switchInCurve: Curves.easeInOutExpo,- switchOutCurve: Curves.easeInOutExpo,- child: InfoItemWidget(- key: ValueKey(title),- leadingIconWidget: const HugeIcon(- icon: HugeIcons.strokeRoundedLocation01,+ final colors = context.componentColors;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(AppLocalizations.of(context).location, style: TextStyles.h2),+ const SizedBox(height: Spacing.lg),+ FutureBuilder<List<Widget>>(+ future: locationTagChips,+ builder: (context, snapshot) {+ final placeChips = snapshot.data ?? const <Widget>[];+ return Wrap(+ spacing: Spacing.sm,+ runSpacing: Spacing.sm,+ children: [+ ...placeChips,+ IconButtonComponent(+ icon: HugeIcon(+ icon: HugeIcons.strokeRoundedPlusSign,+ size: IconSizes.small,+ color: colors.textBase,+ ),+ variant: IconButtonComponentVariant.circular,+ shouldSurfaceExecutionStates: false,+ onTap: () =>+ showAddLocationSheet(context, widget.file.location!),+ ),+ ],+ );+ },),- title: title,- subtitleSection: locationTagChips,- onTap: onTap,- endSection: _loadedLocationTags- ? InfoMap(widget.file)- : const SizedBox.shrink(),-- /// to be used when state issues are fixed when location is updated- // editOnTap: widget.file.ownerID == Configuration.instance.getUserID()!- // ? () {- // showBarModalBottomSheet(- // shape: const RoundedRectangleBorder(- // borderRadius: BorderRadius.vertical(- // top: Radius.circular(5),- // ),- // ),- // backgroundColor:- // getEnteColorScheme(context).backgroundElevated,- // barrierColor: backdropFaintDark,- // context: context,- // builder: (context) {- // return UpdateLocationDataWidget([widget.file]);- // },- // );- // }- // : null,- ),+ InfoMap(widget.file),+ ],);}Future<List<Widget>> _getLocationTags() async {- // await Future.delayed(const Duration(seconds: 1));final locationTags = await locationService.enclosingLocationTags(widget.file.location!,);- if (locationTags.isEmpty) {- if (mounted) {- setState(() {- title = AppLocalizations.of(context).location;- onTap = null;- });- }- return [- ChipButtonWidget(- AppLocalizations.of(context).addLocation,- onTap: () => showAddLocationSheet(context, widget.file.location!),- ),- ];- } else {- if (mounted) {- setState(() {- title = AppLocalizations.of(context).location;- onTap = null;- });- }- final result = locationTags- .map(- (locationTagEntity) => ChipButtonWidget(- locationTagEntity.item.name,- onTap: () {- routeToPage(- context,- LocationScreenStateProvider(- locationTagEntity,- const LocationScreen(),- ),- );- },+ return locationTags+ .map(+ (locationTagEntity) => FilterChipComponent(+ label: locationTagEntity.item.name,+ onChanged: (_) => routeToPage(+ context,+ LocationScreenStateProvider(+ locationTagEntity,+ const LocationScreen(),+ ),),- )- .toList();- result.add(- ChipButtonWidget(- null,- leadingIcon: Icons.add,- iconSize: 15,- onTap: () => showAddLocationSheet(context, widget.file.location!),- ),- );- return result;- }+ ),+ )+ .toList();}}@@ -200,7 +158,7 @@ class _InfoMapState extends State<InfoMap> {padding: const EdgeInsets.only(top: 8),child: ClipRRect(clipBehavior: Clip.antiAliasWithSaveLayer,- borderRadius: const BorderRadius.all(Radius.circular(8)),+ borderRadius: const BorderRadius.all(Radius.circular(Radii.button)),child: SizedBox(height: 124,child: _hasEnabledMap@@ -236,7 +194,7 @@ class _InfoMapState extends State<InfoMap> {IgnorePointer(child: Container(decoration: BoxDecoration(- borderRadius: BorderRadius.circular(8),+ borderRadius: BorderRadius.circular(Radii.button),border: Border.all(color: getEnteColorScheme(context).strokeFaint,),@@ -282,7 +240,9 @@ class _InfoMapState extends State<InfoMap> {),Container(decoration: BoxDecoration(- borderRadius: BorderRadius.circular(8),+ borderRadius: BorderRadius.circular(+ Radii.button,+ ),border: Border.all(color: getEnteColorScheme(context,