feat(mobile): custom date range for map

This commit is contained in:
Yaros
2026-02-14 09:56:09 +01:00
parent 2fb9f84b56
commit 39d2e14d3a
8 changed files with 195 additions and 12 deletions
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:immich_mobile/extensions/translate_extensions.dart';
import 'package:immich_mobile/presentation/widgets/map/map.state.dart';
import 'package:intl/intl.dart';
class MapCustomTimeRange extends StatelessWidget {
const MapCustomTimeRange({super.key, required this.customTimeRange, required this.onChanged});
final CustomTimeRange customTimeRange;
final Function(CustomTimeRange) onChanged;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text("date_after".t(context: context)),
subtitle: Text(
customTimeRange.from != null
? DateFormat.yMMMd().add_jm().format(customTimeRange.from!)
: "not_set".t(context: context),
),
trailing: customTimeRange.from != null
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(customTimeRange.clearFrom()))
: null,
onTap: () async {
final picked = await showDatePicker(
context: context,
initialDate: customTimeRange.from ?? DateTime.now(),
firstDate: DateTime(1970),
lastDate: DateTime.now(),
);
if (picked != null) {
onChanged(customTimeRange.copyWith(from: picked));
}
},
),
ListTile(
title: Text("date_before".t(context: context)),
subtitle: Text(
customTimeRange.to != null
? DateFormat.yMMMd().add_jm().format(customTimeRange.to!)
: "not_set".t(context: context),
),
trailing: customTimeRange.to != null
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(customTimeRange.clearTo()))
: null,
onTap: () async {
final picked = await showDatePicker(
context: context,
initialDate: customTimeRange.to ?? DateTime.now(),
firstDate: DateTime(1970),
lastDate: DateTime.now(),
);
if (picked != null) {
onChanged(customTimeRange.copyWith(to: picked));
}
},
),
],
);
}
}