description format section seperated in itg forms

mohemm_HMG_flutter_upgrade
Sikander Saleem 9 months ago
parent c35074576a
commit a33da491f9

@ -69,46 +69,70 @@ class RequestDetailFragment extends StatelessWidget {
); );
} }
Widget detailView(List<Fields> fields) { Widget detailView(List<Fields> fieldsF) {
List<Fields> fields = List.from(fieldsF);
bool isOdd = false; bool isOdd = false;
if (fields.length % 2 != 0) { if (fields.length % 2 != 0) {
isOdd = true; isOdd = true;
fields.add(new Fields()); fields.add(new Fields());
} }
return GridView.builder(
itemCount: fields.length, int descriptionFormatIndex = fields.indexWhere((element) => element.title == "Description Format" || element.title == "Description Format"); // todo add arabic in future
shrinkWrap: true, Widget? descriptionFormatView;
physics: const NeverScrollableScrollPhysics(), if (descriptionFormatIndex >= 0) {
itemBuilder: (context, index) { Fields descriptionFormat = fields[descriptionFormatIndex];
if (fields[index].value == null) { fields.removeAt(descriptionFormatIndex);
return ItemDetailViewGridItem(
index, descriptionFormatView = ItemDetailViewGridItem(
fields[index].title, 2,
fields[index].multipleValue?.join(", ") ?? "", descriptionFormat.title,
isNeedToShowEmptyDivider: (fields.length == index + 1) descriptionFormat.value == null ? (descriptionFormat.multipleValue?.join(", ") ?? "") : descriptionFormat.value ?? "",
? isOdd type: descriptionFormat.type,
? true maxLine: 0,
: false );
: false, }
type: fields[index].type,
); return Column(
} mainAxisSize: MainAxisSize.min,
return ItemDetailViewGridItem( children: [
index, GridView.builder(
fields[index].title, itemCount: fields.length,
fields[index].value ?? "", shrinkWrap: true,
isNeedToShowEmptyDivider: (fields.length == index + 1) physics: const NeverScrollableScrollPhysics(),
? isOdd itemBuilder: (context, index) {
? true if (fields[index].value == null) {
: false return ItemDetailViewGridItem(
: false, index,
type: fields[index].type, fields[index].title,
); fields[index].multipleValue?.join(", ") ?? "",
}, isNeedToShowEmptyDivider: (fields.length == index + 1)
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( ? isOdd
crossAxisCount: 2, ? true
childAspectRatio: (itemWidth / itemHeight), : false
), : false,
type: fields[index].type,
);
}
return ItemDetailViewGridItem(
index,
fields[index].title,
fields[index].value ?? "",
isNeedToShowEmptyDivider: (fields.length == index + 1)
? isOdd
? true
: false
: false,
type: fields[index].type,
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: (itemWidth / itemHeight),
),
),
if (descriptionFormatView != null) descriptionFormatView,
],
).objectContainerView(); ).objectContainerView();
return ListView.separated( return ListView.separated(
shrinkWrap: true, shrinkWrap: true,

@ -52,8 +52,9 @@ class ItemDetailViewGridItem extends StatelessWidget {
final String? value; final String? value;
final String? type; final String? type;
final bool isNeedToShowEmptyDivider; final bool isNeedToShowEmptyDivider;
final int maxLine;
ItemDetailViewGridItem(this.index, this.title, this.value, {Key? key, this.isNeedToShowEmptyDivider = false, this.type = ""}) : super(key: key); ItemDetailViewGridItem(this.index, this.title, this.value, {Key? key, this.isNeedToShowEmptyDivider = false, this.type = "", this.maxLine = 6}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -76,10 +77,11 @@ class ItemDetailViewGridItem extends StatelessWidget {
), ),
), ),
child: isNeedToShowEmptyDivider child: isNeedToShowEmptyDivider
? Container() ? SizedBox()
: Column( : Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [ children: [
title != null ? Flexible(child: "$title:".toText12Auto(isBold: true, color: const Color(0xff2BB8A6))) : Container(), title != null ? Flexible(child: "$title:".toText12Auto(isBold: true, color: const Color(0xff2BB8A6))) : Container(),
4.width, 4.width,
@ -87,7 +89,7 @@ class ItemDetailViewGridItem extends StatelessWidget {
? type!.toLowerCase() == "table" ? type!.toLowerCase() == "table"
? getStringFromJSON(value!) ? getStringFromJSON(value!)
// : Flexible(child: (value!.isEmpty ? "--" : value).toString().toText12Auto(color: MyColors.normalTextColor, maxLine: 5)) // : Flexible(child: (value!.isEmpty ? "--" : value).toString().toText12Auto(color: MyColors.normalTextColor, maxLine: 5))
: (value!.isEmpty ? "--" : value).toString().toText12Auto(color: MyColors.normalTextColor, maxLine: 6) : (value!.isEmpty ? "--" : value).toString().toText12Auto(color: MyColors.normalTextColor, maxLine: maxLine)
: Container(), : Container(),
], ],
), ),

Loading…
Cancel
Save