This commit is contained in:
Mohammad Salameh
2024-03-17 09:38:26 +03:00
parent 8ac164f0c5
commit 65cbf10485
38 changed files with 686 additions and 901 deletions
@@ -1,6 +1,6 @@
import 'package:flutter/material.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_temp_unit.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';
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
Widget build(BuildContext context) {
@@ -30,7 +30,7 @@ class AcInterface extends StatelessWidget {
backgroundColor: Colors.transparent,
centerTitle: true,
title: BodyLarge(
text: acModel.name ?? "",
text: deviceModel.name ?? "",
fontColor: ColorsManager.primaryColor,
fontWeight: FontsManager.bold,
),
@@ -62,7 +62,7 @@ class AcInterface extends StatelessWidget {
maxHeight: 380,
),
child: AcInterfaceTempUnit(
acModel: acModel,
deviceModel: deviceModel,
),
),
const SizedBox(
@@ -73,7 +73,7 @@ class AcInterface extends StatelessWidget {
maxHeight: 120,
),
child: AcInterfaceControls(
acModel: acModel,
deviceModel: deviceModel,
),
),
],
@@ -1,6 +1,6 @@
import 'package:flutter/material.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/shared_widgets/default_container.dart';
@@ -9,16 +9,16 @@ import '../../../../../generated/assets.dart';
class AcInterfaceControls extends StatelessWidget {
const AcInterfaceControls({
super.key,
required this.acModel,
required this.deviceModel,
});
final ACModel acModel;
final DeviceModel deviceModel;
@override
Widget build(BuildContext context) {
return Column(
children: [
ACModeControlUnit(model: acModel),
ACModeControlUnit(model: deviceModel),
const SizedBox(height: 10),
Row(
children: [
@@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.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/text_widgets/body_large.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/font_manager.dart';
import '../../../model/ac_model.dart';
class AcInterfaceTempUnit extends StatelessWidget {
const AcInterfaceTempUnit({
super.key,
required this.acModel,
required this.deviceModel,
});
final ACModel acModel;
final DeviceModel deviceModel;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => AcCubit(),
child: BlocBuilder<AcCubit, AcState>(
create: (context) => DevicesCubit(),
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return DefaultContainer(
child: Column(
@@ -55,7 +54,8 @@ class AcInterfaceTempUnit extends StatelessWidget {
fontWeight: FontsManager.regular,
),
modifier: (double value) {
return '${acModel.temperature.toStringAsFixed(1)}°C';
// return '${DeviceModel.temperature.toStringAsFixed(1)}°C';
return '${value.toStringAsFixed(1)}°C';
},
mainLabelStyle: context.titleLarge.copyWith(
height: 0,
@@ -72,15 +72,16 @@ class AcInterfaceTempUnit extends StatelessWidget {
),
),
),
min: acModel.bounds.min,
max: acModel.bounds.max,
initialValue: acModel.temperature,
// min: DeviceModel.bounds.min,
// max: DeviceModel.bounds.max,
// initialValue: DeviceModel.temperature,
onChange: (value) {
String valueAsString = value.toStringAsFixed(1);
if (valueAsString.endsWith(".0") ||
valueAsString.endsWith(".5")) {
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,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setACTemp(acModel, acModel.coolTo);
acModel.coolTo -= .5;
// DevicesCubit.get(context)
// .setACTemp(DeviceModel, DeviceModel.coolTo);
// DeviceModel.coolTo -= .5;
},
child: SvgPicture.asset(
Assets.iconsMinus,
@@ -107,7 +108,8 @@ class AcInterfaceTempUnit extends StatelessWidget {
Column(
children: [
BodyLarge(
text: "${acModel.coolTo}° C",
// text: "${DeviceModel.coolTo}° C",
text: '24° C',
style: context.bodyLarge.copyWith(
color:
ColorsManager.primaryColor.withOpacity(0.6),
@@ -125,9 +127,9 @@ class AcInterfaceTempUnit extends StatelessWidget {
dimension: 24,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setACTemp(acModel, acModel.coolTo);
acModel.coolTo += .5;
// DevicesCubit.get(context)
// .setACTemp(DeviceModel, DeviceModel.coolTo);
// DeviceModel.coolTo += .5;
},
child: SvgPicture.asset(
Assets.iconsPlus,
@@ -1,6 +1,5 @@
import 'package:flutter/material.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/shared_widgets/default_container.dart';
import '../../../../../generated/assets.dart';
@@ -11,7 +10,7 @@ class ACModeControlUnit extends StatefulWidget {
required this.model,
});
final ACModel model;
final DeviceModel model;
@override
State<ACModeControlUnit> createState() => _ACModeControlUnitState();
@@ -40,15 +39,15 @@ class _ACModeControlUnitState extends State<ACModeControlUnit> {
child: InkWell(
onTap: () {
setState(() {
widget.model.fanSpeed =
widget.model.fanSpeed == 3 ? 0 : widget.model.fanSpeed + 1;
// widget.model.fanSpeed =
// widget.model.fanSpeed == 3 ? 0 : widget.model.fanSpeed + 1;
});
},
child: DefaultContainer(
height: 55,
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(
onTap: () {
setState(() {
widget.model.tempMode =
widget.model.tempMode == 2 ? 0 : widget.model.tempMode + 1;
// widget.model.tempMode =
// widget.model.tempMode == 2 ? 0 : widget.model.tempMode + 1;
});
},
child: DefaultContainer(
child: const DefaultContainer(
height: 55,
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_bloc/flutter_bloc.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/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../../../../../generated/assets.dart';
import '../../../model/ac_model.dart';
class ACTempWidget extends StatelessWidget {
const ACTempWidget(
this.acModel, {
this.deviceModel, {
super.key,
});
final ACModel acModel;
final DeviceModel deviceModel;
@override
Widget build(BuildContext context) {
return BlocBuilder<AcCubit, AcState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return DefaultContainer(
height: 60,
@@ -30,8 +31,8 @@ class ACTempWidget extends StatelessWidget {
dimension: 24,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setACTemp(acModel, acModel.temperature - 0.5);
// DevicesCubit.get(context)
// .setACTemp(DeviceModel, DeviceModel.temperature - 0.5);
},
child: SvgPicture.asset(
Assets.iconsMinus,
@@ -39,7 +40,8 @@ class ACTempWidget extends StatelessWidget {
),
),
BodyLarge(
text: "${acModel.temperature}° C",
// text: "${DeviceModel.temperature}° C",
text: '25 °C',
style: context.bodyLarge.copyWith(
color: ColorsManager.primaryColor.withOpacity(0.6),
fontSize: 23,
@@ -49,8 +51,8 @@ class ACTempWidget extends StatelessWidget {
dimension: 24,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setACTemp(acModel, acModel.temperature + 0.5);
// DevicesCubit.get(context)
// .setACTemp(DeviceModel, DeviceModel.temperature + 0.5);
},
child: SvgPicture.asset(
Assets.iconsPlus,
@@ -1,7 +1,7 @@
import 'package:flutter/material.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/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_temp_widget.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/text_widgets/body_small.dart';
import '../../../model/ac_model.dart';
class ACsList extends StatelessWidget {
const ACsList({
super.key,
@@ -29,7 +27,7 @@ class ACsList extends StatelessWidget {
const BodySmall(text: "All ACs"),
const SizedBox(height: 5),
UniversalSwitch(
category: AcCubit.category,
category: DevicesCubit.get(context).chosenCategory!,
),
const SizedBox(height: 10),
const UniversalACTemp(),
@@ -40,9 +38,12 @@ class ACsList extends StatelessWidget {
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0),
itemCount: AcCubit.category.devices.length,
itemCount:
DevicesCubit.get(context).chosenCategory!.devices!.length,
itemBuilder: (context, index) {
ACModel ac = AcCubit.category.devices[index] as ACModel;
DeviceModel ac = DevicesCubit.get(context)
.chosenCategory!
.devices![index] as DeviceModel;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -51,7 +52,11 @@ class ACsList extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
BodySmall(
text: AcCubit.category.devices[index].name ?? ""),
text: DevicesCubit.get(context)
.chosenCategory!
.devices![index]
.name ??
""),
IconButton(
onPressed: () {
DevicesCubit.get(context).selectDevice(ac);
@@ -70,19 +75,17 @@ class ACsList extends StatelessWidget {
],
),
const SizedBox(height: 5),
if (AcCubit.category.devices[index] is ACModel)
DevicesDefaultSwitch(
model: ac,
),
DevicesDefaultSwitch(
model: ac,
),
const SizedBox(height: 10),
ACTempWidget(
ac,
),
const SizedBox(height: 10),
if (AcCubit.category.devices[index] is ACModel)
ACModeControlUnit(
model: ac,
),
ACModeControlUnit(
model: ac,
),
const SizedBox(height: 10),
],
);
@@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.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/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/acs_list.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
@@ -18,15 +17,16 @@ class ACsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => AcCubit(),
create: (context) => DevicesCubit(),
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return BlocBuilder<AcCubit, AcState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
ACModel? selectedAC;
if (DevicesCubit.get(context).getSelectedDevice() is ACModel) {
selectedAC =
DevicesCubit.get(context).getSelectedDevice() as ACModel;
DeviceModel? selectedAC;
if (DevicesCubit.get(context).getSelectedDevice()
is DeviceModel) {
selectedAC = DevicesCubit.get(context).getSelectedDevice()
as DeviceModel;
}
return AnnotatedRegion(
value: SystemUiOverlayStyle(
@@ -59,7 +59,7 @@ class ACsView extends StatelessWidget {
),
child: SizedBox.expand(
child: selectedAC != null
? AcInterface(acModel: selectedAC)
? AcInterface(deviceModel: selectedAC)
: const ACsList(),
),
),
@@ -20,7 +20,7 @@ class CategoryViewAppBar extends StatelessWidget
toolbarHeight: Constants.appBarHeight,
centerTitle: true,
title: DisplayMedium(
text: DevicesCubit.get(context).chosenCategory!.name,
text: DevicesCubit.get(context).chosenCategory!.name!,
style: context.displayMedium.copyWith(
color: ColorsManager.primaryColor,
fontWeight: FontWeight.bold,
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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 '../../../../../generated/assets.dart';
@@ -16,7 +16,7 @@ class UniversalACTemp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<AcCubit, AcState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return DefaultContainer(
height: 60,
@@ -27,8 +27,8 @@ class UniversalACTemp extends StatelessWidget {
dimension: 24,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setTempToAll(AcCubit.universalACTemp - .5);
// DevicesCubit.get(context)
// .setTempToAll(DevicesCubit.universalACTemp - .5);
},
child: SvgPicture.asset(
Assets.iconsMinus,
@@ -36,7 +36,8 @@ class UniversalACTemp extends StatelessWidget {
),
),
BodyLarge(
text: "${AcCubit.universalACTemp}° C",
// text: "${DevicesCubit.universalACTemp}° C",
text: '25 °C',
style: context.bodyLarge.copyWith(
color: ColorsManager.primaryColor.withOpacity(0.6),
fontSize: 23,
@@ -46,8 +47,8 @@ class UniversalACTemp extends StatelessWidget {
dimension: 24,
child: InkWell(
onTap: () {
AcCubit.get(context)
.setTempToAll(AcCubit.universalACTemp + .5);
// DevicesCubit.get(context)
// .setTempToAll(DevicesCubit.universalACTemp + .5);
},
child: SvgPicture.asset(
Assets.iconsPlus,
@@ -1,8 +1,7 @@
import 'package:flutter/material.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/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/shared_widgets/devices_default_switch.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 SizedBox(height: 5),
UniversalSwitch(
category: CurtainsCubit.category,
category: DevicesCubit.get(context).chosenCategory!,
),
// other ACs controls
@@ -34,22 +33,25 @@ class CurtainList extends StatelessWidget {
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0),
itemCount: CurtainsCubit.category.devices.length,
itemCount:
DevicesCubit.get(context).chosenCategory!.devices!.length,
itemBuilder: (context, index) {
CurtainModel curtain =
CurtainsCubit.category.devices[index] as CurtainModel;
DeviceModel curtain =
DevicesCubit.get(context).chosenCategory!.devices![index];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 20),
BodySmall(
text:
CurtainsCubit.category.devices[index].name ?? ""),
text: DevicesCubit.get(context)
.chosenCategory!
.devices![index]
.name ??
""),
const SizedBox(height: 5),
if (CurtainsCubit.category.devices[index] is CurtainModel)
DevicesDefaultSwitch(
model: curtain,
),
DevicesDefaultSwitch(
model: curtain,
),
],
);
},
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.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/view/widgets/ACs/category_view_app_bar.dart';
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_list.dart';
@@ -15,47 +14,43 @@ class CurtainView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => CurtainsCubit(),
create: (context) => DevicesCubit(),
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return BlocBuilder<CurtainsCubit, CurtainsState>(
builder: (context, state) {
return AnnotatedRegion(
value: SystemUiOverlayStyle(
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light,
),
child: SafeArea(
child: Scaffold(
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: const CategoryViewAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
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(),
return AnnotatedRegion(
value: SystemUiOverlayStyle(
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
statusBarIconBrightness: Brightness.light,
),
child: SafeArea(
child: Scaffold(
backgroundColor: ColorsManager.backgroundColor,
extendBodyBehindAppBar: true,
extendBody: true,
appBar: const CategoryViewAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
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(),
),
),
);
},
),
),
);
},
),
@@ -1,29 +1,28 @@
import 'package:flutter/material.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/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import '../../../model/light_model.dart';
class LightBrightness extends StatelessWidget {
const LightBrightness({
super.key,
required this.light,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
return BlocBuilder<LightsCubit, LightsState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return GestureDetector(
onHorizontalDragUpdate: (details) => LightsCubit.get(context)
.onHorizontalDragUpdate(light, details.localPosition.dx,
MediaQuery.of(context).size.width - 15),
// onHorizontalDragUpdate: (details) => DevicesCubit().get(context)
// .onHorizontalDragUpdate(light, details.localPosition.dx,
// MediaQuery.of(context).size.width - 15),
child: Stack(
alignment: Alignment.center,
children: [
@@ -36,22 +35,24 @@ class LightBrightness extends StatelessWidget {
duration: const Duration(milliseconds: 0),
child: Container(
height: 60,
width: (MediaQuery.of(context).size.width - 30) *
light.brightness /
100,
// width: (MediaQuery.of(context).size.width - 30) *
// light.brightness /
// 100,
decoration: BoxDecoration(
color: ColorsManager.primaryColor.withOpacity(0.6),
borderRadius: light.brightness != 100
? const BorderRadius.only(
topLeft: Radius.circular(20),
bottomLeft: Radius.circular(20),
)
: BorderRadius.circular(20),
),
color: ColorsManager.primaryColor.withOpacity(0.6),
borderRadius:
// light.brightness != 100 ?
const BorderRadius.only(
topLeft: Radius.circular(20),
bottomLeft: Radius.circular(20),
)
// : BorderRadius.circular(20),
),
),
),
BodyLarge(
text: "${light.brightness}%",
// text: "${light.brightness}%",
text: '100%',
style: context.bodyLarge.copyWith(
color: Colors.black,
fontSize: 23,
@@ -1,7 +1,7 @@
import 'package:flutter/material.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/model/light_model.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_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_timer.dart';
@@ -9,11 +9,11 @@ import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface
class LightInterface extends StatelessWidget {
const LightInterface({super.key, required this.light});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
return BlocBuilder<LightsCubit, LightsState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return Padding(
padding: const EdgeInsets.only(top: 70, right: 20, left: 20),
@@ -1,5 +1,5 @@
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_recent_color.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,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/bloc/lights/lights_cubit.dart';
import 'package:syncrow_app/features/devices/model/light_model.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/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -12,7 +12,7 @@ class LightInterfaceModes extends StatelessWidget {
required this.light,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
@@ -27,10 +27,10 @@ class LightInterfaceModes extends StatelessWidget {
Wrap(
spacing: 25,
children: List.generate(
LightsCubit.get(context).lightModes.length,
DevicesCubit.get(context).lightModes.length,
(index) => InkWell(
onTap: () => LightsCubit.get(context).setLightingMode(
light, LightsCubit.get(context).lightModes[index]!),
// onTap: () => DevicesCubit.get(context).setLightingMode(
// light, DevicesCubit.get(context).lightModes[index]!),
child: Column(
children: [
Container(
@@ -1,7 +1,6 @@
import 'package:flutter/material.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/light_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -15,7 +14,7 @@ class LightInterfaceRecentColor extends StatelessWidget {
required this.light,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
@@ -31,19 +30,20 @@ class LightInterfaceRecentColor extends StatelessWidget {
child: Row(
children: [
...List.generate(
light.recentColors.length > 4 ? 4 : light.recentColors.length,
// light.recentColors.length > 4 ? 4 : light.recentColors.length,
4,
(index) => InkWell(
onTap: () {
LightsCubit.get(context)
.setColor(light, light.recentColors[index]);
},
// onTap: () {
// DevicesCubit.get(context)
// .setColor(light, light.recentColors[index]);
// },
child: Container(
margin: const EdgeInsets.only(right: 10),
width: 40,
height: 40,
decoration: ShapeDecoration(
shape: const CircleBorder(),
color: Color(light.recentColors[index]),
// color: Color(light.recentColors[index]),
),
),
),
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/bloc/lights/lights_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/united_text.dart';
import 'package:syncrow_app/utils/context_extension.dart';
@@ -13,7 +12,7 @@ class LightInterfaceSlider extends StatelessWidget {
required this.light,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
@@ -29,7 +28,8 @@ class LightInterfaceSlider extends StatelessWidget {
children: [
Expanded(
child: UnitedText(
value: light.brightness.toString(),
// value: light.brightness.toString(),
value: '100',
unit: "%",
valueStyle: context.bodyMedium.copyWith(
color: Colors.grey,
@@ -57,9 +57,11 @@ class LightInterfaceSlider extends StatelessWidget {
trackHeight: 5,
),
child: Slider(
value: light.brightness,
onChanged: (value) =>
LightsCubit.get(context).setBrightness(light, value),
// value: light.brightness,
value: 100,
onChanged: (value) {
// DevicesCubit.get(context).setBrightness(light, value);
},
min: 0,
max: 100,
),
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/bloc/lights/lights_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_large.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
@@ -14,7 +13,7 @@ class LightInterfaceSwitch extends StatelessWidget {
required this.light,
});
final LightModel light;
final DeviceModel light;
@override
Widget build(BuildContext context) {
@@ -52,7 +51,7 @@ class LightInterfaceSwitch extends StatelessWidget {
iconSize: MaterialStateProperty.all(25),
),
onPressed: () {
LightsCubit.get(context).toggleLight(light);
// DevicesCubit.get(context).toggleLight(light);
},
icon: const Icon(
Icons.power_settings_new,
@@ -1,10 +1,10 @@
import 'package:flutter/material.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 '../../../../shared_widgets/devices_default_switch.dart';
import '../../../../shared_widgets/text_widgets/body_small.dart';
import '../../../model/light_model.dart';
class LightsList extends StatelessWidget {
const LightsList({
@@ -12,7 +12,7 @@ class LightsList extends StatelessWidget {
required this.lights,
});
final List<LightModel> lights;
final List<DeviceModel> lights;
@override
Widget build(BuildContext context) {
@@ -1,15 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.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/lights/light_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view_list.dart';
import '../../../../../generated/assets.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';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class LightsView extends StatelessWidget {
const LightsView({super.key});
@@ -17,19 +15,20 @@ class LightsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => LightsCubit(),
create: (context) => DevicesCubit(),
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return BlocBuilder<LightsCubit, LightsState>(
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
LightModel? selectedLight;
if (DevicesCubit.get(context).getSelectedDevice() is LightModel) {
selectedLight =
DevicesCubit.get(context).getSelectedDevice() as LightModel;
DeviceModel? selectedLight;
if (DevicesCubit.get(context).getSelectedDevice()
is DeviceModel) {
selectedLight = DevicesCubit.get(context).getSelectedDevice()
as DeviceModel;
}
List<LightModel> lights = [];
for (var device in DevicesCubit.allCategories[1].devices) {
if (device is LightModel) {
List<DeviceModel> lights = [];
if (DevicesCubit.allCategories[1].devices != null) {
for (var device in DevicesCubit.allCategories[1].devices!) {
lights.add(device);
}
}
@@ -1,10 +1,10 @@
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/utils/resource_manager/constants.dart';
import '../../../../shared_widgets/text_widgets/body_small.dart';
import '../../../bloc/devices_cubit.dart';
import '../../../model/light_model.dart';
import '../universal_switch.dart';
class LightsViewList extends StatelessWidget {
@@ -13,7 +13,7 @@ class LightsViewList extends StatelessWidget {
required this.lights,
});
final List<LightModel> lights;
final List<DeviceModel> lights;
@override
Widget build(BuildContext context) {
@@ -1,6 +1,5 @@
import 'package:flutter/material.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_interface.dart';
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
@@ -38,7 +37,7 @@ class RoomPageSwitch extends StatelessWidget {
Navigator.push(
context,
CustomPageRoute(
builder: (context) => AcInterface(acModel: device as ACModel),
builder: (context) => AcInterface(deviceModel: device),
),
);
}
@@ -51,7 +51,7 @@ class WizartSwitches extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
DevicesCubit.allCategories[index].icon,
DevicesCubit.allCategories[index].icon!,
fit: BoxFit.contain,
),
CustomSwitch(
@@ -63,7 +63,7 @@ class WizartSwitches extends StatelessWidget {
child: FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: DevicesCubit.allCategories[index].name,
text: DevicesCubit.allCategories[index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,