first commit
This commit is contained in:
77
siro_driver/lib/views/widgets/circle_container.dart
Executable file
77
siro_driver/lib/views/widgets/circle_container.dart
Executable file
@@ -0,0 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_driver/constant/colors.dart';
|
||||
|
||||
import 'mydialoug.dart';
|
||||
|
||||
class MyCircleContainer extends StatelessWidget {
|
||||
final Widget child;
|
||||
final Color? backgroundColor;
|
||||
final Color? borderColor;
|
||||
|
||||
MyCircleContainer({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.backgroundColor,
|
||||
this.borderColor,
|
||||
});
|
||||
|
||||
final controller = Get.put(CircleController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final effectiveBorderColor = borderColor ?? AppColor.borderColor;
|
||||
|
||||
return GetBuilder<CircleController>(
|
||||
builder: ((controller) {
|
||||
final effectiveBackgroundColor = backgroundColor ??
|
||||
(controller.isActive ? AppColor.accentColor : AppColor.secondaryColor);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
controller.toggleActive();
|
||||
MyDialog().getDialog(
|
||||
'Rejected Orders Count'.tr,
|
||||
'This is the total number of rejected orders per day after accepting the orders'
|
||||
.tr, () {
|
||||
Get.back();
|
||||
});
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
onEnd: () {
|
||||
controller.resetSize();
|
||||
},
|
||||
duration: const Duration(milliseconds: 300),
|
||||
width: controller.size,
|
||||
height: controller.size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: effectiveBackgroundColor,
|
||||
border: Border.all(
|
||||
color: effectiveBorderColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Center(child: child),
|
||||
),
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
class CircleController extends GetxController {
|
||||
bool isActive = false;
|
||||
double size = 40;
|
||||
|
||||
void toggleActive() {
|
||||
isActive = !isActive;
|
||||
size = 60;
|
||||
update();
|
||||
}
|
||||
|
||||
void resetSize() {
|
||||
size = 40;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user