description format section seperated in itg forms

master_eventActivity
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;
if (fields.length % 2 != 0) {
isOdd = true;
fields.add(new Fields());
}
return GridView.builder(
itemCount: fields.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (fields[index].value == null) {
return ItemDetailViewGridItem(
index,
fields[index].title,
fields[index].multipleValue?.join(", ") ?? "",
isNeedToShowEmptyDivider: (fields.length == index + 1)
? isOdd
? true
: 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),
),
int descriptionFormatIndex = fields.indexWhere((element) => element.title == "Description Format" || element.title == "Description Format"); // todo add arabic in future
Widget? descriptionFormatView;
if (descriptionFormatIndex >= 0) {
Fields descriptionFormat = fields[descriptionFormatIndex];
fields.removeAt(descriptionFormatIndex);
descriptionFormatView = ItemDetailViewGridItem(
2,
descriptionFormat.title,
descriptionFormat.value == null ? (descriptionFormat.multipleValue?.join(", ") ?? "") : descriptionFormat.value ?? "",
type: descriptionFormat.type,
maxLine: 0,
);
}
return Column(
mainAxisSize: MainAxisSize.min,
children: [
GridView.builder(
itemCount: fields.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (fields[index].value == null) {
return ItemDetailViewGridItem(
index,
fields[index].title,
fields[index].multipleValue?.join(", ") ?? "",
isNeedToShowEmptyDivider: (fields.length == index + 1)
? isOdd
? true
: 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();
return ListView.separated(
shrinkWrap: true,

@ -52,8 +52,9 @@ class ItemDetailViewGridItem extends StatelessWidget {
final String? value;
final String? type;
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
Widget build(BuildContext context) {
@ -76,10 +77,11 @@ class ItemDetailViewGridItem extends StatelessWidget {
),
),
child: isNeedToShowEmptyDivider
? Container()
? SizedBox()
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
title != null ? Flexible(child: "$title:".toText12Auto(isBold: true, color: const Color(0xff2BB8A6))) : Container(),
4.width,
@ -87,7 +89,7 @@ class ItemDetailViewGridItem extends StatelessWidget {
? type!.toLowerCase() == "table"
? getStringFromJSON(value!)
// : 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(),
],
),

Loading…
Cancel
Save