DiscoverModule/lib/contacts_module/ui_screen/saved_profiles/saved_contact.dart

1314 lines
57 KiB
Dart
Raw Normal View History

2024-08-30 12:24:54 +00:00
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
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/hive_fun.dart';
import 'package:discover_module/contacts_module/provider_class/hcp%20_provider.dart';
import 'package:discover_module/contacts_module/storage_hive/aff_data/insert_aff.dart';
import 'package:discover_module/contacts_module/storage_hive/events_data/crud_event.dart';
import 'package:discover_module/contacts_module/storage_hive/kol_info/curd_kol.dart';
import 'package:discover_module/contacts_module/storage_hive/pub_data/curd_pub.dart';
import 'package:discover_module/contacts_module/storage_hive/trials_data/crud_trials.dart';
import 'package:discover_module/contacts_module/ui_screen/interactionform/util.dart';
import 'package:discover_module/contacts_module/ui_screen/saved_profiles/saved_profile_info.dart';
// import 'package:discover_module/constants.dart';
// import 'package:discover_module/custom_widget/text.dart';
// import 'package:discover_module/hive_fun.dart';
// import 'package:discover_module/provider_class/affiliationsprovider.dart';
// import 'package:discover_module/provider_class/events_provider.dart';
// import 'package:discover_module/provider_class/hcp%20_provider.dart';
// import 'package:discover_module/provider_class/publications_provider.dart';
// import 'package:discover_module/provider_class/trials_provider.dart';
// import 'package:discover_module/storage_hive/aff_data/insert_aff.dart';
// import 'package:discover_module/storage_hive/events_data/crud_event.dart';
// import 'package:discover_module/storage_hive/kol_info/curd_kol.dart';
// import 'package:discover_module/storage_hive/kol_info/kol_info_model_hive.dart';
// import 'package:discover_module/storage_hive/pub_data/curd_pub.dart';
// import 'package:discover_module/storage_hive/trials_data/crud_trials.dart';
// import 'package:discover_module/ui_screen/filters_menu.dart';
// import 'package:discover_module/ui_screen/interactionform/util.dart';
// import 'package:discover_module/ui_screen/new_new_profile.dart';
// import 'package:discover_module/ui_screen/new_new_profile_offline.dart';
// import 'package:discover_module/ui_screen/saved_profiles/saved_profile_info.dart';
2024-08-19 08:44:44 +00:00
import 'package:dropdown_button2/dropdown_button2.dart';
2024-08-13 10:46:26 +00:00
import 'package:dropdownfield2/dropdownfield2.dart';
2024-07-05 08:48:29 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2024-08-19 08:44:44 +00:00
import 'package:flutter/widgets.dart';
2024-07-26 07:17:34 +00:00
import 'package:flutter_svg/svg.dart';
2024-07-05 08:48:29 +00:00
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
2024-07-19 08:45:14 +00:00
import 'package:flutter_profile_picture/flutter_profile_picture.dart';
import 'package:hive_flutter/hive_flutter.dart';
2024-10-07 12:41:28 +00:00
// import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart';
2024-07-05 08:48:29 +00:00
2024-10-07 12:41:28 +00:00
class SavedContacts1 extends StatefulWidget {
const SavedContacts1({Key? key}) : super(key: key);
2024-07-05 08:48:29 +00:00
@override
2024-10-07 12:41:28 +00:00
State<SavedContacts1> createState() => SavedContacts1State();
2024-07-05 08:48:29 +00:00
}
2024-10-07 12:41:28 +00:00
class SavedContacts1State extends State<SavedContacts1> {
2024-08-19 08:44:44 +00:00
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
2024-08-30 12:24:54 +00:00
// final contactBox = Hive.box("mycontact");
2024-07-05 08:48:29 +00:00
bool _switchValue = false;
bool isOnline2 = true;
2024-07-19 08:45:14 +00:00
final TextEditingController _searchController = TextEditingController();
2024-08-13 10:46:26 +00:00
List<String> ddlist = ["aaaa", 'bbb'];
// List<String> ddlist = ['Option 1', 'Option 2', 'Option 3'];
String _selectedValue = '';
2024-08-19 08:44:44 +00:00
String? _selectedValue1;
2024-08-13 10:46:26 +00:00
String dropdownvalue = 'Profile Type';
// List of items in our dropdown menu
var items = [
'Profile Type',
'HCP Name',
'Speciality',
'Country',
'Region',
'State',
'City',
'List',
'Organization',
'Event',
];
2024-08-19 08:44:44 +00:00
bool isSearchClickd = false;
final List<String> _items = ['Option 1', 'Option 2', 'Option 3'];
TextEditingController textEditingController = TextEditingController();
List displayedHCPList = [];
2024-08-30 12:24:54 +00:00
bool ActiveConnection = false;
String T = "";
bool isChecked = false;
//final Set<int> _selectedIndices = Set();
2024-10-07 12:41:28 +00:00
final List<String> _selectedIndices = [];
2024-08-30 12:24:54 +00:00
final List<int> _selectedremoveIndices = [];
bool longpress = false;
bool longpressmy = false;
2024-10-07 12:41:28 +00:00
List offlinekoldata = [];
2024-08-19 08:44:44 +00:00
2024-07-05 08:48:29 +00:00
@override
void initState() {
super.initState();
2024-10-07 12:41:28 +00:00
data();
}
2024-08-19 08:44:44 +00:00
2024-10-07 12:41:28 +00:00
data() async {
offlinekoldata = await retrievekol();
setState(() {});
2024-08-19 08:44:44 +00:00
2024-10-07 12:41:28 +00:00
print("Lenghtttthhhh: ${offlinekoldata.length}");
2024-08-30 12:24:54 +00:00
}
2024-08-19 08:44:44 +00:00
2024-07-05 08:48:29 +00:00
@override
Widget build(BuildContext context) {
2024-10-07 12:41:28 +00:00
// print("ProfileType $dropdownvalue, $_selectedValue1");
2024-08-13 10:46:26 +00:00
2024-08-30 12:24:54 +00:00
// print("all StoredUser: ${HiveFunctions.getAllUsers11()}");
2024-08-19 08:44:44 +00:00
if (_selectedValue1 == "Profile Type") {
print("PPPP11");
2024-08-13 10:46:26 +00:00
setState(() {
ddlist = [
"All Profile",
'Full Profile',
'Basic Profile',
];
});
2024-08-19 08:44:44 +00:00
} else if (_selectedValue1 == "HCP Name") {
2024-10-07 12:41:28 +00:00
print("kkkofflinekoldata ${offlinekoldata.map((e) => e.name)}");
List<String> data = offlinekoldata.map((e) => e.name.toString()).toList();
print("Kol_name_data: $data");
2024-08-19 08:44:44 +00:00
setState(() {
2024-10-07 12:41:28 +00:00
ddlist = data;
2024-08-19 08:44:44 +00:00
});
} else if (_selectedValue1 == "Speciality") {
print("kkk");
2024-10-07 12:41:28 +00:00
List<String> dataspl =
offlinekoldata.map((e) => e.speciality.toString()).toList();
2024-08-19 08:44:44 +00:00
setState(() {
2024-10-07 12:41:28 +00:00
ddlist = dataspl;
2024-08-19 08:44:44 +00:00
});
2024-10-07 12:41:28 +00:00
// setState(() {
// ddlist = [
// "Cardiovascular Disease",
// 'Interventional Cardiology',
// "Cardiovascular Disease",
// ];
// });
2024-08-19 08:44:44 +00:00
} else if (_selectedValue1 == "Country") {
print("kkk");
setState(() {
ddlist = [
"United States",
"United States",
"United States",
];
});
} else if (_selectedValue1 == "State") {
print("kkk");
setState(() {
ddlist = [
"Karnataka",
'Karnataka',
'Karnataka',
];
});
} else if (_selectedValue1 == "City") {
print("kkk");
setState(() {
ddlist = [
"Hubli",
'Hubli',
'Hubli',
];
});
2024-08-13 10:46:26 +00:00
}
2024-07-05 08:48:29 +00:00
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132)));
return SafeArea(
child: Scaffold(
2024-08-19 08:44:44 +00:00
key: _scaffoldKey, // Assign the key to the Scaffold
2024-08-13 10:46:26 +00:00
// backgroundColor: const Color.fromARGB(255, 246, 248, 252),
// backgroundColor: Color.fromARGB(255, 255, 242, 0.92),
2024-11-22 10:38:43 +00:00
2024-07-26 07:17:34 +00:00
appBar: AppBar(
2024-11-22 10:38:43 +00:00
title: Text('Saved Profiles'),
2024-07-26 07:17:34 +00:00
),
2024-11-22 10:38:43 +00:00
// appBar: AppBar(
// automaticallyImplyLeading: false,
// title: isSearchClickd
// ? Container(
// height: 40,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(5.0)),
// child: TextField(
// controller: _searchController,
// onChanged: (value) {
// setState(() {});
// },
// decoration: InputDecoration(
// fillColor: Constants.k2color,
// contentPadding: EdgeInsets.symmetric(vertical: 9.0),
// border: OutlineInputBorder(),
// hintText: "Search",
// // labelText: ' Search',
// prefixIcon: Icon(
// Icons.search,
// ),
// ),
// ),
// )
// : Text("Offline Contacts"),
// actions: [
// IconButton(
// onPressed: () {
// setState(() {
// isSearchClickd = !isSearchClickd;
// if (!isSearchClickd) {
// _searchController.clear();
// }
// });
// },
// icon: Icon(isSearchClickd ? Icons.close : Icons.search))
// ],
// ),
2024-08-13 10:46:26 +00:00
endDrawer: Drawer(
2024-10-07 12:41:28 +00:00
//width: MediaQuery.of(context).size.width * 99.2,
2024-08-13 10:46:26 +00:00
child: listdata(),
),
2024-10-07 12:41:28 +00:00
body:
// ListView.builder(
// itemCount: offlinekoldata.length,
// itemBuilder: (context, index) {
// var data11 = offlinekoldata[index];
// print("Imammmm_data111: $data11");
// return ListTile(
// title: Text("dd ${data11.name}"),
// );
// })
Consumer<hcpProvider>(
2024-07-19 08:45:14 +00:00
builder: (context, hcpProvider, child) {
2024-08-19 08:44:44 +00:00
print("_selectedValueConsumerConsumer_isss: $_selectedValue");
if (_selectedValue.isNotEmpty) {
_searchController.text = _selectedValue;
}
2024-10-07 12:41:28 +00:00
// displayedHCPList = hcpProvider.searchHCP(_searchController.text);
// offlinekoldata = HiveFunctions.OfflineStored_getindexUser(
// _searchController.text);
// where((hcp) =>
// hcp['name'].toLowerCase().contains(query.toLowerCase())
offlinekoldata = offlinekoldata
.where((element) =>
element.name
.toLowerCase()
.contains(_searchController.text.toLowerCase()) ||
element.speciality
.toLowerCase()
.contains(_searchController.text.toLowerCase()) ||
element.addr
.toLowerCase()
.contains(_searchController.text.toLowerCase()))
.toList();
2024-07-19 08:45:14 +00:00
2024-07-05 08:48:29 +00:00
return Column(
2024-08-19 08:44:44 +00:00
crossAxisAlignment: CrossAxisAlignment.start,
2024-07-05 08:48:29 +00:00
children: [
Row(
2024-08-19 08:44:44 +00:00
mainAxisAlignment: MainAxisAlignment.spaceBetween,
//mainAxisSize: MainAxisSize.min,
2024-07-05 08:48:29 +00:00
children: [
2024-08-19 08:44:44 +00:00
// _switchValue
// ? const Text(
// 'All',
// style: TextStyle(
// fontSize: 12,
// decoration: TextDecoration.lineThrough,
// decorationThickness: 0.85,
// ),
// )
// : const Text(
// 'All',
// style: TextStyle(
// fontSize: 12,
// ),
// ),
Container(
child: Wrap(
children: [
Padding(
padding:
const EdgeInsets.only(left: 8.0, right: 2.0),
child: CupertinoSwitch(
activeColor: Color.fromARGB(255, 0, 71, 132),
value: _switchValue,
onChanged: (value) {
setState(() {
_switchValue = value;
});
},
),
2024-07-05 08:48:29 +00:00
),
2024-08-19 08:44:44 +00:00
Padding(
2024-10-07 12:41:28 +00:00
padding:
const EdgeInsets.only(right: 8.0, top: 9.0),
child: !_switchValue
? Text1(
title: 'My Contacts',
txtfont: 15,
txtcolor: Colors.grey,
)
// Text(
// 'My Contacts',
// style: TextStyle(
// fontSize: 15, color: Colors.grey),
// )
: Text1(
title: 'My Contacts',
txtfont: 15,
txtcolor: Colors.grey,
)
// const Text(
// 'My Contacts',
// style: TextStyle(
// fontSize: 15,
// ),
// ),
)
2024-08-19 08:44:44 +00:00
],
),
2024-07-05 08:48:29 +00:00
),
2024-08-19 08:44:44 +00:00
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Row(
children: [
2024-10-07 12:41:28 +00:00
Text1(title: 'My Filters'),
2024-08-19 08:44:44 +00:00
IconButton(
onPressed: () {
2024-10-07 12:41:28 +00:00
retrievekol();
retrieveAffiliations();
retrievePublications();
retrieveEventss();
retrieveTrials();
2024-08-19 08:44:44 +00:00
_scaffoldKey.currentState?.openEndDrawer();
},
icon: Icon(
Icons.sort,
size: 30,
)),
],
),
)
2024-07-05 08:48:29 +00:00
],
),
2024-08-19 08:44:44 +00:00
// Row(
// children: [
// Expanded(
// child: Text(
// _switchValue ? "My Contacts" : "All Contacts",
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 20.0,
// fontWeight: FontWeight.w500,
// ),
// ),
// ),
// ],
// ),
// Padding(
// padding: const EdgeInsets.only(
// top: 8.0, bottom: 8.0, left: 20.0, right: 20.0),
// child: Center(
// child: TextField(
// controller: _searchController,
// onChanged: (value) {
// setState(() {});
// },
// decoration: InputDecoration(
// fillColor: Constants.k2color,
// contentPadding: EdgeInsets.symmetric(vertical: 9.0),
// border: OutlineInputBorder(),
// labelText: ' Search',
// prefixIcon: Icon(
// Icons.search,
// ),
// ),
// ),
// ),
// ),
SizedBox(
height: 5,
2024-07-12 08:40:20 +00:00
),
2024-08-19 08:44:44 +00:00
2024-08-30 12:24:54 +00:00
!_switchValue
? Expanded(
child: ListView.builder(
2024-10-07 12:41:28 +00:00
itemCount: offlinekoldata.length,
2024-08-30 12:24:54 +00:00
itemBuilder: (BuildContext context, int index) {
2024-10-07 12:41:28 +00:00
var data = offlinekoldata[index];
2024-08-30 12:24:54 +00:00
2024-10-07 12:41:28 +00:00
print(
"CheckinggggImage_pathOffline: ${data.img_path}");
2024-08-30 12:24:54 +00:00
return Column(
children: [
ListTile(
onLongPress: () {
print("LongPresss");
setState(() {
longpress = true;
});
},
onTap: () async {
2024-10-07 12:41:28 +00:00
print("Check_data11123 = ${data.name}");
2024-08-30 12:24:54 +00:00
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
2024-10-07 12:41:28 +00:00
SavedNewProfile1(text: data),
2024-08-30 12:24:54 +00:00
),
);
},
2024-10-07 12:41:28 +00:00
leading: data.img_path == ""
2024-08-30 12:24:54 +00:00
? ProfilePicture(
2024-10-07 12:41:28 +00:00
name: data.name,
2024-08-30 12:24:54 +00:00
radius: 30,
fontsize: 12,
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(30),
child: CachedNetworkImage(
2024-10-07 12:41:28 +00:00
imageUrl: data.img_path,
2024-08-30 12:24:54 +00:00
imageBuilder:
(context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
// placeholder: (context, url) =>
// CircularProgressIndicator(),
// errorWidget: (context, url, error) =>
// Icon(Icons.error),
),
),
),
trailing: Visibility(
visible: longpress,
child: Checkbox(
value: _selectedIndices
2024-10-07 12:41:28 +00:00
.contains(data.id.toString()),
2024-08-30 12:24:54 +00:00
onChanged: (value) {
// setState(() {
// _selectedIndices.add(data["id"]);
// // isChecked = value!;
// });
setState(() {
if (value!) {
2024-10-07 12:41:28 +00:00
_selectedIndices
.add(data.id.toString());
2024-08-30 12:24:54 +00:00
} else {
_selectedIndices
2024-10-07 12:41:28 +00:00
.remove(data.id.toString());
2024-08-30 12:24:54 +00:00
}
print(
2024-10-07 12:41:28 +00:00
"id_total123: ${_selectedIndices}");
2024-08-30 12:24:54 +00:00
});
}),
),
2024-10-07 12:41:28 +00:00
title: Text1(
title: data.name,
fontweight: FontWeight.bold,
txtfont: isTablet ? 22 : 16,
2024-07-19 08:45:14 +00:00
),
2024-10-07 12:41:28 +00:00
// Text(
// "${data["name"]}",
// style: TextStyle(
// fontSize: isTablet ? 22 : 16,
// fontWeight: FontWeight.bold,
// ),
// ),
2024-08-30 12:24:54 +00:00
subtitle: Column(
children: [
Row(
children: [
Expanded(
2024-10-07 12:41:28 +00:00
child: Text1(
title: data.speciality ??
data['spl'],
fontweight: FontWeight.normal,
txtfont: isTablet ? 20 : 14,
2024-08-30 12:24:54 +00:00
),
2024-10-07 12:41:28 +00:00
// Text(
// "${data["speciality"] ?? data['spl']},",
// style: TextStyle(
// fontSize: isTablet ? 20 : 14,
// fontWeight: FontWeight.normal,
// ),
// ),
2024-08-30 12:24:54 +00:00
),
],
),
Row(
children: [
2024-10-07 12:41:28 +00:00
Text1(
title: data.name ?? '',
fontweight: FontWeight.normal,
txtfont: 14,
2024-08-30 12:24:54 +00:00
),
2024-10-07 12:41:28 +00:00
// Text(
// "${data["State"] ?? ""},",
// style: const TextStyle(
// fontSize: 14.0,
// fontWeight: FontWeight.normal,
// ),
// ),
2024-08-30 12:24:54 +00:00
SizedBox(
width: 3.0,
),
Expanded(
2024-10-07 12:41:28 +00:00
child: Text1(
title: data.name ?? '',
fontweight: FontWeight.normal,
txtfont: 14,
2024-08-30 12:24:54 +00:00
),
2024-10-07 12:41:28 +00:00
// Text(
// "${data["Country"] ?? ""}",
// style: const TextStyle(
// fontSize: 14.0,
// fontWeight: FontWeight.normal,
// ),
// ),
2024-08-30 12:24:54 +00:00
),
],
),
// Row(
// children: [
// Text(
// "Added by Pooja k\nAdded on 01/07/2023",
// style: const TextStyle(
// fontSize: 12.0,
// fontWeight: FontWeight.normal,
// ),
// )
// ],
// )
],
),
),
2024-10-07 12:41:28 +00:00
Row(
2024-08-30 12:24:54 +00:00
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
2024-08-19 08:44:44 +00:00
children: [
2024-08-30 12:24:54 +00:00
Padding(
padding: EdgeInsets.only(left: 10.0),
2024-10-07 12:41:28 +00:00
child: Text1(
title: "Added by Pooja k",
fontweight: FontWeight.normal,
txtfont: 14,
2024-08-19 08:44:44 +00:00
),
),
2024-08-30 12:24:54 +00:00
Padding(
padding: EdgeInsets.only(right: 10.0),
2024-10-07 12:41:28 +00:00
child: Text1(
title: "Added on 01/07/2023",
fontweight: FontWeight.normal,
txtfont: 14,
2024-08-30 12:24:54 +00:00
),
)
2024-08-19 08:44:44 +00:00
],
),
2024-08-30 12:24:54 +00:00
Divider(),
],
);
},
),
)
: Expanded(
child: ListView.builder(
itemCount: HiveFunctions.getAllUsers11().length,
itemBuilder: (BuildContext context, int index) {
var data = HiveFunctions.getAllUsers11()[index];
print("CheckinggggImage_path: ${data['img_path']}");
print(
"CheckinggggImage_path: ${data['name']},${data['inid']}");
return Column(
children: [
ListTile(
onLongPress: () {
print("LongPresss");
setState(() {
longpressmy = true;
});
},
onTap: () async {
2024-10-07 12:41:28 +00:00
print("Check_data12345 = $data");
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// NewProfile1(text: data),
// ),
// );
2024-08-30 12:24:54 +00:00
},
leading: data["img_path"] == ""
? ProfilePicture(
name: data["name"],
radius: 30,
fontsize: 12,
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(30),
child: CachedNetworkImage(
imageUrl: data["img_path"],
imageBuilder:
(context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
// placeholder: (context, url) =>
// CircularProgressIndicator(),
// errorWidget: (context, url, error) =>
// Icon(Icons.error),
),
),
),
trailing: Visibility(
visible: longpressmy,
child: Checkbox(
value: _selectedremoveIndices
.contains(data["id"]),
onChanged: (value) {
setState(() {
if (value!) {
_selectedremoveIndices
.add(data["id"]);
} else {
_selectedremoveIndices
.remove(data["id"]);
}
print(
"id_total: ${_selectedremoveIndices}");
});
}),
),
title: Text(
"${data["name"]}",
style: TextStyle(
fontSize: isTablet ? 22 : 16,
fontWeight: FontWeight.bold,
),
),
subtitle: Column(
children: [
Row(
children: [
Expanded(
child: Text(
"${data["speciality"] ?? data['spl']},",
style: TextStyle(
fontSize: isTablet ? 20 : 14,
fontWeight: FontWeight.normal,
),
),
),
],
),
Row(
children: [
Text(
"${data["addr"]},",
style: const TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.normal,
),
),
],
),
],
),
),
const Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
2024-07-19 08:45:14 +00:00
children: [
2024-08-30 12:24:54 +00:00
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Text(
"Added by Pooja k",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
),
2024-07-19 08:45:14 +00:00
),
),
2024-08-30 12:24:54 +00:00
Padding(
padding: EdgeInsets.only(right: 10.0),
child: Text(
"Added on 01/07/2023",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
),
),
)
2024-07-19 08:45:14 +00:00
],
),
2024-08-30 12:24:54 +00:00
Divider(),
2024-07-19 08:45:14 +00:00
],
2024-08-30 12:24:54 +00:00
);
},
),
),
!_switchValue
? Align(
alignment: Alignment.bottomCenter,
child: longpress
? Container(
color: const Color.fromARGB(255, 251, 242, 242),
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () async {
print("Selected: ${_selectedIndices}");
print(
"Selected: ${_selectedIndices.length}");
for (int i = 0;
i < _selectedIndices.length;
i++) {
2024-10-07 12:41:28 +00:00
// print(
// 'The id id : ${_selectedIndices[i]}');
// //List<_Row> _rows = [];
2024-08-30 12:24:54 +00:00
2024-10-07 12:41:28 +00:00
// final row = displayedHCPList[
// _selectedIndices[i] - 1];
// var data = displayedHCPList[i];
2024-08-30 12:24:54 +00:00
2024-10-07 12:41:28 +00:00
// print(
// "checking_value_istrends: ${_selectedIndices[i]},${row["name"]}, ${row["id"]}");
// int autoIncrementKey1 =
// await getNextAutoIncrementValue();
// print(autoIncrementKey1);
// HiveFunctions.createUser({
// "inid": autoIncrementKey1,
// "id": autoIncrementKey1,
// "name": row["name"],
// "org": "med",
// "addr": row["addr"],
// "phone": row["phone_no"],
// "phone_no": row["phone_no"],
// "email": row["email"],
// "summarry": row["summarry"],
// "speciality": row["speciality"],
// "sub_speciality":
// row["sub_speciality"],
// "img_path": row["img_path"],
// });
2024-08-30 12:24:54 +00:00
}
_showMyDialog(
"Selected contact has been added to my contacts ");
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.add,
color: Colors.green,
),
),
Text(
'Add to My Contacts',
style: TextStyle(
color: Colors.black,
fontSize: 14.0),
),
],
),
),
Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.download,
color: Colors.blue,
),
),
GestureDetector(
onTap: () {},
child: Text(
'Download',
style:
TextStyle(color: Colors.black),
),
),
],
),
GestureDetector(
onTap: () {
setState(() {
longpress = false;
_selectedIndices.clear();
_selectedremoveIndices.clear();
});
},
child: const Row(
children: [
Padding(
padding: EdgeInsets.all(15.0),
child: Icon(
Icons.close,
color: Colors.red,
),
),
Text(
'Cancel',
style:
TextStyle(color: Colors.black),
),
],
),
),
2024-10-07 12:41:28 +00:00
Expanded(
child: GestureDetector(
onTap: () async {
print(
"Selected: ${_selectedIndices}");
for (int i = 0;
i < _selectedIndices.length;
i++) {
print(
'The id id : ${_selectedIndices[i]}');
// Map<String, dynamic>? row =
// findRecordById(offlinekoldata,
// _selectedIndices[i]);
// print("Storingggg_isss:Row $row");
// print(
// "checking_Deleted_istrends: ${_selectedIndices[i]},${row!["license_no"]}, ${row["email"]}, ${row["img_path"]} ");
await deletekol(
_selectedIndices[i]);
_showMyDialog(
"selected contact has been removed");
}
// print(
// "CheckingAfflist: $affilist");
setState(() {});
},
child: const Row(
children: [
Padding(
padding: EdgeInsets.all(15.0),
child: Icon(
Icons.save,
color: Colors.deepOrange,
),
),
Padding(
padding:
EdgeInsets.only(top: 15.0),
child: Text(
'Delete Offline',
style: TextStyle(
color: Colors.black),
),
),
],
),
),
),
2024-08-30 12:24:54 +00:00
],
2024-08-13 10:46:26 +00:00
),
2024-08-30 12:24:54 +00:00
)
: Container(),
)
: Align(
alignment: Alignment.bottomCenter,
child: longpressmy
? Container(
color: const Color.fromARGB(255, 251, 242, 242),
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () async {
print(
"SelectedRemoveee: ${_selectedremoveIndices}");
print(
"Selected: ${_selectedremoveIndices.length}");
for (int i = 0;
i < _selectedremoveIndices.length;
i++) {
print(
'The id id : ${_selectedremoveIndices[i]}');
//List<_Row> _rows = [];
// final row = displayedHCPList[
// _selectedremoveIndices[i] - 1];
// var data = displayedHCPList[i];
final row =
await HiveFunctions.getuser(
_selectedremoveIndices[i]);
// var data = HiveFunctions.getuser()[i];
print("Delete_Row ${row[i]}");
print("Delete_Row ${row[i]["inid"]}");
// print(
// "checking_valueRemove_istrends: ${_selectedremoveIndices[i]},${row["name"]}, ${row["id"]},${row["inid"]}");
//HiveFunctions.addno(_selectedIndices[i]);
// HiveFunctions.removeno(_selectedremoveIndices[i]);
final row1 =
await HiveFunctions.deleteUser11(
row[i]["inid"]);
setState(() {});
// HiveFunctions.deleteUser(_selectedremoveIndices);
}
_showMyDialog(
"selected contact has been removed");
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.remove,
color: Colors.green,
),
),
Text(
'Remove from My Contacts',
style:
TextStyle(color: Colors.black),
),
],
),
),
Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.download,
color: Colors.blue,
),
),
GestureDetector(
onTap: () {},
child: Text(
'Download',
style:
TextStyle(color: Colors.black),
),
),
],
),
GestureDetector(
onTap: () {
setState(() {
longpressmy = false;
_selectedIndices.clear();
_selectedremoveIndices.clear();
});
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.close,
color: Colors.red,
),
),
Text(
'Cancel',
style: TextStyle(
color: Constants.k2color),
),
],
),
),
],
2024-08-13 10:46:26 +00:00
),
)
2024-08-30 12:24:54 +00:00
: Container(),
),
2024-07-19 08:45:14 +00:00
],
);
},
),
2024-07-05 08:48:29 +00:00
),
);
}
2024-08-13 10:46:26 +00:00
listdata() {
return ListView(
children: <Widget>[
// DrawerHeader removed
ListTile(
title: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(
2024-08-19 08:44:44 +00:00
Icons.sort,
2024-08-13 10:46:26 +00:00
size: 30.0,
),
const Text(
"Filters",
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold),
),
GestureDetector(
onTap: () {
Navigator.pop(context);
// print("hiii");
},
child: const Icon(Icons.cancel))
],
),
),
),
ListTile(
2024-08-19 08:44:44 +00:00
title: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
OutlinedButton(
onPressed: () {
//setState(() {});
Navigator.push(
context,
2024-10-07 12:41:28 +00:00
MaterialPageRoute(builder: (context) => SavedContacts1()),
2024-08-19 08:44:44 +00:00
).then((value) => setState(() {}));
print("refresh done ");
// })
},
child: Text(
'Reset Filter',
style: TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
2024-08-13 10:46:26 +00:00
),
),
2024-08-19 08:44:44 +00:00
],
),
),
2024-08-13 10:46:26 +00:00
2024-08-19 08:44:44 +00:00
ListTile(
title: DropdownButtonHideUnderline(
child: DropdownButtonFormField2<String>(
hint: Text("Select the Type"),
decoration: InputDecoration(
// Add Horizontal padding using menuItemStyleData.padding so it matches
// the menu padding when button's width is not specified.
isDense: true,
contentPadding: const EdgeInsets.symmetric(vertical: 9),
2024-08-13 10:46:26 +00:00
2024-08-19 08:44:44 +00:00
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
// Add more decoration..
),
isExpanded: true,
value: _selectedValue1,
items: items.map((String item) {
return DropdownMenuItem<String>(
value: item,
child: Text(item),
2024-08-13 10:46:26 +00:00
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
2024-08-19 08:44:44 +00:00
_selectedValue1 = newValue;
2024-08-13 10:46:26 +00:00
});
},
2024-08-19 08:44:44 +00:00
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.symmetric(horizontal: 16),
height: 50,
width: 200,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
),
dropdownSearchData: DropdownSearchData(
searchController: textEditingController,
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
// padding: const EdgeInsets.only(
// top: 8,
// bottom: 4,
// right: 8,
// left: 8,
// ),
child: TextFormField(
expands: true,
maxLines: null,
controller: textEditingController,
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 18,
),
hintText: 'Search for an item...',
hintStyle: const TextStyle(fontSize: 12),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
searchMatchFn: (item, searchValue) {
final itemString = item.value.toString().toLowerCase();
final searchString = searchValue.toLowerCase();
return itemString.contains(searchString);
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
textEditingController.clear();
}
},
iconStyleData: IconStyleData(
icon: Icon(Icons.arrow_drop_down),
iconSize: 20,
),
2024-08-13 10:46:26 +00:00
),
),
),
ListTile(
title: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.all(3.5),
child: DropDownField(
hintText: 'Select an option',
items: ddlist,
onValueChanged: (newValue) {
setState(() {
_selectedValue = newValue;
});
},
value: _selectedValue,
),
),
),
),
2024-10-07 12:41:28 +00:00
2024-08-19 08:44:44 +00:00
// ListTile(
2024-10-07 12:41:28 +00:00
// title: Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// OutlinedButton(
// onPressed: () {
// setState(() {});
// print("refresh done 111");
// },
// child: Text(
// 'Saved Profiles',
// style: TextStyle(color: Constants.k2color),
// ),
// style: OutlinedButton.styleFrom(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(12),
// ),
2024-08-19 08:44:44 +00:00
// ),
// ),
2024-10-07 12:41:28 +00:00
// ],
2024-08-19 08:44:44 +00:00
// ),
2024-10-07 12:41:28 +00:00
// ),
2024-08-13 10:46:26 +00:00
],
);
}
2024-08-19 08:44:44 +00:00
filterss(String selectedValue) async {
setState(() {
print("_selectedValue_isss: $_selectedValue");
});
}
2024-08-30 12:24:54 +00:00
Future<void> _showMyDialog(String data) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Successfully'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
// Text('This is a demo alert dialog.'),
Text(data),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
setState(() {
_selectedIndices.clear();
_selectedremoveIndices.clear();
longpress = false;
longpressmy = false;
});
},
),
],
);
},
);
}
Future<int> getNextAutoIncrementValue() async {
var counterBox = await Hive.openBox<int>('counterBox');
if (!counterBox.containsKey('counter')) {
counterBox.put('counter', 0);
}
int? counter = counterBox.get('counter');
counterBox.put('counter', counter! + 1);
await counterBox.close();
return counter;
}
2024-10-07 12:41:28 +00:00
Map<String, dynamic> findRecordById(
List displayedHCPList, String selectedIndic) {
// print(
// "Gettt11111 ${displayedHCPList.firstWhere((element) => element['id'] == int.parse(selectedIndic))}");
return displayedHCPList
.firstWhere((element) => element['id'] == int.parse(selectedIndic));
}
2024-08-19 08:44:44 +00:00
}