mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 11:04:55 +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,
|
||||
|
||||
Reference in New Issue
Block a user