mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: rename customtimerange variables
This commit is contained in:
@@ -27,8 +27,8 @@ class DriftMapRepository extends DriftDatabaseRepository {
|
|||||||
condition = condition & _db.remoteAssetEntity.isFavorite.equals(true);
|
condition = condition & _db.remoteAssetEntity.isFavorite.equals(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
final from = options.customTimeRange.from;
|
final from = options.timeRange.from;
|
||||||
final to = options.customTimeRange.to;
|
final to = options.timeRange.to;
|
||||||
|
|
||||||
if (from != null || to != null) {
|
if (from != null || to != null) {
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class TimelineMapOptions {
|
|||||||
final bool includeArchived;
|
final bool includeArchived;
|
||||||
final bool withPartners;
|
final bool withPartners;
|
||||||
final int relativeDays;
|
final int relativeDays;
|
||||||
final TimeRange customTimeRange;
|
final TimeRange timeRange;
|
||||||
|
|
||||||
const TimelineMapOptions({
|
const TimelineMapOptions({
|
||||||
required this.bounds,
|
required this.bounds,
|
||||||
@@ -30,7 +30,7 @@ class TimelineMapOptions {
|
|||||||
this.includeArchived = false,
|
this.includeArchived = false,
|
||||||
this.withPartners = false,
|
this.withPartners = false,
|
||||||
this.relativeDays = 0,
|
this.relativeDays = 0,
|
||||||
this.customTimeRange = const TimeRange(),
|
this.timeRange = const TimeRange(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,8 +531,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|||||||
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
final from = options.customTimeRange.from;
|
final from = options.timeRange.from;
|
||||||
final to = options.customTimeRange.to;
|
final to = options.timeRange.to;
|
||||||
|
|
||||||
if (from != null || to != null) {
|
if (from != null || to != null) {
|
||||||
// Use custom from/to filters
|
// Use custom from/to filters
|
||||||
@@ -585,8 +585,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|||||||
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
final from = options.customTimeRange.from;
|
final from = options.timeRange.from;
|
||||||
final to = options.customTimeRange.to;
|
final to = options.timeRange.to;
|
||||||
|
|
||||||
if (from != null || to != null) {
|
if (from != null || to != null) {
|
||||||
// Use custom from/to filters
|
// Use custom from/to filters
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class MapState {
|
|||||||
final bool includeArchived;
|
final bool includeArchived;
|
||||||
final bool withPartners;
|
final bool withPartners;
|
||||||
final int relativeDays;
|
final int relativeDays;
|
||||||
final TimeRange customTimeRange;
|
final TimeRange timeRange;
|
||||||
|
|
||||||
const MapState({
|
const MapState({
|
||||||
this.themeMode = ThemeMode.system,
|
this.themeMode = ThemeMode.system,
|
||||||
@@ -39,7 +39,7 @@ class MapState {
|
|||||||
this.includeArchived = false,
|
this.includeArchived = false,
|
||||||
this.withPartners = false,
|
this.withPartners = false,
|
||||||
this.relativeDays = 0,
|
this.relativeDays = 0,
|
||||||
this.customTimeRange = const TimeRange(),
|
this.timeRange = const TimeRange(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -57,7 +57,7 @@ class MapState {
|
|||||||
bool? includeArchived,
|
bool? includeArchived,
|
||||||
bool? withPartners,
|
bool? withPartners,
|
||||||
int? relativeDays,
|
int? relativeDays,
|
||||||
TimeRange? customTimeRange,
|
TimeRange? timeRange,
|
||||||
}) {
|
}) {
|
||||||
return MapState(
|
return MapState(
|
||||||
bounds: bounds ?? this.bounds,
|
bounds: bounds ?? this.bounds,
|
||||||
@@ -66,7 +66,7 @@ class MapState {
|
|||||||
includeArchived: includeArchived ?? this.includeArchived,
|
includeArchived: includeArchived ?? this.includeArchived,
|
||||||
withPartners: withPartners ?? this.withPartners,
|
withPartners: withPartners ?? this.withPartners,
|
||||||
relativeDays: relativeDays ?? this.relativeDays,
|
relativeDays: relativeDays ?? this.relativeDays,
|
||||||
customTimeRange: customTimeRange ?? this.customTimeRange,
|
timeRange: timeRange ?? this.timeRange,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +75,7 @@ class MapState {
|
|||||||
onlyFavorites: onlyFavorites,
|
onlyFavorites: onlyFavorites,
|
||||||
includeArchived: includeArchived,
|
includeArchived: includeArchived,
|
||||||
withPartners: withPartners,
|
withPartners: withPartners,
|
||||||
relativeDays: relativeDays,
|
timeRange: timeRange,
|
||||||
customTimeRange: customTimeRange,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,20 +116,14 @@ class MapStateNotifier extends Notifier<MapState> {
|
|||||||
EventStream.shared.emit(const MapMarkerReloadEvent());
|
EventStream.shared.emit(const MapMarkerReloadEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRelativeTime(int relativeDays) {
|
void setTimeRange(TimeRange range) {
|
||||||
ref.read(appSettingsServiceProvider).setSetting(AppSettingsEnum.mapRelativeDate, relativeDays);
|
|
||||||
state = state.copyWith(relativeDays: relativeDays);
|
|
||||||
EventStream.shared.emit(const MapMarkerReloadEvent());
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCustomTimeRange(TimeRange range) {
|
|
||||||
ref
|
ref
|
||||||
.read(appSettingsServiceProvider)
|
.read(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.mapCustomFrom, range.from == null ? "" : range.from!.toIso8601String());
|
.setSetting(AppSettingsEnum.mapCustomFrom, range.from == null ? "" : range.from!.toIso8601String());
|
||||||
ref
|
ref
|
||||||
.read(appSettingsServiceProvider)
|
.read(appSettingsServiceProvider)
|
||||||
.setSetting(AppSettingsEnum.mapCustomTo, range.to == null ? "" : range.to!.toIso8601String());
|
.setSetting(AppSettingsEnum.mapCustomTo, range.to == null ? "" : range.to!.toIso8601String());
|
||||||
state = state.copyWith(customTimeRange: range);
|
state = state.copyWith(timeRange: range);
|
||||||
EventStream.shared.emit(const MapMarkerReloadEvent());
|
EventStream.shared.emit(const MapMarkerReloadEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,9 +137,8 @@ class MapStateNotifier extends Notifier<MapState> {
|
|||||||
onlyFavorites: appSettingsService.getSetting(AppSettingsEnum.mapShowFavoriteOnly),
|
onlyFavorites: appSettingsService.getSetting(AppSettingsEnum.mapShowFavoriteOnly),
|
||||||
includeArchived: appSettingsService.getSetting(AppSettingsEnum.mapIncludeArchived),
|
includeArchived: appSettingsService.getSetting(AppSettingsEnum.mapIncludeArchived),
|
||||||
withPartners: appSettingsService.getSetting(AppSettingsEnum.mapwithPartners),
|
withPartners: appSettingsService.getSetting(AppSettingsEnum.mapwithPartners),
|
||||||
relativeDays: appSettingsService.getSetting(AppSettingsEnum.mapRelativeDate),
|
|
||||||
bounds: LatLngBounds(northeast: const LatLng(0, 0), southwest: const LatLng(0, 0)),
|
bounds: LatLngBounds(northeast: const LatLng(0, 0), southwest: const LatLng(0, 0)),
|
||||||
customTimeRange: TimeRange(
|
timeRange: TimeRange(
|
||||||
from: customFrom.isNotEmpty ? DateTime.parse(customFrom) : null,
|
from: customFrom.isNotEmpty ? DateTime.parse(customFrom) : null,
|
||||||
to: customTo.isNotEmpty ? DateTime.parse(customTo) : null,
|
to: customTo.isNotEmpty ? DateTime.parse(customTo) : null,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class _DriftMapSettingsSheetState extends ConsumerState<DriftMapSettingsSheet> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
final mapState = ref.read(mapStateProvider);
|
final mapState = ref.read(mapStateProvider);
|
||||||
final timeRange = mapState.customTimeRange;
|
final timeRange = mapState.timeRange;
|
||||||
useCustomRange = timeRange.from != null || timeRange.to != null;
|
useCustomRange = timeRange.from != null || timeRange.to != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +64,10 @@ class _DriftMapSettingsSheetState extends ConsumerState<DriftMapSettingsSheet> {
|
|||||||
onChanged: (withPartners) => ref.read(mapStateProvider.notifier).switchWithPartners(withPartners),
|
onChanged: (withPartners) => ref.read(mapStateProvider.notifier).switchWithPartners(withPartners),
|
||||||
),
|
),
|
||||||
if (useCustomRange) ...[
|
if (useCustomRange) ...[
|
||||||
MapCustomTimeRange(
|
MapTimeRange(
|
||||||
customTimeRange: mapState.customTimeRange,
|
timeRange: mapState.timeRange,
|
||||||
onChanged: (range) {
|
onChanged: (range) {
|
||||||
ref.read(mapStateProvider.notifier).setCustomTimeRange(range);
|
ref.read(mapStateProvider.notifier).setTimeRange(range);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
@@ -76,7 +76,7 @@ class _DriftMapSettingsSheetState extends ConsumerState<DriftMapSettingsSheet> {
|
|||||||
onPressed: () => setState(() {
|
onPressed: () => setState(() {
|
||||||
useCustomRange = false;
|
useCustomRange = false;
|
||||||
ref.read(mapStateProvider.notifier).setRelativeTime(0);
|
ref.read(mapStateProvider.notifier).setRelativeTime(0);
|
||||||
ref.read(mapStateProvider.notifier).setCustomTimeRange(const TimeRange());
|
ref.read(mapStateProvider.notifier).setTimeRange(const TimeRange());
|
||||||
}),
|
}),
|
||||||
child: Text("remove_custom_date_range".t(context: context)),
|
child: Text("remove_custom_date_range".t(context: context)),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|||||||
import 'package:immich_mobile/presentation/widgets/map/map.state.dart';
|
import 'package:immich_mobile/presentation/widgets/map/map.state.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class MapCustomTimeRange extends StatelessWidget {
|
class MapTimeRange extends StatelessWidget {
|
||||||
const MapCustomTimeRange({super.key, required this.customTimeRange, required this.onChanged});
|
const MapTimeRange({super.key, required this.timeRange, required this.onChanged});
|
||||||
|
|
||||||
final TimeRange customTimeRange;
|
final TimeRange timeRange;
|
||||||
final Function(TimeRange) onChanged;
|
final Function(TimeRange) onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -17,44 +17,42 @@ class MapCustomTimeRange extends StatelessWidget {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text("date_after".t(context: context)),
|
title: Text("date_after".t(context: context)),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
customTimeRange.from != null
|
timeRange.from != null
|
||||||
? DateFormat.yMMMd().add_jm().format(customTimeRange.from!)
|
? DateFormat.yMMMd().add_jm().format(timeRange.from!)
|
||||||
: "not_set".t(context: context),
|
: "not_set".t(context: context),
|
||||||
),
|
),
|
||||||
trailing: customTimeRange.from != null
|
trailing: timeRange.from != null
|
||||||
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(customTimeRange.clearFrom()))
|
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(timeRange.clearFrom()))
|
||||||
: null,
|
: null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: customTimeRange.from ?? DateTime.now(),
|
initialDate: timeRange.from ?? DateTime.now(),
|
||||||
firstDate: DateTime(1970),
|
firstDate: DateTime(1970),
|
||||||
lastDate: DateTime.now(),
|
lastDate: DateTime.now(),
|
||||||
);
|
);
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
onChanged(customTimeRange.copyWith(from: picked));
|
onChanged(timeRange.copyWith(from: picked));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("date_before".t(context: context)),
|
title: Text("date_before".t(context: context)),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
customTimeRange.to != null
|
timeRange.to != null ? DateFormat.yMMMd().add_jm().format(timeRange.to!) : "not_set".t(context: context),
|
||||||
? DateFormat.yMMMd().add_jm().format(customTimeRange.to!)
|
|
||||||
: "not_set".t(context: context),
|
|
||||||
),
|
),
|
||||||
trailing: customTimeRange.to != null
|
trailing: timeRange.to != null
|
||||||
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(customTimeRange.clearTo()))
|
? IconButton(icon: const Icon(Icons.close), onPressed: () => onChanged(timeRange.clearTo()))
|
||||||
: null,
|
: null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: customTimeRange.to ?? DateTime.now(),
|
initialDate: timeRange.to ?? DateTime.now(),
|
||||||
firstDate: DateTime(1970),
|
firstDate: DateTime(1970),
|
||||||
lastDate: DateTime.now(),
|
lastDate: DateTime.now(),
|
||||||
);
|
);
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
onChanged(customTimeRange.copyWith(to: picked));
|
onChanged(timeRange.copyWith(to: picked));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user