46 lines
2.0 KiB
Python
46 lines
2.0 KiB
Python
import re
|
|
|
|
with open('kifi-app/lib/features/projects/presentation/widgets/add_task_sheet.dart', 'r') as f:
|
|
content = f.read()
|
|
|
|
content = content.replace("import '../../providers/project_provider.dart';", "import '../../providers/project_provider.dart';\nimport '../../providers/user_provider.dart';\nimport '../../../../core/domain/user.dart';")
|
|
|
|
old_field = r""" PremiumTextField\(
|
|
labelText: 'Assignee Name \(Optional\)',
|
|
prefixIcon: const Icon\(LucideIcons\.user\),
|
|
onSaved: \(val\) => _assigneeName = val \?\? '',
|
|
\),"""
|
|
|
|
new_field = """ Autocomplete<User>(
|
|
optionsBuilder: (TextEditingValue textEditingValue) async {
|
|
if (textEditingValue.text.isEmpty) {
|
|
return const Iterable<User>.empty();
|
|
}
|
|
try {
|
|
return await ref.read(userSearchProvider(textEditingValue.text).future);
|
|
} catch (e) {
|
|
return const Iterable<User>.empty();
|
|
}
|
|
},
|
|
displayStringForOption: (User option) => '${option.name} (${option.email})',
|
|
onSelected: (User selection) {
|
|
_assigneeName = selection.name;
|
|
},
|
|
fieldViewBuilder: (context, textEditingController, focusNode, onFieldSubmitted) {
|
|
return PremiumTextField(
|
|
controller: textEditingController,
|
|
focusNode: focusNode,
|
|
labelText: 'Assignee Name (Optional)',
|
|
prefixIcon: const Icon(LucideIcons.user),
|
|
onSaved: (val) {
|
|
if (_assigneeName.isEmpty) _assigneeName = val ?? '';
|
|
},
|
|
);
|
|
},
|
|
),"""
|
|
|
|
content = re.sub(old_field, new_field, content)
|
|
|
|
with open('kifi-app/lib/features/projects/presentation/widgets/add_task_sheet.dart', 'w') as f:
|
|
f.write(content)
|