Skip to content

Commit

Permalink
Change data profile async
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDespaux committed Jun 20, 2024
1 parent e974dd0 commit 5c969d0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
4 changes: 3 additions & 1 deletion src/adopte_un_candidat/lib/widgets/alert_dialogue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class ChangeInfosProfile extends StatelessWidget {
final TextInputType type;
final String functiontype;
final String uid;
final Function(String) onSave;

ChangeInfosProfile(
{super.key, required this.title, required this.type, required this.uid, required this.functiontype});
{super.key, required this.title, required this.type, required this.uid, required this.functiontype, required this.onSave});

final TextEditingController textFieldController = TextEditingController();

Expand All @@ -30,6 +31,7 @@ class ChangeInfosProfile extends StatelessWidget {
default:
break;
}
onSave(textFieldController.text.trim());
}

@override
Expand Down
54 changes: 33 additions & 21 deletions src/adopte_un_candidat/lib/widgets/profile_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,30 @@ class ProfileRowCategory extends StatelessWidget {
}
}

class ProfileRowCommon extends StatelessWidget {
// ignore: must_be_immutable
class ProfileRowCommon extends StatefulWidget {
final String title;
final String content;
// ignore: prefer_typing_uninitialized_variables
var content;
final TextInputType type;
final String functiontype;
final String uid;

const ProfileRowCommon(
{super.key,
required this.title,
required this.content,
required this.type,
required this.functiontype,
required this.uid});
ProfileRowCommon({
super.key,
required this.title,
required this.content,
required this.type,
required this.functiontype,
required this.uid,
});

void _showChangeInfoDialog(BuildContext context, String title,
TextInputType type, String uid, String functiontype) {
@override
State<ProfileRowCommon> createState() => _ProfileRowCommonState();
}

class _ProfileRowCommonState extends State<ProfileRowCommon> {
void _showChangeInfoDialog(BuildContext context, String title, TextInputType type, String uid, String functiontype) {
showDialog(
context: context,
builder: (BuildContext context) {
Expand All @@ -62,6 +69,11 @@ class ProfileRowCommon extends StatelessWidget {
type: type,
uid: uid,
functiontype: functiontype,
onSave: (newContent) {
setState(() {
widget.content = newContent;
});
},
);
},
);
Expand All @@ -71,7 +83,7 @@ class ProfileRowCommon extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
_showChangeInfoDialog(context, title, type, uid, functiontype);
_showChangeInfoDialog(context, widget.title, widget.type, widget.uid, widget.functiontype);
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 32),
Expand All @@ -90,7 +102,7 @@ class ProfileRowCommon extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
title,
widget.title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
Expand All @@ -104,13 +116,14 @@ class ProfileRowCommon extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
child: SingleChildScrollView(
child: Text(
content,
overflow: TextOverflow.ellipsis,
maxLines: 10,
child: SingleChildScrollView(
child: Text(
widget.content,
overflow: TextOverflow.ellipsis,
maxLines: 10,
),
),
))
),
],
),
),
Expand All @@ -132,7 +145,7 @@ class ProfileRowSoft extends StatelessWidget {
});

@override
Widget build(BuildContext context) {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
context.pushNamed("softskills");
Expand Down Expand Up @@ -181,7 +194,6 @@ Widget build(BuildContext context) {
}
}


class ProfileRowPage extends StatelessWidget {
final String title;
final VoidCallback onTap;
Expand Down

0 comments on commit 5c969d0

Please sign in to comment.