profile_offline

This commit is contained in:
poojakhatawate 2024-06-28 13:44:42 +05:30
parent 77a2cce914
commit 3c828dc74f
9 changed files with 3150 additions and 1072 deletions

View File

@ -1,4 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application <application
android:label="discover_module" android:label="discover_module"
android:name="${applicationName}" android:name="${applicationName}"

View File

@ -7,16 +7,17 @@ import 'package:hive_flutter/hive_flutter.dart';
class Callapi { class Callapi {
getallhcpdata() async { getallhcpdata() async {
// const url = 'http://127.0.0.1:8000/api/users'; // const url = 'http://127.0.0.1:8000/api/users';
const url = 'http://127.0.0.1:8001/api/users'; //const url = 'http://192.168.2.143:8080/api/users';
const url = 'http://192.168.172.50:8080/api/users';
final response = await Dio().get(url); final response = await Dio().get(url);
final jsonresponse = response.data; final jsonresponse = response.data;
// final apihcpdata = Hive.box("hcpdata"); final apihcpdata = Hive.box("hcpdata");
// if (apihcpdata.isNotEmpty) { // if (apihcpdata.isNotEmpty) {
// apihcpdata.clear(); // apihcpdata.clear();
// } // }
if (apihcpdata.isEmpty) {
print("alldata_is: , ${jsonresponse} ${jsonresponse.length}"); print("alldata_is: , ${jsonresponse} ${jsonresponse.length}");
for (int i = 0; i < jsonresponse.length; i++) { for (int i = 0; i < jsonresponse.length; i++) {
print("hcp:data_is: , ${jsonresponse[i]['email']}"); print("hcp:data_is: , ${jsonresponse[i]['email']}");
@ -39,13 +40,15 @@ class Callapi {
"publications_count": jsonresponse[i]['publications_count'], "publications_count": jsonresponse[i]['publications_count'],
}); });
} }
}
return jsonresponse; return jsonresponse;
} }
getsinglehcpdata() async { getsinglehcpdata() async {
// const url = 'http://127.0.0.1:8000/api/users/1'; // const url = 'http://127.0.0.1:8000/api/users/1';
const url = 'http://127.0.0.1:8001/api/users/1'; // const url = 'http://192.168.2.143:8080/api/users/1';
const url = 'http://192.168.172.50:8080/api/users/1';
final responsehcp = await Dio().post(url); final responsehcp = await Dio().post(url);
final jsonresponse1 = responsehcp.data; final jsonresponse1 = responsehcp.data;

View File

@ -1,37 +1,335 @@
import 'package:discover_module/hive_fun.dart'; // 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),
// // ),
// // ),
// // ],
// // );
// // },
// // ),
// // ),
// ],
// );
// }),
// ),
// );
// }
// }
import 'package:discover_module/provider_class/hcp%20_provider.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/interactionform/NewtworkConnectivity.dart';
import 'package:discover_module/ui_screen/ranking.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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:flutter_profile_picture/flutter_profile_picture.dart';
import 'package:hive_flutter/hive_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'package:discover_module/ui_screen/profile.dart';
class Contacts extends StatefulWidget { class Contacts extends StatefulWidget {
const Contacts({super.key}); const Contacts({Key? key}) : super(key: key);
@override @override
State<Contacts> createState() => _ContactsState(); State<Contacts> createState() => _ContactsState();
} }
class _ContactsState extends State<Contacts> { class _ContactsState extends State<Contacts> {
// final _contactbox = Hive.box('mycontact'); final _contactBox = Hive.box("mycontact");
static final _contactbox = Hive.box("mycontact");
bool _switchValue = false; bool _switchValue = false;
bool isOnline2 = true;
// List<dynamic> alldata = _contactbox.values.toList();
@override @override
void initState() { void initState() {
// TODO: implement initState
super.initState(); super.initState();
getcall(); setupConnectivityListener();
getCall();
} }
void getcall() async { 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;
});
}
}
}
// @override
// void dispose() {
// // TODO: implement dispose
// }
void getCall() async {
await Provider.of<hcpProvider>(context, listen: false).getHCPProvider(); await Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
} }
@ -39,25 +337,15 @@ class _ContactsState extends State<Contacts> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); 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( return SafeArea(
child: Scaffold( child: Scaffold(
// appBar: AppBar( body: Consumer<hcpProvider>(
// title: const Text('Contacts'), builder: (context, value, child) {
// ),
body: Consumer<hcpProvider>(builder: (context, value, child) {
print("todoss: ${value},${value.list.length}");
return Column( return Column(
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.center,
.center, // Align children to start and end of the row
children: [ children: [
Expanded( Expanded(
child: Padding( child: Padding(
@ -68,15 +356,11 @@ class _ContactsState extends State<Contacts> {
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontStyle: FontStyle.normal,
color:
_switchValue ? Colors.black : Colors.black),
), ),
), ),
), ),
// Expanded( ),
Row( Row(
// Adjust alignment as needed
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
_switchValue _switchValue
@ -87,18 +371,18 @@ class _ContactsState extends State<Contacts> {
decoration: TextDecoration.lineThrough, decoration: TextDecoration.lineThrough,
decorationThickness: 0.85, decorationThickness: 0.85,
), ),
// TODO: implement dispose
) )
: const Text('All', : const Text(
'All',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
)), ),
),
CupertinoSwitch( CupertinoSwitch(
activeColor: Color.fromARGB(255, 0, 71, 132), activeColor: Color.fromARGB(255, 0, 71, 132),
value: _switchValue, value: _switchValue,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
print("Switch_value_is : $value");
_switchValue = value; _switchValue = value;
}); });
}, },
@ -114,37 +398,34 @@ class _ContactsState extends State<Contacts> {
decorationThickness: 0.85, decorationThickness: 0.85,
), ),
) )
: const Text('My', : const Text(
'My',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
)), ),
),
) )
], ],
), ),
// ), ],
]), ),
isOnline2
Expanded( ? Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: value.list.length, itemCount: value.list.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
// var data = HiveFunctions.getAllUsers()[index];
var data = value.list[index]; var data = value.list[index];
return ListTile(
print("dataaaa_isss:$data");
return Column(
children: [
ListTile(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => Profile( builder: (context) => Profile(
text: data, text: data,
))); ),
),
);
}, },
// title: Text(_contactbox.values.toString()),
leading: ProfilePicture( leading: ProfilePicture(
name: data["name"], name: data["name"],
radius: 20, radius: 20,
@ -152,13 +433,60 @@ class _ContactsState extends State<Contacts> {
), ),
title: Text( title: Text(
data["name"], data["name"],
style: const TextStyle( style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold), fontSize: 18.0,
fontWeight: FontWeight.bold,
), ),
subtitle: const Text( ),
subtitle: Text(
"Added by Pooja.K", "Added by Pooja.K",
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontWeight: FontWeight.normal), fontSize: 14.0,
fontWeight: FontWeight.normal,
),
),
);
},
),
)
: 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,
),
),
);
},
), ),
), ),
], ],
@ -166,53 +494,6 @@ class _ContactsState extends State<Contacts> {
}, },
), ),
), ),
///////////////////////////////////////////////
// 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),
// ),
// ),
// ],
// );
// },
// ),
// ),
],
);
}),
),
); );
} }
} }

