2022-07-07 20:40:54 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-04-23 21:08:45 -05:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 16:19:53 +00:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-05-02 15:59:14 -05:00
|
|
|
import 'package:immich_mobile/providers/album/album_title.provider.dart';
|
2022-04-23 21:08:45 -05:00
|
|
|
|
|
|
|
|
class AlbumTitleTextField extends ConsumerWidget {
|
|
|
|
|
const AlbumTitleTextField({
|
2024-01-27 16:14:32 +00:00
|
|
|
super.key,
|
2022-04-23 21:08:45 -05:00
|
|
|
required this.isAlbumTitleEmpty,
|
|
|
|
|
required this.albumTitleTextFieldFocusNode,
|
|
|
|
|
required this.albumTitleController,
|
|
|
|
|
required this.isAlbumTitleTextFieldFocus,
|
2024-01-27 16:14:32 +00:00
|
|
|
});
|
2022-04-23 21:08:45 -05:00
|
|
|
|
|
|
|
|
final ValueNotifier<bool> isAlbumTitleEmpty;
|
|
|
|
|
final FocusNode albumTitleTextFieldFocusNode;
|
|
|
|
|
final TextEditingController albumTitleController;
|
|
|
|
|
final ValueNotifier<bool> isAlbumTitleTextFieldFocus;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
return TextField(
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
if (v.isEmpty) {
|
|
|
|
|
isAlbumTitleEmpty.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
isAlbumTitleEmpty.value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ref.watch(albumTitleProvider.notifier).setAlbumTitle(v);
|
|
|
|
|
},
|
|
|
|
|
focusNode: albumTitleTextFieldFocusNode,
|
2025-07-29 00:34:03 +05:30
|
|
|
style: TextStyle(fontSize: 28, color: context.colorScheme.onSurface, fontWeight: FontWeight.bold),
|
2022-04-23 21:08:45 -05:00
|
|
|
controller: albumTitleController,
|
|
|
|
|
onTap: () {
|
|
|
|
|
isAlbumTitleTextFieldFocus.value = true;
|
|
|
|
|
|
|
|
|
|
if (albumTitleController.text == 'Untitled') {
|
|
|
|
|
albumTitleController.clear();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
|
|
|
|
suffixIcon: !isAlbumTitleEmpty.value && isAlbumTitleTextFieldFocus.value
|
|
|
|
|
? IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
albumTitleController.clear();
|
|
|
|
|
isAlbumTitleEmpty.value = true;
|
|
|
|
|
},
|
2025-07-29 00:34:03 +05:30
|
|
|
icon: Icon(Icons.cancel_rounded, color: context.primaryColor),
|
2022-04-23 21:08:45 -05:00
|
|
|
splashRadius: 10,
|
|
|
|
|
)
|
|
|
|
|
: null,
|
2025-06-25 13:06:24 +05:30
|
|
|
enabledBorder: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: Colors.transparent),
|
2025-07-29 00:34:03 +05:30
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
2022-04-23 21:08:45 -05:00
|
|
|
),
|
2025-06-25 13:06:24 +05:30
|
|
|
focusedBorder: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: Colors.transparent),
|
2025-07-29 00:34:03 +05:30
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
2022-04-23 21:08:45 -05:00
|
|
|
),
|
2025-04-15 10:54:26 -05:00
|
|
|
hintText: 'add_a_title'.tr(),
|
2024-08-06 19:50:27 +05:30
|
|
|
hintStyle: context.themeData.inputDecorationTheme.hintStyle?.copyWith(
|
2023-08-17 23:26:12 -05:00
|
|
|
fontSize: 28,
|
2024-08-06 14:39:07 -05:00
|
|
|
fontWeight: FontWeight.bold,
|
2023-08-17 23:26:12 -05:00
|
|
|
),
|
2022-04-23 21:08:45 -05:00
|
|
|
focusColor: Colors.grey[300],
|
2024-08-06 14:39:07 -05:00
|
|
|
fillColor: context.colorScheme.surfaceContainerHigh,
|
2022-04-23 21:08:45 -05:00
|
|
|
filled: isAlbumTitleTextFieldFocus.value,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|