feat(#145): lien co-parent cliquable dans la fiche parent.
Squash merge develop → master. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1f8f1b9507
commit
fde63f8e72
@ -113,10 +113,73 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
||||
return '$fn $ln'.trim();
|
||||
}
|
||||
|
||||
String? _coParentSubtitle() {
|
||||
String? _coParentName() {
|
||||
final name = _coParent?.fullName.trim() ?? '';
|
||||
if (name.isEmpty) return null;
|
||||
return 'Co-parent : $name';
|
||||
return name.isEmpty ? null : name;
|
||||
}
|
||||
|
||||
Future<void> _openCoParent() async {
|
||||
if (_saving) return;
|
||||
final co = _coParent;
|
||||
final id = (co?.id ?? '').trim();
|
||||
if (co == null || id.isEmpty) return;
|
||||
|
||||
try {
|
||||
final parent = await UserService.getParent(id);
|
||||
if (!mounted) return;
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (ctx) => AdminParentEditModal(
|
||||
parent: parent,
|
||||
onSaved: () async {
|
||||
try {
|
||||
final refreshed = await UserService.getParent(widget.parent.user.id);
|
||||
if (!mounted) return;
|
||||
setState(() => _coParent = refreshed.coParent);
|
||||
} catch (_) {}
|
||||
widget.onSaved?.call();
|
||||
},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString().replaceFirst('Exception: ', ''))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget? _coParentSubtitle() {
|
||||
final name = _coParentName();
|
||||
if (name == null) return null;
|
||||
|
||||
return Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Co-parent : ',
|
||||
style: TextStyle(fontSize: 13, color: Colors.black54),
|
||||
),
|
||||
InkWell(
|
||||
onTap: _saving ? null : _openCoParent,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 2),
|
||||
child: Text(
|
||||
name,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: ValidationModalTheme.primaryActionBackground,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: ValidationModalTheme.primaryActionBackground
|
||||
.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
@ -395,13 +458,7 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
||||
),
|
||||
if (_coParentSubtitle() != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_coParentSubtitle()!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
_coParentSubtitle()!,
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user