mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 07:24:55 +00:00
add PopScope to setting page
This commit is contained in:
@ -22,141 +22,155 @@ class SettingProfilePage extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var spaces = HomeCubit.getInstance().spaces;
|
var spaces = HomeCubit.getInstance().spaces;
|
||||||
|
|
||||||
return DefaultScaffold(
|
return PopScope(
|
||||||
title: 'Device Settings',
|
canPop: false,
|
||||||
leading: IconButton(
|
onPopInvoked: (didPop) {
|
||||||
onPressed: () {
|
if (didPop) {
|
||||||
Navigator.of(context).pop(true);
|
return;
|
||||||
},
|
}
|
||||||
icon: const Icon(Icons.arrow_back_ios)),
|
Navigator.of(context).pop(true);
|
||||||
child: BlocProvider(
|
},
|
||||||
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
|
child: DefaultScaffold(
|
||||||
..add(const DeviceSettingInitial())
|
title: 'Device Settings',
|
||||||
..add(const DeviceSettingInitialInfo()),
|
leading: IconButton(
|
||||||
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
|
onPressed: () {
|
||||||
builder: (context, state) {
|
Navigator.of(context).pop(true);
|
||||||
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
|
},
|
||||||
return state is DeviceSettingLoadingState
|
icon: const Icon(Icons.arrow_back_ios)),
|
||||||
? const Center(
|
child: BlocProvider(
|
||||||
child: DefaultContainer(
|
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
|
||||||
width: 50,
|
..add(const DeviceSettingInitial())
|
||||||
height: 50,
|
..add(const DeviceSettingInitialInfo()),
|
||||||
child: CircularProgressIndicator()),
|
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
|
||||||
)
|
builder: (context, state) {
|
||||||
: RefreshIndicator(
|
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
|
||||||
onRefresh: () async {
|
return state is DeviceSettingLoadingState
|
||||||
_bloc.add(const DeviceSettingInitial());
|
? const Center(
|
||||||
},
|
child: DefaultContainer(
|
||||||
child: ListView(
|
width: 50,
|
||||||
children: [
|
height: 50,
|
||||||
buildDeviceAvatar(context, device!),
|
child: CircularProgressIndicator()),
|
||||||
const SizedBox(
|
)
|
||||||
height: 10,
|
: RefreshIndicator(
|
||||||
),
|
onRefresh: () async {
|
||||||
SizedBox(
|
_bloc.add(const DeviceSettingInitial());
|
||||||
child: Row(
|
},
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: ListView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
children: [
|
||||||
children: [
|
buildDeviceAvatar(context, device!),
|
||||||
IntrinsicWidth(
|
const SizedBox(
|
||||||
child: ConstrainedBox(
|
height: 10,
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
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(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(
|
IntrinsicWidth(
|
||||||
child: Text('Location'),
|
child: ConstrainedBox(
|
||||||
),
|
constraints:
|
||||||
Row(
|
const BoxConstraints(maxWidth: 200),
|
||||||
children: [
|
child: TextFormField(
|
||||||
SizedBox(
|
maxLength: 30,
|
||||||
child: BodyMedium(
|
style: const TextStyle(
|
||||||
text: _bloc
|
color: Colors.black,
|
||||||
.deviceInfo.subspace.subspaceName,
|
),
|
||||||
fontColor: ColorsManager.textGray,
|
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,
|
const SizedBox(width: 5),
|
||||||
color: ColorsManager.textGray,
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user