Skip to content

Commit 5ec549d

Browse files
committed
notify
1 parent 7c5d6e2 commit 5ec549d

File tree

7 files changed

+100
-5
lines changed

7 files changed

+100
-5
lines changed

waste_management/lib/constants/theming.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const kBackgroundColor = Color.fromRGBO(232, 223, 202, 1);
44
const kPrimaryColor = Color.fromRGBO(26, 77, 46, 1);
55
const ksecondaryHeaderColor = Color.fromRGBO(245, 239, 230, 1);
66
const kPrimaryLightColor = Color.fromRGBO(79, 111, 82, 1);
7-
String uri= 'http://10.42.0.238:8585'; //10.42.0.107
7+
String uri= 'http://192.168.1.109:8585'; //10.42.0.107
88

99
const appBarGradient = LinearGradient(
1010
colors: [

waste_management/lib/models/issueModel.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Issue {
55
final String description;
66
final String latitude;
77
final String longitude;
8+
final bool isAnonymous;
89

910
Issue({
1011
required this.id,
@@ -13,6 +14,7 @@ class Issue {
1314
required this.description,
1415
required this.latitude,
1516
required this.longitude,
17+
required this.isAnonymous
1618
});
1719
}
1820

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/material.dart';
2+
3+
class NotificationScreen extends StatefulWidget {
4+
const NotificationScreen({super.key});
5+
6+
@override
7+
State<NotificationScreen> createState() => _NotificationScreenState();
8+
}
9+
10+
class _NotificationScreenState extends State<NotificationScreen> {
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
body: Center(child: Text("You have no notification right now")),
15+
);
16+
}
17+
}

waste_management/lib/notification/notificiationIcon.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import 'package:flutter/cupertino.dart';
12
import 'package:flutter/material.dart';
23
import 'package:waste_management/constants/theming.dart';
4+
import 'package:waste_management/notification/notificationScreen.dart';
35

46
class NotificationWidget extends StatefulWidget {
57
@override
@@ -13,10 +15,22 @@ class _NotificationWidgetState extends State<NotificationWidget> {
1315
Widget build(BuildContext context) {
1416
return Stack(
1517
children: [
16-
Icon(
17-
Icons.notification_important,
18-
size: 32,
19-
color: ksecondaryHeaderColor,// Adjust icon size as needed
18+
GestureDetector(
19+
onTap: (){
20+
Navigator.push(
21+
context,
22+
// generateRoute(
23+
// RouteSettings(name: HomeScreen.routeName)
24+
// ),
25+
MaterialPageRoute(builder: (context) => NotificationScreen()), // same as above
26+
//(route) => false
27+
);
28+
},
29+
child: Icon(
30+
Icons.notification_important,
31+
size: 32,
32+
color: ksecondaryHeaderColor,// Adjust icon size as needed
33+
),
2034
),
2135
if (notificationCount == 0)
2236
Positioned(

waste_management/lib/services/auth_service.dart

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,55 @@ import 'package:waste_management/router.dart';
1313
import 'package:waste_management/screens/homescreen/adminHomeScreen.dart';
1414
import 'package:waste_management/screens/welcome/loginscreen.dart';
1515
import 'package:waste_management/screens/welcome/otpVerify.dart';
16+
import 'package:waste_management/widgets/citizenFeatures/issueScreen/issueFeed.dart';
1617

1718
class AuthServices {
19+
20+
void issuePost({
21+
required BuildContext context,
22+
required String type,
23+
required String description,
24+
required String latitude,
25+
required String longitude,
26+
required bool isAnonymous,
27+
}) async {
28+
try {
29+
print(type);
30+
print(description);
31+
final res = await http.post(Uri.parse('$uri/issues/create'),
32+
body: jsonEncode({
33+
"issueType": type,
34+
"description": description,
35+
"latitude": latitude,
36+
"longitude": longitude,
37+
"isAnonymous": isAnonymous
38+
}),
39+
headers: <String, String>{
40+
// "Access-Control-Allow-Origin": "*",
41+
'Content-Type': 'application/json; charset=UTF-8',
42+
// 'Accept': '*/*'
43+
});
44+
45+
46+
47+
// print(res.body);
48+
httpErrorHandle(
49+
response: res,
50+
context: context,
51+
onSuccess: () async {
52+
Navigator.push(
53+
context,
54+
MaterialPageRoute(
55+
builder: (context) => IssueFeed()
56+
)
57+
);
58+
});
59+
} catch (e) {
60+
print(e.toString());
61+
showSnackBar(context, e.toString());
62+
}
63+
}
64+
1865
void mailVerify({
1966
required BuildContext context,
2067
required String email,
@@ -137,4 +184,6 @@ class AuthServices {
137184
showSnackBar(context, e.toString());
138185
}
139186
}
187+
188+
140189
}

waste_management/lib/widgets/citizenFeatures/issueScreen/issueFeed.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class _IssueFeedState extends State<IssueFeed> {
2121
description: 'Overflowing bins on the street corner',
2222
latitude: '23.789',
2323
longitude: '90.412',
24+
isAnonymous: false,
2425
),
2526
Issue(
2627
id: '2',
@@ -29,6 +30,7 @@ class _IssueFeedState extends State<IssueFeed> {
2930
description: 'Public littering near the park',
3031
latitude: '23.791',
3132
longitude: '90.415',
33+
isAnonymous: false,
3234
),
3335
];
3436

waste_management/lib/widgets/citizenFeatures/issueScreen/issueScreen.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:waste_management/models/issueModel.dart';
3+
import 'package:waste_management/services/auth_service.dart';
34

45
class IssuePage extends StatefulWidget {
56
final Function(Issue) addIssue; // Function to add issue
@@ -17,8 +18,17 @@ class _IssuePageState extends State<IssuePage> {
1718

1819
String? _selectedIssue;
1920
bool _isAnonymous = false;
21+
final AuthServices authService = AuthServices();
2022

2123
void _submitIssue(BuildContext context) {
24+
authService.issuePost(
25+
context: context,
26+
type: _selectedIssue!,
27+
description: _descriptionController.text,
28+
latitude: _latitudeController.text,
29+
longitude: _longitudeController.text,
30+
isAnonymous: _isAnonymous
31+
);
2232
// Create a new Issue object with the provided data
2333
Issue newIssue = Issue(
2434
id: DateTime.now().toString(), // Unique ID based on timestamp
@@ -27,6 +37,7 @@ class _IssuePageState extends State<IssuePage> {
2737
description: _descriptionController.text,
2838
latitude: _latitudeController.text,
2939
longitude: _longitudeController.text,
40+
isAnonymous: _isAnonymous,
3041
);
3142

3243
// Call the addIssue function passed from IssueFeed

0 commit comments

Comments
 (0)