View File

@ -1,10 +1,27 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:connectivity_plus/connectivity_plus.dart';
class NetworkConnectivity { class NetworkConnectivity {
// Future<bool> isInternetAvailable() async {
// var connectivityResult = await (Connectivity().checkConnectivity());
// return connectivityResult != ConnectivityResult.none;
// }
Future<bool> isInternetAvailable() async { Future<bool> isInternetAvailable() async {
var connectivityResult = await (Connectivity().checkConnectivity()); var connectivityResult = await Connectivity().checkConnectivity();
return connectivityResult != ConnectivityResult.none; if (connectivityResult == ConnectivityResult.none) {
return false;
} else {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
return true;
}
return false;
} on SocketException catch (_) {
return false;
}
}
} }
} }

View File

@ -1246,7 +1246,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
), ),
child: Wrap( child: Wrap(
children: [ children: [
GestureDetector(child: Text("data")), //GestureDetector(child: Text("data")),
GridView.builder( GridView.builder(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

View File

@ -73,6 +73,7 @@ class _InteractionListScreenState extends State<InteractionListScreen> {
cacheExtent: double.parse( cacheExtent: double.parse(
provider.intConfigDataList.length.toString()), provider.intConfigDataList.length.toString()),
itemBuilder: (context, index) { itemBuilder: (context, index) {
print("ism Screenindex $index");
return Column( return Column(
children: [ children: [
ListTile( ListTile(
@ -112,6 +113,8 @@ class _InteractionListScreenState extends State<InteractionListScreen> {
-1 -1
? InkWell( ? InkWell(
onTap: () { onTap: () {
print("inwesm Screenindex $index");
if (getCount( if (getCount(
provider.intConfigDataList[index] provider.intConfigDataList[index]
.name, .name,

View File

@ -153,8 +153,8 @@ class _DataSource extends DataTableSource {
selected: row.selected, selected: row.selected,
onSelectChanged: (value) { onSelectChanged: (value) {
// print("hii"); // print("hii");
Navigator.push( // Navigator.push(
context, MaterialPageRoute(builder: (context) => Profile())); // context, MaterialPageRoute(builder: (context) => Profile()));
}, },
cells: [ cells: [
DataCell(Text(row.valueA)), DataCell(Text(row.valueA)),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff