diff --git a/lib/features/devices/view/device_settings/profile_page.dart b/lib/features/devices/view/device_settings/profile_page.dart index ad37d05..c8b7bee 100644 --- a/lib/features/devices/view/device_settings/profile_page.dart +++ b/lib/features/devices/view/device_settings/profile_page.dart @@ -22,141 +22,155 @@ class SettingProfilePage extends StatelessWidget { Widget build(BuildContext context) { var spaces = HomeCubit.getInstance().spaces; - return DefaultScaffold( - title: 'Device Settings', - leading: IconButton( - onPressed: () { - Navigator.of(context).pop(true); - }, - icon: const Icon(Icons.arrow_back_ios)), - child: BlocProvider( - create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '') - ..add(const DeviceSettingInitial()) - ..add(const DeviceSettingInitialInfo()), - child: BlocBuilder( - builder: (context, state) { - final _bloc = BlocProvider.of(context); - return state is DeviceSettingLoadingState - ? const Center( - child: DefaultContainer( - width: 50, - height: 50, - child: CircularProgressIndicator()), - ) - : RefreshIndicator( - onRefresh: () async { - _bloc.add(const DeviceSettingInitial()); - }, - child: ListView( - children: [ - buildDeviceAvatar(context, device!), - const SizedBox( - height: 10, - ), - SizedBox( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - IntrinsicWidth( - child: ConstrainedBox( - constraints: - const BoxConstraints(maxWidth: 200), - child: TextFormField( - maxLength: 30, - style: const TextStyle( - color: Colors.black, - ), - textAlign: TextAlign.center, - focusNode: _bloc.focusNode, - controller: _bloc.nameController, - enabled: _bloc.editName, - onEditingComplete: () { - _bloc.add(const SaveNameEvent()); - }, - decoration: const InputDecoration( - hintText: "Your Name", - border: InputBorder.none, - fillColor: Colors.white10, - counterText: '', - ), - ), - ), - ), - const SizedBox(width: 5), - InkWell( - onTap: () { - _bloc.add(const ChangeNameEvent(value: true)); - }, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10), - child: SvgPicture.asset( - Assets.sosEditProfile, - color: Colors.grey, - fit: BoxFit.contain, - height: MediaQuery.of(context).size.height * - 0.02, - ), - ), - ), - ], + return PopScope( + canPop: false, + onPopInvoked: (didPop) { + if (didPop) { + return; + } + Navigator.of(context).pop(true); + }, + child: DefaultScaffold( + title: 'Device Settings', + leading: IconButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + icon: const Icon(Icons.arrow_back_ios)), + child: BlocProvider( + create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '') + ..add(const DeviceSettingInitial()) + ..add(const DeviceSettingInitialInfo()), + child: BlocBuilder( + builder: (context, state) { + final _bloc = BlocProvider.of(context); + return state is DeviceSettingLoadingState + ? const Center( + child: DefaultContainer( + width: 50, + height: 50, + child: CircularProgressIndicator()), + ) + : RefreshIndicator( + onRefresh: () async { + _bloc.add(const DeviceSettingInitial()); + }, + child: ListView( + children: [ + buildDeviceAvatar(context, device!), + const SizedBox( + height: 10, ), - ), - const SizedBox(height: 20), - const BodyMedium( - text: 'Smart Device Information', - fontWeight: FontWeight.w700, - fontSize: 12, - fontColor: ColorsManager.grayColor, - ), - const SizedBox(height: 7), - DefaultContainer( - padding: const EdgeInsets.all(20), - child: InkWell( - onTap: () async { - if (HomeCubit.visitorPasswordManagement) { - bool? val = await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => LocationSettingPage( - space: spaces!.first, - deviceId: device?.uuid ?? '', - )), - ); - if (val != null && val == true) { - _bloc.add(const DeviceSettingInitialInfo()); - } - } - }, + SizedBox( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - const SizedBox( - child: Text('Location'), - ), - Row( - children: [ - SizedBox( - child: BodyMedium( - text: _bloc - .deviceInfo.subspace.subspaceName, - fontColor: ColorsManager.textGray, + IntrinsicWidth( + child: ConstrainedBox( + constraints: + const BoxConstraints(maxWidth: 200), + child: TextFormField( + maxLength: 30, + style: const TextStyle( + color: Colors.black, + ), + textAlign: TextAlign.center, + focusNode: _bloc.focusNode, + controller: _bloc.nameController, + enabled: _bloc.editName, + onEditingComplete: () { + _bloc.add(const SaveNameEvent()); + }, + decoration: const InputDecoration( + hintText: "Your Name", + border: InputBorder.none, + fillColor: Colors.white10, + counterText: '', ), ), - const Icon( - Icons.arrow_forward_ios, - size: 15, - color: ColorsManager.textGray, + ), + ), + const SizedBox(width: 5), + InkWell( + onTap: () { + _bloc.add( + const ChangeNameEvent(value: true)); + }, + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 10), + child: SvgPicture.asset( + Assets.sosEditProfile, + color: Colors.grey, + fit: BoxFit.contain, + height: + MediaQuery.of(context).size.height * + 0.02, ), - ], - ) + ), + ), ], ), ), - ) - ], - ), - ); - }, + const SizedBox(height: 20), + const BodyMedium( + text: 'Smart Device Information', + fontWeight: FontWeight.w700, + fontSize: 12, + fontColor: ColorsManager.grayColor, + ), + const SizedBox(height: 7), + DefaultContainer( + padding: const EdgeInsets.all(20), + child: InkWell( + onTap: () async { + if (HomeCubit.visitorPasswordManagement) { + bool? val = await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + LocationSettingPage( + space: spaces!.first, + deviceId: device?.uuid ?? '', + )), + ); + if (val != null && val == true) { + _bloc.add(const DeviceSettingInitialInfo()); + } + } + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const SizedBox( + child: Text('Location'), + ), + Row( + children: [ + SizedBox( + child: BodyMedium( + text: _bloc + .deviceInfo.subspace.subspaceName, + fontColor: ColorsManager.textGray, + ), + ), + const Icon( + Icons.arrow_forward_ios, + size: 15, + color: ColorsManager.textGray, + ), + ], + ) + ], + ), + ), + ) + ], + ), + ); + }, + ), ), ), );