2024-10-07 12:41:28 +00:00
|
|
|
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/material.dart';
|
2024-11-22 10:38:43 +00:00
|
|
|
import 'package:flutter/widgets.dart';
|
2024-10-07 12:41:28 +00:00
|
|
|
|
|
|
|
class CustomExpansionTile<T> extends StatefulWidget {
|
|
|
|
final String title;
|
2024-11-22 10:38:43 +00:00
|
|
|
final List<T>? itemList;
|
2024-10-07 12:41:28 +00:00
|
|
|
final String buttonText;
|
|
|
|
final String field1;
|
|
|
|
final String field2;
|
2024-11-22 10:38:43 +00:00
|
|
|
bool? noexpand;
|
|
|
|
final VoidCallback? onButtonPressed; // Add this parameter for button callback
|
2024-10-07 12:41:28 +00:00
|
|
|
|
|
|
|
final Function(T) onItemSelected;
|
|
|
|
|
2024-11-22 10:38:43 +00:00
|
|
|
CustomExpansionTile({
|
2024-10-07 12:41:28 +00:00
|
|
|
Key? key,
|
|
|
|
required this.title,
|
2024-11-22 10:38:43 +00:00
|
|
|
this.itemList,
|
2024-10-07 12:41:28 +00:00
|
|
|
required this.buttonText,
|
|
|
|
required this.onItemSelected,
|
|
|
|
required this.field1,
|
|
|
|
required this.field2,
|
2024-11-22 10:38:43 +00:00
|
|
|
this.noexpand,
|
|
|
|
this.onButtonPressed, // Initialize it
|
2024-10-07 12:41:28 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_CustomExpansionTileState createState() => _CustomExpansionTileState<T>();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CustomExpansionTileState<T> extends State<CustomExpansionTile<T>> {
|
|
|
|
bool _isExpanded = false;
|
|
|
|
|
2024-11-22 10:38:43 +00:00
|
|
|
//var noexpand;
|
|
|
|
|
2024-10-07 12:41:28 +00:00
|
|
|
@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),
|
|
|
|
),
|
2024-11-22 10:38:43 +00:00
|
|
|
color: Constants.bgwhitecolor,
|
2024-10-07 12:41:28 +00:00
|
|
|
child: ExpansionTile(
|
2024-11-22 10:38:43 +00:00
|
|
|
backgroundColor: Constants.bgwhitecolor,
|
2024-10-07 12:41:28 +00:00
|
|
|
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(
|
2024-11-22 10:38:43 +00:00
|
|
|
title: "(${widget.itemList!.length})",
|
2024-10-07 12:41:28 +00:00
|
|
|
txtcolor: Colors.black,
|
|
|
|
fontweight: FontWeight.normal,
|
|
|
|
txtfont: 16.0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
children: [
|
2024-11-22 10:38:43 +00:00
|
|
|
Visibility(
|
|
|
|
visible: widget.noexpand!,
|
|
|
|
child: Scrollbar(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minWidth: MediaQuery.of(context).size.width,
|
|
|
|
),
|
|
|
|
color: Colors.white,
|
|
|
|
child: DataTable(
|
|
|
|
showCheckboxColumn: false,
|
|
|
|
columns: [
|
|
|
|
DataColumn(
|
|
|
|
label: Expanded(
|
|
|
|
child: Text(
|
|
|
|
widget.field1 ?? 'Item',
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
softWrap: true,
|
|
|
|
),
|
2024-10-07 12:41:28 +00:00
|
|
|
),
|
|
|
|
),
|
2024-11-22 10:38:43 +00:00
|
|
|
DataColumn(
|
|
|
|
label: Expanded(
|
|
|
|
child: Text(
|
|
|
|
widget.field2 ?? 'Details',
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w600),
|
|
|
|
),
|
2024-10-07 12:41:28 +00:00
|
|
|
),
|
|
|
|
),
|
2024-11-22 10:38:43 +00:00
|
|
|
],
|
|
|
|
rows: List.generate(widget.itemList!.take(2).length,
|
|
|
|
(index) {
|
|
|
|
final item = widget.itemList![index];
|
2024-10-07 12:41:28 +00:00
|
|
|
|
2024-11-22 10:38:43 +00:00
|
|
|
return DataRow(
|
|
|
|
onSelectChanged: (value) {
|
|
|
|
widget.onItemSelected(widget.itemList![index]);
|
|
|
|
},
|
|
|
|
cells: [
|
|
|
|
DataCell(getdatacel1(item)),
|
|
|
|
DataCell(
|
|
|
|
getdatacel2(item),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
2024-10-07 12:41:28 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-22 10:38:43 +00:00
|
|
|
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),
|
|
|
|
),
|
2024-10-07 12:41:28 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
getdatacel1(T location) {
|
|
|
|
if (location is Data) {
|
|
|
|
return Text1(title: "${location.address1}");
|
|
|
|
} 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 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}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|