Files
syncrow-app/lib/features/devices/view/widgets/room_page_switch.dart
Mohammad Salameh a20dfa3709 Refactor device status handling and update UI components
- Update device status handling from 'status' to 'isOnline' for consistency
- Remove unused imports and redundant code related to light switches
- Refactor UI components to use 'isOnline' instead of 'status' for device status
2024-04-01 09:58:51 +03:00

86 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.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/shared_widgets/custom_switch.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/utils/context_extension.dart';
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class RoomPageSwitch extends StatelessWidget {
const RoomPageSwitch({
super.key,
required this.device,
});
final DeviceModel device;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
//Navigate to the chosen category view without animation
// Navigator.push(
// context,
// CustomPageRoute(
// builder: (context) {
// return DevicesCubit.get(context)
// .chosenCategoryView!;
// },
// ),
// );
if (device.productType == DeviceType.AC) {
Navigator.push(
context,
CustomPageRoute(
builder: (context) => AcInterface(deviceModel: device),
),
);
}
},
child: DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(top: 10, right: 10, left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
device.icon!,
fit: BoxFit.contain,
),
CustomSwitch(
device: device,
),
],
),
Expanded(
child: FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: device.name ?? "",
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 24,
color: Colors.grey,
),
),
),
),
],
),
),
),
);
}
}