initialized Devices Page

This commit is contained in:
Mohammad Salameh
2024-02-20 16:01:50 +03:00
parent d27063f149
commit cdfb778884
22 changed files with 551 additions and 18 deletions

View File

@ -0,0 +1,77 @@
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;
const CustomSwitch({super.key, required this.value, required this.onChanged});
@override
_CustomSwitchState createState() => _CustomSwitchState();
}
class _CustomSwitchState extends State<CustomSwitch>
with SingleTickerProviderStateMixin {
Animation? _circleAnimation;
AnimationController? _animationController;
@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)
.animate(CurvedAnimation(
parent: _animationController!, curve: Curves.linear));
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _animationController!,
builder: (context, child) {
return GestureDetector(
onTap: () {
_animationController!.isCompleted
? _animationController!.reverse()
: _animationController!.forward();
widget.value == false
? widget.onChanged(true)
: widget.onChanged(false);
},
child: Container(
width: 45.0,
height: 28.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24.0),
color: _circleAnimation!.value == Alignment.centerLeft
? Colors.grey
: ColorsManager.primaryColor,
),
child: Padding(
padding: const EdgeInsets.all(2.0),
child: Container(
alignment: widget.value
? ((Directionality.of(context) == TextDirection.rtl)
? Alignment.centerRight
: Alignment.centerLeft)
: ((Directionality.of(context) == TextDirection.rtl)
? Alignment.centerLeft
: Alignment.centerRight),
child: Container(
width: 20.0,
height: 20.0,
decoration: const BoxDecoration(
shape: BoxShape.circle, color: Colors.white),
),
),
),
),
);
},
);
}
}

View File

@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
class DefaultContainer extends StatelessWidget {
const DefaultContainer({
super.key,
required this.child,
});
final Widget child;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.all(10),
child: child,
);
}
}

View File

@ -10,6 +10,7 @@ class BodyLarge extends StatelessWidget {
this.textAlign,
this.style,
this.height,
this.fontWeight,
});
final String text;
@ -19,10 +20,13 @@ class BodyLarge extends StatelessWidget {
final double? height;
final FontWeight? fontWeight;
@override
Widget build(BuildContext context) => CustomText(
text,
style: style ?? context.bodyLarge.copyWith(height: height ?? 1.5),
textAlign: textAlign,
fontWeight: fontWeight,
);
}

View File

@ -9,6 +9,7 @@ class BodySmall extends StatelessWidget {
this.style,
this.fontColor,
this.fontSize,
this.fontWeight,
});
final String text;
@ -17,6 +18,7 @@ class BodySmall extends StatelessWidget {
final Color? fontColor;
final double? fontSize;
final FontWeight? fontWeight;
@override
Widget build(BuildContext context) => CustomText(
@ -24,5 +26,6 @@ class BodySmall extends StatelessWidget {
style: style ?? context.bodySmall,
fontColor: fontColor,
fontSize: fontSize,
fontWeight: fontWeight,
);
}

View File

@ -11,7 +11,8 @@ class CustomText extends StatelessWidget {
this.maxLines,
this.textDirection,
this.fontSize,
this.fontColor});
this.fontColor,
this.fontWeight});
final String text;
final TextStyle? style;
@ -24,14 +25,16 @@ class CustomText extends StatelessWidget {
final double? fontSize;
final Color? fontColor;
final FontWeight? fontWeight;
@override
Widget build(BuildContext context) {
return SelectableText(
text,
style: style!.copyWith(
fontSize: fontSize,
color: fontColor ?? ColorsManager.textPrimaryColor,
),
fontSize: fontSize,
color: fontColor ?? ColorsManager.textPrimaryColor,
fontWeight: fontWeight),
textAlign: textAlign,
onTap: onTap,
minLines: minLines,