feat: create inventory in or out picker

This commit is contained in:
louis 2024-03-20 10:37:52 +08:00
parent 9a8b04f3e9
commit 504dc26ed4
5 changed files with 220 additions and 105 deletions

View File

@ -1,9 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/db_helper/dbHelper.dart';
import 'package:sk_base_mobile/screens/new_inventory_inout/new_inventory_inout.dart';
import 'package:sk_base_mobile/util/date.util.dart';
import 'package:sk_base_mobile/util/logger_util.dart';
import 'package:sk_base_mobile/util/modal.util.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
import 'components/responsive.dart';
class InventoryInoutController extends GetxController {
RxMap userData = {}.obs;
@ -24,7 +30,158 @@ class InventoryInoutController extends GetxController {
RxList model = [].obs;
final ScrollController scrollController = ScrollController();
InventoryInoutController() {}
Future<void> showInOrOutPickerDialog() async {
showDialog(
context: Get.overlayContext!,
builder: (_) => Align(
alignment: Alignment.center,
widthFactor: 1,
heightFactor: 1,
child: SizedBox(
width: ScreenAdaper.width(1000),
height: ScreenAdaper.height(500),
child: 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: [
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
left: value * 80,
child: GestureDetector(
onTap: () {
Get.back();
showInventoryInoutCreateDialog();
},
child: Container(
height: ScreenAdaper.height(350),
width: ScreenAdaper.height(350),
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(80),
),
SizedBox(
height: ScreenAdaper.height(10),
),
Text(
'入库',
style: TextStyle(
decoration: TextDecoration.none,
color: AppTheme.nearlyWhite,
fontSize: ScreenAdaper.sp(60),
letterSpacing: ScreenAdaper.width(5),
fontWeight: FontWeight.w700),
)
]),
)),
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
right: 80 * value,
child: GestureDetector(
onTap: () {
Get.back();
showInventoryInoutCreateDialog();
},
child: Container(
height: ScreenAdaper.height(350),
width: ScreenAdaper.height(350),
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(80),
),
SizedBox(
height: ScreenAdaper.height(10),
),
Text(
'出库',
style: TextStyle(
decoration: TextDecoration.none,
color: AppTheme.nearlyWhite,
fontSize: ScreenAdaper.sp(60),
letterSpacing:
ScreenAdaper.width(5),
fontWeight: FontWeight.w700),
)
])),
)),
],
);
},
))),
);
}
///
Future<void> showInventoryInoutCreateDialog() async {
final isTablet = Responsive.isTablet(Get.context!);
isTablet
? showGeneralDialog(
context: Get.overlayContext!,
barrierLabel: "Barrier",
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5),
transitionDuration: const Duration(milliseconds: 400),
pageBuilder: (_, __, ___) {
return Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: Material(child: NewInventoryInout()),
),
);
},
transitionBuilder: (_, anim, __, child) {
Tween<Offset> tween;
tween = Tween(begin: const Offset(0, -1), end: Offset.zero);
return SlideTransition(
position: tween.animate(
CurvedAnimation(parent: anim, curve: Curves.easeInOut),
),
child: child,
);
},
)
: showModalBottomSheet(
elevation: 0,
isScrollControlled: true,
backgroundColor: Colors.white,
context: Get.overlayContext!,
builder: (context) {
return NewInventoryInout();
},
);
}
getTasks() async {
db.getData().then((value) {

View File

@ -14,25 +14,21 @@ class LandingPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: GestureDetector(
onTap: () {
controller.showCreateBtn.value = true;
},
child: Stack(children: [
const BackColors(),
SafeArea(
child: Obx(() => Scaffold(
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
floatingActionButton: controller.currentIndex.value == 0
? FloatingCreateButton()
: null,
bottomNavigationBar: BottomNavBar(),
backgroundColor: Colors.transparent,
body: Obx(() =>
controller.pages[controller.currentIndex.value]),
)))
])),
child: Stack(children: [
const BackColors(),
SafeArea(
child: Obx(() => Scaffold(
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
floatingActionButton: controller.currentIndex.value == 0
? FloatingCreateButton()
: null,
bottomNavigationBar: BottomNavBar(),
backgroundColor: Colors.transparent,
body: Obx(
() => controller.pages[controller.currentIndex.value]),
)))
]),
);
}
}

View File

@ -1,63 +1,21 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
import 'package:sk_base_mobile/screens/inventory_inout/components/responsive.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/screens/new_inventory_inout/new_inventory_inout.dart';
import 'package:sk_base_mobile/util/logger_util.dart';
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>();
@override
Widget build(BuildContext context) {
final isTablet = Responsive.isTablet(context);
return Obx(() => controller.showCreateBtn.value
? InkWell(
borderRadius: BorderRadius.circular(ScreenAdaper.sp(50)),
onTap: () {
controller.showCreateBtn.value = false;
return;
!isTablet
? showGeneralDialog(
context: context,
barrierLabel: "Barrier",
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5),
transitionDuration: const Duration(milliseconds: 400),
pageBuilder: (_, __, ___) {
return Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(30),
child: Material(child: NewInventoryInout()),
),
);
},
transitionBuilder: (_, anim, __, child) {
Tween<Offset> tween;
tween =
Tween(begin: const Offset(0, -1), end: Offset.zero);
return SlideTransition(
position: tween.animate(
CurvedAnimation(
parent: anim, curve: Curves.easeInOut),
),
child: child,
);
},
)
: showModalBottomSheet(
elevation: 0,
isScrollControlled: true,
backgroundColor: Colors.white,
context: context,
builder: (context) {
return NewInventoryInout();
},
);
},
onTap: inventoryInoutController.showInOrOutPickerDialog,
child: Container(
height: ScreenAdaper.height(140),
width: ScreenAdaper.height(140),
@ -82,40 +40,45 @@ class FloatingCreateButton extends StatelessWidget {
return Stack(
alignment: Alignment.center,
children: [
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),
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
]),
),
Text(
'入库',
style: TextStyle(
color: AppTheme.nearlyWhite,
fontSize: ScreenAdaper.sp(50),
letterSpacing: ScreenAdaper.width(5),
fontWeight: FontWeight.w700),
)
]),
),
),
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)),

View File

@ -5,10 +5,10 @@ import 'package:sk_base_mobile/constants/constants.dart';
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
class GradientButton extends StatelessWidget {
VoidCallback? onPressed;
bool isLoading;
String buttonText;
GradientButton(
final VoidCallback? onPressed;
final bool isLoading;
final String buttonText;
const GradientButton(
{super.key,
this.buttonText = TextEnum.createInventoryInOutBtnText,
this.onPressed,

View File

@ -2,9 +2,8 @@ import 'package:flutter/cupertino.dart';
class TapToDismissKeyboard extends StatelessWidget {
final Widget? child;
late BuildContext context;
TapToDismissKeyboard({this.child, required context});
final BuildContext context;
const TapToDismissKeyboard({super.key, this.child, required this.context});
@override
Widget build(BuildContext context) {