mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-25 00:14:42 +01:00
Fix not grouping by month when zoomed out to the lowest level
This commit is contained in:
parent
feea195e60
commit
47348cf10a
4 changed files with 36 additions and 5 deletions
|
@ -38,6 +38,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
on<_SetEnableMemoryCollection>(_onSetEnableMemoryCollection);
|
on<_SetEnableMemoryCollection>(_onSetEnableMemoryCollection);
|
||||||
on<_SetSortByName>(_onSetSortByName);
|
on<_SetSortByName>(_onSetSortByName);
|
||||||
on<_SetMemoriesRange>(_onSetMemoriesRange);
|
on<_SetMemoriesRange>(_onSetMemoriesRange);
|
||||||
|
on<_UpdateDateTimeGroup>(_onUpdateDateTimeGroup);
|
||||||
|
|
||||||
on<_SetError>(_onSetError);
|
on<_SetError>(_onSetError);
|
||||||
|
|
||||||
|
@ -236,18 +237,22 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int newZoom;
|
final int newZoom;
|
||||||
|
final currZoom = state.zoom;
|
||||||
if (state.scale! >= 1.25) {
|
if (state.scale! >= 1.25) {
|
||||||
// scale up
|
// scale up
|
||||||
newZoom = (state.zoom + 1).clamp(-1, 2);
|
newZoom = (currZoom + 1).clamp(-1, 2);
|
||||||
} else if (state.scale! <= 0.75) {
|
} else if (state.scale! <= 0.75) {
|
||||||
newZoom = (state.zoom - 1).clamp(-1, 2);
|
newZoom = (currZoom - 1).clamp(-1, 2);
|
||||||
} else {
|
} else {
|
||||||
newZoom = state.zoom;
|
newZoom = currZoom;
|
||||||
}
|
}
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
zoom: newZoom,
|
zoom: newZoom,
|
||||||
scale: null,
|
scale: null,
|
||||||
));
|
));
|
||||||
|
if ((currZoom >= 0) != (newZoom >= 0)) {
|
||||||
|
add(const _UpdateDateTimeGroup());
|
||||||
|
}
|
||||||
unawaited(prefController.setHomePhotosZoomLevel(newZoom));
|
unawaited(prefController.setHomePhotosZoomLevel(newZoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +277,11 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
_transformItems(state.files);
|
_transformItems(state.files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onUpdateDateTimeGroup(_UpdateDateTimeGroup ev, Emitter<_State> emit) {
|
||||||
|
_log.info(ev);
|
||||||
|
_transformItems(state.files);
|
||||||
|
}
|
||||||
|
|
||||||
void _onSetError(_SetError ev, Emitter<_State> emit) {
|
void _onSetError(_SetError ev, Emitter<_State> emit) {
|
||||||
_log.info(ev);
|
_log.info(ev);
|
||||||
emit(state.copyWith(error: ExceptionEvent(ev.error, ev.stackTrace)));
|
emit(state.copyWith(error: ExceptionEvent(ev.error, ev.stackTrace)));
|
||||||
|
@ -286,6 +296,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
sort: prefController.isPhotosTabSortByName.value
|
sort: prefController.isPhotosTabSortByName.value
|
||||||
? _ItemSort.filename
|
? _ItemSort.filename
|
||||||
: _ItemSort.dateTime,
|
: _ItemSort.dateTime,
|
||||||
|
isGroupByDay: prefController.homePhotosZoomLevel.value >= 0,
|
||||||
memoriesDayRange: prefController.memoriesRange.value,
|
memoriesDayRange: prefController.memoriesRange.value,
|
||||||
locale: language_util.getSelectedLocale() ??
|
locale: language_util.getSelectedLocale() ??
|
||||||
PlatformDispatcher.instance.locale,
|
PlatformDispatcher.instance.locale,
|
||||||
|
@ -349,7 +360,7 @@ _ItemTransformerResult _buildItem(_ItemTransformerArgument arg) {
|
||||||
final sortedFiles =
|
final sortedFiles =
|
||||||
arg.files.where((f) => f.fdIsArchived != true).sorted(sorter);
|
arg.files.where((f) => f.fdIsArchived != true).sorted(sorter);
|
||||||
final dateHelper = arg.sort == _ItemSort.dateTime
|
final dateHelper = arg.sort == _ItemSort.dateTime
|
||||||
? photo_list_util.DateGroupHelper(isMonthOnly: false)
|
? photo_list_util.DateGroupHelper(isMonthOnly: !arg.isGroupByDay)
|
||||||
: null;
|
: null;
|
||||||
final today = clock.now();
|
final today = clock.now();
|
||||||
final memoryCollectionHelper = arg.sort == _ItemSort.dateTime
|
final memoryCollectionHelper = arg.sort == _ItemSort.dateTime
|
||||||
|
@ -369,7 +380,7 @@ _ItemTransformerResult _buildItem(_ItemTransformerArgument arg) {
|
||||||
}
|
}
|
||||||
final date = dateHelper?.onFile(file);
|
final date = dateHelper?.onFile(file);
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
transformed.add(_DateItem(date: date));
|
transformed.add(_DateItem(date: date, isMonthOnly: !arg.isGroupByDay));
|
||||||
}
|
}
|
||||||
transformed.add(item);
|
transformed.add(item);
|
||||||
memoryCollectionHelper?.addFile(file);
|
memoryCollectionHelper?.addFile(file);
|
||||||
|
|
|
@ -238,6 +238,14 @@ class _SetMemoriesRange implements _Event {
|
||||||
final int value;
|
final int value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@toString
|
||||||
|
class _UpdateDateTimeGroup implements _Event {
|
||||||
|
const _UpdateDateTimeGroup();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => _$toString();
|
||||||
|
}
|
||||||
|
|
||||||
@toString
|
@toString
|
||||||
class _SetError implements _Event {
|
class _SetError implements _Event {
|
||||||
const _SetError(this.error, [this.stackTrace]);
|
const _SetError(this.error, [this.stackTrace]);
|
||||||
|
|
|
@ -76,6 +76,7 @@ class _VideoItem extends _FileItem {
|
||||||
class _DateItem extends _Item {
|
class _DateItem extends _Item {
|
||||||
const _DateItem({
|
const _DateItem({
|
||||||
required this.date,
|
required this.date,
|
||||||
|
required this.isMonthOnly,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -88,10 +89,12 @@ class _DateItem extends _Item {
|
||||||
Widget buildWidget(BuildContext context) {
|
Widget buildWidget(BuildContext context) {
|
||||||
return PhotoListDate(
|
return PhotoListDate(
|
||||||
date: date,
|
date: date,
|
||||||
|
isMonthOnly: isMonthOnly,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
|
final bool isMonthOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum _ItemSort { dateTime, filename }
|
enum _ItemSort { dateTime, filename }
|
||||||
|
@ -101,6 +104,7 @@ class _ItemTransformerArgument {
|
||||||
required this.account,
|
required this.account,
|
||||||
required this.files,
|
required this.files,
|
||||||
required this.sort,
|
required this.sort,
|
||||||
|
required this.isGroupByDay,
|
||||||
required this.memoriesDayRange,
|
required this.memoriesDayRange,
|
||||||
required this.locale,
|
required this.locale,
|
||||||
});
|
});
|
||||||
|
@ -108,6 +112,7 @@ class _ItemTransformerArgument {
|
||||||
final Account account;
|
final Account account;
|
||||||
final List<FileDescriptor> files;
|
final List<FileDescriptor> files;
|
||||||
final _ItemSort sort;
|
final _ItemSort sort;
|
||||||
|
final bool isGroupByDay;
|
||||||
final int memoriesDayRange;
|
final int memoriesDayRange;
|
||||||
final Locale locale;
|
final Locale locale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,6 +273,13 @@ extension _$_SetMemoriesRangeToString on _SetMemoriesRange {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension _$_UpdateDateTimeGroupToString on _UpdateDateTimeGroup {
|
||||||
|
String _$toString() {
|
||||||
|
// ignore: unnecessary_string_interpolations
|
||||||
|
return "_UpdateDateTimeGroup {}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension _$_SetErrorToString on _SetError {
|
extension _$_SetErrorToString on _SetError {
|
||||||
String _$toString() {
|
String _$toString() {
|
||||||
// ignore: unnecessary_string_interpolations
|
// ignore: unnecessary_string_interpolations
|
||||||
|
|
Loading…
Add table
Reference in a new issue