feat: grid view auto height for each item
This commit is contained in:
parent
8a06486f93
commit
c475f8b553
|
@ -23,8 +23,8 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(
|
||||||
vertical: ScreenAdaper.height(15),
|
vertical: ScreenAdaper.height(10),
|
||||||
horizontal: ScreenAdaper.width(15)),
|
horizontal: ScreenAdaper.width(10)),
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: ScreenAdaper.width(defaultPadding),
|
horizontal: ScreenAdaper.width(defaultPadding),
|
||||||
vertical: ScreenAdaper.height(defaultPadding)),
|
vertical: ScreenAdaper.height(defaultPadding)),
|
||||||
|
@ -42,116 +42,6 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
buildImage(),
|
buildImage(),
|
||||||
Expanded(child: buildContent()),
|
Expanded(child: buildContent()),
|
||||||
|
|
||||||
// const Spacer(
|
|
||||||
// flex: 2,
|
|
||||||
// ),
|
|
||||||
// controller.list[ind][index].inOrOut ==
|
|
||||||
// InventoryInOrOutEnumValues[InventoryInOrOutEnum.In]
|
|
||||||
// ? Container(
|
|
||||||
// height: ScreenAdaper.height(40),
|
|
||||||
// width: ScreenAdaper.width(40),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// shape: BoxShape.circle,
|
|
||||||
// gradient: const LinearGradient(
|
|
||||||
// begin: Alignment.topCenter,
|
|
||||||
// end: Alignment.bottomCenter,
|
|
||||||
// colors: [
|
|
||||||
// lightOrange,
|
|
||||||
// darkOrange,
|
|
||||||
// ]),
|
|
||||||
// boxShadow: [
|
|
||||||
// BoxShadow(
|
|
||||||
// color: lightOrange,
|
|
||||||
// offset: Offset(0, ScreenAdaper.height(10)),
|
|
||||||
// blurRadius: ScreenAdaper.sp(10))
|
|
||||||
// ]),
|
|
||||||
// child: const Icon(
|
|
||||||
// Icons.done,
|
|
||||||
// color: Colors.white,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// : Align(
|
|
||||||
// alignment: Alignment.topRight,
|
|
||||||
// child: Padding(
|
|
||||||
// padding: EdgeInsets.only(top: ScreenAdaper.height(20)),
|
|
||||||
// child: PopupMenuButton(
|
|
||||||
// onSelected: (value) => {
|
|
||||||
// // controller.onTaskComplete(value, index, ind,
|
|
||||||
// // controller.list[ind][index].key, context)
|
|
||||||
// },
|
|
||||||
// surfaceTintColor: Colors.white,
|
|
||||||
// padding: EdgeInsets.zero,
|
|
||||||
// icon: Icon(
|
|
||||||
// Icons.more_vert_rounded,
|
|
||||||
// color: Colors.grey,
|
|
||||||
// size: ScreenAdaper.height(24),
|
|
||||||
// ),
|
|
||||||
// shape: OutlineInputBorder(
|
|
||||||
// borderRadius:
|
|
||||||
// BorderRadius.circular(ScreenAdaper.sp(20)),
|
|
||||||
// borderSide: BorderSide.none,
|
|
||||||
// ),
|
|
||||||
// itemBuilder: (context) {
|
|
||||||
// return [
|
|
||||||
// PopupMenuItem(
|
|
||||||
// height: ScreenAdaper.height(20),
|
|
||||||
// value: 1,
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// Icon(
|
|
||||||
// Icons.edit_note,
|
|
||||||
// color: Colors.orange,
|
|
||||||
// size: ScreenAdaper.height(14),
|
|
||||||
// ),
|
|
||||||
// SizedBox(
|
|
||||||
// width:
|
|
||||||
// ScreenAdaper.width(defaultPadding) /
|
|
||||||
// 2,
|
|
||||||
// ),
|
|
||||||
// const Text('Edit')
|
|
||||||
// ],
|
|
||||||
// )),
|
|
||||||
// PopupMenuItem(
|
|
||||||
// height: ScreenAdaper.height(25),
|
|
||||||
// value: 2,
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// Icon(
|
|
||||||
// Icons.delete_outline,
|
|
||||||
// color: Colors.orange,
|
|
||||||
// size: ScreenAdaper.height(14),
|
|
||||||
// ),
|
|
||||||
// SizedBox(
|
|
||||||
// width:
|
|
||||||
// ScreenAdaper.width(defaultPadding) /
|
|
||||||
// 2,
|
|
||||||
// ),
|
|
||||||
// Text('Delete')
|
|
||||||
// ],
|
|
||||||
// )),
|
|
||||||
// PopupMenuItem(
|
|
||||||
// height: ScreenAdaper.height(25),
|
|
||||||
// value: 3,
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// Icon(
|
|
||||||
// Icons.done_all_outlined,
|
|
||||||
// color: Colors.orange,
|
|
||||||
// size: ScreenAdaper.height(14),
|
|
||||||
// ),
|
|
||||||
// SizedBox(
|
|
||||||
// width:
|
|
||||||
// ScreenAdaper.width(defaultPadding) /
|
|
||||||
// 2,
|
|
||||||
// ),
|
|
||||||
// Text('Complete')
|
|
||||||
// ],
|
|
||||||
// )),
|
|
||||||
// ];
|
|
||||||
// },
|
|
||||||
// )),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -178,7 +68,7 @@ class InventoryInoutCard extends StatelessWidget {
|
||||||
buildInOrOut()
|
buildInOrOut()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Spacer(),
|
// Spacer(),
|
||||||
Text(
|
Text(
|
||||||
controller.list[ind][index].product?.company?.name ?? '-',
|
controller.list[ind][index].product?.company?.name ?? '-',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
|
@ -17,7 +17,7 @@ class InventoryInoutView extends StatelessWidget {
|
||||||
controller: controller.pageController,
|
controller: controller.pageController,
|
||||||
children: List.generate(
|
children: List.generate(
|
||||||
controller.daysNum,
|
controller.daysNum,
|
||||||
(index) => TaskList(
|
(index) => InventoryInoutViewItem(
|
||||||
index: index,
|
index: index,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:sk_base_mobile/app_theme.dart';
|
import 'package:sk_base_mobile/app_theme.dart';
|
||||||
import 'package:sk_base_mobile/constants/constants.dart';
|
import 'package:sk_base_mobile/constants/constants.dart';
|
||||||
|
@ -8,43 +9,36 @@ import 'package:sk_base_mobile/screens/inventory_inout/inventory_inout_controlle
|
||||||
import 'package:sk_base_mobile/util/util.dart';
|
import 'package:sk_base_mobile/util/util.dart';
|
||||||
import 'package:sk_base_mobile/widgets/loading_indicator.dart';
|
import 'package:sk_base_mobile/widgets/loading_indicator.dart';
|
||||||
|
|
||||||
class TaskList extends StatelessWidget {
|
class InventoryInoutViewItem extends StatelessWidget {
|
||||||
const TaskList({super.key, required this.index});
|
const InventoryInoutViewItem({super.key, required this.index});
|
||||||
final int index;
|
final int index;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Responsive(
|
return Responsive(
|
||||||
tablet: Grid(
|
tablet: Grid(
|
||||||
crossAsis: 2,
|
columnNum: 2,
|
||||||
ratio: 2.2,
|
|
||||||
ind: index,
|
ind: index,
|
||||||
),
|
),
|
||||||
largeTablet: Grid(
|
largeTablet: Grid(
|
||||||
crossAsis: 3,
|
columnNum: 3,
|
||||||
ratio: 2.3,
|
|
||||||
ind: index,
|
ind: index,
|
||||||
),
|
),
|
||||||
mobile: Grid(
|
mobile: Grid(
|
||||||
ratio: 3,
|
columnNum: 1,
|
||||||
crossAsis: 1,
|
|
||||||
ind: index,
|
ind: index,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Grid extends StatelessWidget {
|
class Grid extends StatelessWidget {
|
||||||
final int crossAsis;
|
final int columnNum;
|
||||||
final double ratio;
|
|
||||||
final int ind;
|
final int ind;
|
||||||
final controller = Get.find<InventoryInoutController>();
|
final controller = Get.find<InventoryInoutController>();
|
||||||
Grid(
|
Grid({super.key, required this.columnNum, required this.ind});
|
||||||
{super.key,
|
|
||||||
required this.crossAsis,
|
|
||||||
required this.ratio,
|
|
||||||
required this.ind});
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() => controller.loading.value
|
return Obx(
|
||||||
|
() => controller.loading.value
|
||||||
? const LoadingIndicator(common: true)
|
? const LoadingIndicator(common: true)
|
||||||
: controller.list[ind].isEmpty
|
: controller.list[ind].isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
|
@ -57,17 +51,27 @@ class Grid extends StatelessWidget {
|
||||||
fontSize: ScreenAdaper.height(30)),
|
fontSize: ScreenAdaper.height(30)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: GridView.builder(
|
: MasonryGridView.count(
|
||||||
padding: const EdgeInsets.only(top: 40),
|
padding: EdgeInsets.only(top: ScreenAdaper.height(60)),
|
||||||
|
crossAxisCount: columnNum,
|
||||||
itemCount: controller.list[ind].length,
|
itemCount: controller.list[ind].length,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: crossAsis, childAspectRatio: ratio),
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return InventoryInoutCard(
|
return InventoryInoutCard(
|
||||||
index: index,
|
index: index,
|
||||||
ind: ind,
|
ind: ind,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
),
|
||||||
|
);
|
||||||
|
// : GridView.count(
|
||||||
|
// padding: const EdgeInsets.only(top: 40),
|
||||||
|
// crossAxisCount: columnNum,
|
||||||
|
// children: List.generate(controller.list[ind].length, (index) {
|
||||||
|
// return InventoryInoutCard(
|
||||||
|
// index: index,
|
||||||
|
// ind: ind,
|
||||||
|
// );
|
||||||
|
// }),
|
||||||
|
// ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,6 +358,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.9.0"
|
version: "5.9.0"
|
||||||
|
flutter_staggered_grid_view:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_staggered_grid_view
|
||||||
|
sha256: "19e7abb550c96fbfeb546b23f3ff356ee7c59a019a651f8f102a4ba9b7349395"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
|
@ -60,6 +60,7 @@ dependencies:
|
||||||
decimal: ^2.3.3
|
decimal: ^2.3.3
|
||||||
photo_view: ^0.14.0
|
photo_view: ^0.14.0
|
||||||
image_gallery_saver: ^2.0.3
|
image_gallery_saver: ^2.0.3
|
||||||
|
flutter_staggered_grid_view: ^0.7.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue