DiscoverModule/lib/ui_screen/new_contacts.dart

683 lines
24 KiB
Dart
Raw Normal View History

2024-07-19 08:45:14 +00:00
import 'package:discover_module/constants.dart';
2024-07-05 08:48:29 +00:00
import 'package:discover_module/provider_class/hcp%20_provider.dart';
2024-08-13 10:46:26 +00:00
import 'package:discover_module/ui_screen/filters_menu.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-07-05 08:48:29 +00:00
import 'package:discover_module/ui_screen/profile.dart';
2024-07-19 08:45:14 +00:00
import 'package:discover_module/ui_screen/new_profile.dart';
import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart';
2024-07-05 08:48:29 +00:00
class Contacts1 extends StatefulWidget {
const Contacts1({Key? key}) : super(key: key);
@override
State<Contacts1> createState() => _Contacts1State();
}
class _Contacts1State extends State<Contacts1> {
2024-08-19 08:44:44 +00:00
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
2024-07-05 08:48:29 +00:00
final _contactBox = Hive.box("mycontact");
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-07-05 08:48:29 +00:00
@override
void initState() {
super.initState();
2024-07-19 08:45:14 +00:00
Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
2024-08-19 08:44:44 +00:00
// getDropdownlist();
2024-07-05 08:48:29 +00:00
}
2024-08-19 08:44:44 +00:00
// getDropdownlist() {
// final provider =
// Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
// final datta = provider.list;
// print("Providerrrrr_is ${datta}");
// }
2024-07-05 08:48:29 +00:00
@override
Widget build(BuildContext context) {
2024-08-19 08:44:44 +00:00
print("ProfileType $dropdownvalue, $_selectedValue1");
2024-08-13 10:46:26 +00:00
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") {
print("kkk");
setState(() {
ddlist = [
'Abraham, William',
"Abbas,Samer",
'Butler, Javed',
];
});
} else if (_selectedValue1 == "Speciality") {
print("kkk");
setState(() {
ddlist = [
"Cardiovascular Disease",
'Interventional Cardiology',
"Cardiovascular Disease",
];
});
} 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-07-26 07:17:34 +00:00
appBar: AppBar(
automaticallyImplyLeading: false,
2024-08-19 08:44:44 +00:00
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("Contacts"),
actions: [
IconButton(
onPressed: () {
setState(() {
isSearchClickd = !isSearchClickd;
if (!isSearchClickd) {
_searchController.clear();
}
});
},
icon: Icon(isSearchClickd ? Icons.close : Icons.search))
],
2024-07-26 07:17:34 +00:00
),
2024-08-13 10:46:26 +00:00
endDrawer: Drawer(
// width: MediaQuery.of(context).size.width * 99.2,
child: listdata(),
),
2024-07-05 08:48:29 +00:00
body: 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;
}
displayedHCPList = hcpProvider.searchHCP(_searchController.text);
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(
padding:
const EdgeInsets.only(right: 8.0, top: 9.0),
child: !_switchValue
? const Text(
'My Contacts',
style: TextStyle(
fontSize: 15, color: Colors.grey),
)
: const Text(
'My Contacts',
style: TextStyle(
fontSize: 15,
),
2024-07-05 08:48:29 +00:00
),
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: [
Text("Filters"),
IconButton(
onPressed: () {
_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-07-19 08:45:14 +00:00
Expanded(
child: ListView.builder(
itemCount: displayedHCPList.length,
itemBuilder: (BuildContext context, int index) {
var data = displayedHCPList[index];
return Column(
children: [
ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NewProfile(text: data),
),
);
},
leading: data["img_path"] == null
? ProfilePicture(
name: data["name"],
radius: 20,
fontsize: 12,
)
: ClipOval(
child: SizedBox.fromSize(
2024-08-19 08:44:44 +00:00
size: Size.fromRadius(30), // Image radius
child: Image.network(data["img_path"],
fit: BoxFit.fill),
2024-07-19 08:45:14 +00:00
),
),
2024-08-19 08:44:44 +00:00
// trailing: Icon(
// Icons.person_add_rounded,
// color: Constants.k2color,
// size: 30.0,
// ),
2024-07-19 08:45:14 +00:00
title: Text(
"${data["name"]}",
style: const TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
subtitle: Column(
children: [
2024-08-19 08:44:44 +00:00
Row(
children: [
Expanded(
child: Text(
"${data["speciality"]},",
style: const TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.normal,
),
),
),
],
),
2024-07-19 08:45:14 +00:00
Row(
children: [
Text(
2024-08-19 08:44:44 +00:00
"${data["addr"]},",
2024-07-19 08:45:14 +00:00
style: const TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.normal,
),
),
],
),
2024-08-13 10:46:26 +00:00
// Row(
// children: [
// Text(
// "Added by Pooja k\nAdded on 01/07/2023",
// style: const TextStyle(
// fontSize: 12.0,
// fontWeight: FontWeight.normal,
// ),
// )
// ],
// )
2024-07-19 08:45:14 +00:00
],
),
),
2024-08-13 10:46:26 +00:00
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Text(
"Added by Pooja k",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
),
),
),
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
Divider(),
],
);
},
2024-07-12 08:40:20 +00:00
),
),
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,
MaterialPageRoute(builder: (context) => Contacts1()),
).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
],
),
),
// ListTile(
// title: SizedBox(
// width: MediaQuery.of(context).size.width,
// child: DropdownButtonFormField(
// decoration: InputDecoration(
// enabledBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10),
// borderSide: BorderSide(width: 1, color: Colors.black)),
// focusedBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(10),
// borderSide: BorderSide(width: 1, color: Colors.black),
// ),
// ),
// value: dropdownvalue,
// items: items.map((String items) {
// return DropdownMenuItem(
// value: items,
// child: Text(
// items,
// style: TextStyle(fontSize: 14.0),
// ),
// );
// }).toList(),
// // After selecting the desired option,it will
// // change button value to selected value
// onChanged: (String? newValue) {
// setState(() {
// dropdownvalue = newValue!;
// });
// },
// ),
// ),
// ),
2024-08-13 10:46:26 +00:00
2024-08-19 08:44:44 +00:00
ListTile(
title: DropdownButtonHideUnderline(
child: DropdownButtonFormField2<String>(
// decoration: InputDecoration(
// border: OutlineInputBorder(),
// labelText: 'Select an option',
// ),
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: ButtonStyleData(
// height: 50,
// padding: EdgeInsets.symmetric(horizontal: 14),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// border: Border.all(color: Colors.grey),
// ),
// ),
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-08-19 08:44:44 +00:00
// ListTile(
// title: Padding(
// padding: const EdgeInsets.only(left: 35.0, right: 35.0),
// child: OutlinedButton(
// onPressed: () async {
// filterss(_selectedValue);
// },
// child: Text(
// '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
filterss(String selectedValue) async {
setState(() {
print("_selectedValue_isss: $_selectedValue");
});
}
}