mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 18:47:56 +00:00
Update device icons and refactor AC interface widget
- Update device icons to match new design requirements - Refactor AC interface widget to use a more descriptive variable name - Implement temperature control functionality in AC interface widget
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_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/generated/assets.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/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class DeviceModel {
|
|||||||
} else if (type == DeviceType.Curtain) {
|
} else if (type == DeviceType.Curtain) {
|
||||||
icon = Assets.iconsCurtain;
|
icon = Assets.iconsCurtain;
|
||||||
} else if (type == DeviceType.ThreeGang) {
|
} else if (type == DeviceType.ThreeGang) {
|
||||||
icon = Assets.iconsLight;
|
icon = Assets.icons3GangSwitch;
|
||||||
} else if (type == DeviceType.Gateway) {
|
} else if (type == DeviceType.Gateway) {
|
||||||
icon = Assets.iconsGateway;
|
icon = Assets.iconsGateway;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class AcInterface extends StatelessWidget {
|
|||||||
maxHeight: 380,
|
maxHeight: 380,
|
||||||
),
|
),
|
||||||
child: AcInterfaceTempUnit(
|
child: AcInterfaceTempUnit(
|
||||||
deviceModel: deviceModel,
|
acDevice: deviceModel,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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/devices_cubit.dart';
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.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/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';
|
||||||
@@ -10,20 +11,25 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar
|
|||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.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 '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 AcInterfaceTempUnit extends StatelessWidget {
|
class AcInterfaceTempUnit extends StatelessWidget {
|
||||||
const AcInterfaceTempUnit({
|
const AcInterfaceTempUnit({
|
||||||
super.key,
|
super.key,
|
||||||
required this.deviceModel,
|
required this.acDevice,
|
||||||
});
|
});
|
||||||
|
|
||||||
final DeviceModel deviceModel;
|
final DeviceModel acDevice;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<DevicesCubit, DevicesState>(
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
double setToTemp = acDevice.status
|
||||||
|
.firstWhere((element) => element.code == 'temp_set')
|
||||||
|
.value /
|
||||||
|
10;
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -72,7 +78,7 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
// min: DeviceModel.bounds.min,
|
// min: DeviceModel.bounds.min,
|
||||||
// max: DeviceModel.bounds.max,
|
// max: DeviceModel.bounds.max,
|
||||||
initialValue: deviceModel.status
|
initialValue: acDevice.status
|
||||||
.firstWhere(
|
.firstWhere(
|
||||||
(element) => element.code == 'temp_current')
|
(element) => element.code == 'temp_current')
|
||||||
.value /
|
.value /
|
||||||
@@ -98,9 +104,14 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
dimension: 24,
|
dimension: 24,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// DevicesCubit.getInstance()
|
if (setToTemp > 20) {
|
||||||
// .setACTemp(DeviceModel, DeviceModel.coolTo);
|
DevicesCubit.getInstance().deviceControl(
|
||||||
// DeviceModel.coolTo -= .5;
|
DeviceControlModel(
|
||||||
|
deviceId: acDevice.id,
|
||||||
|
code: 'temp_set',
|
||||||
|
value: (setToTemp - 0.5) * 10),
|
||||||
|
acDevice.id!);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsMinus,
|
Assets.iconsMinus,
|
||||||
@@ -111,8 +122,7 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
BodyLarge(
|
BodyLarge(
|
||||||
// text: "${DeviceModel.coolTo}° C",
|
// text: "${DeviceModel.coolTo}° C",
|
||||||
text:
|
text: '$setToTemp° C',
|
||||||
'${deviceModel.status.firstWhere((element) => element.code == 'temp_set').value / 10}° C',
|
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
color:
|
color:
|
||||||
ColorsManager.primaryColor.withOpacity(0.6),
|
ColorsManager.primaryColor.withOpacity(0.6),
|
||||||
@@ -133,6 +143,15 @@ class AcInterfaceTempUnit extends StatelessWidget {
|
|||||||
// DevicesCubit.getInstance()
|
// DevicesCubit.getInstance()
|
||||||
// .setACTemp(DeviceModel, DeviceModel.coolTo);
|
// .setACTemp(DeviceModel, DeviceModel.coolTo);
|
||||||
// DeviceModel.coolTo += .5;
|
// DeviceModel.coolTo += .5;
|
||||||
|
|
||||||
|
if (setToTemp < 30) {
|
||||||
|
DevicesCubit.getInstance().deviceControl(
|
||||||
|
DeviceControlModel(
|
||||||
|
deviceId: acDevice.id,
|
||||||
|
code: 'temp_set',
|
||||||
|
value: (setToTemp + 0.5) * 10),
|
||||||
|
acDevice.id!);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
Assets.iconsPlus,
|
Assets.iconsPlus,
|
||||||
|
|||||||
Reference in New Issue
Block a user