mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
AC devices page implemented
AC Cubit Add New Devices Cubit Arch will be used Devices Cubit (for devices categories, and devices page) { AC cubit, Lights cubit. ... } Replaced AssetsManager with Assets Class (auto generated)
This commit is contained in:
@ -2,10 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class CustomSwitch extends StatefulWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
// final bool value;
|
||||
// final ValueChanged<bool> onChanged;
|
||||
|
||||
const CustomSwitch({super.key, required this.value, required this.onChanged});
|
||||
const CustomSwitch({
|
||||
super.key,
|
||||
// required this.value,
|
||||
// required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
_CustomSwitchState createState() => _CustomSwitchState();
|
||||
@ -16,14 +20,20 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
Animation? _circleAnimation;
|
||||
AnimationController? _animationController;
|
||||
|
||||
bool value = false;
|
||||
|
||||
void onChange(bool customValue){
|
||||
value = customValue ;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animationController = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 100));
|
||||
_circleAnimation = AlignmentTween(
|
||||
begin: widget.value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
end: widget.value ? Alignment.centerLeft : Alignment.centerRight)
|
||||
begin: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
end: value ? Alignment.centerLeft : Alignment.centerRight)
|
||||
.animate(CurvedAnimation(
|
||||
parent: _animationController!, curve: Curves.linear));
|
||||
}
|
||||
@ -35,12 +45,14 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
builder: (context, child) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_animationController!.isCompleted
|
||||
? _animationController!.reverse()
|
||||
: _animationController!.forward();
|
||||
widget.value == false
|
||||
? widget.onChanged(true)
|
||||
: widget.onChanged(false);
|
||||
setState(() {
|
||||
_animationController!.isCompleted
|
||||
? _animationController!.reverse()
|
||||
: _animationController!.forward();
|
||||
value == false
|
||||
? onChange(true)
|
||||
: onChange(false);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
width: 45.0,
|
||||
@ -54,13 +66,9 @@ class _CustomSwitchState extends State<CustomSwitch>
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: Container(
|
||||
alignment: widget.value
|
||||
? ((Directionality.of(context) == TextDirection.rtl)
|
||||
alignment: value
|
||||
? Alignment.centerRight
|
||||
: Alignment.centerLeft)
|
||||
: ((Directionality.of(context) == TextDirection.rtl)
|
||||
? Alignment.centerLeft
|
||||
: Alignment.centerRight),
|
||||
: Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: 20.0,
|
||||
height: 20.0,
|
||||
|
@ -4,13 +4,19 @@ class DefaultContainer extends StatelessWidget {
|
||||
const DefaultContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.height,
|
||||
this.width,
|
||||
});
|
||||
|
||||
final double? height;
|
||||
final double? width;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: height,
|
||||
width: width,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
83
lib/features/shared_widgets/devices_default_switch.dart
Normal file
83
lib/features/shared_widgets/devices_default_switch.dart
Normal file
@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DevicesDefaultSwitch extends StatefulWidget {
|
||||
const DevicesDefaultSwitch({
|
||||
super.key,
|
||||
required this.model,
|
||||
});
|
||||
|
||||
final ACModel model;
|
||||
|
||||
@override
|
||||
State<DevicesDefaultSwitch> createState() => _DevicesDefaultSwitchState();
|
||||
}
|
||||
|
||||
class _DevicesDefaultSwitchState extends State<DevicesDefaultSwitch> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
// isOn = !isOn;
|
||||
widget.model.status = !widget.model.status;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.model.status
|
||||
? ColorsManager.primaryColor
|
||||
: Colors.white,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
bottomLeft: Radius.circular(15),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: "ON",
|
||||
fontColor: widget.model.status ? Colors.white : null,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.model.status = !widget.model.status;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.model.status
|
||||
? Colors.white
|
||||
: ColorsManager.primaryColor,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(15),
|
||||
bottomRight: Radius.circular(15),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: "OFF",
|
||||
fontColor: widget.model.status ? null : Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/assets_manager.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
class SyncrowLogo extends StatelessWidget {
|
||||
const SyncrowLogo({
|
||||
@ -14,7 +14,7 @@ class SyncrowLogo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Image.asset(isDark ? ImageManager.blackLogo : ImageManager.whiteLogo,
|
||||
return Image.asset(isDark ? Assets.imagesBlackLogo : Assets.imagesWhiteLogo,
|
||||
scale: 1, width: width);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class BodyLarge extends StatelessWidget {
|
||||
this.style,
|
||||
this.height,
|
||||
this.fontWeight,
|
||||
this.fontColor,
|
||||
});
|
||||
|
||||
final String text;
|
||||
@ -22,11 +23,17 @@ class BodyLarge extends StatelessWidget {
|
||||
|
||||
final FontWeight? fontWeight;
|
||||
|
||||
final Color? fontColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CustomText(
|
||||
text,
|
||||
style: style ?? context.bodyLarge.copyWith(height: height ?? 1.5),
|
||||
textAlign: textAlign,
|
||||
fontWeight: fontWeight,
|
||||
style: style ??
|
||||
context.bodyLarge.copyWith(
|
||||
height: height ?? 1.5,
|
||||
fontWeight: fontWeight,
|
||||
color: fontColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class CustomText extends StatelessWidget {
|
||||
const CustomText(this.text,
|
||||
@ -31,10 +30,7 @@ class CustomText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SelectableText(
|
||||
text,
|
||||
style: style!.copyWith(
|
||||
fontSize: fontSize,
|
||||
color: fontColor ?? ColorsManager.textPrimaryColor,
|
||||
fontWeight: fontWeight),
|
||||
style: style,
|
||||
textAlign: textAlign,
|
||||
onTap: onTap,
|
||||
minLines: minLines,
|
||||
|
Reference in New Issue
Block a user