@@ -9,7 +9,7 @@ import '../../../model/project_data.dart';
99import '../../../utils/navigator/navigator.dart' ;
1010import '../../../utils/switches/text_switch.dart' ;
1111import '../../../utils/tiles/header_tile.dart' ;
12- import '../../../utils/tiles/ participant_tile.dart' ;
12+ import 'participant_tile.dart' ;
1313import '../instances/instances_list_page.dart' ;
1414
1515class NewProjectPage extends StatefulWidget {
@@ -44,6 +44,7 @@ class _NewProjectPageState extends State<NewProjectPage> {
4444 children: [
4545 Expanded (
4646 child: SelectFormField (
47+ enabled: widget.project == null ,
4748 validator: (value) => value == null || value.isEmpty
4849 ? 'You must select a project instance!'
4950 : null ,
@@ -62,17 +63,20 @@ class _NewProjectPageState extends State<NewProjectPage> {
6263 widget.projectData.instance = Instance .fromName (v);
6364 });
6465 },
65- decoration: const InputDecoration (
66+ decoration: InputDecoration (
6667 labelText: "Project instance" ,
67- border: OutlineInputBorder (),
68- suffixIcon: Icon (Icons .arrow_drop_down),
68+ border: const OutlineInputBorder (),
69+ suffixIcon: const Icon (Icons .arrow_drop_down),
70+ labelStyle:
71+ TextStyle (color: Theme .of (context).colorScheme.onPrimary),
6972 ),
7073 ),
7174 ),
7275 const SizedBox (width: 5 ),
7376 IconButton (
74- onPressed: () {
75- navigatorPush (context, () => const InstancesListPage ());
77+ onPressed: () async {
78+ await navigatorPush (context, () => const InstancesListPage ());
79+ setState (() {});
7680 },
7781 icon: const Icon (Icons .settings),
7882 ),
@@ -99,19 +103,58 @@ class _NewProjectPageState extends State<NewProjectPage> {
99103 border: const OutlineInputBorder (),
100104 ),
101105 ),
106+ if (widget.project != null )
107+ const SizedBox (
108+ height: 12 ,
109+ ),
110+ if (widget.project != null )
111+ SelectFormField (
112+ type: SelectFormFieldType .dropdown,
113+ initialValue:
114+ widget.project! .currentParticipant? .pseudo ?? "anonymous" ,
115+ items: [
116+ ...widget.project! .participants.map <Map <String , dynamic >>((e) => {
117+ 'value' : e.pseudo,
118+ }),
119+ const {'value' : 'anonymous' , 'label' : 'Anonymous' },
120+ ],
121+ onChanged: (v) {
122+ setState (() {
123+ if (v == 'anonymous' ) {
124+ widget.project! .currentParticipant = null ;
125+ widget.project! .currentParticipantId = null ;
126+ } else {
127+ widget.project! .currentParticipant =
128+ widget.project! .participantByPseudo (v);
129+ widget.project! .currentParticipantId =
130+ widget.project! .currentParticipant? .localId;
131+ }
132+ });
133+ },
134+ decoration: const InputDecoration (
135+ labelText: "Who are you ?" ,
136+ border: OutlineInputBorder (),
137+ suffixIcon: Icon (Icons .arrow_drop_down),
138+ ),
139+ ),
102140 const SizedBox (
103141 height: 12 ,
104142 ),
105- if (widget.project != null ) ParticipantListWidget (widget.project! ),
143+ if (widget.project != null )
144+ ParticipantListWidget (
145+ widget.project! ,
146+ reloadParent: () => setState (() {}),
147+ ),
106148 ]),
107149 );
108150 }
109151}
110152
111153class ParticipantListWidget extends StatefulWidget {
112- const ParticipantListWidget (this .project, {super .key});
154+ const ParticipantListWidget (this .project, {super .key, this .reloadParent });
113155
114156 final Project project;
157+ final Function ()? reloadParent;
115158
116159 @override
117160 State <ParticipantListWidget > createState () => _ParticipantListWidgetState ();
@@ -140,7 +183,7 @@ class _ParticipantListWidgetState extends State<ParticipantListWidget> {
140183 ? null
141184 : widget.project.participants.elementAt (index),
142185 setHasNew: setHasNew,
143- onChange: () => setState (() {}),
186+ onChange: widget.reloadParent ?? () => setState (() {}),
144187 ),
145188 itemCount: widget.project.participants.length + (hasNew ? 1 : 0 ),
146189 ),
0 commit comments