Skip to content

Commit

Permalink
Issue in profile page (#57)
Browse files Browse the repository at this point in the history
* In Progressed complaints is counted in pending complaints button

* solved issue with count in filed and resolved complaints button
  • Loading branch information
diya31ag authored Nov 17, 2020
1 parent e5b12eb commit 6c9fd1e
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 159 deletions.
7 changes: 3 additions & 4 deletions lib/ad_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ class _AdProfileState extends State<AdProfile> {
.collection(
'complaints')
.where('status',
whereIn: [
'Passed',
'In Progress'
])
whereIn: ['Passed', 'In Progress']
)
.where('category',
isEqualTo: user
.data[
Expand Down Expand Up @@ -622,3 +620,4 @@ class _AdProfileState extends State<AdProfile> {
});
}
}

3 changes: 2 additions & 1 deletion lib/filed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:math';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:provider/provider.dart';
import 'ComplaintDialog.dart';
import 'loading.dart';

GlobalKey<ScaffoldState> _scaffoldState = GlobalKey<ScaffoldState>();
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
Expand Down Expand Up @@ -202,7 +203,7 @@ class _ComplaintTile1State extends State<ComplaintTile1> {
return Text('Press button to start.');
case ConnectionState.active:
case ConnectionState.waiting:
return Text('Awaiting result...');
return Loading();
case ConnectionState.done:
if (user.hasError) return Text('Error: ${user.error}');
return ComplaintOverviewCard(
Expand Down
283 changes: 129 additions & 154 deletions lib/st_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'camera.dart';
import 'card.dart';
import 'dart:math';

var user = FirebaseAuth.instance.currentUser;
var st = FirebaseAuth.instance.currentUser;

class CurveClipper extends CustomClipper<Path> {
@override
Expand Down Expand Up @@ -35,70 +35,6 @@ class CurveClipper extends CustomClipper<Path> {
bool shouldReclip(oldCliper) => false;
}

/*class ProfilePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var query = MediaQuery.of(context);
return Container(
color: Color(0xFF181D3D),
child: SafeArea(
child: Scaffold(
body: Container(
child: ListView(children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 4,
child: ClipPath(
clipper: CurveClipper(),
child: Container(
constraints: BoxConstraints.expand(),
color: Color(0xFF181D3D),
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
backgroundImage: AssetImage(
'assets/app_logo_final_jpg_ws.jpg'),
radius: 25.0,
),
SizedBox(
width: 35.0,
),
Text(
'InstiComplaints',
style: TextStyle(
fontSize: 25.0,
color: Colors.white,
fontFamily: 'Amaranth',
),
),
],
),
SizedBox(height: query.size.height / 25),
Text('Profile',
style: TextStyle(
color: Colors.white,
fontFamily: 'Roboto',
fontSize: (30 *
MediaQuery.of(context)
.size
.height) /
1000)),
],
),
)),
),
]))),
),
);
}
}*/

GlobalKey<ScaffoldState> _scaffoldState = GlobalKey<ScaffoldState>();
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
new GlobalKey<RefreshIndicatorState>();
Expand All @@ -114,7 +50,7 @@ class _ProfileState extends State<Profile> {
var query = MediaQuery.of(context);
return FutureBuilder(
future:
FirebaseFirestore.instance.collection('users').doc(user.uid).get(),
FirebaseFirestore.instance.collection('users').doc(st.uid).get(),
builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> user) {
switch (user.connectionState) {
case ConnectionState.none:
Expand All @@ -126,17 +62,26 @@ class _ProfileState extends State<Profile> {
List<String> ls =
List.from(user.data['list of my filed Complaints']);
List<String> res_list = [];
for (var i = 0; i < ls.length; i++) {
/*for (var i = 0; i < ls.length; i++) {
FirebaseFirestore.instance
.collection('complaints')
.where('status', isEqualTo: 'Solved')
.where(FieldPath.documentId, isEqualTo: ls[i])
.limit(1)
.where('status', isEqualTo: 'Solved').limit(1)\\
.get()
.then((data) {
return res_list.add(FieldPath.documentId.toString());
});
}*/
for (var i = 0; i < ls.length; i++) {
FirebaseFirestore.instance
.collection('complaints')
.where('status', isEqualTo: 'Solved')
.where('uid', isEqualTo: st.uid)
.limit(1)
.get()
.then((value) =>
res_list.add(FieldPath.documentId.toString()));
}
print(res_list);
return Container(
color: Color(0xFF181D3D),
child: SafeArea(
Expand Down Expand Up @@ -210,92 +155,122 @@ class _ProfileState extends State<Profile> {
),
SizedBox(height: 20.0),
SizedBox(
child: Row(children: [
Expanded(
flex: 3,
child: FlatButton(
onPressed: () {
Navigator.pushNamed(context, '/filed');
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
child: Column(
children: [
Text((ls.length).toString(),
style: TextStyle(
fontSize: 25.0,
color: Colors.grey[800],
fontFamily: 'Roboto',
)),
SizedBox(height: 5.0),
Text('Complaints Filed',
style: TextStyle(
color: Colors.grey[800],
fontFamily: 'Roboto',
fontSize: 3 *
query.size.width /
100,
)),
],
),
),
),
color: Colors.blueGrey[50],
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[400],
width: 1.0,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.circular(0.0),
)),
),
Expanded(
flex: 3,
child: FlatButton(
onPressed: () {
Navigator.pushNamed(context, '/resolved');
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
child: Column(
children: [
Text(res_list.length.toString(),
style: TextStyle(
fontSize: 25.0,
color: Colors.grey[800],
fontFamily: 'Roboto',
)),
SizedBox(height: 5.0),
Padding(
padding: const EdgeInsets.only(
left: 0),
child: Text('Complaints Resolved',
style: TextStyle(
color: Colors.grey[800],
fontFamily: 'Roboto',
fontSize: 3 *
query.size.width /
100,
)),
child: StreamBuilder(
stream: FirebaseFirestore.instance
.collection('complaints')
.where('status', isEqualTo: 'Solved')
.where('uid', isEqualTo: st.uid)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Text('',
style: TextStyle(
fontSize: 25.0,
color: Colors.grey[800],
fontFamily: 'Roboto',
));
}
return Row(children: [
Expanded(
flex: 3,
child: FlatButton(
onPressed: () {
Navigator.pushNamed(
context, '/filed');
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
child: Column(
children: [
Text(
(ls.length -
snapshot.data.docs
.length)
.toString(),
style: TextStyle(
fontSize: 25.0,
color: Colors.grey[800],
fontFamily: 'Roboto',
)),
SizedBox(height: 5.0),
Text('Complaints Filed',
style: TextStyle(
color: Colors.grey[800],
fontFamily: 'Roboto',
fontSize: 3 *
query.size.width /
100,
)),
],
),
),
],
),
),
),
color: Colors.blueGrey[50],
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[400],
width: 1.0,
style: BorderStyle.solid,
),
borderRadius:
BorderRadius.circular(0.0),
)),
),
color: Colors.blueGrey[50],
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[400],
width: 1.0,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.circular(0.0),
)),
)
]),
Expanded(
flex: 3,
child: FlatButton(
onPressed: () {
Navigator.pushNamed(
context, '/resolved');
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
child: Column(
children: [
Text(
snapshot.data.docs.length
.toString(),
style: TextStyle(
fontSize: 25.0,
color: Colors.grey[800],
fontFamily: 'Roboto',
)),
SizedBox(height: 5.0),
Padding(
padding:
const EdgeInsets.only(
left: 0),
child: Text(
'Complaints Resolved',
style: TextStyle(
color:
Colors.grey[800],
fontFamily: 'Roboto',
fontSize: 3 *
query.size.width /
100,
)),
),
],
),
),
),
color: Colors.blueGrey[50],
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.grey[400],
width: 1.0,
style: BorderStyle.solid,
),
borderRadius:
BorderRadius.circular(0.0),
)),
)
]);
}),
),
SizedBox(height: 15.0),
Card(
Expand Down

0 comments on commit 6c9fd1e

Please sign in to comment.