Converted all the devices models to extends from DeviceModel for the purpose of unifying.

Initialized Lights feature.
This commit is contained in:
Mohammad Salameh
2024-03-02 21:57:11 +03:00
parent 8203836332
commit bcaed7a4b8
17 changed files with 229 additions and 67 deletions
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:sleek_circular_slider/sleek_circular_slider.dart';
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.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_medium.dart';
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.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';
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart';
@@ -8,6 +8,8 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import '../../../model/ac_model.dart';
class ACsList extends StatelessWidget {
const ACsList({
super.key,
@@ -43,11 +45,16 @@ class ACsList extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
BodySmall(
text: DevicesCubit.categories[0].devices[index].name),
text:
DevicesCubit.categories[0].devices[index].name ??
""),
IconButton(
onPressed: () {
AcCubit.get(context).selectAC(
DevicesCubit.categories[0].devices[index]);
var device =
DevicesCubit.categories[0].devices[index];
if (device is ACModel) {
AcCubit.get(context).selectAC(device);
}
},
icon: const Icon(
Icons.arrow_forward_ios,
@@ -63,17 +70,21 @@ class ACsList extends StatelessWidget {
],
),
const SizedBox(height: 5),
DevicesDefaultSwitch(
model: DevicesCubit.categories[0].devices[index],
),
if (DevicesCubit.categories[0].devices[index] is ACModel)
DevicesDefaultSwitch(
model:
DevicesCubit.categories[0].devices[index] as ACModel,
),
const SizedBox(height: 10),
ACTempWidget(
index,
),
const SizedBox(height: 10),
ACModeControlUnit(
model: DevicesCubit.categories[0].devices[index],
),
if (DevicesCubit.categories[0].devices[index] is ACModel)
ACModeControlUnit(
model:
DevicesCubit.categories[0].devices[index] as ACModel,
),
const SizedBox(height: 10),
],
);
@@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_app_bar.dart';
import 'package:syncrow_app/features/app_layout/view/widgets/default_nav_bar.dart';
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart';
import 'package:syncrow_app/features/devices/model/ac_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
@@ -4,7 +4,7 @@ import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
import '../../../../../utils/resource_manager/color_manager.dart';
import '../../../../shared_widgets/text_widgets/body_medium.dart';
import '../../../bloc/ac_cubit.dart';
import '../../../bloc/AC/ac_cubit.dart';
class UniversalACSwitch extends StatelessWidget {
const UniversalACSwitch({
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/AC/ac_cubit.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import '../../../../../generated/assets.dart';
@@ -1,10 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../bloc/lights/lights_cubit.dart';
class LightsView extends StatelessWidget {
const LightsView({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
return BlocProvider(
create: (context) => LightsCubit(),
child: BlocBuilder<LightsCubit, LightsState>(
builder: (context, state) => const Center(
child: Text('LightsView'),
),
),
);
}
}