2024-06-28 08:14:42 +00:00
|
|
|
// import 'package:discover_module/hive_fun.dart';
|
|
|
|
// import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart';
|
|
|
|
|
|
|
|
// import 'package:discover_module/provider_class/hcp%20_provider.dart';
|
|
|
|
// import 'package:discover_module/ui_screen/profile.dart';
|
|
|
|
// import 'package:discover_module/ui_screen/ranking.dart';
|
|
|
|
// import 'package:flutter/cupertino.dart';
|
|
|
|
// import 'package:flutter/material.dart';
|
|
|
|
// import 'package:flutter/services.dart';
|
|
|
|
// import 'package:flutter/widgets.dart';
|
|
|
|
// import 'package:flutter_profile_picture/flutter_profile_picture.dart';
|
|
|
|
// import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
// import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
// class Contacts extends StatefulWidget {
|
|
|
|
// const Contacts({super.key});
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// State<Contacts> createState() => _ContactsState();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// class _ContactsState extends State<Contacts> {
|
|
|
|
// // final _contactbox = Hive.box('mycontact');
|
|
|
|
// static final _contactbox = Hive.box("mycontact");
|
|
|
|
|
|
|
|
// bool _switchValue = false;
|
|
|
|
|
|
|
|
// bool isOnline2 = false;
|
|
|
|
|
|
|
|
// // List<dynamic> alldata = _contactbox.values.toList();
|
|
|
|
// @override
|
|
|
|
// void initState() {
|
|
|
|
// // TODO: implement initState
|
|
|
|
// super.initState();
|
|
|
|
// setupConnectivityListener();
|
|
|
|
|
|
|
|
// getcall();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// NetworkConnectivity networkConnectivity = NetworkConnectivity();
|
|
|
|
|
|
|
|
// Future<void> setupConnectivityListener() async {
|
|
|
|
// while (true) {
|
|
|
|
// bool isOnline = await networkConnectivity.isInternetAvailable();
|
|
|
|
// print('Internetcontact available: $isOnline');
|
|
|
|
// // Perform actions based on connectivity status
|
|
|
|
// await Future.delayed(Duration(seconds: 10));
|
|
|
|
|
|
|
|
// setState(() {
|
|
|
|
// isOnline2 = isOnline;
|
|
|
|
// }); // Example: Check every 10 seconds
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// void getcall() async {
|
|
|
|
// await Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
// SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
// SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132)));
|
|
|
|
// print(
|
|
|
|
// "newdata_is: ${_contactbox.values.toList()},${_contactbox.values.toList().length}");
|
|
|
|
|
|
|
|
// print(
|
|
|
|
// "Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} ");
|
|
|
|
|
|
|
|
// return SafeArea(
|
|
|
|
// child: Scaffold(
|
|
|
|
// // appBar: AppBar(
|
|
|
|
// // title: const Text('Contacts'),
|
|
|
|
// // ),
|
|
|
|
// body: Consumer<hcpProvider>(builder: (context, value, child) {
|
|
|
|
// print("todoss: ${value},${value.list.length}");
|
|
|
|
// return Column(
|
|
|
|
// children: [
|
|
|
|
// Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment
|
|
|
|
// .center, // Align children to start and end of the row
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
// Expanded(
|
|
|
|
// child: Padding(
|
|
|
|
// padding: const EdgeInsets.only(left: 45.0),
|
|
|
|
// child: Text(
|
|
|
|
// _switchValue ? "My Contacts" : "All Contacts",
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 20.0,
|
|
|
|
// fontWeight: FontWeight.w500,
|
|
|
|
// fontStyle: FontStyle.normal,
|
|
|
|
// color:
|
|
|
|
// _switchValue ? Colors.black : Colors.black),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// // Expanded(
|
|
|
|
// Row(
|
|
|
|
// // Adjust alignment as needed
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
// children: [
|
|
|
|
// _switchValue
|
|
|
|
// ? const Text(
|
|
|
|
// 'All',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12,
|
|
|
|
// decoration: TextDecoration.lineThrough,
|
|
|
|
// decorationThickness: 0.85,
|
|
|
|
// ),
|
|
|
|
// // TODO: implement dispose
|
|
|
|
// )
|
|
|
|
// : const Text('All',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12,
|
|
|
|
// )),
|
|
|
|
// CupertinoSwitch(
|
|
|
|
// activeColor: Color.fromARGB(255, 0, 71, 132),
|
|
|
|
// value: _switchValue,
|
|
|
|
// onChanged: (value) {
|
|
|
|
// setState(() {
|
|
|
|
// print("Switch_value_is : $value");
|
|
|
|
// _switchValue = value;
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
// child: !_switchValue
|
|
|
|
// ? const Text(
|
|
|
|
// 'My',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12,
|
|
|
|
// decoration: TextDecoration.lineThrough,
|
|
|
|
// decorationThickness: 0.85,
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// : const Text('My',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 12,
|
|
|
|
// )),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// // ),
|
|
|
|
// ]),
|
|
|
|
// isOnline2
|
|
|
|
// ? Expanded(
|
|
|
|
// child: ListView.builder(
|
|
|
|
// itemCount: value.list.length,
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
// // var data = HiveFunctions.getAllUsers()[index];
|
|
|
|
// var data = value.list[index];
|
|
|
|
|
|
|
|
// print("dataaaa_isss:$data");
|
|
|
|
|
|
|
|
// return Column(
|
|
|
|
// children: [
|
|
|
|
// ListTile(
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// MaterialPageRoute(
|
|
|
|
// builder: (context) => Profile(
|
|
|
|
// text: data,
|
|
|
|
// )));
|
|
|
|
// },
|
|
|
|
// // title: Text(_contactbox.values.toString()),
|
|
|
|
// leading: ProfilePicture(
|
|
|
|
// name: data["name"],
|
|
|
|
// radius: 20,
|
|
|
|
// fontsize: 12,
|
|
|
|
// ),
|
|
|
|
// title: Text(
|
|
|
|
// data["name"],
|
|
|
|
// style: const TextStyle(
|
|
|
|
// fontSize: 18.0,
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// subtitle: const Text(
|
|
|
|
// "Added by Pooja.K",
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14.0,
|
|
|
|
// fontWeight: FontWeight.normal),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// : Expanded(
|
|
|
|
// child: ListView.builder(
|
|
|
|
// itemCount: HiveFunctions.getAllUsers().length,
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
// var data = HiveFunctions.getAllUsers()[index];
|
|
|
|
|
|
|
|
// print("dataaaa_isss:$data");
|
|
|
|
|
|
|
|
// return Column(
|
|
|
|
// children: [
|
|
|
|
// ListTile(
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// MaterialPageRoute(
|
|
|
|
// builder: (context) => Profile(
|
|
|
|
// text: data,
|
|
|
|
// )));
|
|
|
|
// },
|
|
|
|
// // title: Text(_contactbox.values.toString()),
|
|
|
|
// leading: ProfilePicture(
|
|
|
|
// name: data["name"],
|
|
|
|
// radius: 20,
|
|
|
|
// fontsize: 12,
|
|
|
|
// ),
|
|
|
|
// title: Text(
|
|
|
|
// data["name"],
|
|
|
|
// style: const TextStyle(
|
|
|
|
// fontSize: 18.0,
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// subtitle: const Text(
|
|
|
|
// "Added by Pooja.K",
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14.0,
|
|
|
|
// fontWeight: FontWeight.normal),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ///////////////////////////////////////////////
|
|
|
|
// // Expanded(
|
|
|
|
// // child: ListView.builder(
|
|
|
|
// // itemCount: HiveFunctions.getAllUsers().length,
|
|
|
|
// // itemBuilder: (BuildContext context, int index) {
|
|
|
|
// // var data = HiveFunctions.getAllUsers()[index];
|
|
|
|
|
|
|
|
// // print("dataaaa_isss:$data");
|
|
|
|
|
|
|
|
// // return Column(
|
|
|
|
// // children: [
|
|
|
|
// // ListTile(
|
|
|
|
// // onTap: () {
|
|
|
|
// // Navigator.push(
|
|
|
|
// // context,
|
|
|
|
// // MaterialPageRoute(
|
|
|
|
// // builder: (context) => Profile(
|
|
|
|
// // text: data,
|
|
|
|
// // )));
|
|
|
|
// // },
|
|
|
|
// // // title: Text(_contactbox.values.toString()),
|
|
|
|
// // leading: ProfilePicture(
|
|
|
|
// // name: data["name"],
|
|
|
|
// // radius: 20,
|
|
|
|
// // fontsize: 12,
|
|
|
|
// // ),
|
|
|
|
// // title: Text(
|
|
|
|
// // data["name"],
|
|
|
|
// // style: const TextStyle(
|
|
|
|
// // fontSize: 18.0, fontWeight: FontWeight.bold),
|
|
|
|
// // ),
|
|
|
|
// // subtitle: const Text(
|
|
|
|
// // "Added by Pooja.K",
|
|
|
|
// // style: TextStyle(
|
|
|
|
// // fontSize: 14.0, fontWeight: FontWeight.normal),
|
|
|
|
// // ),
|
|
|
|
// // ),
|
|
|
|
// // ],
|
|
|
|
// // );
|
|
|
|
// // },
|
|
|
|
// // ),
|
|
|
|
// // ),
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// }),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
2024-06-27 08:38:43 +00:00
|
|
|
import 'package:discover_module/provider_class/hcp%20_provider.dart';
|
2024-06-28 08:14:42 +00:00
|
|
|
import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart';
|
2024-07-05 08:48:29 +00:00
|
|
|
import 'package:discover_module/ui_screen/new_profile.dart';
|
2024-05-20 10:29:02 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_profile_picture/flutter_profile_picture.dart';
|
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
2024-06-27 08:38:43 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2024-06-28 08:14:42 +00:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:discover_module/ui_screen/profile.dart';
|
2024-05-20 10:29:02 +00:00
|
|
|
|
|
|
|
class Contacts extends StatefulWidget {
|
2024-06-28 08:14:42 +00:00
|
|
|
const Contacts({Key? key}) : super(key: key);
|
2024-05-20 10:29:02 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<Contacts> createState() => _ContactsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ContactsState extends State<Contacts> {
|
2024-06-28 08:14:42 +00:00
|
|
|
final _contactBox = Hive.box("mycontact");
|
2024-05-20 10:29:02 +00:00
|
|
|
bool _switchValue = false;
|
2024-06-28 08:14:42 +00:00
|
|
|
bool isOnline2 = true;
|
2024-05-20 10:29:02 +00:00
|
|
|
|
2024-06-27 08:38:43 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-06-28 08:14:42 +00:00
|
|
|
setupConnectivityListener();
|
|
|
|
getCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> setupConnectivityListener() async {
|
|
|
|
while (true) {
|
|
|
|
bool isOnline = await NetworkConnectivity().isInternetAvailable();
|
|
|
|
print('Internet contact available: $isOnline');
|
|
|
|
await Future.delayed(Duration(seconds: 2));
|
|
|
|
if (mounted) {
|
|
|
|
setState(() {
|
|
|
|
isOnline2 = isOnline;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2024-06-27 08:38:43 +00:00
|
|
|
}
|
|
|
|
|
2024-06-28 08:14:42 +00:00
|
|
|
// @override
|
|
|
|
// void dispose() {
|
|
|
|
// // TODO: implement dispose
|
|
|
|
// }
|
|
|
|
void getCall() async {
|
2024-06-27 08:38:43 +00:00
|
|
|
await Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
|
|
|
|
}
|
2024-05-20 10:29:02 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-06-24 11:36:09 +00:00
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132)));
|
2024-05-20 10:29:02 +00:00
|
|
|
|
2024-06-10 11:11:00 +00:00
|
|
|
return SafeArea(
|
|
|
|
child: Scaffold(
|
2024-06-28 08:14:42 +00:00
|
|
|
body: Consumer<hcpProvider>(
|
|
|
|
builder: (context, value, child) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2024-06-27 08:38:43 +00:00
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 45.0),
|
|
|
|
child: Text(
|
|
|
|
_switchValue ? "My Contacts" : "All Contacts",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
2024-06-28 08:14:42 +00:00
|
|
|
fontSize: 20.0,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
2024-06-27 08:38:43 +00:00
|
|
|
),
|
2024-06-10 11:11:00 +00:00
|
|
|
),
|
2024-05-20 10:29:02 +00:00
|
|
|
),
|
2024-06-27 08:38:43 +00:00
|
|
|
Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
_switchValue
|
2024-06-10 11:11:00 +00:00
|
|
|
? const Text(
|
2024-06-27 08:38:43 +00:00
|
|
|
'All',
|
2024-06-10 11:11:00 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
decoration: TextDecoration.lineThrough,
|
|
|
|
decorationThickness: 0.85,
|
|
|
|
),
|
|
|
|
)
|
2024-06-28 08:14:42 +00:00
|
|
|
: const Text(
|
|
|
|
'All',
|
2024-06-10 11:11:00 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
2024-06-28 08:14:42 +00:00
|
|
|
),
|
|
|
|
),
|
2024-06-27 08:38:43 +00:00
|
|
|
CupertinoSwitch(
|
|
|
|
activeColor: Color.fromARGB(255, 0, 71, 132),
|
|
|
|
value: _switchValue,
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
_switchValue = value;
|
|
|
|
});
|
|
|
|
},
|
2024-06-10 11:11:00 +00:00
|
|
|
),
|
2024-06-27 08:38:43 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
child: !_switchValue
|
|
|
|
? const Text(
|
|
|
|
'My',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
decoration: TextDecoration.lineThrough,
|
|
|
|
decorationThickness: 0.85,
|
|
|
|
),
|
|
|
|
)
|
2024-06-28 08:14:42 +00:00
|
|
|
: const Text(
|
|
|
|
'My',
|
2024-06-27 08:38:43 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
2024-06-28 08:14:42 +00:00
|
|
|
),
|
|
|
|
),
|
2024-06-27 08:38:43 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2024-06-28 08:14:42 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
isOnline2
|
|
|
|
? Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: value.list.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
var data = value.list[index];
|
|
|
|
return ListTile(
|
|
|
|
onTap: () {
|
2024-07-05 08:48:29 +00:00
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// MaterialPageRoute(
|
|
|
|
// builder: (context) => Profile(
|
|
|
|
// text: data,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
|
2024-06-28 08:14:42 +00:00
|
|
|
Navigator.push(
|
2024-07-05 08:48:29 +00:00
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (_) =>
|
|
|
|
NewProfile(text: data)));
|
2024-06-28 08:14:42 +00:00
|
|
|
},
|
2024-07-05 08:48:29 +00:00
|
|
|
leading: data["img_path"] == null
|
|
|
|
? ProfilePicture(
|
|
|
|
name: data["name"],
|
|
|
|
radius: 20,
|
|
|
|
fontsize: 12,
|
|
|
|
)
|
|
|
|
: ClipOval(
|
|
|
|
child: SizedBox.fromSize(
|
|
|
|
size: Size.fromRadius(20),
|
|
|
|
child: Image.network(data["img_path"],
|
|
|
|
fit: BoxFit.cover),
|
|
|
|
),
|
|
|
|
),
|
2024-06-28 08:14:42 +00:00
|
|
|
title: Text(
|
|
|
|
data["name"],
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
"Added by Pooja.K",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.0,
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2024-06-27 08:38:43 +00:00
|
|
|
},
|
2024-06-10 11:11:00 +00:00
|
|
|
),
|
2024-06-28 08:14:42 +00:00
|
|
|
)
|
|
|
|
: Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: _contactBox.values.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
var data = _contactBox.get(index);
|
|
|
|
print(":data_is: $data");
|
|
|
|
return ListTile(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => Profile(
|
|
|
|
text: data!,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
leading: ProfilePicture(
|
|
|
|
name: data["name"],
|
|
|
|
radius: 20,
|
|
|
|
fontsize: 12,
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
data["name"],
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
"Added by Pooja.K",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.0,
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-20 10:29:02 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|