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,174 +1,195 @@
import 'package:discover_module/hive_fun.dart'; // import 'package:discover_module/hive_fun.dart';
import 'package:discover_module/provider_class/hcp%20_provider.dart'; // import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.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 { // import 'package:discover_module/provider_class/hcp%20_provider.dart';
const Contacts({super.key}); // 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';
@override // class Contacts extends StatefulWidget {
State<Contacts> createState() => _ContactsState(); // const Contacts({super.key});
}
class _ContactsState extends State<Contacts> { // @override
// final _contactbox = Hive.box('mycontact'); // State<Contacts> createState() => _ContactsState();
static final _contactbox = Hive.box("mycontact"); // }
bool _switchValue = false; // class _ContactsState extends State<Contacts> {
// // final _contactbox = Hive.box('mycontact');
// static final _contactbox = Hive.box("mycontact");
// List<dynamic> alldata = _contactbox.values.toList(); // bool _switchValue = false;
@override
void initState() {
// TODO: implement initState
super.initState();
getcall();
}
void getcall() async { // bool isOnline2 = false;
await Provider.of<hcpProvider>(context, listen: false).getHCPProvider();
}
@override // // List<dynamic> alldata = _contactbox.values.toList();
Widget build(BuildContext context) { // @override
SystemChrome.setSystemUIOverlayStyle( // void initState() {
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); // // TODO: implement initState
print( // super.initState();
"newdata_is: ${_contactbox.values.toList()},${_contactbox.values.toList().length}"); // setupConnectivityListener();
print( // getcall();
"Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} "); // }
return SafeArea( // NetworkConnectivity networkConnectivity = NetworkConnectivity();
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: [ // Future<void> setupConnectivityListener() async {
Expanded( // while (true) {
child: Padding( // bool isOnline = await networkConnectivity.isInternetAvailable();
padding: const EdgeInsets.only(left: 45.0), // print('Internetcontact available: $isOnline');
child: Text( // // Perform actions based on connectivity status
_switchValue ? "My Contacts" : "All Contacts", // await Future.delayed(Duration(seconds: 10));
textAlign: TextAlign.center,
style: TextStyle( // setState(() {
fontSize: 20.0, // isOnline2 = isOnline;
fontWeight: FontWeight.w500, // }); // Example: Check every 10 seconds
fontStyle: FontStyle.normal, // }
color: // }
_switchValue ? Colors.black : Colors.black),
), // 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( // Expanded(
Row( // child: Padding(
// Adjust alignment as needed // padding: const EdgeInsets.only(left: 45.0),
mainAxisSize: MainAxisSize.min, // child: Text(
children: [ // _switchValue ? "My Contacts" : "All Contacts",
_switchValue // textAlign: TextAlign.center,
? const Text( // style: TextStyle(
'All', // fontSize: 20.0,
style: TextStyle( // fontWeight: FontWeight.w500,
fontSize: 12, // fontStyle: FontStyle.normal,
decoration: TextDecoration.lineThrough, // color:
decorationThickness: 0.85, // _switchValue ? Colors.black : Colors.black),
),
// 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,
)),
)
],
),
// ), // ),
]), // ),
// ),
// // 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];
Expanded( // print("dataaaa_isss:$data");
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: [
return Column( // ListTile(
children: [ // onTap: () {
ListTile( // Navigator.push(
onTap: () { // context,
Navigator.push( // MaterialPageRoute(
context, // builder: (context) => Profile(
MaterialPageRoute( // text: data,
builder: (context) => Profile( // )));
text: data, // },
))); // // title: Text(_contactbox.values.toString()),
}, // leading: ProfilePicture(
// title: Text(_contactbox.values.toString()), // name: data["name"],
leading: ProfilePicture( // radius: 20,
name: data["name"], // fontsize: 12,
radius: 20, // ),
fontsize: 12, // title: Text(
), // data["name"],
title: Text( // style: const TextStyle(
data["name"], // fontSize: 18.0,
style: const TextStyle( // fontWeight: FontWeight.bold),
fontSize: 18.0, fontWeight: FontWeight.bold), // ),
), // subtitle: const Text(
subtitle: const Text( // "Added by Pooja.K",
"Added by Pooja.K", // style: TextStyle(
style: TextStyle( // fontSize: 14.0,
fontSize: 14.0, fontWeight: FontWeight.normal), // fontWeight: FontWeight.normal),
), // ),
), // ),
], // ],
); // );
}, // },
), // ),
), // )
// : Expanded(
///////////////////////////////////////////////
// Expanded(
// child: ListView.builder( // child: ListView.builder(
// itemCount: HiveFunctions.getAllUsers().length, // itemCount: HiveFunctions.getAllUsers().length,
// itemBuilder: (BuildContext context, int index) { // itemBuilder: (BuildContext context, int index) {
@ -196,12 +217,14 @@ class _ContactsState extends State<Contacts> {
// title: Text( // title: Text(
// data["name"], // data["name"],
// style: const TextStyle( // style: const TextStyle(
// fontSize: 18.0, fontWeight: FontWeight.bold), // fontSize: 18.0,
// fontWeight: FontWeight.bold),
// ), // ),
// subtitle: const Text( // subtitle: const 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),
// ), // ),
// ), // ),
// ], // ],
@ -209,9 +232,267 @@ 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),
// // ),
// // ),
// // ],
// // );
// // },
// // ),
// // ),
// ],
// );
// }),
// ),
// );
// }
// }
import 'package:discover_module/provider_class/hcp%20_provider.dart';
import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart';
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';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'package:discover_module/ui_screen/profile.dart';
class Contacts extends StatefulWidget {
const Contacts({Key? key}) : super(key: key);
@override
State<Contacts> createState() => _ContactsState();
}
class _ContactsState extends State<Contacts> {
final _contactBox = Hive.box("mycontact");
bool _switchValue = false;
bool isOnline2 = true;
@override
void initState() {
super.initState();
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;
});
}
}
}
// @override
// void dispose() {
// // TODO: implement dispose
// }
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)));
return SafeArea(
child: Scaffold(
body: Consumer<hcpProvider>(
builder: (context, value, child) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
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,
),
),
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
_switchValue
? const Text(
'All',
style: TextStyle(
fontSize: 12,
decoration: TextDecoration.lineThrough,
decorationThickness: 0.85,
),
)
: const Text(
'All',
style: TextStyle(
fontSize: 12,
),
),
CupertinoSwitch(
activeColor: Color.fromARGB(255, 0, 71, 132),
value: _switchValue,
onChanged: (value) {
setState(() {
_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 = value.list[index];
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,
),
),
);
},
),
)
: 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,
),
),
);
},
),
),
], ],
); );
}), },
),
), ),
); );
} }

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