@@ -22,10 +22,14 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
2222 @override
2323 void initState () {
2424 super .initState ();
25- // Initialize controller with current advertising name
25+ // Initialize controller with current profile name
2626 Future .microtask (() async {
27- final currentName = await ref.read (advertisingNameProvider.future);
28- _nameController.text = currentName;
27+ final profile = await ref.read (profileControllerProvider.future);
28+ if (profile != null ) {
29+ setState (() {
30+ _nameController.text = profile.username;
31+ });
32+ }
2933 });
3034 }
3135
@@ -251,9 +255,9 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
251255 maxLength: BLEAdvertiser .maxNameLength,
252256 style: const TextStyle (color: AppTheme .onSurfaceVariant),
253257 decoration: InputDecoration (
254- labelText: 'Display Alias ' ,
258+ labelText: 'User Identity ' ,
255259 labelStyle: TextStyle (color: AppTheme .onSurfaceVariant.withValues (alpha: 0.38 )),
256- hintText: 'Enter mesh name...' ,
260+ hintText: 'Enter your name...' ,
257261 border: OutlineInputBorder (
258262 borderRadius: BorderRadius .circular (16 ),
259263 borderSide: BorderSide (color: AppTheme .onSurfaceVariant.withValues (alpha: 0.1 )),
@@ -272,14 +276,16 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
272276 onPressed: () {
273277 final newName = _nameController.text.trim ();
274278 if (newName.isNotEmpty) {
275- ref.read (advertisingNameProvider .notifier).change (newName);
279+ ref.read (profileControllerProvider .notifier).updateUsername (newName);
276280 ScaffoldMessenger .of (context).showSnackBar (
277- const SnackBar (content: Text ('Identity synchronized with mesh ' )),
281+ const SnackBar (content: Text ('Profile identity updated ' )),
278282 );
283+ // Clear focus
284+ FocusScope .of (context).unfocus ();
279285 }
280286 },
281- icon: const Icon (Icons .sync , size: 18 ),
282- label: const Text ('SYNC NAME ' ),
287+ icon: const Icon (Icons .save , size: 18 ),
288+ label: const Text ('UPDATE PROFILE ' ),
283289 style: ElevatedButton .styleFrom (
284290 padding: const EdgeInsets .symmetric (vertical: 12 ),
285291 ),
0 commit comments