mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 22:17:55 +00:00
Converted all the devices models to extends from DeviceModel for the purpose of unifying.
Initialized Lights feature.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/screens/screens_view.dart';
|
||||
@@ -28,7 +29,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
static DevicesCubit get(context) => BlocProvider.of(context);
|
||||
|
||||
static var categories = <DevicesCategoryModel>[
|
||||
static List<DevicesCategoryModel> categories = [
|
||||
DevicesCategoryModel(
|
||||
devices: [
|
||||
ACModel(
|
||||
@@ -38,6 +39,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
temperature: 20,
|
||||
fanSpeed: 0,
|
||||
tempMode: 0,
|
||||
type: '',
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
),
|
||||
ACModel(
|
||||
name: "Master Bedroom AC",
|
||||
@@ -46,6 +51,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
temperature: 20,
|
||||
fanSpeed: 0,
|
||||
tempMode: 0,
|
||||
type: '',
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
),
|
||||
],
|
||||
icon: Assets.iconsAC,
|
||||
@@ -54,7 +63,32 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
page: const ACsView(),
|
||||
),
|
||||
DevicesCategoryModel(
|
||||
devices: [],
|
||||
devices: [
|
||||
LightModel(
|
||||
name: "Living Room Light",
|
||||
id: '0',
|
||||
status: false,
|
||||
color: 0,
|
||||
brightness: 20,
|
||||
lightingMode: 1,
|
||||
timer: null,
|
||||
type: '',
|
||||
location: '',
|
||||
image: '',
|
||||
),
|
||||
LightModel(
|
||||
name: "Master Bedroom Light",
|
||||
id: '1',
|
||||
status: false,
|
||||
color: 2,
|
||||
brightness: 40,
|
||||
lightingMode: 1,
|
||||
timer: null,
|
||||
type: '',
|
||||
location: '',
|
||||
image: '',
|
||||
),
|
||||
],
|
||||
icon: Assets.iconsLight,
|
||||
name: 'Lights',
|
||||
type: DeviceType.Lights,
|
||||
@@ -101,7 +135,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
|
||||
void areAllDevicesOff(DevicesCategoryModel category) {
|
||||
for (var device in category.devices) {
|
||||
if (device.status) {
|
||||
if (device.status ?? false) {
|
||||
category.devicesStatus = false;
|
||||
emit(CategorySwitchChanged());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user