mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00

- Refactor device control logic in the app to improve readability and maintainability. - Add temperature modes (hot, cold, wind) and fan speeds (auto, low, middle, high) enums. - Update icon mappings and utility functions for temperature modes and fan speeds.
69 lines
2.2 KiB
Dart
69 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_app/features/devices/model/device_model.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/resource_manager/color_manager.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
|
|
|
import '../../../../shared_widgets/default_container.dart';
|
|
|
|
class LightInterfaceSwitch extends StatelessWidget {
|
|
const LightInterfaceSwitch({
|
|
super.key,
|
|
required this.light,
|
|
});
|
|
|
|
final DeviceModel light;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DefaultContainer(
|
|
boxConstraints: const BoxConstraints(
|
|
maxHeight: 65,
|
|
),
|
|
margin: const EdgeInsets.symmetric(vertical: 10),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
BodyLarge(
|
|
text: light.isOnline ?? false
|
|
? StringsManager.on
|
|
: StringsManager.off,
|
|
style:
|
|
context.bodyLarge.copyWith(color: Colors.grey, fontSize: 24),
|
|
),
|
|
Container(
|
|
width: 35,
|
|
decoration: ShapeDecoration(
|
|
color: light.isOnline ?? false
|
|
? ColorsManager.primaryColorWithOpacity
|
|
: Colors.grey,
|
|
shape: const CircleBorder(),
|
|
),
|
|
child: Center(
|
|
child: IconButton(
|
|
style: ButtonStyle(
|
|
padding: MaterialStateProperty.all(
|
|
const EdgeInsets.all(0),
|
|
),
|
|
iconSize: MaterialStateProperty.all(25),
|
|
),
|
|
onPressed: () {
|
|
// DevicesCubit.getInstance().toggleLight(light);
|
|
},
|
|
icon: const Icon(
|
|
Icons.power_settings_new,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|