-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae4619f
commit 5b0671a
Showing
11 changed files
with
404 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,63 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:transport/fetch_firestore_data.dart'; | ||
import 'package:transport/user.dart'; | ||
import 'package:transport/user_card.dart'; | ||
import 'constants.dart'; | ||
import 'my_request.dart'; | ||
|
||
class CatalogueTab extends StatelessWidget { | ||
final List<User> users; | ||
CatalogueTab({required this.users}); | ||
class CatalogueTab extends StatefulWidget { | ||
const CatalogueTab({super.key}); | ||
@override | ||
State<CatalogueTab> createState() => _CatalogueTabState(); | ||
} | ||
|
||
class _CatalogueTabState extends State<CatalogueTab> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return MyWidget(); | ||
return Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const Padding( | ||
padding: EdgeInsets.fromLTRB(10, 5, 0, 0), | ||
child: Text('My Request', style: TextStyle(), textAlign: TextAlign.left,), | ||
), | ||
Container( | ||
child: MyCard(), | ||
), | ||
], | ||
), | ||
const SizedBox(height: 20,), | ||
const Padding( | ||
padding: EdgeInsets.fromLTRB(10, 5, 0, 0), | ||
child: Text('Others Request'), | ||
), | ||
Expanded( | ||
child: FutureBuilder<List<QueryDocumentSnapshot>>( | ||
future: fetchFirestoreDocuments(), | ||
builder: (BuildContext context, | ||
AsyncSnapshot<List<QueryDocumentSnapshot>> snapshot) { | ||
if (snapshot.connectionState == ConnectionState.waiting) { return const Text('Loading...'); } | ||
if (snapshot.hasError) {return Text('Error: ${snapshot.error}');} | ||
List<QueryDocumentSnapshot> documents = snapshot.data!; | ||
|
||
return ListView.builder( | ||
itemCount: documents.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
var name = documents[index].get('Name'); | ||
var time = documents[index].get('Time'); | ||
var isMatched = documents[index].get('isMatched'); | ||
return UserCard(color: isMatched? Colors.green : null, name: name, time: time, isMatched: false); | ||
}, | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
), | ||
);; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
|
||
late String userUid; | ||
bool myList=false; | ||
Future<bool> duplicates() async { | ||
QuerySnapshot querySnapshot = await FirebaseFirestore.instance | ||
.collection('Users') | ||
.where("Uid", isEqualTo: userUid) | ||
.get(); | ||
if (querySnapshot.docs.isNotEmpty) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
|
||
Future<List<QueryDocumentSnapshot>> fetchFirestoreDocuments() async { | ||
QuerySnapshot querySnapshot = await FirebaseFirestore.instance.collection('Users').get(); | ||
// Access the documents in the query snapshot | ||
List<QueryDocumentSnapshot> documents = querySnapshot.docs; | ||
return documents; | ||
} | ||
|
||
void deleteContact(String documentId) { | ||
FirebaseFirestore.instance.collection('Users').doc(documentId).delete() | ||
.then((value) { | ||
print('Contact deleted successfully.'); | ||
}) | ||
.catchError((error) { | ||
print('Failed to delete contact: $error'); | ||
}); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.