148 lines
5.2 KiB
Dart
148 lines
5.2 KiB
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/widgets.dart';
|
|
import 'package:flutter_profile_picture/flutter_profile_picture.dart';
|
|
import 'package:hive_flutter/hive_flutter.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;
|
|
|
|
// List<dynamic> alldata = _contactbox.values.toList();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
print(
|
|
"newdata_is: ${_contactbox.values.toList()},${_contactbox.values.toList().length}");
|
|
|
|
print(
|
|
"Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} ");
|
|
|
|
return Scaffold(
|
|
// appBar: AppBar(
|
|
// title: const Text('Contacts'),
|
|
// ),
|
|
body: 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,
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
// ),
|
|
]),
|
|
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()));
|
|
},
|
|
// 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),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|