mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
temp
This commit is contained in:
@ -1,56 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
||||||
|
|
||||||
part 'ac_state.dart';
|
|
||||||
|
|
||||||
class AcCubit extends Cubit<AcState> {
|
|
||||||
AcCubit() : super(AcInitial());
|
|
||||||
|
|
||||||
static AcCubit get(context) => BlocProvider.of(context);
|
|
||||||
|
|
||||||
static DevicesCategoryModel category = DevicesCubit.allCategories[0];
|
|
||||||
|
|
||||||
ACModel? getSelectedAC() {
|
|
||||||
for (var ac in category.devices) {
|
|
||||||
if (ac is ACModel && ac.isSelected) {
|
|
||||||
return ac;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTempToAll(double temperature) {
|
|
||||||
for (DeviceModel ac in category.devices) {
|
|
||||||
if (ac is ACModel) {
|
|
||||||
if (ac.temperature != temperature &&
|
|
||||||
ac.bounds.min <= temperature &&
|
|
||||||
temperature <= ac.bounds.max) {
|
|
||||||
setACTemp(ac, temperature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
universalACTemp = temperature;
|
|
||||||
emit(ACsTempChanged(temperature));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setACTemp(ACModel model, double temp) {
|
|
||||||
if (model.bounds.min <= temp && temp <= model.bounds.max) {
|
|
||||||
model.temperature = temp;
|
|
||||||
}
|
|
||||||
emit(ACsTempChanged(temp));
|
|
||||||
}
|
|
||||||
|
|
||||||
double getTemp(int index) {
|
|
||||||
var device = category.devices[index];
|
|
||||||
if (device is ACModel) {
|
|
||||||
return device.temperature;
|
|
||||||
}
|
|
||||||
return 0.0; // or any default value you prefer
|
|
||||||
}
|
|
||||||
|
|
||||||
static double universalACTemp = 20;
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
part of 'ac_cubit.dart';
|
|
||||||
|
|
||||||
@immutable
|
|
||||||
abstract class AcState {}
|
|
||||||
|
|
||||||
class AcInitial extends AcState {}
|
|
||||||
|
|
||||||
class ACsStatusChanged extends AcState {}
|
|
||||||
|
|
||||||
class SwitchACsOff extends AcState {}
|
|
||||||
|
|
||||||
class SwitchACsOn extends AcState {}
|
|
||||||
|
|
||||||
class ACsTempChanged extends AcState {
|
|
||||||
final double temperature;
|
|
||||||
|
|
||||||
ACsTempChanged(this.temperature);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ACsAverageTemp extends AcState {}
|
|
||||||
|
|
||||||
class ACsFanSpeedChanged extends AcState {}
|
|
||||||
|
|
||||||
class ACsTempModeChanged extends AcState {}
|
|
||||||
|
|
||||||
class ACTurnedOn extends AcState {}
|
|
||||||
|
|
||||||
class ACTurnedOff extends AcState {}
|
|
||||||
|
|
||||||
class ACSelected extends AcState {}
|
|
@ -1,13 +0,0 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
|
||||||
|
|
||||||
part 'curtains_state.dart';
|
|
||||||
|
|
||||||
class CurtainsCubit extends Cubit<CurtainsState> {
|
|
||||||
CurtainsCubit() : super(CurtainsInitial());
|
|
||||||
|
|
||||||
static CurtainsCubit get(context) => BlocProvider.of(context);
|
|
||||||
|
|
||||||
static DevicesCategoryModel category = DevicesCubit.allCategories[3];
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
part of 'curtains_cubit.dart';
|
|
||||||
|
|
||||||
abstract class CurtainsState {}
|
|
||||||
|
|
||||||
class CurtainsInitial extends CurtainsState {}
|
|
@ -1,19 +1,16 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.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/light_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.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/gateway/gateway_view.dart';
|
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/lights/lights_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights_switches/light_switches.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights_switches/light_switches.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
|
||||||
import 'package:syncrow_app/services/api/devices_api.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/network_exception.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -26,229 +23,229 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
static DevicesCubit get(context) => BlocProvider.of(context);
|
static DevicesCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static List<DevicesCategoryModel> allCategories = [
|
static List<DevicesCategoryModel> allCategories = [
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [
|
// devices: [
|
||||||
ACModel(
|
// DeviceModel(
|
||||||
name: "Living Room AC",
|
// name: "Living Room AC",
|
||||||
id: 0,
|
// id: 0,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
temperature: 20,
|
// temperature: 20,
|
||||||
fanSpeed: 0,
|
// fanSpeed: 0,
|
||||||
tempMode: 0,
|
// tempMode: 0,
|
||||||
coolTo: 20,
|
// coolTo: 20,
|
||||||
type: DeviceType.AC,
|
// type: DeviceType.AC,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
bounds: Bounds(
|
// bounds: Bounds(
|
||||||
min: 20,
|
// min: 20,
|
||||||
max: 30,
|
// max: 30,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
ACModel(
|
// DeviceModel(
|
||||||
name: "Master Bedroom AC",
|
// name: "Master Bedroom AC",
|
||||||
id: 1,
|
// id: 1,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
temperature: 20,
|
// temperature: 20,
|
||||||
fanSpeed: 0,
|
// fanSpeed: 0,
|
||||||
tempMode: 0,
|
// tempMode: 0,
|
||||||
coolTo: 20,
|
// coolTo: 20,
|
||||||
type: DeviceType.AC,
|
// type: DeviceType.AC,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
bounds: Bounds(
|
// bounds: Bounds(
|
||||||
min: 20,
|
// min: 20,
|
||||||
max: 30,
|
// max: 30,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
ACModel(
|
// DeviceModel(
|
||||||
name: "Kitchen AC",
|
// name: "Kitchen AC",
|
||||||
id: 2,
|
// id: 2,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
temperature: 20,
|
// temperature: 20,
|
||||||
fanSpeed: 0,
|
// fanSpeed: 0,
|
||||||
tempMode: 0,
|
// tempMode: 0,
|
||||||
coolTo: 20,
|
// coolTo: 20,
|
||||||
type: DeviceType.AC,
|
// type: DeviceType.AC,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
bounds: Bounds(
|
// bounds: Bounds(
|
||||||
min: 20,
|
// min: 20,
|
||||||
max: 30,
|
// max: 30,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
ACModel(
|
// DeviceModel(
|
||||||
name: "Bathroom AC",
|
// name: "Bathroom AC",
|
||||||
id: 3,
|
// id: 3,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
temperature: 20,
|
// temperature: 20,
|
||||||
fanSpeed: 0,
|
// fanSpeed: 0,
|
||||||
tempMode: 0,
|
// tempMode: 0,
|
||||||
coolTo: 20,
|
// coolTo: 20,
|
||||||
type: DeviceType.AC,
|
// type: DeviceType.AC,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
bounds: Bounds(
|
// bounds: Bounds(
|
||||||
min: 20,
|
// min: 20,
|
||||||
max: 30,
|
// max: 30,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
icon: Assets.iconsAC,
|
// icon: Assets.iconsAC,
|
||||||
name: 'ACs',
|
// name: 'ACs',
|
||||||
type: DeviceType.AC,
|
// type: DeviceType.AC,
|
||||||
page: const ACsView(),
|
// page: const ACsView(),
|
||||||
),
|
// ),
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [
|
// devices: [
|
||||||
LightModel(
|
// DeviceModel(
|
||||||
name: "Living Room Light",
|
// name: "Living Room Light",
|
||||||
id: 0,
|
// id: 0,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
color: 0,
|
// color: 0,
|
||||||
brightness: 20,
|
// brightness: 20,
|
||||||
lightingMode: 1,
|
// lightingMode: 1,
|
||||||
timer: null,
|
// timer: null,
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
image: '',
|
// image: '',
|
||||||
recentColors: [
|
// recentColors: [
|
||||||
0xFF83D9FF,
|
// 0xFF83D9FF,
|
||||||
0xFFFC3E81,
|
// 0xFFFC3E81,
|
||||||
0xFFC0FF66,
|
// 0xFFC0FF66,
|
||||||
0xFFFDC242,
|
// 0xFFFDC242,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
LightModel(
|
// DeviceModel(
|
||||||
name: "Master Bedroom Light",
|
// name: "Master Bedroom Light",
|
||||||
id: 1,
|
// id: 1,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
color: 2,
|
// color: 2,
|
||||||
brightness: 40,
|
// brightness: 40,
|
||||||
lightingMode: 1,
|
// lightingMode: 1,
|
||||||
timer: null,
|
// timer: null,
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
image: '',
|
// image: '',
|
||||||
recentColors: [
|
// recentColors: [
|
||||||
0xFF83D9FF,
|
// 0xFF83D9FF,
|
||||||
0xFFFC3E81,
|
// 0xFFFC3E81,
|
||||||
0xFFC0FF66,
|
// 0xFFC0FF66,
|
||||||
0xFFFDC242,
|
// 0xFFFDC242,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
LightModel(
|
// DeviceModel(
|
||||||
name: "Kitchen Light",
|
// name: "Kitchen Light",
|
||||||
id: 2,
|
// id: 2,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
color: 1,
|
// color: 1,
|
||||||
brightness: 60,
|
// brightness: 60,
|
||||||
lightingMode: 1,
|
// lightingMode: 1,
|
||||||
timer: null,
|
// timer: null,
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
image: '',
|
// image: '',
|
||||||
recentColors: [
|
// recentColors: [
|
||||||
0xFF83D9FF,
|
// 0xFF83D9FF,
|
||||||
0xFFFC3E81,
|
// 0xFFFC3E81,
|
||||||
0xFFC0FF66,
|
// 0xFFC0FF66,
|
||||||
0xFFFDC242,
|
// 0xFFFDC242,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
LightModel(
|
// DeviceModel(
|
||||||
name: "Bathroom Light",
|
// name: "Bathroom Light",
|
||||||
id: 3,
|
// id: 3,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
color: 3,
|
// color: 3,
|
||||||
brightness: 80,
|
// brightness: 80,
|
||||||
lightingMode: 1,
|
// lightingMode: 1,
|
||||||
timer: null,
|
// timer: null,
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
image: '',
|
// image: '',
|
||||||
recentColors: [
|
// recentColors: [
|
||||||
0xFF83D9FF,
|
// 0xFF83D9FF,
|
||||||
0xFFFC3E81,
|
// 0xFFFC3E81,
|
||||||
0xFFC0FF66,
|
// 0xFFC0FF66,
|
||||||
0xFFFDC242,
|
// 0xFFFDC242,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
LightModel(
|
// DeviceModel(
|
||||||
name: "Balcony Light",
|
// name: "Balcony Light",
|
||||||
id: 4,
|
// id: 4,
|
||||||
functions: [],
|
// functions: [],
|
||||||
status: false,
|
// status: false,
|
||||||
color: 4,
|
// color: 4,
|
||||||
brightness: 100,
|
// brightness: 100,
|
||||||
lightingMode: 1,
|
// lightingMode: 1,
|
||||||
timer: null,
|
// timer: null,
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
image: '',
|
// image: '',
|
||||||
recentColors: [
|
// recentColors: [
|
||||||
0xFF83D9FF,
|
// 0xFF83D9FF,
|
||||||
0xFFFC3E81,
|
// 0xFFFC3E81,
|
||||||
0xFFC0FF66,
|
// 0xFFC0FF66,
|
||||||
0xFFFDC242,
|
// 0xFFFDC242,
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
icon: Assets.iconsLight,
|
// icon: Assets.iconsLight,
|
||||||
name: 'Lights',
|
// name: 'Lights',
|
||||||
type: DeviceType.Lights,
|
// type: DeviceType.Lights,
|
||||||
page: const LightsView(),
|
// page: const LightsView(),
|
||||||
),
|
// ),
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [],
|
// devices: [],
|
||||||
icon: Assets.iconsDoorLock,
|
// icon: Assets.iconsDoorLock,
|
||||||
name: 'Doors',
|
// name: 'Doors',
|
||||||
type: DeviceType.Door,
|
// type: DeviceType.DoorLock,
|
||||||
page: const DoorView(),
|
// page: const DoorView(),
|
||||||
),
|
// ),
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [
|
// devices: [
|
||||||
CurtainModel(
|
// DeviceModel(
|
||||||
openPercentage: 10,
|
// openPercentage: 10,
|
||||||
id: 1,
|
// id: 1,
|
||||||
functions: [],
|
// functions: [],
|
||||||
name: "Living Room Curtain",
|
// name: "Living Room Curtain",
|
||||||
status: false,
|
// status: false,
|
||||||
type: DeviceType.Curtain,
|
// type: DeviceType.Curtain,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
),
|
// ),
|
||||||
CurtainModel(
|
// DeviceModel(
|
||||||
openPercentage: 20,
|
// openPercentage: 20,
|
||||||
id: 2,
|
// id: 2,
|
||||||
functions: [],
|
// functions: [],
|
||||||
name: "Master Bedroom Curtain",
|
// name: "Master Bedroom Curtain",
|
||||||
status: false,
|
// status: false,
|
||||||
type: DeviceType.Curtain,
|
// type: DeviceType.Curtain,
|
||||||
image: '',
|
// image: '',
|
||||||
timer: null,
|
// timer: null,
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
icon: Assets.iconsCurtain,
|
// icon: Assets.iconsCurtain,
|
||||||
name: 'Curtains',
|
// name: 'Curtains',
|
||||||
type: DeviceType.Curtain,
|
// type: DeviceType.Curtain,
|
||||||
page: const CurtainView(),
|
// page: const CurtainView(),
|
||||||
),
|
// ),
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [],
|
// devices: [],
|
||||||
icon: Assets.icons3GangSwitch,
|
// icon: Assets.icons3GangSwitch,
|
||||||
name: 'Bedroom Lights',
|
// name: 'Bedroom Lights',
|
||||||
type: DeviceType.ThreeGang,
|
// type: DeviceType.ThreeGang,
|
||||||
page: const LightSwitchesView(),
|
// page: const LightSwitchesView(),
|
||||||
),
|
// ),
|
||||||
DevicesCategoryModel(
|
// DevicesCategoryModel(
|
||||||
devices: [],
|
// devices: [],
|
||||||
icon: Assets.iconsGateway,
|
// icon: Assets.iconsGateway,
|
||||||
name: 'Gateway',
|
// name: 'Gateway',
|
||||||
type: DeviceType.Gateway,
|
// type: DeviceType.Gateway,
|
||||||
page: const GateWayView(),
|
// page: const GateWayView(),
|
||||||
),
|
// ),
|
||||||
];
|
];
|
||||||
|
|
||||||
selectCategory(int index) {
|
selectCategory(int index) {
|
||||||
@ -272,7 +269,22 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
Widget? get chosenCategoryView {
|
Widget? get chosenCategoryView {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories) {
|
||||||
if (category.isSelected) {
|
if (category.isSelected) {
|
||||||
return category.page;
|
switch (category.type) {
|
||||||
|
case DeviceType.AC:
|
||||||
|
return const ACsView();
|
||||||
|
case DeviceType.Lights:
|
||||||
|
return const LightsView();
|
||||||
|
case DeviceType.DoorLock:
|
||||||
|
return const DoorView();
|
||||||
|
case DeviceType.Curtain:
|
||||||
|
return const CurtainView();
|
||||||
|
case DeviceType.ThreeGang:
|
||||||
|
return const LightSwitchesView();
|
||||||
|
case DeviceType.Gateway:
|
||||||
|
return const GateWayView();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -289,11 +301,13 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
selectDevice(DeviceModel device) {
|
selectDevice(DeviceModel device) {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories) {
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
if (device.isSelected) {
|
for (var device in category.devices!) {
|
||||||
category.isSelected = false;
|
if (device.isSelected) {
|
||||||
emit(DeviceSelected());
|
category.isSelected = false;
|
||||||
return;
|
emit(DeviceSelected());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,9 +317,11 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
DeviceModel? getSelectedDevice() {
|
DeviceModel? getSelectedDevice() {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories) {
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
if (device.isSelected) {
|
for (var device in category.devices!) {
|
||||||
return device;
|
if (device.isSelected) {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,13 +331,17 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
changeCategorySwitchValue(DevicesCategoryModel category) {
|
changeCategorySwitchValue(DevicesCategoryModel category) {
|
||||||
if (category.devicesStatus != null) {
|
if (category.devicesStatus != null) {
|
||||||
category.devicesStatus = !category.devicesStatus!;
|
category.devicesStatus = !category.devicesStatus!;
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
device.status = category.devicesStatus;
|
for (var device in category.devices!) {
|
||||||
|
device.status = category.devicesStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
category.devicesStatus = true;
|
category.devicesStatus = true;
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
device.status = true;
|
for (var device in category.devices!) {
|
||||||
|
device.status = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateDevicesStatus(category);
|
updateDevicesStatus(category);
|
||||||
@ -331,59 +351,72 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
turnOnOffDevice(DeviceModel device) {
|
turnOnOffDevice(DeviceModel device) {
|
||||||
device.status = !device.status!;
|
device.status = !device.status!;
|
||||||
DevicesCategoryModel category = allCategories
|
DevicesCategoryModel category = allCategories.firstWhere((category) {
|
||||||
.firstWhere((category) => category.devices.contains(device));
|
if (category.devices != null) {
|
||||||
|
return category.devices!.contains(device);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
updateDevicesStatus(category);
|
updateDevicesStatus(category);
|
||||||
emit(DeviceSwitchChanged());
|
emit(DeviceSwitchChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDevicesStatus(DevicesCategoryModel category) {
|
updateDevicesStatus(DevicesCategoryModel category) {
|
||||||
if (category.devices.isNotEmpty) {
|
if (category.devices != null) {
|
||||||
bool? tempStatus = category.devices[0].status;
|
if (category.devices!.isNotEmpty) {
|
||||||
for (var ac in category.devices) {
|
bool? tempStatus = category.devices![0].status;
|
||||||
//check if there any ac have a different status than the initial ==> turn off the universal switch
|
for (var ac in category.devices!) {
|
||||||
if (ac.status != tempStatus) {
|
//check if there any ac have a different status than the initial ==> turn off the universal switch
|
||||||
category.devicesStatus = null;
|
if (ac.status != tempStatus) {
|
||||||
|
category.devicesStatus = null;
|
||||||
|
emit(DeviceSwitchChanged());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
category.devicesStatus = tempStatus;
|
||||||
emit(DeviceSwitchChanged());
|
emit(DeviceSwitchChanged());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
category.devicesStatus = tempStatus;
|
} else {
|
||||||
|
category.devicesStatus = null;
|
||||||
emit(DeviceSwitchChanged());
|
emit(DeviceSwitchChanged());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
category.devicesStatus = null;
|
|
||||||
emit(DeviceSwitchChanged());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
turnAllDevicesOff(DevicesCategoryModel category) {
|
turnAllDevicesOff(DevicesCategoryModel category) {
|
||||||
if (category.devices.isNotEmpty) {
|
if (category.devices != null) {
|
||||||
for (var device in category.devices) {
|
if (category.devices!.isNotEmpty) {
|
||||||
device.status = false;
|
for (var device in category.devices!) {
|
||||||
|
device.status = false;
|
||||||
|
}
|
||||||
|
changeCategorySwitchValue(category);
|
||||||
|
updateDevicesStatus(category);
|
||||||
|
emit(CategorySwitchChanged());
|
||||||
}
|
}
|
||||||
changeCategorySwitchValue(category);
|
|
||||||
updateDevicesStatus(category);
|
|
||||||
emit(CategorySwitchChanged());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
turnAllDevicesOn(DevicesCategoryModel category) {
|
turnAllDevicesOn(DevicesCategoryModel category) {
|
||||||
if (category.devices.isNotEmpty) {
|
if (category.devices != null) {
|
||||||
for (var device in category.devices) {
|
if (category.devices!.isNotEmpty) {
|
||||||
device.status = true;
|
for (var device in category.devices!) {
|
||||||
|
device.status = true;
|
||||||
|
}
|
||||||
|
changeCategorySwitchValue(category);
|
||||||
|
updateDevicesStatus(category);
|
||||||
|
emit(CategorySwitchChanged());
|
||||||
}
|
}
|
||||||
changeCategorySwitchValue(category);
|
|
||||||
updateDevicesStatus(category);
|
|
||||||
emit(CategorySwitchChanged());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
areAllDevicesOff(DevicesCategoryModel category) {
|
areAllDevicesOff(DevicesCategoryModel category) {
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
if (device.status ?? false) {
|
for (var device in category.devices!) {
|
||||||
category.devicesStatus = false;
|
if (device.status ?? false) {
|
||||||
emit(CategorySwitchChanged());
|
category.devicesStatus = false;
|
||||||
return;
|
emit(CategorySwitchChanged());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,8 +424,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
clearCategoriesSelection(BuildContext context) {
|
clearCategoriesSelection(BuildContext context) {
|
||||||
for (var category in allCategories) {
|
for (var category in allCategories) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
for (var device in category.devices) {
|
if (category.devices != null) {
|
||||||
device.isSelected = false;
|
for (var device in category.devices!) {
|
||||||
|
device.isSelected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Navigator.popUntil(context, (route) => route.isFirst);
|
Navigator.popUntil(context, (route) => route.isFirst);
|
||||||
@ -422,4 +457,108 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
emit(DeviceControlError(ServerFailure.fromDioError(e).errMessage));
|
emit(DeviceControlError(ServerFailure.fromDioError(e).errMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchGroups(
|
||||||
|
SpaceModel space,
|
||||||
|
) async {
|
||||||
|
emit(DevicesCategoriesLoading());
|
||||||
|
try {
|
||||||
|
allCategories = await DevicesAPI.fetchGroups(space.id!);
|
||||||
|
emit(DevicesCategoriesSuccess());
|
||||||
|
} on DioException catch (e) {
|
||||||
|
emit(DevicesCategoriesError(ServerFailure.fromDioError(e).errMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///Lights
|
||||||
|
onHorizontalDragUpdate(DeviceModel light, double dx, double screenWidth) {
|
||||||
|
double newBrightness = (dx / (screenWidth - 15) * 100);
|
||||||
|
if (newBrightness > 100) {
|
||||||
|
newBrightness = 100;
|
||||||
|
} else if (newBrightness < 0) {
|
||||||
|
newBrightness = 0;
|
||||||
|
}
|
||||||
|
// setBrightness(light, newBrightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<int, LightMode> lightModes = {
|
||||||
|
0: LightMode.Doze,
|
||||||
|
1: LightMode.Relax,
|
||||||
|
2: LightMode.Reading,
|
||||||
|
3: LightMode.Energizing,
|
||||||
|
};
|
||||||
|
|
||||||
|
// setLightingMode(DeviceModel light, LightMode mode) {
|
||||||
|
// light.lightingMode =
|
||||||
|
// lightModes.entries.firstWhere((element) => element.value == mode).key;
|
||||||
|
// emit(LightModeChanged(mode));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// toggleLight(DeviceModel light) {
|
||||||
|
// light.status != null ? light.status = !light.status! : light.status = true;
|
||||||
|
// emit(LightToggled(light));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// setColor(DeviceModel light, int color) {
|
||||||
|
// light.color = color;
|
||||||
|
// emit(LightColorChanged(color));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int getBrightness(DeviceModel light) {
|
||||||
|
// return light.brightness.toInt();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setBrightness(DeviceModel light, double value) {
|
||||||
|
// value = (value / 5).ceil() * 5;
|
||||||
|
// if (value != light.brightness) {
|
||||||
|
// light.brightness = value;
|
||||||
|
// emit(LightBrightnessChanged(value));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
///ACs
|
||||||
|
// DeviceModel? getSelectedAC() {
|
||||||
|
// for (var ac in category.devices) {
|
||||||
|
// if (ac is DeviceModel && ac.isSelected) {
|
||||||
|
// return ac;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void setTempToAll(double temperature) {
|
||||||
|
// for (DeviceModel ac in category.devices) {
|
||||||
|
// if (ac is DeviceModel) {
|
||||||
|
// if (ac.temperature != temperature &&
|
||||||
|
// ac.bounds.min <= temperature &&
|
||||||
|
// temperature <= ac.bounds.max) {
|
||||||
|
// setACTemp(ac, temperature);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// universalACTemp = temperature;
|
||||||
|
// emit(ACsTempChanged(temperature));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void setACTemp(DeviceModel model, double temp) {
|
||||||
|
// if (model.bounds.min <= temp && temp <= model.bounds.max) {
|
||||||
|
// model.temperature = temp;
|
||||||
|
// }
|
||||||
|
// emit(ACsTempChanged(temp));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// double getTemp(int index) {
|
||||||
|
// var device = category.devices[index];
|
||||||
|
// if (device is DeviceModel) {
|
||||||
|
// return device.temperature;
|
||||||
|
// }
|
||||||
|
// return 0.0; // or any default value you prefer
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
enum LightMode {
|
||||||
|
Doze,
|
||||||
|
Relax,
|
||||||
|
Reading,
|
||||||
|
Energizing,
|
||||||
}
|
}
|
||||||
|
@ -30,3 +30,13 @@ class DeviceControlError extends DevicesState {
|
|||||||
|
|
||||||
DeviceControlError(this.errorMsg);
|
DeviceControlError(this.errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DevicesCategoriesLoading extends DevicesState {}
|
||||||
|
|
||||||
|
class DevicesCategoriesSuccess extends DevicesState {}
|
||||||
|
|
||||||
|
class DevicesCategoriesError extends DevicesState {
|
||||||
|
final String errorMsg;
|
||||||
|
|
||||||
|
DevicesCategoriesError(this.errorMsg);
|
||||||
|
}
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
|
||||||
|
|
||||||
part 'lights_state.dart';
|
|
||||||
|
|
||||||
class LightsCubit extends Cubit<LightsState> {
|
|
||||||
LightsCubit() : super(LightsInitial());
|
|
||||||
|
|
||||||
static LightsCubit get(context) => BlocProvider.of(context);
|
|
||||||
|
|
||||||
Map<int, LightMode> lightModes = {
|
|
||||||
0: LightMode.doze,
|
|
||||||
1: LightMode.relax,
|
|
||||||
2: LightMode.reading,
|
|
||||||
3: LightMode.energizing,
|
|
||||||
};
|
|
||||||
|
|
||||||
setLightingMode(LightModel light, LightMode mode) {
|
|
||||||
light.lightingMode =
|
|
||||||
lightModes.entries.firstWhere((element) => element.value == mode).key;
|
|
||||||
emit(LightModeChanged(mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleLight(LightModel light) {
|
|
||||||
light.status != null ? light.status = !light.status! : light.status = true;
|
|
||||||
emit(LightToggled(light));
|
|
||||||
}
|
|
||||||
|
|
||||||
setColor(LightModel light, int color) {
|
|
||||||
light.color = color;
|
|
||||||
emit(LightColorChanged(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
int getBrightness(LightModel light) {
|
|
||||||
return light.brightness.toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
setBrightness(LightModel light, double value) {
|
|
||||||
value = (value / 5).ceil() * 5;
|
|
||||||
if (value != light.brightness) {
|
|
||||||
light.brightness = value;
|
|
||||||
emit(LightBrightnessChanged(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onHorizontalDragUpdate(LightModel light, double dx, double screenWidth) {
|
|
||||||
double newBrightness = (dx / (screenWidth - 15) * 100);
|
|
||||||
if (newBrightness > 100) {
|
|
||||||
newBrightness = 100;
|
|
||||||
} else if (newBrightness < 0) {
|
|
||||||
newBrightness = 0;
|
|
||||||
}
|
|
||||||
setBrightness(light, newBrightness);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum LightMode {
|
|
||||||
doze,
|
|
||||||
relax,
|
|
||||||
reading,
|
|
||||||
energizing,
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
part of 'lights_cubit.dart';
|
|
||||||
|
|
||||||
abstract class LightsState {}
|
|
||||||
|
|
||||||
class LightsInitial extends LightsState {}
|
|
||||||
|
|
||||||
class LightsLoading extends LightsState {}
|
|
||||||
|
|
||||||
class LightsSuccess extends LightsState {}
|
|
||||||
|
|
||||||
class LightsFailure extends LightsState {
|
|
||||||
final String message;
|
|
||||||
|
|
||||||
LightsFailure(this.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
class LightBrightnessChanged extends LightsState {
|
|
||||||
final double brightness;
|
|
||||||
|
|
||||||
LightBrightnessChanged(this.brightness);
|
|
||||||
}
|
|
||||||
|
|
||||||
class LightToggled extends LightsState {
|
|
||||||
final LightModel light;
|
|
||||||
|
|
||||||
LightToggled(this.light);
|
|
||||||
}
|
|
||||||
|
|
||||||
class LightColorChanged extends LightsState {
|
|
||||||
final int color;
|
|
||||||
|
|
||||||
LightColorChanged(this.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
class LightModeChanged extends LightsState {
|
|
||||||
final LightMode mode;
|
|
||||||
|
|
||||||
LightModeChanged(this.mode);
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
||||||
|
|
||||||
class ACModel extends DeviceModel {
|
|
||||||
late double temperature;
|
|
||||||
|
|
||||||
late int fanSpeed;
|
|
||||||
|
|
||||||
late int tempMode;
|
|
||||||
|
|
||||||
late double coolTo;
|
|
||||||
|
|
||||||
late Bounds bounds;
|
|
||||||
|
|
||||||
ACModel({
|
|
||||||
required this.temperature,
|
|
||||||
required this.fanSpeed,
|
|
||||||
required this.tempMode,
|
|
||||||
required this.coolTo,
|
|
||||||
required this.bounds,
|
|
||||||
required super.id,
|
|
||||||
required super.name,
|
|
||||||
required super.type,
|
|
||||||
required super.status,
|
|
||||||
required super.image,
|
|
||||||
required super.timer,
|
|
||||||
required super.functions,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'temperature': temperature,
|
|
||||||
'fanSpeed': fanSpeed,
|
|
||||||
'tempMode': tempMode,
|
|
||||||
'coolTo': coolTo,
|
|
||||||
'id': id,
|
|
||||||
'name': name,
|
|
||||||
'status': status,
|
|
||||||
'type': type,
|
|
||||||
'image': image,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
factory ACModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
List<FunctionModel> func = [];
|
|
||||||
if (json['functions'] != null) {
|
|
||||||
json['functions'].forEach((v) {
|
|
||||||
func.add(FunctionModel.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return ACModel(
|
|
||||||
id: json['id'],
|
|
||||||
name: json['name'],
|
|
||||||
status: json['status'],
|
|
||||||
temperature: json['temperature'],
|
|
||||||
fanSpeed: json['fanSpeed'],
|
|
||||||
tempMode: json['tempMode'],
|
|
||||||
type: json['type'],
|
|
||||||
image: json['image'],
|
|
||||||
timer: json['timer'],
|
|
||||||
coolTo: json['coolTo'],
|
|
||||||
bounds: Bounds.fromJson(json['bounds']),
|
|
||||||
functions: func,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Bounds {
|
|
||||||
late double min;
|
|
||||||
late double max;
|
|
||||||
|
|
||||||
Bounds({
|
|
||||||
required this.min,
|
|
||||||
required this.max,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'min': min,
|
|
||||||
'max': max,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
factory Bounds.fromJson(Map<String, dynamic> json) {
|
|
||||||
return Bounds(
|
|
||||||
min: json['min'],
|
|
||||||
max: json['max'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
||||||
|
|
||||||
class CurtainModel extends DeviceModel {
|
|
||||||
late int openPercentage;
|
|
||||||
|
|
||||||
CurtainModel({
|
|
||||||
required this.openPercentage,
|
|
||||||
required super.id,
|
|
||||||
required super.name,
|
|
||||||
required super.type,
|
|
||||||
required super.status,
|
|
||||||
required super.image,
|
|
||||||
required super.timer,
|
|
||||||
required super.functions,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'openPercentage': openPercentage,
|
|
||||||
'timer': timer,
|
|
||||||
'id': id,
|
|
||||||
'name': name,
|
|
||||||
'status': status,
|
|
||||||
'type': type,
|
|
||||||
'image': image,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
factory CurtainModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
List<FunctionModel> func = [];
|
|
||||||
if (json['functions'] != null) {
|
|
||||||
json['functions'].forEach((v) {
|
|
||||||
func.add(FunctionModel.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return CurtainModel(
|
|
||||||
id: json['id'],
|
|
||||||
name: json['name'],
|
|
||||||
status: json['status'],
|
|
||||||
openPercentage: json['openPercentage'],
|
|
||||||
timer: json['timer'],
|
|
||||||
type: json['type'],
|
|
||||||
image: json['image'],
|
|
||||||
functions: func,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +1,55 @@
|
|||||||
// ignore_for_file: constant_identifier_names
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
import 'package:flutter/cupertino.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/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
class DevicesCategoryModel {
|
class DevicesCategoryModel {
|
||||||
final String name;
|
int? id;
|
||||||
final String icon;
|
final String? name;
|
||||||
|
final String? icon;
|
||||||
final Widget page;
|
|
||||||
|
|
||||||
bool? devicesStatus;
|
bool? devicesStatus;
|
||||||
final List<DeviceModel> devices;
|
final List<DeviceModel>? devices;
|
||||||
|
|
||||||
final DeviceType type;
|
final DeviceType? type;
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
|
|
||||||
DevicesCategoryModel(
|
DevicesCategoryModel(
|
||||||
{this.isSelected = false,
|
{this.isSelected = false,
|
||||||
required this.page,
|
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.devices}) {
|
required this.devices}) {
|
||||||
//sets the initial status of the devices
|
//sets the initial status of the devices
|
||||||
if (devices.isNotEmpty) {
|
if (devices != null) {
|
||||||
bool tempStatus = devices.first.status ?? false;
|
if (devices!.isNotEmpty) {
|
||||||
for (var device in devices) {
|
bool tempStatus = devices!.first.status ?? false;
|
||||||
if (device.status != tempStatus) {
|
for (var device in devices!) {
|
||||||
devicesStatus = false;
|
if (device.status != tempStatus) {
|
||||||
break;
|
devicesStatus = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
devicesStatus = tempStatus;
|
||||||
}
|
}
|
||||||
devicesStatus = tempStatus;
|
} else {
|
||||||
|
devicesStatus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicesCategoryModel.fromJson(Map<String, dynamic> json)
|
||||||
|
: name = json['groupName'],
|
||||||
|
id = json['groupId'],
|
||||||
|
icon = json['icon'],
|
||||||
|
type = deviceTypeMap[json['groupName']] ?? DeviceType.Other,
|
||||||
|
devices = [],
|
||||||
|
isSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, DeviceType> deviceTypeMap = {
|
||||||
|
'Ceiling Presence Sensors': DeviceType.Sensors,
|
||||||
|
'Wall presence sensor': DeviceType.Sensors,
|
||||||
|
'Door Locks': DeviceType.DoorLock,
|
||||||
|
'Gateways': DeviceType.Gateway,
|
||||||
|
'ACs': DeviceType.AC,
|
||||||
|
};
|
||||||
|
@ -30,7 +30,7 @@ class DeviceModel {
|
|||||||
case DeviceType.Lights:
|
case DeviceType.Lights:
|
||||||
icon = Assets.iconsLight;
|
icon = Assets.iconsLight;
|
||||||
break;
|
break;
|
||||||
case DeviceType.Door:
|
case DeviceType.DoorLock:
|
||||||
icon = Assets.iconsDoorLock;
|
icon = Assets.iconsDoorLock;
|
||||||
break;
|
break;
|
||||||
case DeviceType.Curtain:
|
case DeviceType.Curtain:
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
||||||
|
|
||||||
class LightModel extends DeviceModel {
|
|
||||||
late double brightness;
|
|
||||||
late int color;
|
|
||||||
|
|
||||||
late int lightingMode;
|
|
||||||
|
|
||||||
late List<int> recentColors;
|
|
||||||
|
|
||||||
LightModel({
|
|
||||||
required this.brightness,
|
|
||||||
required this.color,
|
|
||||||
required this.lightingMode,
|
|
||||||
required this.recentColors,
|
|
||||||
required super.id,
|
|
||||||
required super.name,
|
|
||||||
required super.type,
|
|
||||||
required super.status,
|
|
||||||
required super.image,
|
|
||||||
required super.timer,
|
|
||||||
required super.functions,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'luminance': brightness,
|
|
||||||
'color': color,
|
|
||||||
'lightingMode': lightingMode,
|
|
||||||
'timer': timer,
|
|
||||||
'recentColors': recentColors,
|
|
||||||
'id': id,
|
|
||||||
'name': name,
|
|
||||||
'status': status,
|
|
||||||
'type': type,
|
|
||||||
'image': image,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
factory LightModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
List<FunctionModel> func = [];
|
|
||||||
if (json['functions'] != null) {
|
|
||||||
json['functions'].forEach((v) {
|
|
||||||
func.add(FunctionModel.fromJson(v));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return LightModel(
|
|
||||||
id: json['id'],
|
|
||||||
name: json['name'],
|
|
||||||
status: json['status'],
|
|
||||||
brightness: json['luminance'],
|
|
||||||
color: json['color'],
|
|
||||||
lightingMode: json['lightingMode'],
|
|
||||||
timer: json['timer'],
|
|
||||||
type: json['type'],
|
|
||||||
image: json['image'],
|
|
||||||
recentColors: json['recentColors'],
|
|
||||||
functions: func,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_controls.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_controls.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_unit.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_unit.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';
|
||||||
@ -10,9 +10,9 @@ 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 AcInterface extends StatelessWidget {
|
class AcInterface extends StatelessWidget {
|
||||||
const AcInterface({super.key, required this.acModel});
|
const AcInterface({super.key, required this.deviceModel});
|
||||||
|
|
||||||
final ACModel acModel;
|
final DeviceModel deviceModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -30,7 +30,7 @@ class AcInterface extends StatelessWidget {
|
|||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: BodyLarge(
|
title: BodyLarge(
|
||||||
text: acModel.name ?? "",
|
text: deviceModel.name ?? "",
|
||||||
fontColor: ColorsManager.primaryColor,
|
fontColor: ColorsManager.primaryColor,
|
||||||
fontWeight: FontsManager.bold,
|
fontWeight: FontsManager.bold,
|
||||||
),
|
),
|
||||||
@ -62,7 +62,7 @@ class AcInterface extends StatelessWidget {
|
|||||||
maxHeight: 380,
|
maxHeight: 380,
|
||||||
),
|
),
|
||||||
child: AcInterfaceTempUnit(
|
child: AcInterfaceTempUnit(
|
||||||
acModel: acModel,
|
deviceModel: deviceModel,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@ -73,7 +73,7 @@ class AcInterface extends StatelessWidget {
|
|||||||
maxHeight: 120,
|
maxHeight: 120,
|
||||||
),
|
),
|
||||||
child: AcInterfaceControls(
|
child: AcInterfaceControls(
|
||||||
acModel: acModel,
|
deviceModel: deviceModel,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.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_mode_control_unit.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
|
|
||||||
@ -9,16 +9,16 @@ import '../../../../../generated/assets.dart';
|
|||||||
class AcInterfaceControls extends StatelessWidget {
|
class AcInterfaceControls extends StatelessWidget {
|
||||||
const AcInterfaceControls({
|
const AcInterfaceControls({
|
||||||
super.key,
|
super.key,
|
||||||
required this.acModel,
|
required this.deviceModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ACModel acModel;
|
final DeviceModel deviceModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
ACModeControlUnit(model: acModel),
|
ACModeControlUnit(model: deviceModel),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:sleek_circular_slider/sleek_circular_slider.dart';
|
import 'package:sleek_circular_slider/sleek_circular_slider.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/model/device_model.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';
|
||||||
@ -11,21 +12,19 @@ import 'package:syncrow_app/utils/context_extension.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/font_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||||
|
|
||||||
import '../../../model/ac_model.dart';
|
|
||||||
|
|
||||||
class AcInterfaceTempUnit extends StatelessWidget {
|
class AcInterfaceTempUnit extends StatelessWidget {
|
||||||
const AcInterfaceTempUnit({
|
const AcInterfaceTempUnit({
|
||||||
super.key,
|
super.key,
|
||||||
required this.acModel,
|
required this.deviceModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ACModel acModel;
|
final DeviceModel deviceModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => AcCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
child: BlocBuilder<AcCubit, AcState>(
|
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -55,7 +54,8 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
fontWeight: FontsManager.regular,
|
fontWeight: FontsManager.regular,
|
||||||
),
|
),
|
||||||
modifier: (double value) {
|
modifier: (double value) {
|
||||||
return '${acModel.temperature.toStringAsFixed(1)}°C';
|
// return '${DeviceModel.temperature.toStringAsFixed(1)}°C';
|
||||||
|
return '${value.toStringAsFixed(1)}°C';
|
||||||
},
|
},
|
||||||
mainLabelStyle: context.titleLarge.copyWith(
|
mainLabelStyle: context.titleLarge.copyWith(
|
||||||
height: 0,
|
height: 0,
|
||||||
@ -72,15 +72,16 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
min: acModel.bounds.min,
|
// min: DeviceModel.bounds.min,
|
||||||
max: acModel.bounds.max,
|
// max: DeviceModel.bounds.max,
|
||||||
initialValue: acModel.temperature,
|
// initialValue: DeviceModel.temperature,
|
||||||
onChange: (value) {
|
onChange: (value) {
|
||||||
String valueAsString = value.toStringAsFixed(1);
|
String valueAsString = value.toStringAsFixed(1);
|
||||||
if (valueAsString.endsWith(".0") ||
|
if (valueAsString.endsWith(".0") ||
|
||||||
valueAsString.endsWith(".5")) {
|
valueAsString.endsWith(".5")) {
|
||||||
value = double.parse(valueAsString);
|
value = double.parse(valueAsString);
|
||||||
AcCubit.get(context).setACTemp(acModel, value);
|
// DevicesCubit.get(context)
|
||||||
|
// .setACTemp(DeviceModel, value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -95,9 +96,9 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setACTemp(acModel, acModel.coolTo);
|
// .setACTemp(DeviceModel, DeviceModel.coolTo);
|
||||||
acModel.coolTo -= .5;
|
// DeviceModel.coolTo -= .5;
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsMinus,
|
Assets.iconsMinus,
|
||||||
@ -107,7 +108,8 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
BodyLarge(
|
BodyLarge(
|
||||||
text: "${acModel.coolTo}° C",
|
// text: "${DeviceModel.coolTo}° C",
|
||||||
|
text: '24° C',
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
color:
|
color:
|
||||||
ColorsManager.primaryColor.withOpacity(0.6),
|
ColorsManager.primaryColor.withOpacity(0.6),
|
||||||
@ -125,9 +127,9 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setACTemp(acModel, acModel.coolTo);
|
// .setACTemp(DeviceModel, DeviceModel.coolTo);
|
||||||
acModel.coolTo += .5;
|
// DeviceModel.coolTo += .5;
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsPlus,
|
Assets.iconsPlus,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.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/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
|
|
||||||
import '../../../../../generated/assets.dart';
|
import '../../../../../generated/assets.dart';
|
||||||
@ -11,7 +10,7 @@ class ACModeControlUnit extends StatefulWidget {
|
|||||||
required this.model,
|
required this.model,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ACModel model;
|
final DeviceModel model;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ACModeControlUnit> createState() => _ACModeControlUnitState();
|
State<ACModeControlUnit> createState() => _ACModeControlUnitState();
|
||||||
@ -40,15 +39,15 @@ class _ACModeControlUnitState extends State<ACModeControlUnit> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.model.fanSpeed =
|
// widget.model.fanSpeed =
|
||||||
widget.model.fanSpeed == 3 ? 0 : widget.model.fanSpeed + 1;
|
// widget.model.fanSpeed == 3 ? 0 : widget.model.fanSpeed + 1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
height: 55,
|
height: 55,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SvgPicture.asset(fanSpeeds[widget.model.fanSpeed]),
|
// child: SvgPicture.asset(fanSpeeds[widget.model.fanSpeed]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -57,15 +56,16 @@ class _ACModeControlUnitState extends State<ACModeControlUnit> {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.model.tempMode =
|
// widget.model.tempMode =
|
||||||
widget.model.tempMode == 2 ? 0 : widget.model.tempMode + 1;
|
// widget.model.tempMode == 2 ? 0 : widget.model.tempMode + 1;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: DefaultContainer(
|
child: const DefaultContainer(
|
||||||
height: 55,
|
height: 55,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SvgPicture.asset(tempModes[widget.model.tempMode]),
|
// child: SvgPicture.asset(tempModes[widget.model.tempMode]),
|
||||||
),
|
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.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/devices/bloc/devices_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.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/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
import '../../../../../generated/assets.dart';
|
import '../../../../../generated/assets.dart';
|
||||||
import '../../../model/ac_model.dart';
|
|
||||||
|
|
||||||
class ACTempWidget extends StatelessWidget {
|
class ACTempWidget extends StatelessWidget {
|
||||||
const ACTempWidget(
|
const ACTempWidget(
|
||||||
this.acModel, {
|
this.deviceModel, {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ACModel acModel;
|
final DeviceModel deviceModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<AcCubit, AcState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
height: 60,
|
height: 60,
|
||||||
@ -30,8 +31,8 @@ class ACTempWidget extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setACTemp(acModel, acModel.temperature - 0.5);
|
// .setACTemp(DeviceModel, DeviceModel.temperature - 0.5);
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsMinus,
|
Assets.iconsMinus,
|
||||||
@ -39,7 +40,8 @@ class ACTempWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
BodyLarge(
|
BodyLarge(
|
||||||
text: "${acModel.temperature}° C",
|
// text: "${DeviceModel.temperature}° C",
|
||||||
|
text: '25 °C',
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
color: ColorsManager.primaryColor.withOpacity(0.6),
|
color: ColorsManager.primaryColor.withOpacity(0.6),
|
||||||
fontSize: 23,
|
fontSize: 23,
|
||||||
@ -49,8 +51,8 @@ class ACTempWidget extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setACTemp(acModel, acModel.temperature + 0.5);
|
// .setACTemp(DeviceModel, DeviceModel.temperature + 0.5);
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsPlus,
|
Assets.iconsPlus,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/bloc/devices_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.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_mode_control_unit.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart';
|
||||||
@ -9,8 +9,6 @@ import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
import '../../../model/ac_model.dart';
|
|
||||||
|
|
||||||
class ACsList extends StatelessWidget {
|
class ACsList extends StatelessWidget {
|
||||||
const ACsList({
|
const ACsList({
|
||||||
super.key,
|
super.key,
|
||||||
@ -29,7 +27,7 @@ class ACsList extends StatelessWidget {
|
|||||||
const BodySmall(text: "All ACs"),
|
const BodySmall(text: "All ACs"),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
UniversalSwitch(
|
UniversalSwitch(
|
||||||
category: AcCubit.category,
|
category: DevicesCubit.get(context).chosenCategory!,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const UniversalACTemp(),
|
const UniversalACTemp(),
|
||||||
@ -40,9 +38,12 @@ class ACsList extends StatelessWidget {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
itemCount: AcCubit.category.devices.length,
|
itemCount:
|
||||||
|
DevicesCubit.get(context).chosenCategory!.devices!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
ACModel ac = AcCubit.category.devices[index] as ACModel;
|
DeviceModel ac = DevicesCubit.get(context)
|
||||||
|
.chosenCategory!
|
||||||
|
.devices![index] as DeviceModel;
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -51,7 +52,11 @@ class ACsList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
BodySmall(
|
BodySmall(
|
||||||
text: AcCubit.category.devices[index].name ?? ""),
|
text: DevicesCubit.get(context)
|
||||||
|
.chosenCategory!
|
||||||
|
.devices![index]
|
||||||
|
.name ??
|
||||||
|
""),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
DevicesCubit.get(context).selectDevice(ac);
|
DevicesCubit.get(context).selectDevice(ac);
|
||||||
@ -70,19 +75,17 @@ class ACsList extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
if (AcCubit.category.devices[index] is ACModel)
|
DevicesDefaultSwitch(
|
||||||
DevicesDefaultSwitch(
|
model: ac,
|
||||||
model: ac,
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
ACTempWidget(
|
ACTempWidget(
|
||||||
ac,
|
ac,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
if (AcCubit.category.devices[index] is ACModel)
|
ACModeControlUnit(
|
||||||
ACModeControlUnit(
|
model: ac,
|
||||||
model: ac,
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.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/ACs/ac_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
||||||
@ -18,15 +17,16 @@ class ACsView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => AcCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
child: BlocBuilder<DevicesCubit, DevicesState>(
|
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return BlocBuilder<AcCubit, AcState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
ACModel? selectedAC;
|
DeviceModel? selectedAC;
|
||||||
if (DevicesCubit.get(context).getSelectedDevice() is ACModel) {
|
if (DevicesCubit.get(context).getSelectedDevice()
|
||||||
selectedAC =
|
is DeviceModel) {
|
||||||
DevicesCubit.get(context).getSelectedDevice() as ACModel;
|
selectedAC = DevicesCubit.get(context).getSelectedDevice()
|
||||||
|
as DeviceModel;
|
||||||
}
|
}
|
||||||
return AnnotatedRegion(
|
return AnnotatedRegion(
|
||||||
value: SystemUiOverlayStyle(
|
value: SystemUiOverlayStyle(
|
||||||
@ -59,7 +59,7 @@ class ACsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: SizedBox.expand(
|
child: SizedBox.expand(
|
||||||
child: selectedAC != null
|
child: selectedAC != null
|
||||||
? AcInterface(acModel: selectedAC)
|
? AcInterface(deviceModel: selectedAC)
|
||||||
: const ACsList(),
|
: const ACsList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -20,7 +20,7 @@ class CategoryViewAppBar extends StatelessWidget
|
|||||||
toolbarHeight: Constants.appBarHeight,
|
toolbarHeight: Constants.appBarHeight,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: DisplayMedium(
|
title: DisplayMedium(
|
||||||
text: DevicesCubit.get(context).chosenCategory!.name,
|
text: DevicesCubit.get(context).chosenCategory!.name!,
|
||||||
style: context.displayMedium.copyWith(
|
style: context.displayMedium.copyWith(
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.primaryColor,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.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/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
|
|
||||||
import '../../../../../generated/assets.dart';
|
import '../../../../../generated/assets.dart';
|
||||||
@ -16,7 +16,7 @@ class UniversalACTemp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<AcCubit, AcState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
height: 60,
|
height: 60,
|
||||||
@ -27,8 +27,8 @@ class UniversalACTemp extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setTempToAll(AcCubit.universalACTemp - .5);
|
// .setTempToAll(DevicesCubit.universalACTemp - .5);
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsMinus,
|
Assets.iconsMinus,
|
||||||
@ -36,7 +36,8 @@ class UniversalACTemp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
BodyLarge(
|
BodyLarge(
|
||||||
text: "${AcCubit.universalACTemp}° C",
|
// text: "${DevicesCubit.universalACTemp}° C",
|
||||||
|
text: '25 °C',
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
color: ColorsManager.primaryColor.withOpacity(0.6),
|
color: ColorsManager.primaryColor.withOpacity(0.6),
|
||||||
fontSize: 23,
|
fontSize: 23,
|
||||||
@ -46,8 +47,8 @@ class UniversalACTemp extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
AcCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setTempToAll(AcCubit.universalACTemp + .5);
|
// .setTempToAll(DevicesCubit.universalACTemp + .5);
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsPlus,
|
Assets.iconsPlus,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/curtains/curtains_cubit.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/curtain_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
@ -26,7 +25,7 @@ class CurtainList extends StatelessWidget {
|
|||||||
const BodySmall(text: "All Curtains"),
|
const BodySmall(text: "All Curtains"),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
UniversalSwitch(
|
UniversalSwitch(
|
||||||
category: CurtainsCubit.category,
|
category: DevicesCubit.get(context).chosenCategory!,
|
||||||
),
|
),
|
||||||
|
|
||||||
// other ACs controls
|
// other ACs controls
|
||||||
@ -34,22 +33,25 @@ class CurtainList extends StatelessWidget {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
itemCount: CurtainsCubit.category.devices.length,
|
itemCount:
|
||||||
|
DevicesCubit.get(context).chosenCategory!.devices!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
CurtainModel curtain =
|
DeviceModel curtain =
|
||||||
CurtainsCubit.category.devices[index] as CurtainModel;
|
DevicesCubit.get(context).chosenCategory!.devices![index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
BodySmall(
|
BodySmall(
|
||||||
text:
|
text: DevicesCubit.get(context)
|
||||||
CurtainsCubit.category.devices[index].name ?? ""),
|
.chosenCategory!
|
||||||
|
.devices![index]
|
||||||
|
.name ??
|
||||||
|
""),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
if (CurtainsCubit.category.devices[index] is CurtainModel)
|
DevicesDefaultSwitch(
|
||||||
DevicesDefaultSwitch(
|
model: curtain,
|
||||||
model: curtain,
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/curtains/curtains_cubit.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/view/widgets/ACs/category_view_app_bar.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_list.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_list.dart';
|
||||||
@ -15,47 +14,43 @@ class CurtainView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => CurtainsCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
child: BlocBuilder<DevicesCubit, DevicesState>(
|
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return BlocBuilder<CurtainsCubit, CurtainsState>(
|
return AnnotatedRegion(
|
||||||
builder: (context, state) {
|
value: SystemUiOverlayStyle(
|
||||||
return AnnotatedRegion(
|
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
||||||
value: SystemUiOverlayStyle(
|
statusBarIconBrightness: Brightness.light,
|
||||||
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
),
|
||||||
statusBarIconBrightness: Brightness.light,
|
child: SafeArea(
|
||||||
),
|
child: Scaffold(
|
||||||
child: SafeArea(
|
backgroundColor: ColorsManager.backgroundColor,
|
||||||
child: Scaffold(
|
extendBodyBehindAppBar: true,
|
||||||
backgroundColor: ColorsManager.backgroundColor,
|
extendBody: true,
|
||||||
extendBodyBehindAppBar: true,
|
appBar: const CategoryViewAppBar(),
|
||||||
extendBody: true,
|
body: Container(
|
||||||
appBar: const CategoryViewAppBar(),
|
width: MediaQuery.sizeOf(context).width,
|
||||||
body: Container(
|
height: MediaQuery.sizeOf(context).height,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
decoration: const BoxDecoration(
|
||||||
height: MediaQuery.sizeOf(context).height,
|
image: DecorationImage(
|
||||||
decoration: const BoxDecoration(
|
image: AssetImage(
|
||||||
image: DecorationImage(
|
Assets.imagesBackground,
|
||||||
image: AssetImage(
|
|
||||||
Assets.imagesBackground,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
opacity: 0.4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
top: Constants.appBarHeight,
|
|
||||||
left: Constants.defaultPadding,
|
|
||||||
right: Constants.defaultPadding,
|
|
||||||
),
|
|
||||||
child: const CurtainList(),
|
|
||||||
),
|
),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
opacity: 0.4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: Constants.appBarHeight,
|
||||||
|
left: Constants.defaultPadding,
|
||||||
|
right: Constants.defaultPadding,
|
||||||
|
),
|
||||||
|
child: const CurtainList(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -1,29 +1,28 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_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/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/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
import '../../../model/light_model.dart';
|
|
||||||
|
|
||||||
class LightBrightness extends StatelessWidget {
|
class LightBrightness extends StatelessWidget {
|
||||||
const LightBrightness({
|
const LightBrightness({
|
||||||
super.key,
|
super.key,
|
||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<LightsCubit, LightsState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onHorizontalDragUpdate: (details) => LightsCubit.get(context)
|
// onHorizontalDragUpdate: (details) => DevicesCubit().get(context)
|
||||||
.onHorizontalDragUpdate(light, details.localPosition.dx,
|
// .onHorizontalDragUpdate(light, details.localPosition.dx,
|
||||||
MediaQuery.of(context).size.width - 15),
|
// MediaQuery.of(context).size.width - 15),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -36,22 +35,24 @@ class LightBrightness extends StatelessWidget {
|
|||||||
duration: const Duration(milliseconds: 0),
|
duration: const Duration(milliseconds: 0),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 60,
|
height: 60,
|
||||||
width: (MediaQuery.of(context).size.width - 30) *
|
// width: (MediaQuery.of(context).size.width - 30) *
|
||||||
light.brightness /
|
// light.brightness /
|
||||||
100,
|
// 100,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.primaryColor.withOpacity(0.6),
|
color: ColorsManager.primaryColor.withOpacity(0.6),
|
||||||
borderRadius: light.brightness != 100
|
borderRadius:
|
||||||
? const BorderRadius.only(
|
// light.brightness != 100 ?
|
||||||
topLeft: Radius.circular(20),
|
const BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(20),
|
topLeft: Radius.circular(20),
|
||||||
)
|
bottomLeft: Radius.circular(20),
|
||||||
: BorderRadius.circular(20),
|
)
|
||||||
),
|
// : BorderRadius.circular(20),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BodyLarge(
|
BodyLarge(
|
||||||
text: "${light.brightness}%",
|
// text: "${light.brightness}%",
|
||||||
|
text: '100%',
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 23,
|
fontSize: 23,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_contols.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_contols.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_switch.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_switch.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_timer.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_timer.dart';
|
||||||
@ -9,11 +9,11 @@ import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface
|
|||||||
class LightInterface extends StatelessWidget {
|
class LightInterface extends StatelessWidget {
|
||||||
const LightInterface({super.key, required this.light});
|
const LightInterface({super.key, required this.light});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<LightsCubit, LightsState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(top: 70, right: 20, left: 20),
|
padding: const EdgeInsets.only(top: 70, right: 20, left: 20),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_modes.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_modes.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_recent_color.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_recent_color.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_slider.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface_slider.dart';
|
||||||
@ -11,7 +11,7 @@ class LightInterfaceContols extends StatelessWidget {
|
|||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.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';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
@ -12,7 +12,7 @@ class LightInterfaceModes extends StatelessWidget {
|
|||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -27,10 +27,10 @@ class LightInterfaceModes extends StatelessWidget {
|
|||||||
Wrap(
|
Wrap(
|
||||||
spacing: 25,
|
spacing: 25,
|
||||||
children: List.generate(
|
children: List.generate(
|
||||||
LightsCubit.get(context).lightModes.length,
|
DevicesCubit.get(context).lightModes.length,
|
||||||
(index) => InkWell(
|
(index) => InkWell(
|
||||||
onTap: () => LightsCubit.get(context).setLightingMode(
|
// onTap: () => DevicesCubit.get(context).setLightingMode(
|
||||||
light, LightsCubit.get(context).lightModes[index]!),
|
// light, DevicesCubit.get(context).lightModes[index]!),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ class LightInterfaceRecentColor extends StatelessWidget {
|
|||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -31,19 +30,20 @@ class LightInterfaceRecentColor extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
...List.generate(
|
...List.generate(
|
||||||
light.recentColors.length > 4 ? 4 : light.recentColors.length,
|
// light.recentColors.length > 4 ? 4 : light.recentColors.length,
|
||||||
|
4,
|
||||||
(index) => InkWell(
|
(index) => InkWell(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
LightsCubit.get(context)
|
// DevicesCubit.get(context)
|
||||||
.setColor(light, light.recentColors[index]);
|
// .setColor(light, light.recentColors[index]);
|
||||||
},
|
// },
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(right: 10),
|
margin: const EdgeInsets.only(right: 10),
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
color: Color(light.recentColors[index]),
|
// color: Color(light.recentColors[index]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.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';
|
||||||
import 'package:syncrow_app/features/shared_widgets/united_text.dart';
|
import 'package:syncrow_app/features/shared_widgets/united_text.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
@ -13,7 +12,7 @@ class LightInterfaceSlider extends StatelessWidget {
|
|||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -29,7 +28,8 @@ class LightInterfaceSlider extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: UnitedText(
|
child: UnitedText(
|
||||||
value: light.brightness.toString(),
|
// value: light.brightness.toString(),
|
||||||
|
value: '100',
|
||||||
unit: "%",
|
unit: "%",
|
||||||
valueStyle: context.bodyMedium.copyWith(
|
valueStyle: context.bodyMedium.copyWith(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
@ -57,9 +57,11 @@ class LightInterfaceSlider extends StatelessWidget {
|
|||||||
trackHeight: 5,
|
trackHeight: 5,
|
||||||
),
|
),
|
||||||
child: Slider(
|
child: Slider(
|
||||||
value: light.brightness,
|
// value: light.brightness,
|
||||||
onChanged: (value) =>
|
value: 100,
|
||||||
LightsCubit.get(context).setBrightness(light, value),
|
onChanged: (value) {
|
||||||
|
// DevicesCubit.get(context).setBrightness(light, value);
|
||||||
|
},
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.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/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
@ -14,7 +13,7 @@ class LightInterfaceSwitch extends StatelessWidget {
|
|||||||
required this.light,
|
required this.light,
|
||||||
});
|
});
|
||||||
|
|
||||||
final LightModel light;
|
final DeviceModel light;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -52,7 +51,7 @@ class LightInterfaceSwitch extends StatelessWidget {
|
|||||||
iconSize: MaterialStateProperty.all(25),
|
iconSize: MaterialStateProperty.all(25),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
LightsCubit.get(context).toggleLight(light);
|
// DevicesCubit.get(context).toggleLight(light);
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.power_settings_new,
|
Icons.power_settings_new,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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/view/widgets/lights/light_brightness.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_brightness.dart';
|
||||||
|
|
||||||
import '../../../../shared_widgets/devices_default_switch.dart';
|
import '../../../../shared_widgets/devices_default_switch.dart';
|
||||||
import '../../../../shared_widgets/text_widgets/body_small.dart';
|
import '../../../../shared_widgets/text_widgets/body_small.dart';
|
||||||
import '../../../model/light_model.dart';
|
|
||||||
|
|
||||||
class LightsList extends StatelessWidget {
|
class LightsList extends StatelessWidget {
|
||||||
const LightsList({
|
const LightsList({
|
||||||
@ -12,7 +12,7 @@ class LightsList extends StatelessWidget {
|
|||||||
required this.lights,
|
required this.lights,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<LightModel> lights;
|
final List<DeviceModel> lights;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/view/widgets/ACs/category_view_app_bar.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view_list.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view_list.dart';
|
||||||
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import '../../../../../generated/assets.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
import '../../../../../utils/resource_manager/color_manager.dart';
|
|
||||||
import '../../../bloc/devices_cubit.dart';
|
|
||||||
import '../../../bloc/lights/lights_cubit.dart';
|
|
||||||
import '../../../model/light_model.dart';
|
|
||||||
import 'light_interface.dart';
|
|
||||||
|
|
||||||
class LightsView extends StatelessWidget {
|
class LightsView extends StatelessWidget {
|
||||||
const LightsView({super.key});
|
const LightsView({super.key});
|
||||||
@ -17,19 +15,20 @@ class LightsView extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => LightsCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
child: BlocBuilder<DevicesCubit, DevicesState>(
|
child: BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return BlocBuilder<LightsCubit, LightsState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
LightModel? selectedLight;
|
DeviceModel? selectedLight;
|
||||||
if (DevicesCubit.get(context).getSelectedDevice() is LightModel) {
|
if (DevicesCubit.get(context).getSelectedDevice()
|
||||||
selectedLight =
|
is DeviceModel) {
|
||||||
DevicesCubit.get(context).getSelectedDevice() as LightModel;
|
selectedLight = DevicesCubit.get(context).getSelectedDevice()
|
||||||
|
as DeviceModel;
|
||||||
}
|
}
|
||||||
List<LightModel> lights = [];
|
List<DeviceModel> lights = [];
|
||||||
for (var device in DevicesCubit.allCategories[1].devices) {
|
if (DevicesCubit.allCategories[1].devices != null) {
|
||||||
if (device is LightModel) {
|
for (var device in DevicesCubit.allCategories[1].devices!) {
|
||||||
lights.add(device);
|
lights.add(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_list.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_list.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
import '../../../../shared_widgets/text_widgets/body_small.dart';
|
import '../../../../shared_widgets/text_widgets/body_small.dart';
|
||||||
import '../../../bloc/devices_cubit.dart';
|
import '../../../bloc/devices_cubit.dart';
|
||||||
import '../../../model/light_model.dart';
|
|
||||||
import '../universal_switch.dart';
|
import '../universal_switch.dart';
|
||||||
|
|
||||||
class LightsViewList extends StatelessWidget {
|
class LightsViewList extends StatelessWidget {
|
||||||
@ -13,7 +13,7 @@ class LightsViewList extends StatelessWidget {
|
|||||||
required this.lights,
|
required this.lights,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<LightModel> lights;
|
final List<DeviceModel> lights;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.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/ACs/ac_interface.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/custom_switch.dart';
|
||||||
@ -38,7 +37,7 @@ class RoomPageSwitch extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
CustomPageRoute(
|
CustomPageRoute(
|
||||||
builder: (context) => AcInterface(acModel: device as ACModel),
|
builder: (context) => AcInterface(deviceModel: device),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class WizartSwitches extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
DevicesCubit.allCategories[index].icon,
|
DevicesCubit.allCategories[index].icon!,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
CustomSwitch(
|
CustomSwitch(
|
||||||
@ -63,7 +63,7 @@ class WizartSwitches extends StatelessWidget {
|
|||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: BodyLarge(
|
child: BodyLarge(
|
||||||
text: DevicesCubit.allCategories[index].name,
|
text: DevicesCubit.allCategories[index].name!,
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
height: 0,
|
height: 0,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.dart';
|
import 'package:syncrow_app/services/api/http_service.dart';
|
||||||
@ -15,4 +16,20 @@ class DevicesAPI {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<List<DevicesCategoryModel>> fetchGroups(int spaceId) async {
|
||||||
|
final response = await HTTPService().get(
|
||||||
|
path: ApiEndpoints.control,
|
||||||
|
queryParameters: {'homeId': spaceId, 'pageSize': 100, 'page': 1},
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
List<DevicesCategoryModel> categories = [];
|
||||||
|
for (var category in json['groups']) {
|
||||||
|
categories.add(DevicesCategoryModel.fromJson(category));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
print('fetchGroups response: $response');
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,10 @@ abstract class Constants {
|
|||||||
enum DeviceType {
|
enum DeviceType {
|
||||||
AC,
|
AC,
|
||||||
Lights,
|
Lights,
|
||||||
Door,
|
DoorLock,
|
||||||
Curtain,
|
Curtain,
|
||||||
ThreeGang,
|
ThreeGang,
|
||||||
Gateway,
|
Gateway,
|
||||||
|
Sensors,
|
||||||
|
Other,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user