mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 07:14:55 +00:00
pull to refresh
This commit is contained in:
@ -29,297 +29,314 @@ class CeilingSensorInterface extends StatelessWidget {
|
||||
// .firstWhere((element) => element.code == "presence_state")
|
||||
// .value
|
||||
// .toString();
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()),
|
||||
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(builder: (context, state) {
|
||||
CeilingSensorModel ceilingSensorModel =
|
||||
CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: '');
|
||||
if (state is UpdateState) {
|
||||
ceilingSensorModel = state.ceilingSensorModel;
|
||||
} else if (state is LoadingNewSate) {
|
||||
ceilingSensorModel = state.ceilingSensorModel;
|
||||
}
|
||||
return AnnotatedRegion(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: ColorsManager.backgroundColor,
|
||||
extendBodyBehindAppBar: true,
|
||||
extendBody: true,
|
||||
appBar: DeviceAppbar(
|
||||
deviceName: ceilingSensor.name!,
|
||||
deviceUuid: ceilingSensor.uuid!,
|
||||
),
|
||||
body: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
padding: const EdgeInsets.all(Constants.defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
Assets.assetsImagesBackground,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
opacity: 0.4,
|
||||
),
|
||||
),
|
||||
child: state is LoadingInitialState
|
||||
? const Center(
|
||||
child: RefreshProgressIndicator(),
|
||||
)
|
||||
: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// InkWell(
|
||||
// onTap: () {
|
||||
// if ((ceilingSensor.isOnline ?? false) == false) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: Text(
|
||||
// 'Device is offline',
|
||||
// ),
|
||||
// backgroundColor: Colors.red,
|
||||
// ),
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
// String controlCode = 'sensitivity';
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => ParameterControlDialog(
|
||||
// title: 'Sensitivity',
|
||||
// sensor: ceilingSensor,
|
||||
// controlCode: controlCode,
|
||||
// value: ceilingSensor.status
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .value as int,
|
||||
// min: ceilingSensor.functions
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .values
|
||||
// ?.min ??
|
||||
// 0,
|
||||
// max: ceilingSensor.functions
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .values
|
||||
// ?.max ??
|
||||
// 0,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// child:
|
||||
// ),
|
||||
SvgPicture.asset(
|
||||
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
|
||||
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
|
||||
: Assets.assetsIconsPresenceSensorAssetsPresence,
|
||||
width: 100,
|
||||
height: 100,
|
||||
// colorFilter: ColorFilter.mode(
|
||||
// (ceilingSensor.isOnline ?? false)
|
||||
// ? ColorsManager.primaryColor
|
||||
// : Colors.grey.withOpacity(0.9),
|
||||
// BlendMode.srcIn,
|
||||
// ),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyMedium(
|
||||
text:
|
||||
StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
|
||||
// (ceilingSensor.isOnline ?? false)
|
||||
// ? StringHelpers.toTitleCase(ceilingSensor.status
|
||||
// .firstWhere((element) =>
|
||||
// element.code == 'presence_state')
|
||||
// .value
|
||||
// .toString())
|
||||
// : "Offline",
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: ListView(
|
||||
children: [
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(text: 'Sports Para'),
|
||||
BodyLarge(
|
||||
text: '0',
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
width: 1,
|
||||
height: 45,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(
|
||||
text: 'Detection Range',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
),
|
||||
BodyLarge(
|
||||
text: '0.0M',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
width: 1,
|
||||
height: 45,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(
|
||||
text: 'Movement',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
),
|
||||
BodyLarge(
|
||||
text: 'none',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
...List.generate(
|
||||
ceilingSensorButtons().length,
|
||||
(index) => DefaultContainer(
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
|
||||
onTap: () async {
|
||||
if (ceilingSensorButtons()[index]['title'] == 'Sensitivity') {
|
||||
final result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ParameterControlDialog(
|
||||
title: ceilingSensorButtons()[index]['title']
|
||||
.toString(),
|
||||
sensor: ceilingSensor,
|
||||
value: ceilingSensorModel.sensitivity,
|
||||
min: 0,
|
||||
max: 10,
|
||||
);
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
BlocProvider.of<CeilingSensorBloc>(context).add(
|
||||
ChangeValueEvent(
|
||||
value: result, code: 'sensitivity'));
|
||||
}
|
||||
}
|
||||
|
||||
// if (ceilingSensorButtons[index]['page'] != null) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// ceilingSensorButtons[index]['page'] as Widget,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
ceilingSensorButtons()[index]['icon'] as String,
|
||||
// width: 30,
|
||||
// height: 50,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 25,
|
||||
),
|
||||
BodyMedium(
|
||||
text: ceilingSensorButtons()[index]['title']
|
||||
as String,
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (ceilingSensorButtons()[index]['withArrow'] == true)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(ceilingSensorButtons(
|
||||
sensitivity_val: ceilingSensorModel
|
||||
.sensitivity
|
||||
.toString())[index]['val']
|
||||
.toString()),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 15,
|
||||
),
|
||||
],
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
CeilingSensorBloc(deviceId: ceilingSensor.uuid ?? '')..add(InitialEvent()),
|
||||
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(builder: (context, state) {
|
||||
CeilingSensorModel ceilingSensorModel =
|
||||
CeilingSensorModel(presenceState: 'none', sensitivity: 1, checkingResult: '');
|
||||
if (state is UpdateState) {
|
||||
ceilingSensorModel = state.ceilingSensorModel;
|
||||
} else if (state is LoadingNewSate) {
|
||||
ceilingSensorModel = state.ceilingSensorModel;
|
||||
}
|
||||
return AnnotatedRegion(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: ColorsManager.backgroundColor,
|
||||
extendBodyBehindAppBar: true,
|
||||
extendBody: true,
|
||||
appBar: DeviceAppbar(
|
||||
deviceName: ceilingSensor.name!,
|
||||
deviceUuid: ceilingSensor.uuid!,
|
||||
),
|
||||
body: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
padding: const EdgeInsets.all(Constants.defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
Assets.assetsImagesBackground,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
opacity: 0.4,
|
||||
),
|
||||
),
|
||||
child: state is LoadingInitialState
|
||||
? const Center(
|
||||
child: RefreshProgressIndicator(),
|
||||
) : SafeArea(
|
||||
child:
|
||||
RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
BlocProvider.of<CeilingSensorBloc>(context).add(InitialEvent());
|
||||
},
|
||||
child:Container(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
// InkWell(
|
||||
// onTap: () {
|
||||
// if ((ceilingSensor.isOnline ?? false) == false) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: Text(
|
||||
// 'Device is offline',
|
||||
// ),
|
||||
// backgroundColor: Colors.red,
|
||||
// ),
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
// String controlCode = 'sensitivity';
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => ParameterControlDialog(
|
||||
// title: 'Sensitivity',
|
||||
// sensor: ceilingSensor,
|
||||
// controlCode: controlCode,
|
||||
// value: ceilingSensor.status
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .value as int,
|
||||
// min: ceilingSensor.functions
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .values
|
||||
// ?.min ??
|
||||
// 0,
|
||||
// max: ceilingSensor.functions
|
||||
// .firstWhere((element) => element.code == controlCode)
|
||||
// .values
|
||||
// ?.max ??
|
||||
// 0,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// child:
|
||||
// ),
|
||||
|
||||
SvgPicture.asset(
|
||||
ceilingSensorModel.presenceState.toLowerCase() == 'motion'
|
||||
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
|
||||
: Assets.assetsIconsPresenceSensorAssetsPresence,
|
||||
width: 100,
|
||||
height: 100,
|
||||
// colorFilter: ColorFilter.mode(
|
||||
// (ceilingSensor.isOnline ?? false)
|
||||
// ? ColorsManager.primaryColor
|
||||
// : Colors.grey.withOpacity(0.9),
|
||||
// BlendMode.srcIn,
|
||||
// ),
|
||||
),
|
||||
],
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyMedium(
|
||||
text:
|
||||
StringHelpers.toTitleCase(ceilingSensorModel.presenceState),
|
||||
// (ceilingSensor.isOnline ?? false)
|
||||
// ? StringHelpers.toTitleCase(ceilingSensor.status
|
||||
// .firstWhere((element) =>
|
||||
// element.code == 'presence_state')
|
||||
// .value
|
||||
// .toString())
|
||||
// : "Offline",
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
children: [
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(text: 'Sports Para'),
|
||||
BodyLarge(
|
||||
text: '0',
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
width: 1,
|
||||
height: 45,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(
|
||||
text: 'Detection Range',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
),
|
||||
BodyLarge(
|
||||
text: '0.0M',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Container(
|
||||
width: 1,
|
||||
height: 45,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const BodySmall(
|
||||
text: 'Movement',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
),
|
||||
BodyLarge(
|
||||
text: 'none',
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
...List.generate(
|
||||
ceilingSensorButtons().length,
|
||||
(index) => DefaultContainer(
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
|
||||
onTap: () async {
|
||||
if (ceilingSensorButtons()[index]['title'] == 'Sensitivity') {
|
||||
final result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ParameterControlDialog(
|
||||
title: ceilingSensorButtons()[index]['title']
|
||||
.toString(),
|
||||
sensor: ceilingSensor,
|
||||
value: ceilingSensorModel.sensitivity,
|
||||
min: 0,
|
||||
max: 10,
|
||||
);
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
BlocProvider.of<CeilingSensorBloc>(context).add(
|
||||
ChangeValueEvent(
|
||||
value: result, code: 'sensitivity'));
|
||||
}
|
||||
}
|
||||
|
||||
// if (ceilingSensorButtons[index]['page'] != null) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// ceilingSensorButtons[index]['page'] as Widget,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
ceilingSensorButtons()[index]['icon'] as String,
|
||||
// width: 30,
|
||||
// height: 50,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 25,
|
||||
),
|
||||
BodyMedium(
|
||||
text: ceilingSensorButtons()[index]['title']
|
||||
as String,
|
||||
style: context.bodyMedium.copyWith(
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (ceilingSensorButtons()[index]['withArrow'] == true)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(ceilingSensorButtons(
|
||||
sensitivity_val: ceilingSensorModel
|
||||
.sensitivity
|
||||
.toString())[index]['val']
|
||||
.toString()),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: ColorsManager.greyColor,
|
||||
size: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
) ,
|
||||
)
|
||||
|
||||
)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user