mobile_skt/lib/widgets/floating_action.dart

123 lines
5.6 KiB
Dart
Raw Normal View History

2024-03-19 11:09:07 +08:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
2024-03-19 11:09:07 +08:00
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controller.dart';
import 'package:sk_base_mobile/screens/landing/landing_controller.dart';
import 'package:sk_base_mobile/util/logger_util.dart';
2024-03-19 11:09:07 +08:00
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class FloatingCreateButton extends StatelessWidget {
FloatingCreateButton({super.key});
final controller = Get.find<LandingController>();
final inventoryInoutController = Get.find<InventoryInoutController>();
2024-03-19 11:09:07 +08:00
@override
Widget build(BuildContext context) {
return Obx(() => controller.showCreateBtn.value
? InkWell(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(50)),
onTap: inventoryInoutController.showInOrOutPickerDialog,
child: Container(
height: ScreenAdaper.height(140),
width: ScreenAdaper.height(140),
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(colors: [
AppTheme.primaryColorLight,
AppTheme.primaryColor
])),
child: Icon(
Icons.add,
color: Colors.white,
size: ScreenAdaper.sp(70),
),
),
)
: TweenAnimationBuilder(
curve: Curves.easeInOut,
tween: Tween<double>(begin: 0, end: 1),
duration: const Duration(milliseconds: 200),
builder: (context, value, child) {
return Stack(
alignment: Alignment.center,
children: [
GestureDetector(
onTap: () {
print('元素被点击');
// 在这里添加你的代码
},
child: Transform.translate(
offset: Offset(-ScreenAdaper.width(120) * value,
-ScreenAdaper.height(120)),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: ScreenAdaper.height(200),
width: ScreenAdaper.height(200),
decoration: const BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(30)),
gradient: LinearGradient(colors: [
AppTheme.primaryColorLight,
AppTheme.primaryColor
]),
),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.add_circle_outline,
color: AppTheme.nearlyWhite,
size: ScreenAdaper.sp(70),
),
Text(
'入库',
style: TextStyle(
color: AppTheme.nearlyWhite,
fontSize: ScreenAdaper.sp(50),
letterSpacing: ScreenAdaper.width(5),
fontWeight: FontWeight.w700),
)
]),
))),
Transform.translate(
offset: Offset(ScreenAdaper.width(120) * value,
-ScreenAdaper.height(120)),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: ScreenAdaper.height(200),
width: ScreenAdaper.height(200),
decoration: const BoxDecoration(
// shape: BoxShape.circle,
borderRadius: BorderRadius.all(Radius.circular(30)),
gradient: LinearGradient(colors: [
AppTheme.primaryColorLight,
AppTheme.primaryColor
]),
),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
// 减号、
Icons.remove_circle_outline,
color: AppTheme.nearlyWhite,
size: ScreenAdaper.sp(70),
),
Text(
'出库',
style: TextStyle(
color: AppTheme.nearlyWhite,
fontSize: ScreenAdaper.sp(50),
letterSpacing: ScreenAdaper.width(5),
fontWeight: FontWeight.w700),
)
])),
),
],
2024-03-19 11:09:07 +08:00
);
},
));
2024-03-19 11:09:07 +08:00
}
}