mirror of
https://github.com/immich-app/immich.git
synced 2024-12-22 01:47:08 +02:00
2b5cef156c
* Add i18n framework to mobile app and write simple translation generator * Replace all texts in login_form with i18n keys * Localization of sharing section * Localization of asset viewer section * Use JSON as base translation format * Add check for missing/unused translation keys * Add localizely * Remove i18n directory in favour of localizely * Backup Translation * More translations * Translate home page * Translation of search page * Translate new server version announcement * Reformat code * Fix typo in german translation * Update englisch translations * Change translation keys to match dart filenames * Add /api to translated endpoint_urls * Update localizely.yml * Add languages to ios plist * Remove unused keys * Added script to check outdated key in other translations * Add download key to localizely.yml Co-authored-by: Alex <alex.tran1502@gmail.com>
83 lines
2.8 KiB
Dart
83 lines
2.8 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/modules/sharing/models/shared_album.model.dart';
|
|
import 'package:immich_mobile/modules/sharing/providers/album_viewer.provider.dart';
|
|
|
|
class AlbumViewerEditableTitle extends HookConsumerWidget {
|
|
final SharedAlbum albumInfo;
|
|
final FocusNode titleFocusNode;
|
|
const AlbumViewerEditableTitle(
|
|
{Key? key, required this.albumInfo, required this.titleFocusNode})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final titleTextEditController =
|
|
useTextEditingController(text: albumInfo.albumName);
|
|
|
|
void onFocusModeChange() {
|
|
if (!titleFocusNode.hasFocus && titleTextEditController.text.isEmpty) {
|
|
ref.watch(albumViewerProvider.notifier).setEditTitleText("Untitled");
|
|
titleTextEditController.text = "Untitled";
|
|
}
|
|
}
|
|
|
|
useEffect(() {
|
|
titleFocusNode.addListener(onFocusModeChange);
|
|
return () {
|
|
titleFocusNode.removeListener(onFocusModeChange);
|
|
};
|
|
}, []);
|
|
|
|
return TextField(
|
|
onChanged: (value) {
|
|
if (value.isEmpty) {
|
|
} else {
|
|
ref.watch(albumViewerProvider.notifier).setEditTitleText(value);
|
|
}
|
|
},
|
|
focusNode: titleFocusNode,
|
|
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
|
controller: titleTextEditController,
|
|
onTap: () {
|
|
FocusScope.of(context).requestFocus(titleFocusNode);
|
|
|
|
ref
|
|
.watch(albumViewerProvider.notifier)
|
|
.setEditTitleText(albumInfo.albumName);
|
|
ref.watch(albumViewerProvider.notifier).enableEditAlbum();
|
|
|
|
if (titleTextEditController.text == 'Untitled') {
|
|
titleTextEditController.clear();
|
|
}
|
|
},
|
|
decoration: InputDecoration(
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
|
suffixIcon: titleFocusNode.hasFocus
|
|
? IconButton(
|
|
onPressed: () {
|
|
titleTextEditController.clear();
|
|
},
|
|
icon: const Icon(Icons.cancel_rounded),
|
|
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),
|
|
),
|
|
focusColor: Colors.grey[300],
|
|
fillColor: Colors.grey[200],
|
|
filled: titleFocusNode.hasFocus,
|
|
hintText: 'share_add_title'.tr(),
|
|
),
|
|
);
|
|
}
|
|
}
|