Files
Kifi/scratch/patch_project_init.py

43 lines
1.2 KiB
Python

import re
with open('kifi-app/lib/features/projects/presentation/widgets/add_project_sheet.dart', 'r') as f:
content = f.read()
old_init = """class _AddProjectSheetState extends ConsumerState<AddProjectSheet> {
final _formKey = GlobalKey<FormState>();
String _name = '';
String _description = '';
double _budget = 0;
int? _selectedCustomerId;
bool _isLoading = false;
@override
Widget build(BuildContext context) {"""
new_init = """class _AddProjectSheetState extends ConsumerState<AddProjectSheet> {
final _formKey = GlobalKey<FormState>();
String _name = '';
String _description = '';
double _budget = 0;
int? _selectedCustomerId;
bool _isLoading = false;
@override
void initState() {
super.initState();
if (widget.project != null) {
_name = widget.project!.name;
_description = widget.project!.description ?? '';
_budget = widget.project!.budget ?? 0;
_selectedCustomerId = widget.project!.customerId;
}
}
@override
Widget build(BuildContext context) {"""
content = content.replace(old_init, new_init)
with open('kifi-app/lib/features/projects/presentation/widgets/add_project_sheet.dart', 'w') as f:
f.write(content)