DiscoverModule/lib/ui_screen/contacts.dart

219 lines
8.4 KiB
Dart
Raw Normal View History

2024-06-27 08:38:43 +00:00
import 'package:discover_module/hive_fun.dart';
import 'package:discover_module/provider_class/hcp%20_provider.dart';
2024-05-20 10:29:02 +00:00
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';
2024-06-24 11:36:09 +00:00
import 'package:flutter/services.dart';
2024-05-20 10:29:02 +00:00
import 'package:flutter/widgets.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-05-20 10:29:02 +00:00
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;
// List<dynamic> alldata = _contactbox.values.toList();
2024-06-27 08:38:43 +00:00
@override
void initState() {
// TODO: implement initState
super.initState();
getcall();
}
void getcall() async {
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
print(
"newdata_is: ${_contactbox.values.toList()},${_contactbox.values.toList().length}");
print(
"Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} ");
2024-06-10 11:11:00 +00:00
return SafeArea(
child: Scaffold(
// appBar: AppBar(
// title: const Text('Contacts'),
// ),
2024-06-27 08:38:43 +00:00
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),
),
2024-06-10 11:11:00 +00:00
),
2024-05-20 10:29:02 +00:00
),
2024-06-27 08:38:43 +00:00
// Expanded(
Row(
// Adjust alignment as needed
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-27 08:38:43 +00:00
// TODO: implement dispose
2024-06-10 11:11:00 +00:00
)
2024-06-27 08:38:43 +00:00
: const Text('All',
2024-06-10 11:11:00 +00:00
style: TextStyle(
fontSize: 12,
)),
2024-06-27 08:38:43 +00:00
CupertinoSwitch(
activeColor: Color.fromARGB(255, 0, 71, 132),
value: _switchValue,
onChanged: (value) {
setState(() {
print("Switch_value_is : $value");
_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,
),
)
: const Text('My',
style: TextStyle(
fontSize: 12,
)),
)
],
),
// ),
]),
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),
),
2024-06-10 11:11:00 +00:00
),
2024-06-27 08:38:43 +00:00
],
);
},
),
2024-06-10 11:11:00 +00:00
),
2024-06-27 08:38:43 +00:00
///////////////////////////////////////////////
// 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-05-20 10:29:02 +00:00
),
);
}
}