2022-07-07 20:40:54 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-04-24 04:08:45 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:immich_mobile/modules/album/providers/album_title.provider.dart';
|
2022-04-24 04:08:45 +02:00
|
|
|
|
|
|
|
class AlbumTitleTextField extends ConsumerWidget {
|
|
|
|
const AlbumTitleTextField({
|
|
|
|
Key? key,
|
|
|
|
required this.isAlbumTitleEmpty,
|
|
|
|
required this.albumTitleTextFieldFocusNode,
|
|
|
|
required this.albumTitleController,
|
|
|
|
required this.isAlbumTitleTextFieldFocus,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final ValueNotifier<bool> isAlbumTitleEmpty;
|
|
|
|
final FocusNode albumTitleTextFieldFocusNode;
|
|
|
|
final TextEditingController albumTitleController;
|
|
|
|
final ValueNotifier<bool> isAlbumTitleTextFieldFocus;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-08-16 01:53:30 +02:00
|
|
|
final isDarkTheme = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
|
2022-04-24 04:08:45 +02:00
|
|
|
return TextField(
|
|
|
|
onChanged: (v) {
|
|
|
|
if (v.isEmpty) {
|
|
|
|
isAlbumTitleEmpty.value = true;
|
|
|
|
} else {
|
|
|
|
isAlbumTitleEmpty.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ref.watch(albumTitleProvider.notifier).setAlbumTitle(v);
|
|
|
|
},
|
|
|
|
focusNode: albumTitleTextFieldFocusNode,
|
2022-06-25 22:12:47 +02:00
|
|
|
style: TextStyle(
|
2022-07-13 14:23:48 +02:00
|
|
|
fontSize: 28,
|
|
|
|
color: Colors.grey[700],
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-04-24 04:08:45 +02: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;
|
|
|
|
},
|
2022-08-16 01:53:30 +02:00
|
|
|
icon: Icon(
|
|
|
|
Icons.cancel_rounded,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
),
|
2022-04-24 04:08:45 +02:00
|
|
|
splashRadius: 10,
|
|
|
|
)
|
|
|
|
: null,
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: const BorderSide(color: Colors.transparent),
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: const BorderSide(color: Colors.transparent),
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
2022-07-07 20:40:54 +02:00
|
|
|
hintText: 'share_add_title'.tr(),
|
2022-04-24 04:08:45 +02:00
|
|
|
focusColor: Colors.grey[300],
|
2022-08-16 01:53:30 +02:00
|
|
|
fillColor: isDarkTheme
|
|
|
|
? const Color.fromARGB(255, 32, 33, 35)
|
|
|
|
: Colors.grey[200],
|
2022-04-24 04:08:45 +02:00
|
|
|
filled: isAlbumTitleTextFieldFocus.value,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|