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">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="discover_module"
android:name="${applicationName}"

View File

@ -7,16 +7,17 @@ import 'package:hive_flutter/hive_flutter.dart';
class Callapi {
getallhcpdata() async {
// 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 jsonresponse = response.data;
// final apihcpdata = Hive.box("hcpdata");
final apihcpdata = Hive.box("hcpdata");
// if (apihcpdata.isNotEmpty) {
// apihcpdata.clear();
// }
if (apihcpdata.isEmpty) {
print("alldata_is: , ${jsonresponse} ${jsonresponse.length}");
for (int i = 0; i < jsonresponse.length; i++) {
print("hcp:data_is: , ${jsonresponse[i]['email']}");
@ -39,13 +40,15 @@ class Callapi {
"publications_count": jsonresponse[i]['publications_count'],
});
}
}
return jsonresponse;
}
getsinglehcpdata() async {
// 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 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/ui_screen/profile.dart';
import 'package:discover_module/ui_screen/ranking.dart';
import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.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';
import 'package:flutter/services.dart';
import 'package:discover_module/ui_screen/profile.dart';
class Contacts extends StatefulWidget {
const Contacts({super.key});
const Contacts({Key? key}) : super(key: key);
@override
State<Contacts> createState() => _ContactsState();
}
class _ContactsState extends State<Contacts> {
// final _contactbox = Hive.box('mycontact');
static final _contactbox = Hive.box("mycontact");
final _contactBox = Hive.box("mycontact");
bool _switchValue = false;
bool isOnline2 = true;
// List<dynamic> alldata = _contactbox.values.toList();
@override
void initState() {
// TODO: implement 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();
}
@ -39,25 +337,15 @@ class _ContactsState extends State<Contacts> {
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}");
body: Consumer<hcpProvider>(
builder: (context, value, child) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment
.center, // Align children to start and end of the row
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Padding(
@ -68,15 +356,11 @@ class _ContactsState extends State<Contacts> {
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
@ -87,18 +371,18 @@ class _ContactsState extends State<Contacts> {
decoration: TextDecoration.lineThrough,
decorationThickness: 0.85,
),
// TODO: implement dispose
)
: const Text('All',
: 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;
});
},
@ -114,37 +398,34 @@ class _ContactsState extends State<Contacts> {
decorationThickness: 0.85,
),
)
: const Text('My',
: const Text(
'My',
style: TextStyle(
fontSize: 12,
)),
),
),
)
],
),
// ),
]),
Expanded(
],
),
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(
return ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Profile(
text: data,
)));
),
),
);
},
// title: Text(_contactbox.values.toString()),
leading: ProfilePicture(
name: data["name"],
radius: 20,
@ -152,13 +433,60 @@ class _ContactsState extends State<Contacts> {
),
title: Text(
data["name"],
style: const TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
subtitle: const Text(
),
subtitle: Text(
"Added by Pooja.K",
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:io';
import 'package:connectivity_plus/connectivity_plus.dart';
class NetworkConnectivity {
// Future<bool> isInternetAvailable() async {
// var connectivityResult = await (Connectivity().checkConnectivity());
// return connectivityResult != ConnectivityResult.none;
// }
Future<bool> isInternetAvailable() async {
var connectivityResult = await (Connectivity().checkConnectivity());
return connectivityResult != ConnectivityResult.none;
var connectivityResult = await Connectivity().checkConnectivity();
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(
children: [
GestureDetector(child: Text("data")),
//GestureDetector(child: Text("data")),
GridView.builder(
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff