Skip to content

Commit 19f452a

Browse files
rate
1 parent 8a6a679 commit 19f452a

33 files changed

+2010
-426
lines changed

android/app/build.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ android {
3434
sourceCompatibility JavaVersion.VERSION_1_8
3535
targetCompatibility JavaVersion.VERSION_1_8
3636
}
37-
37+
lintOptions {
38+
disable 'InvalidPackage'
39+
disable "Instantiatable"
40+
checkReleaseBuilds false
41+
abortOnError false
42+
}
3843
kotlinOptions {
3944
jvmTarget = '1.8'
4045
}
@@ -70,5 +75,6 @@ flutter {
7075

7176
dependencies {
7277
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
78+
implementation 'com.facebook.android:facebook-android-sdk:latest.release'
7379
implementation platform('com.google.firebase:firebase-bom:31.1.1')
7480
}
+38-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.example.nelaamproject">
33
<uses-permission android:name="android.permission.RECORD_AUDIO" />
4-
<application
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<application
56
android:label="NEELAM HUB"
67
android:name="${applicationName}"
78
android:icon="@mipmap/ic_launcher">
9+
<meta-data android:name="com.facebook.sdk.ApplicationId"
10+
android:value="@string/facebook_app_id" />
11+
<meta-data android:name="com.facebook.sdk.ClientToken"
12+
android:value="@string/facebook_client_token" />
13+
14+
<activity android:name="com.facebook.FacebookActivity"
15+
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
16+
android:label="@string/app_name" />
17+
<activity
18+
android:name="com.facebook.CustomTabActivity"
19+
android:exported="true">
20+
<intent-filter>
21+
<action android:name="android.intent.action.VIEW" />
22+
<category android:name="android.intent.category.DEFAULT" />
23+
<category android:name="android.intent.category.BROWSABLE" />
24+
<data android:scheme="@string/fb_login_protocol_scheme" />
25+
</intent-filter>
26+
</activity>
27+
828
<activity
929
android:name=".MainActivity"
1030
android:exported="true"
@@ -18,12 +38,23 @@
1838
while the Flutter UI initializes. After that, this theme continues
1939
to determine the Window background behind the Flutter UI. -->
2040
<meta-data
21-
android:name="io.flutter.embedding.android.NormalTheme"
22-
android:resource="@style/NormalTheme"
23-
/>
41+
android:name="io.flutter.embedding.android.NormalTheme"
42+
android:resource="@style/NormalTheme"
43+
/>
44+
<meta-data
45+
android:name="com.google.firebase.messaging.default_notification_channel_id"
46+
android:value="flutterNotification"
47+
/>
48+
<intent-filter>
49+
<action android:name="android.intent.action.MAIN" />
50+
<category android:name="android.intent.category.LAUNCHER" />
51+
</intent-filter>
52+
<intent-filter>
53+
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
54+
<category android:name="android.intent.category.DEFAULT" />
55+
</intent-filter>
2456
<intent-filter>
25-
<action android:name="android.intent.action.MAIN"/>
26-
<category android:name="android.intent.category.LAUNCHER"/>
57+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
2758
</intent-filter>
2859
</activity>
2960
<!-- Don't delete the meta-data below.
@@ -32,4 +63,4 @@
3263
android:name="flutterEmbedding"
3364
android:value="2" />
3465
</application>
35-
</manifest>
66+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">Neelam</string>
4+
<string name="facebook_app_id">1160934054556249</string>
5+
<string name="fb_login_protocol_scheme">fb1160934054556249</string>
6+
<string name="facebook_client_token">4c776fb600bd8e46f655ae0c3c29f29b</string>
7+
</resources>

lib/backend/auth/authFunctions.dart

+59-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import 'package:cloud_firestore/cloud_firestore.dart';
22
import 'package:firebase_auth/firebase_auth.dart';
33
import 'package:flutter/material.dart';
4+
import 'package:firebase_messaging/firebase_messaging.dart';
45
import 'package:get/get.dart';
56
import 'package:google_sign_in/google_sign_in.dart';
67
import 'package:nelaamproject/Widgets/snackbar.dart';
8+
79
Color kPrimaryColor = Colors.lightBlue.shade900;
10+
811
class AuthFunction extends GetxController {
912
static AuthFunction instance = Get.find();
1013

@@ -37,20 +40,33 @@ class AuthFunction extends GetxController {
3740
.collection('users')
3841
.doc(cred.user!.uid)
3942
.set({
40-
'username':username,
41-
'password':password,
42-
'email':email,
43-
'profileUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRhW0hzwECDKq0wfUqFADEJaNGESHQ8GRCJIg&usqp=CAU',
44-
'posts':[],
45-
'status':'unavailable',
46-
'statusT':DateTime.now(),
47-
'uid':cred.user!.uid,
48-
'bid post':[],
49-
'like posts':[],
50-
'verify':false,
51-
'rating':0,
52-
'response':'good',
53-
});
43+
'username': username,
44+
'password': password,
45+
'email': email,
46+
'profileUrl':
47+
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRhW0hzwECDKq0wfUqFADEJaNGESHQ8GRCJIg&usqp=CAU',
48+
'posts': [],
49+
'status': 'unavailable',
50+
'statusT': DateTime.now(),
51+
'uid': cred.user!.uid,
52+
'bid post': [],
53+
'like posts': [],
54+
'5 star': [],
55+
'4 star': [],
56+
'3 star': [],
57+
'2 star': [],
58+
'1 star': [],
59+
'verify': false,
60+
'rating': 0,
61+
'response': 'good',
62+
});
63+
String? token = await FirebaseMessaging.instance.getToken();
64+
await FirebaseFirestore.instance
65+
.collection("users")
66+
.doc(_auth.currentUser!.uid)
67+
.update({
68+
"token": token,
69+
});
5470
// Get.to(homePgae(), transition: Transition.rightToLeft);
5571
if (password.isEmpty && username.isEmpty && email.isEmpty) {
5672
err = 'fields-error';
@@ -88,6 +104,13 @@ class AuthFunction extends GetxController {
88104
try {
89105
UserCredential userCredential = await FirebaseAuth.instance
90106
.signInWithEmailAndPassword(email: email, password: password);
107+
String? token = await FirebaseMessaging.instance.getToken();
108+
await FirebaseFirestore.instance
109+
.collection("users")
110+
.doc(_auth.currentUser!.uid)
111+
.update({
112+
"token": token,
113+
});
91114
print("Login done");
92115
// Get.to(homePgae(), transition: Transition.rightToLeft);
93116

@@ -156,19 +179,31 @@ class AuthFunction extends GetxController {
156179
.collection('users')
157180
.doc(user.uid)
158181
.set({
159-
'username':user.displayName,
182+
'username': user.displayName,
160183
// 'password':password,
161-
'email':user.email,
184+
'email': user.email,
162185
'profileUrl': user.photoURL,
163-
'posts':[],
164-
'status':'unavailable',
165-
'statusT':DateTime.now(),
166-
'uid':user.uid,
167-
'verify':false,
168-
'rating':0,
169-
'response':'good',
170-
});
186+
'posts': [],
187+
'status': 'unavailable',
188+
'statusT': DateTime.now(),
189+
'uid': user.uid,
190+
'verify': false,
191+
'rating': 0,
192+
'5 star': [],
193+
'4 star': [],
194+
'3 star': [],
195+
'2 star': [],
196+
'1 star': [],
197+
'response': 'good',
198+
});
171199
}
200+
String? token = await FirebaseMessaging.instance.getToken();
201+
await FirebaseFirestore.instance
202+
.collection("users")
203+
.doc(_auth.currentUser!.uid)
204+
.update({
205+
"token": token,
206+
});
172207
res = true;
173208
}
174209
} on FirebaseAuthException catch (e) {
+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
import 'dart:convert';
2+
import 'package:http/http.dart' as http;
3+
import 'package:firebase_messaging/firebase_messaging.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
6+
7+
class LocalNotificationService {
8+
static final FlutterLocalNotificationsPlugin _notificationsPlugin =
9+
FlutterLocalNotificationsPlugin();
10+
11+
// after this create a method initialize to initialize localnotification
12+
13+
static void initialize() {
14+
// initializationSettings for Android
15+
const InitializationSettings initializationSettings =
16+
InitializationSettings(
17+
android: AndroidInitializationSettings("@mipmap/ic_launcher"),
18+
);
19+
20+
_notificationsPlugin.initialize(
21+
initializationSettings,
22+
// onDidReceiveNotificationResponse: (String? id) async {
23+
// print("onSelectNotification");
24+
// if (id!.isNotEmpty) {
25+
// print("Router Value1234 $id");
26+
27+
// // Navigator.of(context).push(
28+
// // MaterialPageRoute(
29+
// // builder: (context) => DemoScreen(
30+
// // id: id,
31+
// // ),
32+
// // ),
33+
// // );
34+
35+
// }
36+
// },
37+
);
38+
}
39+
40+
static sendPushMessage(String body, String title, String token) async {
41+
try {
42+
print('sending');
43+
final response =
44+
await http.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
45+
headers: {
46+
'Content-Type': 'application/json',
47+
'Authorization':
48+
'key= AAAAcJG6v-U:APA91bE1u0R-KyQlfI6D0j9Ku216LBHV78xxdSfRg2j-7R280EBsTNmB4Vgmw4TxTAjbqMj7RM7Estb12sYXQCIxOrSczzgpC9BcueEnIaW4Gq0NTynIQV20rnSw0hVD_3yGqzAOkKnT ',
49+
},
50+
body: json.encode({
51+
"pirority": "high",
52+
"registration_ids": [
53+
token,
54+
// "cxDaTRu1T-eMCVEBycQAuj:APA91bFHXtHF20bGBRNVOcNKJ9hpxpSdjBbWL9QN0Es79hi4i_VpBlUYu8aNNHDovxibTvnIdu5EPmd6-85qbgtFUimiim6FfwTeieehy8_sUs_w7UNacJYRFq9wxWJVnEfVy9KhVhfM"
55+
],
56+
"notification": {
57+
"body": body,
58+
"title": title,
59+
"android_channel_id": "flutterNotification",
60+
"sound": false
61+
}
62+
}));
63+
print('sent ${response.statusCode}and ${response.request}');
64+
} catch (e) {
65+
print(e.toString());
66+
}
67+
}
68+
69+
/////////////////////////for audio/////////////////////////////////
70+
static sendPushAudio(
71+
String body, String title, String token, String imageurl) async {
72+
try {
73+
print('sending');
74+
final response =
75+
await http.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
76+
headers: {
77+
'Content-Type': 'application/json',
78+
'Authorization':
79+
'key= AAAAcJG6v-U:APA91bE1u0R-KyQlfI6D0j9Ku216LBHV78xxdSfRg2j-7R280EBsTNmB4Vgmw4TxTAjbqMj7RM7Estb12sYXQCIxOrSczzgpC9BcueEnIaW4Gq0NTynIQV20rnSw0hVD_3yGqzAOkKnT ',
80+
},
81+
body: json.encode({
82+
"pirority": "high",
83+
"registration_ids": [
84+
token,
85+
// "cxDaTRu1T-eMCVEBycQAuj:APA91bFHXtHF20bGBRNVOcNKJ9hpxpSdjBbWL9QN0Es79hi4i_VpBlUYu8aNNHDovxibTvnIdu5EPmd6-85qbgtFUimiim6FfwTeieehy8_sUs_w7UNacJYRFq9wxWJVnEfVy9KhVhfM"
86+
],
87+
"notification": {
88+
"body": body,
89+
"title": title,
90+
"image": imageurl,
91+
"android_channel_id": "flutterNotification",
92+
"sound": false
93+
}
94+
}));
95+
print('sent ${response.statusCode}and ${response.request}');
96+
} catch (e) {
97+
print(e.toString());
98+
}
99+
}
100+
101+
///////////////////////////////////////////////////////////
102+
static sendPushImage(
103+
String body, String title, String token, String imageUrl) async {
104+
try {
105+
print('sending');
106+
final response =
107+
await http.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
108+
headers: {
109+
'Content-Type': 'application/json',
110+
'Authorization':
111+
'key= AAAAcJG6v-U:APA91bE1u0R-KyQlfI6D0j9Ku216LBHV78xxdSfRg2j-7R280EBsTNmB4Vgmw4TxTAjbqMj7RM7Estb12sYXQCIxOrSczzgpC9BcueEnIaW4Gq0NTynIQV20rnSw0hVD_3yGqzAOkKnT ',
112+
},
113+
body: json.encode({
114+
"pirority": "high",
115+
"registration_ids": [
116+
token,
117+
// "cxDaTRu1T-eMCVEBycQAuj:APA91bFHXtHF20bGBRNVOcNKJ9hpxpSdjBbWL9QN0Es79hi4i_VpBlUYu8aNNHDovxibTvnIdu5EPmd6-85qbgtFUimiim6FfwTeieehy8_sUs_w7UNacJYRFq9wxWJVnEfVy9KhVhfM"
118+
],
119+
"notification": {
120+
"body": body,
121+
"title": title,
122+
"image": imageUrl,
123+
"android_channel_id": "flutterNotification",
124+
"sound": false
125+
}
126+
}));
127+
print('sent ${response.statusCode}and ${response.request}');
128+
} catch (e) {
129+
print(e.toString());
130+
}
131+
}
132+
133+
///////////////////////////////////////////////////////////
134+
static void createanddisplaynotification(RemoteMessage message) async {
135+
try {
136+
final id = DateTime.now().millisecondsSinceEpoch ~/ 1000;
137+
const NotificationDetails notificationDetails = NotificationDetails(
138+
android: AndroidNotificationDetails(
139+
"flutterNotification",
140+
"flutterNotificationchannel",
141+
importance: Importance.max,
142+
priority: Priority.high,
143+
color: Colors.blue,
144+
colorized: true,
145+
),
146+
);
147+
148+
await _notificationsPlugin.show(
149+
id,
150+
message.notification!.title,
151+
message.notification!.body,
152+
notificationDetails,
153+
payload: message.data['_id'],
154+
);
155+
} on Exception catch (e) {
156+
print(e);
157+
}
158+
}
159+
}

lib/drawer/categories.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ class _CategoriesPageState extends State<CategoriesPage> {
7979
TopDealsConst(
8080
title: "Consumer Electronics", image: "electronics"),
8181
TopDealsConst(title: "Crafts", image: "crafts"),
82-
TopDealsConst(title: "Dolls and Bears", image: "bears"),
82+
TopDealsConst(title: "Dolls & Bears", image: "bears"),
8383
],
8484
),
8585
),
8686
SingleChildScrollView(
8787
scrollDirection: Axis.horizontal,
8888
child: Row(
8989
children: [
90-
TopDealsConst(title: "Home and Garden", image: "garden"),
90+
TopDealsConst(title: "Home & Garden", image: "garden"),
9191
TopDealsConst(title: "Sporting Goods", image: "sports"),
92-
TopDealsConst(title: "Toys and Hobbies", image: "toys"),
92+
TopDealsConst(title: "Toys & Hobbies", image: "toys"),
9393
],
9494
),
9595
),

0 commit comments

Comments
 (0)