2022-09-28 18:30:38 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-11-20 15:58:03 +01:00
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
2022-09-28 18:30:38 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 17:19:53 +01:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-08-06 16:20:27 +02:00
|
|
|
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
2024-05-07 06:04:21 +02:00
|
|
|
import 'package:immich_mobile/widgets/asset_grid/asset_grid_data_structure.dart';
|
2024-05-02 22:59:14 +02:00
|
|
|
import 'package:immich_mobile/providers/app_settings.provider.dart';
|
|
|
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
|
|
|
import 'package:immich_mobile/providers/haptic_feedback.provider.dart';
|
2022-09-28 18:30:38 +02:00
|
|
|
|
2023-11-20 15:58:03 +01:00
|
|
|
class GroupDividerTitle extends HookConsumerWidget {
|
2023-02-09 18:35:44 +01:00
|
|
|
const GroupDividerTitle({
|
2024-01-27 17:14:32 +01:00
|
|
|
super.key,
|
2023-01-18 16:59:23 +01:00
|
|
|
required this.text,
|
2022-10-01 19:19:40 +02:00
|
|
|
required this.multiselectEnabled,
|
|
|
|
required this.onSelect,
|
|
|
|
required this.onDeselect,
|
|
|
|
required this.selected,
|
2024-01-27 17:14:32 +01:00
|
|
|
});
|
2022-09-28 18:30:38 +02:00
|
|
|
|
2023-01-18 16:59:23 +01:00
|
|
|
final String text;
|
2022-10-01 19:19:40 +02:00
|
|
|
final bool multiselectEnabled;
|
|
|
|
final Function onSelect;
|
|
|
|
final Function onDeselect;
|
|
|
|
final bool selected;
|
2022-09-28 18:30:38 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-11-20 15:58:03 +01:00
|
|
|
final appSettingService = ref.watch(appSettingsServiceProvider);
|
|
|
|
final groupBy = useState(GroupAssetsBy.day);
|
|
|
|
|
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
groupBy.value = GroupAssetsBy.values[
|
|
|
|
appSettingService.getSetting<int>(AppSettingsEnum.groupAssetsBy)];
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
|
2022-10-01 19:19:40 +02:00
|
|
|
void handleTitleIconClick() {
|
2024-04-15 07:50:47 +02:00
|
|
|
ref.read(hapticFeedbackProvider.notifier).heavyImpact();
|
2022-10-01 19:19:40 +02:00
|
|
|
if (selected) {
|
|
|
|
onDeselect();
|
2022-09-28 18:30:38 +02:00
|
|
|
} else {
|
2022-10-01 19:19:40 +02:00
|
|
|
onSelect();
|
2022-09-28 18:30:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
2023-11-20 15:58:03 +01:00
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: groupBy.value == GroupAssetsBy.month ? 32.0 : 16.0,
|
2023-06-29 05:33:57 +02:00
|
|
|
bottom: 16.0,
|
2022-09-28 18:30:38 +02:00
|
|
|
left: 12.0,
|
|
|
|
right: 12.0,
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-01-18 16:59:23 +01:00
|
|
|
text,
|
2023-11-20 15:58:03 +01:00
|
|
|
style: groupBy.value == GroupAssetsBy.month
|
|
|
|
? context.textTheme.bodyLarge?.copyWith(
|
|
|
|
fontSize: 24.0,
|
|
|
|
)
|
|
|
|
: context.textTheme.labelLarge?.copyWith(
|
|
|
|
color: context.textTheme.labelLarge?.color?.withAlpha(250),
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
2022-09-28 18:30:38 +02:00
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
GestureDetector(
|
2022-10-01 19:19:40 +02:00
|
|
|
onTap: handleTitleIconClick,
|
|
|
|
child: multiselectEnabled && selected
|
2022-09-28 18:30:38 +02:00
|
|
|
? Icon(
|
|
|
|
Icons.check_circle_rounded,
|
2023-11-09 17:19:53 +01:00
|
|
|
color: context.primaryColor,
|
2022-09-28 18:30:38 +02:00
|
|
|
)
|
2024-08-06 16:20:27 +02:00
|
|
|
: Icon(
|
2022-09-28 18:30:38 +02:00
|
|
|
Icons.check_circle_outline_rounded,
|
2024-08-06 16:20:27 +02:00
|
|
|
color: context.colorScheme.onSurfaceSecondary,
|
2022-09-28 18:30:38 +02:00
|
|
|
),
|
2023-08-19 00:52:40 +02:00
|
|
|
),
|
2022-09-28 18:30:38 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|