mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 02:24:55 +00:00
Update device interfaces and add new doors list view widget
- Add a new widget 'DoorsListView' for displaying a list of smart doors - Update the navigation method to devices interfaces in 'RoomPageSwitch' widget - Add battery and doorlock icons to auto generated assets
This commit is contained in:
@ -14,7 +14,7 @@ import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.
|
||||
import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/doors_list_view.dart';
|
||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||
import 'package:syncrow_app/services/api/network_exception.dart';
|
||||
import 'package:syncrow_app/services/api/spaces_api.dart';
|
||||
@ -84,7 +84,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
case DeviceType.LightBulb:
|
||||
return const LightsView();
|
||||
case DeviceType.DoorLock:
|
||||
return const DoorView();
|
||||
return const DoorsListView();
|
||||
case DeviceType.Curtain:
|
||||
return const CurtainView();
|
||||
// case DeviceType.ThreeGang:
|
||||
|
||||
@ -12,9 +12,9 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
|
||||
class AcInterface extends StatelessWidget {
|
||||
const AcInterface({super.key, required this.deviceModel});
|
||||
const AcInterface({super.key, required this.ac});
|
||||
|
||||
final DeviceModel deviceModel;
|
||||
final DeviceModel ac;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -43,7 +43,7 @@ class AcInterface extends StatelessWidget {
|
||||
backgroundColor: Colors.transparent,
|
||||
centerTitle: true,
|
||||
title: BodyLarge(
|
||||
text: deviceModel.name ?? "",
|
||||
text: ac.name ?? "",
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
@ -75,7 +75,7 @@ class AcInterface extends StatelessWidget {
|
||||
maxHeight: 380,
|
||||
),
|
||||
child: AcInterfaceTempUnit(
|
||||
acDevice: deviceModel,
|
||||
acDevice: ac,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@ -86,7 +86,7 @@ class AcInterface extends StatelessWidget {
|
||||
maxHeight: 120,
|
||||
),
|
||||
child: AcInterfaceControls(
|
||||
deviceModel: deviceModel,
|
||||
deviceModel: ac,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -55,7 +55,7 @@ class ACsView extends StatelessWidget {
|
||||
),
|
||||
child: SizedBox.expand(
|
||||
child: selectedAC != null
|
||||
? AcInterface(deviceModel: selectedAC)
|
||||
? AcInterface(ac: selectedAC)
|
||||
: const ACsList(),
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
/// This widget represents a switch for a device on the room page.
|
||||
///
|
||||
/// This widget displays the icon and name of the device, along with a switch
|
||||
/// to control its state. Tapping on the widget opens the device interface.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@ -5,6 +11,7 @@ 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/view/widgets/ACs/ac_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
@ -25,58 +32,7 @@ class RoomPageSwitch extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
switch (device.productType) {
|
||||
case DeviceType.AC:
|
||||
{
|
||||
print("AC");
|
||||
Navigator.push(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
builder: (context) => BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: AcInterface(deviceModel: device),
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case DeviceType.WallSensor:
|
||||
break;
|
||||
case DeviceType.CeilingSensor:
|
||||
break;
|
||||
case DeviceType.Curtain:
|
||||
break;
|
||||
case DeviceType.Blind:
|
||||
break;
|
||||
case DeviceType.DoorLock:
|
||||
break;
|
||||
case DeviceType.Gateway:
|
||||
break;
|
||||
case DeviceType.LightBulb:
|
||||
Navigator.push(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
builder: (context) => BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: LightInterface(light: device),
|
||||
),
|
||||
),
|
||||
);
|
||||
case DeviceType.ThreeGang:
|
||||
Navigator.push(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
builder: (context) => BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: ThreeGangInterface(
|
||||
gangSwitch: device,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
showDeviceInterface(device, context);
|
||||
},
|
||||
child: DefaultContainer(
|
||||
child: Padding(
|
||||
@ -119,3 +75,48 @@ class RoomPageSwitch extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows the device interface based on the product type of the device.
|
||||
///
|
||||
/// The [device] parameter represents the device model.
|
||||
void showDeviceInterface(DeviceModel device, BuildContext context) {
|
||||
switch (device.productType) {
|
||||
case DeviceType.AC:
|
||||
navigateToInterface(AcInterface(ac: device), context);
|
||||
break;
|
||||
case DeviceType.WallSensor:
|
||||
break;
|
||||
case DeviceType.CeilingSensor:
|
||||
break;
|
||||
case DeviceType.Curtain:
|
||||
break;
|
||||
case DeviceType.Blind:
|
||||
break;
|
||||
case DeviceType.DoorLock:
|
||||
navigateToInterface(DoorInterface(doorlock: device), context);
|
||||
break;
|
||||
case DeviceType.Gateway:
|
||||
break;
|
||||
case DeviceType.LightBulb:
|
||||
navigateToInterface(LightInterface(light: device), context);
|
||||
case DeviceType.ThreeGang:
|
||||
navigateToInterface(ThreeGangInterface(gangSwitch: device), context);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigates to the specified device interface.
|
||||
///
|
||||
/// The [interface] parameter represents the widget interface.
|
||||
void navigateToInterface(Widget interface, context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
builder: (context) => BlocProvider(
|
||||
create: (context) => DevicesCubit.getInstance(),
|
||||
child: interface,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DoorView extends StatelessWidget {
|
||||
const DoorView({super.key});
|
||||
class DoorsListView extends StatelessWidget {
|
||||
const DoorsListView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Reference in New Issue
Block a user