1184 lines
41 KiB
Dart
1184 lines
41 KiB
Dart
|
import 'package:discover_module/contacts_module/constants.dart';
|
||
|
import 'package:discover_module/contacts_module/custom_widget/icontext_widget.dart';
|
||
|
import 'package:discover_module/contacts_module/custom_widget/text.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_Certificate_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_aff_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_awards_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_education_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_email_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_event_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_location_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_pno_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_training_k2.dart';
|
||
|
import 'package:discover_module/contacts_module/storage_hive/edu_data/edu_model_hive.dart';
|
||
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/rendering.dart';
|
||
|
import 'package:flutter/widgets.dart';
|
||
|
|
||
|
class CardCustomExpansionTile<T> extends StatefulWidget {
|
||
|
final String title;
|
||
|
final List<T>? itemList;
|
||
|
final String buttonText;
|
||
|
final String field1;
|
||
|
final String field2;
|
||
|
bool? noexpand;
|
||
|
final VoidCallback? onButtonPressed; // Add this parameter for button callback
|
||
|
|
||
|
final Function(T)? onItemSelected;
|
||
|
|
||
|
CardCustomExpansionTile({
|
||
|
Key? key,
|
||
|
required this.title,
|
||
|
this.itemList,
|
||
|
required this.buttonText,
|
||
|
this.onItemSelected,
|
||
|
required this.field1,
|
||
|
required this.field2,
|
||
|
this.noexpand,
|
||
|
this.onButtonPressed, // Initialize it
|
||
|
}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_CustomExpansionTileState createState() => _CustomExpansionTileState<T>();
|
||
|
}
|
||
|
|
||
|
class _CustomExpansionTileState<T> extends State<CardCustomExpansionTile<T>> {
|
||
|
bool _isExpanded = false;
|
||
|
|
||
|
List<GlobalKey> keys = [];
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
// Initialize keys for each item in the list
|
||
|
keys = List.generate(widget.itemList!.length, (index) => GlobalKey());
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
print("Chekingg_Field_one: ${widget.field1}");
|
||
|
|
||
|
return ListTileTheme(
|
||
|
dense: true,
|
||
|
child: Padding(
|
||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||
|
child: Container(
|
||
|
child: Card(
|
||
|
margin: EdgeInsets.all(1.0),
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(0.0),
|
||
|
),
|
||
|
color: Constants.bgwhitecolor,
|
||
|
child: ExpansionTile(
|
||
|
backgroundColor: Constants.bgwhitecolor,
|
||
|
initiallyExpanded: false,
|
||
|
maintainState: true,
|
||
|
onExpansionChanged: (bool expanded) {
|
||
|
setState(() {
|
||
|
_isExpanded = expanded;
|
||
|
});
|
||
|
},
|
||
|
trailing: Icon(
|
||
|
_isExpanded
|
||
|
? Icons.keyboard_arrow_up
|
||
|
: Icons.keyboard_arrow_down,
|
||
|
color: Colors.black,
|
||
|
),
|
||
|
title: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Text1(
|
||
|
title: widget.title,
|
||
|
txtcolor: Colors.black,
|
||
|
fontweight: FontWeight.normal,
|
||
|
txtfont: 16.0,
|
||
|
),
|
||
|
const SizedBox(width: 8.0),
|
||
|
Text1(
|
||
|
title: "(${widget.itemList!.length})",
|
||
|
txtcolor: Colors.black,
|
||
|
fontweight: FontWeight.normal,
|
||
|
txtfont: 16.0,
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
children: [
|
||
|
Visibility(
|
||
|
visible: widget.noexpand ??
|
||
|
true, // Ensure that it's not null, default to true
|
||
|
child: Container(
|
||
|
// height: widget.noexpand ?? false
|
||
|
// ? 200.0
|
||
|
// : 0, // Restrict height to avoid overflow
|
||
|
|
||
|
height: widget.noexpand ?? false
|
||
|
// ? widget.itemList!.length * 40.0
|
||
|
? getDynamicHeight()
|
||
|
: 0,
|
||
|
|
||
|
child: ListView.builder(
|
||
|
itemCount: widget.itemList!.take(2).length,
|
||
|
itemBuilder: (context, index) {
|
||
|
var data = widget.itemList![index];
|
||
|
print("Dattattta_is: $data");
|
||
|
|
||
|
return Container(
|
||
|
key: keys[index],
|
||
|
constraints: BoxConstraints(
|
||
|
minWidth: MediaQuery.of(context).size.width,
|
||
|
),
|
||
|
color: Colors.white,
|
||
|
child: Container(
|
||
|
color: Colors.white,
|
||
|
child: Padding(
|
||
|
padding: const EdgeInsets.all(12.0),
|
||
|
child: Column(
|
||
|
children: [displaylocationData(data)],
|
||
|
),
|
||
|
),
|
||
|
));
|
||
|
}),
|
||
|
),
|
||
|
),
|
||
|
Visibility(
|
||
|
visible: widget.noexpand!,
|
||
|
child: Container(
|
||
|
color: Colors.white,
|
||
|
child: Align(
|
||
|
alignment: Alignment.center,
|
||
|
child: Padding(
|
||
|
padding: const EdgeInsets.all(8.0),
|
||
|
child: OutlinedButton(
|
||
|
onPressed: widget.onButtonPressed,
|
||
|
child: Text(
|
||
|
widget.buttonText,
|
||
|
style: TextStyle(color: Constants.k2color),
|
||
|
),
|
||
|
style: OutlinedButton.styleFrom(
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(12),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
getdatacel1(T location) {
|
||
|
if (location is Data) {
|
||
|
return location.address1 != null
|
||
|
? Text1(title: "${location.address1}")
|
||
|
: SizedBox();
|
||
|
} else if (location is DataPhno) {
|
||
|
return Text1(title: "${location.phoneTypeName}");
|
||
|
} else if (location is EmailData) {
|
||
|
return Text1(title: "${location.emailTypeName}");
|
||
|
} else if (location is TrainingList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is EducationList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is AwardsList) {
|
||
|
return Text1(title: "${location.name}");
|
||
|
} else if (location is CertificateList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is AffList) {
|
||
|
return Text1(title: "${location.title}");
|
||
|
} else if (location is EventList) {
|
||
|
return Text1(title: "${location.name}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getdatacel2(T location) {
|
||
|
if (location is Data) {
|
||
|
return location.postalCode != null
|
||
|
? Text1(title: "${location.postalCode}")
|
||
|
: SizedBox.shrink();
|
||
|
// return Text1(title: "${location.postalCode}");
|
||
|
} else if (location is DataPhno) {
|
||
|
return Text1(title: "${location.number}");
|
||
|
} else if (location is EmailData) {
|
||
|
return Text1(title: "${location.email}");
|
||
|
} else if (location is TrainingList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is EducationList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is AwardsList) {
|
||
|
return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
} else if (location is CertificateList) {
|
||
|
return Text1(title: "${location.specialty}");
|
||
|
} else if (location is AffList) {
|
||
|
return Text1(title: "${location.role}");
|
||
|
} else if (location is EventList) {
|
||
|
return Text1(title: "${location.notes}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getdatacel3(T location) {
|
||
|
if (location is Data) {
|
||
|
return Text1(title: "${location.countryName}");
|
||
|
|
||
|
// return Text1(title: "${location.postalCode}");
|
||
|
} else if (location is DataPhno) {
|
||
|
return Text1(title: "${location.number}");
|
||
|
} else if (location is EmailData) {
|
||
|
return Text1(title: "${location.email}");
|
||
|
} else if (location is TrainingList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is EducationList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is AwardsList) {
|
||
|
return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
} else if (location is CertificateList) {
|
||
|
return Text1(title: "${location.specialty}");
|
||
|
} else if (location is AffList) {
|
||
|
return Text1(title: "${location.role}");
|
||
|
} else if (location is EventList) {
|
||
|
return Text1(title: "${location.notes}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getdatacel4(T location) {
|
||
|
if (location is Data) {
|
||
|
return Text1(title: "${location.stateName}");
|
||
|
|
||
|
// return Text1(title: "${location.postalCode}");
|
||
|
} else if (location is DataPhno) {
|
||
|
return Text1(title: "${location.number}");
|
||
|
} else if (location is EmailData) {
|
||
|
return Text1(title: "${location.email}");
|
||
|
} else if (location is TrainingList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is EducationList) {
|
||
|
return Text1(title: "${location.degree}");
|
||
|
} else if (location is AwardsList) {
|
||
|
return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
} else if (location is CertificateList) {
|
||
|
return Text1(title: "${location.specialty}");
|
||
|
} else if (location is AffList) {
|
||
|
return Text1(title: "${location.role}");
|
||
|
} else if (location is EventList) {
|
||
|
return Text1(title: "${location.notes}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
getdatacel5(T location) {
|
||
|
if (location is Data) {
|
||
|
return location.organizationName != null
|
||
|
// ignore: dead_code
|
||
|
? Text1(
|
||
|
title: "${location.organizationName}",
|
||
|
txtfont: 20.0,
|
||
|
)
|
||
|
: Text1(
|
||
|
title: "Aissel",
|
||
|
txtfont: 20.0,
|
||
|
);
|
||
|
} else if (location is DataPhno) {
|
||
|
return Text1(title: "${location.phoneTypeName}");
|
||
|
} else if (location is EmailData) {
|
||
|
return Text1(title: "${location.emailTypeName}");
|
||
|
} else if (location is TrainingList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is EducationList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is AwardsList) {
|
||
|
return Text1(title: "${location.name}");
|
||
|
} else if (location is CertificateList) {
|
||
|
return Text1(title: "${location.organizationId}");
|
||
|
} else if (location is AffList) {
|
||
|
return Text1(title: "${location.title}");
|
||
|
} else if (location is EventList) {
|
||
|
return Text1(title: "${location.name}");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Widget _buildAddressText(Data data) {
|
||
|
List<Widget> addressParts = [];
|
||
|
|
||
|
if (data.address1 != null)
|
||
|
addressParts.add(Text1(title: data.address1! + ", "));
|
||
|
if (data.cityName != null)
|
||
|
addressParts.add(Text1(title: data.cityName! + ", "));
|
||
|
if (data.stateName != null)
|
||
|
addressParts.add(Text1(title: data.stateName! + ", "));
|
||
|
if (data.countryName != null)
|
||
|
addressParts.add(Text1(title: data.countryName! + ", "));
|
||
|
if (data.postalCode != null)
|
||
|
addressParts.add(Text1(title: data.postalCode!));
|
||
|
|
||
|
return Row(
|
||
|
children: addressParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildPhoneText(DataPhno data) {
|
||
|
List<Widget> phoneParts = [];
|
||
|
|
||
|
if (data.phoneTypeName != null)
|
||
|
phoneParts.add(Text1(title: data.phoneTypeName! + ", "));
|
||
|
|
||
|
if (data.number != null)
|
||
|
phoneParts.add(Text1(title: data.number!.toString() + ", "));
|
||
|
|
||
|
if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
phoneParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: phoneParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildEmailText(EmailData data) {
|
||
|
List<Widget> emailParts = [];
|
||
|
|
||
|
if (data.email != null) emailParts.add(Text1(title: data.email! + ", "));
|
||
|
|
||
|
if (data.emailTypeName != null)
|
||
|
emailParts.add(Text1(title: data.emailTypeName!.toString() + ", "));
|
||
|
|
||
|
// if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
// emailParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: emailParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildTrainingText(TrainingList data) {
|
||
|
List<Widget> emailParts = [];
|
||
|
|
||
|
if (data.specialty != null)
|
||
|
emailParts.add(Text1(title: data.specialty! + ", "));
|
||
|
|
||
|
if (data.degree != null)
|
||
|
emailParts.add(Text1(title: data.degree!.toString() + ", "));
|
||
|
|
||
|
// if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
// emailParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: emailParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildEducationText(EducationList data) {
|
||
|
List<Widget> emailParts = [];
|
||
|
|
||
|
if (data.specialty != null)
|
||
|
emailParts.add(Text1(title: data.specialty! + ", "));
|
||
|
|
||
|
if (data.degree != null)
|
||
|
emailParts.add(Text1(title: data.degree!.toString() + ", "));
|
||
|
|
||
|
// if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
// emailParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: emailParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildAwardsText(AwardsList data) {
|
||
|
List<Widget> emailParts = [];
|
||
|
|
||
|
if (data.name != null) emailParts.add(Text1(title: data.name! + ", "));
|
||
|
|
||
|
if (data.url != null)
|
||
|
emailParts.add(Text1(title: data.url!.toString() + ", "));
|
||
|
|
||
|
// if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
// emailParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: emailParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildCertificateText(CertificateList data) {
|
||
|
List<Widget> emailParts = [];
|
||
|
|
||
|
if (data.specialty != null)
|
||
|
emailParts.add(Text1(title: data.specialty! + ", "));
|
||
|
|
||
|
if (data.url != null)
|
||
|
emailParts.add(Text1(title: data.url!.toString() + ", "));
|
||
|
|
||
|
// if (data.formattedIsPrimary != null) if (data.formattedIsPrimary == "No")
|
||
|
// emailParts.add(Text1(title: "Not a primarry No" + ", "));
|
||
|
|
||
|
return Row(
|
||
|
children: emailParts,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget displaylocationData(T data) {
|
||
|
if (data is Data) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
//icon: Icons.business,
|
||
|
text: data.organizationName ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.location_pin,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildAddressText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is DataPhno) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
// icon: Icons.business,
|
||
|
text: data.organizationName ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildPhoneText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is EmailData) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
// icon: Icons.business,
|
||
|
text: data.emailTypeName ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildEmailText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is TrainingList) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
// icon: Icons.business,
|
||
|
text: data.specialty ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildTrainingText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is EducationList) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
// icon: Icons.business,
|
||
|
text: data.specialty ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildEducationText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is AwardsList) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
// icon: Icons.business,
|
||
|
text: data.name ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildAwardsText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
} else if (data is CertificateList) {
|
||
|
return Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
Align(
|
||
|
alignment: Alignment.centerLeft,
|
||
|
child: IconTextRow(
|
||
|
//icon: Icons.business,
|
||
|
text: data.specialty ?? "Aissel",
|
||
|
fontSize: 16.0,
|
||
|
iconColor: Constants.k2color,
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: [
|
||
|
// Icon(
|
||
|
// Icons.call,
|
||
|
// size: 20.0,
|
||
|
// color: Constants.k2color,
|
||
|
// ),
|
||
|
SizedBox(width: 8.0),
|
||
|
_buildCertificateText(data),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
return SizedBox.shrink(); // Fallback in case data is not matched
|
||
|
}
|
||
|
|
||
|
// displaylocationData(T data) {
|
||
|
// if (data is Data) {
|
||
|
// return Column(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Align(
|
||
|
// alignment: Alignment.centerLeft,
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.business, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color: Constants
|
||
|
// .k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(
|
||
|
// width: 8.0), // Add some spacing between the icon and text
|
||
|
// Text(
|
||
|
// data.organizationName ?? "Aissel", // Your text widget
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 16.0, // Your font size
|
||
|
// ),
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
// Row(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.location_pin, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color:
|
||
|
// Constants.k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// data.address1 != null
|
||
|
// ? Text1(title: data.address1! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.cityName != null
|
||
|
// ? Text1(title: data.cityName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.stateName != null
|
||
|
// ? Text1(title: data.stateName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.countryName != null
|
||
|
// ? Text1(title: data.countryName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.postalCode != null
|
||
|
// ? Text1(title: data.postalCode!)
|
||
|
// : SizedBox.shrink(),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ],
|
||
|
// );
|
||
|
// } else if (data is DataPhno) {
|
||
|
// return Column(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Align(
|
||
|
// alignment: Alignment.centerLeft,
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.business, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color: Constants
|
||
|
// .k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// Text1(
|
||
|
// title: data.organizationName ?? "Aissel",
|
||
|
// txtfont: 16.0,
|
||
|
// ),
|
||
|
// ],
|
||
|
// )),
|
||
|
// Row(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.call, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color:
|
||
|
// Constants.k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// data.phoneTypeName != null
|
||
|
// ? Text1(title: data.phoneTypeName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.formattedIsPrimary != null
|
||
|
// ? Text1(title: data.formattedIsPrimary!.toString() + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.number != null
|
||
|
// ? Text1(title: data.number!.toString() + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ],
|
||
|
// );
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
double getDynamicHeight() {
|
||
|
double totalHeight = 0.0;
|
||
|
|
||
|
// Measure the height of each item after rendering
|
||
|
for (int i = 0; i < widget.itemList!.length; i++) {
|
||
|
final RenderBox? renderBox =
|
||
|
keys[i].currentContext?.findRenderObject() as RenderBox?;
|
||
|
if (renderBox != null) {
|
||
|
totalHeight += renderBox.size.height;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return totalHeight;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// import 'package:discover_module/contacts_module/constants.dart';
|
||
|
// import 'package:discover_module/contacts_module/custom_widget/text.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_Certificate_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_aff_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_awards_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_education_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_email_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_event_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_location_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_pno_k2.dart';
|
||
|
// import 'package:discover_module/contacts_module/model_class/k2_api_model/kol_training_k2.dart';
|
||
|
// import 'package:flutter/cupertino.dart';
|
||
|
// import 'package:flutter/material.dart';
|
||
|
// import 'package:flutter/rendering.dart';
|
||
|
// import 'package:flutter/widgets.dart';
|
||
|
|
||
|
// class CardCustomExpansionTile<T> extends StatefulWidget {
|
||
|
// final String title;
|
||
|
// final List<T>? itemList;
|
||
|
// final String buttonText;
|
||
|
// final String field1;
|
||
|
// final String field2;
|
||
|
// bool? noexpand;
|
||
|
// final VoidCallback? onButtonPressed; // Add this parameter for button callback
|
||
|
|
||
|
// final Function(T) onItemSelected;
|
||
|
|
||
|
// CardCustomExpansionTile({
|
||
|
// Key? key,
|
||
|
// required this.title,
|
||
|
// this.itemList,
|
||
|
// required this.buttonText,
|
||
|
// required this.onItemSelected,
|
||
|
// required this.field1,
|
||
|
// required this.field2,
|
||
|
// this.noexpand,
|
||
|
// this.onButtonPressed, // Initialize it
|
||
|
// }) : super(key: key);
|
||
|
|
||
|
// @override
|
||
|
// _CustomExpansionTileState createState() => _CustomExpansionTileState<T>();
|
||
|
// }
|
||
|
|
||
|
// class _CustomExpansionTileState<T> extends State<CardCustomExpansionTile<T>> {
|
||
|
// bool _isExpanded = false;
|
||
|
|
||
|
// List<GlobalKey> keys = [];
|
||
|
|
||
|
// @override
|
||
|
// void initState() {
|
||
|
// super.initState();
|
||
|
// // Initialize keys for each item in the list
|
||
|
// keys = List.generate(widget.itemList!.length, (index) => GlobalKey());
|
||
|
// }
|
||
|
|
||
|
// @override
|
||
|
// Widget build(BuildContext context) {
|
||
|
// print("Chekingg_Field_one: ${widget.field1}");
|
||
|
|
||
|
// return ListTileTheme(
|
||
|
// dense: true,
|
||
|
// child: Padding(
|
||
|
// padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||
|
// child: Container(
|
||
|
// child: Card(
|
||
|
// margin: EdgeInsets.all(1.0),
|
||
|
// shape: RoundedRectangleBorder(
|
||
|
// borderRadius: BorderRadius.circular(0.0),
|
||
|
// ),
|
||
|
// color: Constants.k2color11,
|
||
|
// child: ExpansionTile(
|
||
|
// backgroundColor: Constants.k2color11,
|
||
|
// initiallyExpanded: false,
|
||
|
// maintainState: true,
|
||
|
// onExpansionChanged: (bool expanded) {
|
||
|
// setState(() {
|
||
|
// _isExpanded = expanded;
|
||
|
// });
|
||
|
// },
|
||
|
// trailing: Icon(
|
||
|
// _isExpanded
|
||
|
// ? Icons.keyboard_arrow_up
|
||
|
// : Icons.keyboard_arrow_down,
|
||
|
// color: Colors.black,
|
||
|
// ),
|
||
|
// title: Row(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Text1(
|
||
|
// title: widget.title,
|
||
|
// txtcolor: Colors.black,
|
||
|
// fontweight: FontWeight.normal,
|
||
|
// txtfont: 16.0,
|
||
|
// ),
|
||
|
// const SizedBox(width: 8.0),
|
||
|
// Text1(
|
||
|
// title: "(${widget.itemList!.length})",
|
||
|
// txtcolor: Colors.black,
|
||
|
// fontweight: FontWeight.normal,
|
||
|
// txtfont: 16.0,
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// children: [
|
||
|
// Visibility(
|
||
|
// visible: widget.noexpand ??
|
||
|
// true, // Ensure that it's not null, default to true
|
||
|
// child: Container(
|
||
|
// // height: widget.noexpand ?? false
|
||
|
// // ? 200.0
|
||
|
// // : 0, // Restrict height to avoid overflow
|
||
|
|
||
|
// height: widget.noexpand ?? false
|
||
|
// // ? widget.itemList!.length * 40.0
|
||
|
// ? getDynamicHeight()
|
||
|
// : 0,
|
||
|
|
||
|
// child: ListView.builder(
|
||
|
// itemCount: widget.itemList!.take(2).length,
|
||
|
// itemBuilder: (context, index) {
|
||
|
// var data = widget.itemList![index];
|
||
|
// print("Dattattta_is: $data");
|
||
|
|
||
|
// return Container(
|
||
|
// key: keys[index],
|
||
|
// constraints: BoxConstraints(
|
||
|
// minWidth: MediaQuery.of(context).size.width,
|
||
|
// ),
|
||
|
// color: Colors.white,
|
||
|
// child: Container(
|
||
|
// color: Colors.white,
|
||
|
// child: Padding(
|
||
|
// padding: const EdgeInsets.all(12.0),
|
||
|
// child: Column(
|
||
|
// children: [displaylocationData(data)],
|
||
|
// ),
|
||
|
// ),
|
||
|
// ));
|
||
|
// }),
|
||
|
// ),
|
||
|
// ),
|
||
|
// Visibility(
|
||
|
// visible: widget.noexpand!,
|
||
|
// child: Container(
|
||
|
// color: Colors.white,
|
||
|
// child: Align(
|
||
|
// alignment: Alignment.center,
|
||
|
// child: Padding(
|
||
|
// padding: const EdgeInsets.all(8.0),
|
||
|
// child: OutlinedButton(
|
||
|
// onPressed: widget.onButtonPressed,
|
||
|
// child: Text(
|
||
|
// widget.buttonText,
|
||
|
// style: TextStyle(color: Constants.k2color),
|
||
|
// ),
|
||
|
// style: OutlinedButton.styleFrom(
|
||
|
// shape: RoundedRectangleBorder(
|
||
|
// borderRadius: BorderRadius.circular(12),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ),
|
||
|
// );
|
||
|
// }
|
||
|
|
||
|
// getdatacel1(T location) {
|
||
|
// if (location is Data) {
|
||
|
// return location.address1 != null
|
||
|
// ? Text1(title: "${location.address1}")
|
||
|
// : SizedBox();
|
||
|
// } else if (location is DataPhno) {
|
||
|
// return Text1(title: "${location.phoneTypeName}");
|
||
|
// } else if (location is EmailData) {
|
||
|
// return Text1(title: "${location.emailTypeName}");
|
||
|
// } else if (location is TrainingList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is EducationList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is AwardsList) {
|
||
|
// return Text1(title: "${location.name}");
|
||
|
// } else if (location is CertificateList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is AffList) {
|
||
|
// return Text1(title: "${location.title}");
|
||
|
// } else if (location is EventList) {
|
||
|
// return Text1(title: "${location.name}");
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// getdatacel2(T location) {
|
||
|
// if (location is Data) {
|
||
|
// return location.postalCode != null
|
||
|
// ? Text1(title: "${location.postalCode}")
|
||
|
// : SizedBox.shrink();
|
||
|
// // return Text1(title: "${location.postalCode}");
|
||
|
// } else if (location is DataPhno) {
|
||
|
// return Text1(title: "${location.number}");
|
||
|
// } else if (location is EmailData) {
|
||
|
// return Text1(title: "${location.email}");
|
||
|
// } else if (location is TrainingList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is EducationList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is AwardsList) {
|
||
|
// return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
// } else if (location is CertificateList) {
|
||
|
// return Text1(title: "${location.specialty}");
|
||
|
// } else if (location is AffList) {
|
||
|
// return Text1(title: "${location.role}");
|
||
|
// } else if (location is EventList) {
|
||
|
// return Text1(title: "${location.notes}");
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// getdatacel3(T location) {
|
||
|
// if (location is Data) {
|
||
|
// return Text1(title: "${location.countryName}");
|
||
|
|
||
|
// // return Text1(title: "${location.postalCode}");
|
||
|
// } else if (location is DataPhno) {
|
||
|
// return Text1(title: "${location.number}");
|
||
|
// } else if (location is EmailData) {
|
||
|
// return Text1(title: "${location.email}");
|
||
|
// } else if (location is TrainingList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is EducationList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is AwardsList) {
|
||
|
// return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
// } else if (location is CertificateList) {
|
||
|
// return Text1(title: "${location.specialty}");
|
||
|
// } else if (location is AffList) {
|
||
|
// return Text1(title: "${location.role}");
|
||
|
// } else if (location is EventList) {
|
||
|
// return Text1(title: "${location.notes}");
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// getdatacel4(T location) {
|
||
|
// if (location is Data) {
|
||
|
// return Text1(title: "${location.stateName}");
|
||
|
|
||
|
// // return Text1(title: "${location.postalCode}");
|
||
|
// } else if (location is DataPhno) {
|
||
|
// return Text1(title: "${location.number}");
|
||
|
// } else if (location is EmailData) {
|
||
|
// return Text1(title: "${location.email}");
|
||
|
// } else if (location is TrainingList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is EducationList) {
|
||
|
// return Text1(title: "${location.degree}");
|
||
|
// } else if (location is AwardsList) {
|
||
|
// return Text1(title: "${location.startDate} ${location.endDate}");
|
||
|
// } else if (location is CertificateList) {
|
||
|
// return Text1(title: "${location.specialty}");
|
||
|
// } else if (location is AffList) {
|
||
|
// return Text1(title: "${location.role}");
|
||
|
// } else if (location is EventList) {
|
||
|
// return Text1(title: "${location.notes}");
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// getdatacel5(T location) {
|
||
|
// if (location is Data) {
|
||
|
// return location.organizationName != null
|
||
|
// // ignore: dead_code
|
||
|
// ? Text1(
|
||
|
// title: "${location.organizationName}",
|
||
|
// txtfont: 20.0,
|
||
|
// )
|
||
|
// : Text1(
|
||
|
// title: "Aissel",
|
||
|
// txtfont: 20.0,
|
||
|
// );
|
||
|
// } else if (location is DataPhno) {
|
||
|
// return Text1(title: "${location.phoneTypeName}");
|
||
|
// } else if (location is EmailData) {
|
||
|
// return Text1(title: "${location.emailTypeName}");
|
||
|
// } else if (location is TrainingList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is EducationList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is AwardsList) {
|
||
|
// return Text1(title: "${location.name}");
|
||
|
// } else if (location is CertificateList) {
|
||
|
// return Text1(title: "${location.organizationId}");
|
||
|
// } else if (location is AffList) {
|
||
|
// return Text1(title: "${location.title}");
|
||
|
// } else if (location is EventList) {
|
||
|
// return Text1(title: "${location.name}");
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// displaylocationData(T data) {
|
||
|
// if (data is Data) {
|
||
|
// return Column(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Align(
|
||
|
// alignment: Alignment.centerLeft,
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.business, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color: Constants
|
||
|
// .k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(
|
||
|
// width: 8.0), // Add some spacing between the icon and text
|
||
|
// Text(
|
||
|
// data.organizationName ?? "Aissel", // Your text widget
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 16.0, // Your font size
|
||
|
// ),
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
// Row(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.location_pin, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color:
|
||
|
// Constants.k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// data.address1 != null
|
||
|
// ? Text1(title: data.address1! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.cityName != null
|
||
|
// ? Text1(title: data.cityName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.stateName != null
|
||
|
// ? Text1(title: data.stateName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.countryName != null
|
||
|
// ? Text1(title: data.countryName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.postalCode != null
|
||
|
// ? Text1(title: data.postalCode!)
|
||
|
// : SizedBox.shrink(),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ],
|
||
|
// );
|
||
|
// } else if (data is DataPhno) {
|
||
|
// return Column(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Align(
|
||
|
// alignment: Alignment.centerLeft,
|
||
|
// child: Row(
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.business, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color: Constants
|
||
|
// .k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// Text1(
|
||
|
// title: data.organizationName ?? "Aissel",
|
||
|
// txtfont: 16.0,
|
||
|
// ),
|
||
|
// ],
|
||
|
// )),
|
||
|
// Row(
|
||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Icon(
|
||
|
// Icons.call, // Replace with any icon you want
|
||
|
// size: 20.0, // Adjust the size of the icon
|
||
|
// color:
|
||
|
// Constants.k2color, // Change the color of the icon if needed
|
||
|
// ),
|
||
|
// SizedBox(width: 8.0),
|
||
|
// data.phoneTypeName != null
|
||
|
// ? Text1(title: data.phoneTypeName! + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.formattedIsPrimary != null
|
||
|
// ? Text1(title: data.formattedIsPrimary!.toString() + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// data.number != null
|
||
|
// ? Text1(title: data.number!.toString() + ", ")
|
||
|
// : SizedBox.shrink(),
|
||
|
// ],
|
||
|
// ),
|
||
|
// ],
|
||
|
// );
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// double getDynamicHeight() {
|
||
|
// double totalHeight = 0.0;
|
||
|
|
||
|
// // Measure the height of each item after rendering
|
||
|
// for (int i = 0; i < widget.itemList!.length; i++) {
|
||
|
// final RenderBox? renderBox =
|
||
|
// keys[i].currentContext?.findRenderObject() as RenderBox?;
|
||
|
// if (renderBox != null) {
|
||
|
// totalHeight += renderBox.size.height;
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// return totalHeight;
|
||
|
// }
|
||
|
// }
|