mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
Merge branch 'master' of https://github.com/SoPat712/RUSwipeShare
This commit is contained in:
@@ -3,27 +3,37 @@ import 'dart:ffi';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class TimeRange {
|
||||
late DateTime startTime;
|
||||
late DateTime endTime;
|
||||
late Timestamp startTime;
|
||||
late Timestamp endTime;
|
||||
|
||||
TimeRange(this.startTime, this.endTime);
|
||||
}
|
||||
|
||||
class PriceRange {
|
||||
int low = 0;
|
||||
int high = 0;
|
||||
double low = 0;
|
||||
double high = 0;
|
||||
|
||||
PriceRange(this.low, this.high);
|
||||
}
|
||||
|
||||
class Seller {
|
||||
class Seller implements Comparable<Seller> {
|
||||
String name = "";
|
||||
String uid = "";
|
||||
List<String> location;
|
||||
List<dynamic> location;
|
||||
TimeRange availableTime;
|
||||
int price;
|
||||
|
||||
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Name: $name, Price: $price";
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTo(Seller other) {
|
||||
return name.compareTo(other.name);
|
||||
}
|
||||
}
|
||||
|
||||
class Filter {
|
||||
@@ -36,17 +46,18 @@ class Filter {
|
||||
|
||||
Future<List<Seller>> getSellers(Filter filter) async {
|
||||
CollectionReference users = FirebaseFirestore.instance.collection('sellers');
|
||||
List<Seller> sellers = List.empty();
|
||||
List<Seller> sellers = List.empty(growable: true);
|
||||
|
||||
final Query query = users
|
||||
.where('location', arrayContainsAny: filter.locations)
|
||||
.where('price', isGreaterThanOrEqualTo: filter.price?.low, isLessThanOrEqualTo: filter.price?.high)
|
||||
.where('start-time', isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
|
||||
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
|
||||
.where('price',
|
||||
isGreaterThanOrEqualTo: filter.price?.low,
|
||||
isLessThanOrEqualTo: filter.price?.high);
|
||||
|
||||
final QuerySnapshot snapshot = await query.get();
|
||||
for (var doc in snapshot.docs) {
|
||||
sellers.add(Seller(doc["name"], doc["uid"], doc["location"], TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||
}
|
||||
return sellers;
|
||||
}
|
||||
|
Reference in New Issue
Block a user