mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
update devices
This commit is contained in:
@ -10,9 +10,11 @@ import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
|||||||
import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdown.dart';
|
import 'package:syncrow_app/features/app_layout/view/widgets/app_bar_home_dropdown.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/user_model.dart';
|
import 'package:syncrow_app/features/auth/model/user_model.dart';
|
||||||
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/ceiling_bloc/ceiling_sensor_state.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/devices_view_body.dart';
|
||||||
@ -20,6 +22,7 @@ import 'package:syncrow_app/features/menu/view/menu_view.dart';
|
|||||||
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||||
|
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||||
@ -395,6 +398,19 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
|
|
||||||
emitSafe(NavChangePage());
|
emitSafe(NavChangePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDevice(String deviceId) async {
|
||||||
|
try {
|
||||||
|
final response = await DevicesAPI.firmwareDevice(
|
||||||
|
deviceId:deviceId ,
|
||||||
|
firmwareVersion: '0'
|
||||||
|
);
|
||||||
|
if (response['success'] ?? false) {
|
||||||
|
CustomSnackBar.displaySnackBar('Update Success');
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomNavigationBarItem defaultBottomNavBarItem({required String icon, required String label}) {
|
BottomNavigationBarItem defaultBottomNavBarItem({required String icon, required String label}) {
|
||||||
|
@ -15,6 +15,8 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
|
import '../device_appbar.dart';
|
||||||
|
|
||||||
class ACsView extends StatelessWidget {
|
class ACsView extends StatelessWidget {
|
||||||
final DeviceModel? deviceModel;
|
final DeviceModel? deviceModel;
|
||||||
const ACsView({this.deviceModel, super.key});
|
const ACsView({this.deviceModel, super.key});
|
||||||
@ -39,14 +41,9 @@ class ACsView extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar: DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: deviceModel!.name!,
|
||||||
centerTitle: true,
|
deviceUuid: deviceModel!.uuid!,
|
||||||
title: BodyLarge(
|
|
||||||
text: deviceModel?.name ?? "",
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
@ -20,6 +20,8 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
|
import '../device_appbar.dart';
|
||||||
|
|
||||||
class CeilingSensorInterface extends StatelessWidget {
|
class CeilingSensorInterface extends StatelessWidget {
|
||||||
const CeilingSensorInterface({super.key, required this.ceilingSensor});
|
const CeilingSensorInterface({super.key, required this.ceilingSensor});
|
||||||
final DeviceModel ceilingSensor;
|
final DeviceModel ceilingSensor;
|
||||||
@ -49,15 +51,12 @@ class CeilingSensorInterface extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar:DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: ceilingSensor.name!,
|
||||||
centerTitle: true,
|
deviceUuid: ceilingSensor.uuid!,
|
||||||
title: BodyLarge(
|
|
||||||
text: ceilingSensor.name ?? "",
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
|
45
lib/features/devices/view/widgets/device_appbar.dart
Normal file
45
lib/features/devices/view/widgets/device_appbar.dart
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/popup_menu_widget.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
|
class DeviceAppbar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
final String deviceName;
|
||||||
|
final String deviceUuid;
|
||||||
|
final double appBarHeight = 56.0;
|
||||||
|
final void Function()? onPressed;
|
||||||
|
const DeviceAppbar({super.key, required this.deviceName, required this.deviceUuid,this.onPressed});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
centerTitle: true,
|
||||||
|
title: BodyLarge(
|
||||||
|
text: deviceName ?? "",
|
||||||
|
fontColor: ColorsManager.primaryColor,
|
||||||
|
fontWeight: FontsManager.bold,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
IconButton(onPressed: () {
|
||||||
|
showPopupMenu(context: context, items: [
|
||||||
|
PopupMenuItem(
|
||||||
|
onTap: () async {
|
||||||
|
|
||||||
|
HomeCubit.getInstance().updateDevice(deviceUuid);
|
||||||
|
},
|
||||||
|
value: 'Update',
|
||||||
|
child: const Text('Update'),
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
}, icon: Icon(Icons.edit))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => Size.fromHeight(appBarHeight);
|
||||||
|
}
|
@ -6,6 +6,7 @@ import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_bloc.dart
|
|||||||
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/gateway_bloc/gateway_state.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
@ -37,14 +38,9 @@ class GateWayView extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar:DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: 'Gateway',
|
||||||
centerTitle: true,
|
deviceUuid: gatewayObj.uuid!,
|
||||||
title: const BodyLarge(
|
|
||||||
text: 'Gateway',
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
11
lib/features/devices/view/widgets/popup_menu_widget.dart
Normal file
11
lib/features/devices/view/widgets/popup_menu_widget.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
void showPopupMenu(
|
||||||
|
{required BuildContext context, List<PopupMenuEntry<String>>? items}) async {
|
||||||
|
await showMenu(
|
||||||
|
context: context,
|
||||||
|
position: RelativeRect.fromLTRB( MediaQuery.of(context).size.width/2 , 100, 0, 0),
|
||||||
|
items: items!,
|
||||||
|
elevation: 8.0,
|
||||||
|
);
|
||||||
|
}
|
@ -109,7 +109,8 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageRouteBuilder(
|
PageRouteBuilder(
|
||||||
pageBuilder: (context, animation1, animation2) => DoorInterface(doorLock: device)));
|
pageBuilder: (context, animation1, animation2) => DoorInterface(doorLock: device))
|
||||||
|
);
|
||||||
// navigateToInterface(DoorInterface(doorlock: device), context);
|
// navigateToInterface(DoorInterface(doorlock: device), context);
|
||||||
break;
|
break;
|
||||||
case DeviceType.Gateway:
|
case DeviceType.Gateway:
|
||||||
|
@ -6,6 +6,8 @@ import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_eve
|
|||||||
import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_state.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
|
import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/popup_menu_widget.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_button.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_button.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_grid.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_grid.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_status_bar.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_status_bar.dart';
|
||||||
@ -16,15 +18,18 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
class DoorInterface extends StatelessWidget {
|
class DoorInterface extends StatelessWidget {
|
||||||
const DoorInterface({super.key, required this.doorLock});
|
|
||||||
|
DoorInterface({super.key, required this.doorLock});
|
||||||
|
|
||||||
final DeviceModel doorLock;
|
final DeviceModel doorLock;
|
||||||
|
final GlobalKey _menuKey = GlobalKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => SmartDoorBloc(deviceId: doorLock.uuid ?? '')..add(InitialEvent()),
|
create: (context) => SmartDoorBloc(deviceId: doorLock.uuid ?? '')..add(InitialEvent()),
|
||||||
child: BlocConsumer<SmartDoorBloc, SmartDoorState>(listener: (context, state) {
|
child: BlocConsumer<SmartDoorBloc, SmartDoorState>(
|
||||||
|
listener: (context, state) {
|
||||||
if (state is FailedState) {
|
if (state is FailedState) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@ -33,6 +38,7 @@ class DoorInterface extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
SmartDoorModel smartDoorModel = SmartDoorModel(
|
SmartDoorModel smartDoorModel = SmartDoorModel(
|
||||||
unlockFingerprint: 0,
|
unlockFingerprint: 0,
|
||||||
@ -68,14 +74,9 @@ class DoorInterface extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar: DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: doorLock.name!,
|
||||||
centerTitle: true,
|
deviceUuid: doorLock.uuid!,
|
||||||
title: BodyLarge(
|
|
||||||
text: doorLock.name ?? "",
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
@ -125,4 +126,50 @@ class DoorInterface extends StatelessWidget {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// PopupMenuButton<String>(
|
||||||
|
// icon: Container(
|
||||||
|
// width: 48,
|
||||||
|
// height: 48,
|
||||||
|
// padding: const EdgeInsets.all(6),
|
||||||
|
// alignment: AlignmentDirectional.center,
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// shape: BoxShape.circle,
|
||||||
|
// color: bloc.settingIconClicked
|
||||||
|
// ? KeyperColors.settingIconBG
|
||||||
|
// : KeyperColors.whiteFont,
|
||||||
|
// ),
|
||||||
|
// child: Image.asset(
|
||||||
|
// ImageConstants.settingIcon,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// position: PopupMenuPosition.under,
|
||||||
|
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
|
// constraints: const BoxConstraints(),
|
||||||
|
// enableFeedback: false,
|
||||||
|
// onSelected: (String value) {
|
||||||
|
// if (value == 'logout') {
|
||||||
|
// if (mounted) {
|
||||||
|
// bloc.logoutDialog(context);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (value == 'delete account') {
|
||||||
|
// if (mounted) {
|
||||||
|
// bloc.deleteAccountDialog(context);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// itemBuilder: (context) {
|
||||||
|
// bloc.settingIcon(true);
|
||||||
|
// return bloc.displayMenuOption(context, bloc);
|
||||||
|
// },
|
||||||
|
// onCanceled: () {
|
||||||
|
// bloc.settingIcon(false);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,12 +2,11 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_screen.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_screen.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
|
||||||
|
|
||||||
class ThreeGangInterface extends StatelessWidget {
|
class ThreeGangInterface extends StatelessWidget {
|
||||||
const ThreeGangInterface({super.key, required this.gangSwitch});
|
const ThreeGangInterface({super.key, required this.gangSwitch});
|
||||||
@ -24,14 +23,9 @@ class ThreeGangInterface extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar:DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: gangSwitch.name!,
|
||||||
centerTitle: true,
|
deviceUuid: gangSwitch.uuid!,
|
||||||
title: BodyLarge(
|
|
||||||
text: gangSwitch.name ?? "",
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_app/features/devices/bloc/wall_sensor_bloc/wall_sensor_s
|
|||||||
import 'package:syncrow_app/features/devices/bloc/wall_sensor_bloc/wall_sensor_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/wall_sensor_bloc/wall_sensor_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/wall_sensor_model.dart';
|
import 'package:syncrow_app/features/devices/model/wall_sensor_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
@ -56,14 +57,9 @@ class WallMountedInterface extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.backgroundColor,
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
appBar: AppBar(
|
appBar: DeviceAppbar(
|
||||||
backgroundColor: Colors.transparent,
|
deviceName: deviceModel.name!,
|
||||||
centerTitle: true,
|
deviceUuid: deviceModel.uuid!,
|
||||||
title: BodyLarge(
|
|
||||||
text: deviceModel.name ?? "",
|
|
||||||
fontColor: ColorsManager.primaryColor,
|
|
||||||
fontWeight: FontsManager.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
|
@ -90,6 +90,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String addDeviceToRoom = '$baseUrl/device/room';
|
static const String addDeviceToRoom = '$baseUrl/device/room';
|
||||||
static const String addDeviceToGroup = '$baseUrl/device/group';
|
static const String addDeviceToGroup = '$baseUrl/device/group';
|
||||||
static const String controlDevice = '$baseUrl/device/{deviceUuid}/control';
|
static const String controlDevice = '$baseUrl/device/{deviceUuid}/control';
|
||||||
|
static const String firmwareDevice = '$baseUrl/device/{deviceUuid}/firmware/{firmwareVersion}';
|
||||||
static const String getDevicesByUserId = '$baseUrl/device/user/{userId}';
|
static const String getDevicesByUserId = '$baseUrl/device/user/{userId}';
|
||||||
|
|
||||||
//GET
|
//GET
|
||||||
|
@ -9,6 +9,27 @@ import 'package:syncrow_app/services/api/http_service.dart';
|
|||||||
class DevicesAPI {
|
class DevicesAPI {
|
||||||
static final HTTPService _httpService = HTTPService();
|
static final HTTPService _httpService = HTTPService();
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> firmwareDevice(
|
||||||
|
{
|
||||||
|
required String deviceId,
|
||||||
|
required String firmwareVersion}) async {
|
||||||
|
try {
|
||||||
|
final response = await _httpService.post(
|
||||||
|
path: ApiEndpoints.firmwareDevice
|
||||||
|
.replaceAll('{deviceUuid}', deviceId)
|
||||||
|
.replaceAll('{firmwareVersion}', firmwareVersion),
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return json;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
print('response==$response');
|
||||||
|
return response;
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Future<Map<String, dynamic>> controlDevice(
|
static Future<Map<String, dynamic>> controlDevice(
|
||||||
DeviceControlModel controlModel, String deviceId) async {
|
DeviceControlModel controlModel, String deviceId) async {
|
||||||
try {
|
try {
|
||||||
@ -27,20 +48,26 @@ class DevicesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
||||||
Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
|
Map<String, dynamic> params = {
|
||||||
|
"homeId": spaceId,
|
||||||
|
"pageSize": 100,
|
||||||
|
"pageNo": 1
|
||||||
|
};
|
||||||
|
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.groupBySpace.replaceAll("{spaceUuid}", spaceId),
|
path: ApiEndpoints.groupBySpace.replaceAll("{spaceUuid}", spaceId),
|
||||||
queryParameters: params,
|
queryParameters: params,
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json['groups']),
|
expectedResponseModel: (json) =>
|
||||||
|
DevicesCategoryModel.fromJsonList(json['groups']),
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctionsStatus
|
||||||
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
@ -68,7 +95,8 @@ class DevicesAPI {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||||
|
String gatewayId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
|
Reference in New Issue
Block a user