mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
Switches updated
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtain_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/door_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/gateway_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/screens_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/screens/screens_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
import '../model/device_category_model.dart';
|
||||
import '../view/widgets/ac_view.dart';
|
||||
import '../view/widgets/lights_view.dart';
|
||||
import '../view/widgets/ACs/ac_view.dart';
|
||||
import '../view/widgets/lights/lights_view.dart';
|
||||
|
||||
part 'devices_state.dart';
|
||||
|
||||
|
@ -4,7 +4,7 @@ import 'package:gap/gap.dart';
|
||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
|
||||
import '../../../../generated/assets.dart';
|
||||
import '../../../../../generated/assets.dart';
|
||||
|
||||
class ACControlUnit extends StatefulWidget {
|
||||
const ACControlUnit({
|
@ -3,10 +3,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/a_c_control_unit.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/a_c_control_unit.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_a_c_switch.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_a_c_temp.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/devices_temp_widget.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/universal_a_c_switch.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/universal_a_c_temp.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../utils/resource_manager/color_manager.dart';
|
||||
import '../../../shared_widgets/text_widgets/body_medium.dart';
|
||||
import '../../bloc/ac_cubit.dart';
|
||||
import '../../../../../utils/resource_manager/color_manager.dart';
|
||||
import '../../../../shared_widgets/text_widgets/body_medium.dart';
|
||||
import '../../../bloc/ac_cubit.dart';
|
||||
|
||||
class UniversalACSwitch extends StatelessWidget {
|
||||
const UniversalACSwitch({
|
@ -3,10 +3,10 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/ac_cubit.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
import '../../../../generated/assets.dart';
|
||||
import '../../../../utils/resource_manager/color_manager.dart';
|
||||
import '../../../shared_widgets/default_container.dart';
|
||||
import '../../../shared_widgets/text_widgets/body_large.dart';
|
||||
import '../../../../../generated/assets.dart';
|
||||
import '../../../../../utils/resource_manager/color_manager.dart';
|
||||
import '../../../../shared_widgets/default_container.dart';
|
||||
import '../../../../shared_widgets/text_widgets/body_large.dart';
|
||||
|
||||
class UniversalACTemp extends StatelessWidget {
|
||||
const UniversalACTemp({
|
@ -4,6 +4,7 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/custom_switch.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/resource_manager/font_manager.dart';
|
||||
|
||||
import '../../bloc/devices_cubit.dart';
|
||||
|
||||
@ -31,39 +32,32 @@ class Switches extends StatelessWidget {
|
||||
return InkWell(
|
||||
onTap: () => DevicesCubit.get(context).updateCategory(index),
|
||||
child: DefaultContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
DevicesCubit.categories[index].icon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 30,
|
||||
height: 20,
|
||||
child: CustomSwitch(
|
||||
// value: DevicesCubit
|
||||
// .categories[index]
|
||||
// .switchValue,
|
||||
//
|
||||
// onChanged: (value) => DevicesCubit.get(context)
|
||||
// .changeSwitchValue( DevicesCubit
|
||||
// .categories[index]
|
||||
// .switchValue),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
BodyLarge(
|
||||
text: DevicesCubit.categories[index].name,
|
||||
fontWeight: FontWeight.bold,
|
||||
)
|
||||
],
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
DevicesCubit.categories[index].icon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
CustomSwitch(),
|
||||
],
|
||||
),
|
||||
BodyLarge(
|
||||
text: DevicesCubit.categories[index].name,
|
||||
fontWeight: FontsManager.bold,
|
||||
fontSize: 24,
|
||||
fontColor: const Color(0xFF848484),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -18,9 +18,11 @@ class MenuView extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
const ProfileTab(),
|
||||
...MenuCubit.of(context)
|
||||
.menuLists
|
||||
.map((list) => MenuList(listModel: list))
|
||||
...MenuCubit.of(context).menuLists.map(
|
||||
(list) => MenuList(
|
||||
listModel: list,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -22,20 +22,24 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
|
||||
bool value = false;
|
||||
|
||||
void onChange(bool customValue){
|
||||
value = customValue ;
|
||||
void onChange(bool customValue) {
|
||||
value = customValue;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animationController = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 100));
|
||||
vsync: this, duration: const Duration(milliseconds: 300));
|
||||
_circleAnimation = AlignmentTween(
|
||||
begin: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
end: value ? Alignment.centerLeft : Alignment.centerRight)
|
||||
.animate(CurvedAnimation(
|
||||
parent: _animationController!, curve: Curves.linear));
|
||||
begin: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
end: value ? Alignment.centerLeft : Alignment.centerRight,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController!,
|
||||
curve: Curves.linear,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -49,9 +53,7 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
_animationController!.isCompleted
|
||||
? _animationController!.reverse()
|
||||
: _animationController!.forward();
|
||||
value == false
|
||||
? onChange(true)
|
||||
: onChange(false);
|
||||
value ? onChange(false) : onChange(true);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
@ -60,20 +62,33 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
color: _circleAnimation!.value == Alignment.centerLeft
|
||||
? Colors.grey
|
||||
? Color(0xFFD9D9D9)
|
||||
: ColorsManager.primaryColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: Center(
|
||||
child: Container(
|
||||
alignment: value
|
||||
? Alignment.centerRight
|
||||
: Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle, color: Colors.white),
|
||||
width: 40.0,
|
||||
height: 23.0,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: Container(
|
||||
alignment:
|
||||
value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: _circleAnimation!.value == Alignment.centerLeft
|
||||
? Color(0xFFD9D9D9)
|
||||
: ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -12,6 +12,7 @@ class BodyLarge extends StatelessWidget {
|
||||
this.height,
|
||||
this.fontWeight,
|
||||
this.fontColor,
|
||||
this.fontSize,
|
||||
});
|
||||
|
||||
final String text;
|
||||
@ -25,6 +26,8 @@ class BodyLarge extends StatelessWidget {
|
||||
|
||||
final Color? fontColor;
|
||||
|
||||
final double? fontSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CustomText(
|
||||
text,
|
||||
@ -34,6 +37,7 @@ class BodyLarge extends StatelessWidget {
|
||||
height: height ?? 1.5,
|
||||
fontWeight: fontWeight,
|
||||
color: fontColor,
|
||||
fontSize: fontSize,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user