mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
100 lines
2.5 KiB
Dart
100 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/assets_manager.dart';
|
|
|
|
import '../model/device_category_model.dart';
|
|
|
|
part 'devices_state.dart';
|
|
|
|
class DevicesCubit extends Cubit<DevicesState> {
|
|
DevicesCubit() : super(DevicesInitial()) {
|
|
getCategories();
|
|
}
|
|
|
|
bool ACSwitchValue = false;
|
|
bool lightsSwitchValue = false;
|
|
bool doorSwitchValue = false;
|
|
bool curtainSwitchValue = false;
|
|
bool screensSwitchValue = false;
|
|
bool gatewaySwitchValue = false;
|
|
|
|
void changeSwitchValue(DeviceType device) {
|
|
switch (device) {
|
|
case DeviceType.AC:
|
|
ACSwitchValue = !ACSwitchValue;
|
|
break;
|
|
case DeviceType.Lights:
|
|
lightsSwitchValue = !lightsSwitchValue;
|
|
break;
|
|
case DeviceType.Door:
|
|
doorSwitchValue = !doorSwitchValue;
|
|
break;
|
|
case DeviceType.Curtain:
|
|
curtainSwitchValue = !curtainSwitchValue;
|
|
break;
|
|
case DeviceType.Screens:
|
|
screensSwitchValue = !screensSwitchValue;
|
|
break;
|
|
case DeviceType.Gateway:
|
|
gatewaySwitchValue = !gatewaySwitchValue;
|
|
break;
|
|
}
|
|
emit(DevicesSuccess());
|
|
}
|
|
|
|
static DevicesCubit get(context) => BlocProvider.of(context);
|
|
|
|
var categories = <DevicesCategoryModel>[];
|
|
|
|
Future<List<DevicesCategoryModel>> getCategories() async {
|
|
emit(DevicesLoading());
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
emit(DevicesSuccess());
|
|
|
|
return categories = [
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.ac,
|
|
name: 'ACs',
|
|
switchValue: false,
|
|
type: DeviceType.AC,
|
|
),
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.light,
|
|
name: 'Lights',
|
|
switchValue: false,
|
|
type: DeviceType.Lights,
|
|
),
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.doorLock,
|
|
name: 'Doors',
|
|
switchValue: false,
|
|
type: DeviceType.Door,
|
|
),
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.curtain,
|
|
name: 'Curtains',
|
|
switchValue: false,
|
|
type: DeviceType.Curtain,
|
|
),
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.screen,
|
|
name: 'Screens',
|
|
switchValue: false,
|
|
type: DeviceType.Screens,
|
|
),
|
|
DevicesCategoryModel(
|
|
devices: [],
|
|
icon: IconsManager.gateway,
|
|
name: 'Gateway',
|
|
switchValue: false,
|
|
type: DeviceType.Gateway,
|
|
),
|
|
];
|
|
}
|
|
}
|