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:
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'meetings.dart';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class MainScreen extends StatefulWidget {
|
||||
const MainScreen({Key? key}) : super(key: key);
|
||||
|
||||
@@ -11,6 +13,13 @@ class MainScreen extends StatefulWidget {
|
||||
class _MainScreenState extends State<MainScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("OOOGABOOGA");
|
||||
getSellers(Filter(
|
||||
["Sbarro"],
|
||||
PriceRange(8, 10),
|
||||
TimeRange(Timestamp.fromDate(DateTime(2023, 2, 26, 12, 50)),
|
||||
Timestamp.fromDate(DateTime(2023, 2, 26, 11, 50)))))
|
||||
.then((value) => {print(value)});
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Main Beens"),
|
||||
|
@@ -3,45 +3,78 @@ 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 Seller {
|
||||
class PriceRange {
|
||||
int low = 0;
|
||||
int high = 0;
|
||||
|
||||
PriceRange(this.low, this.high);
|
||||
}
|
||||
|
||||
class Seller implements Comparable<Seller> {
|
||||
String name = "";
|
||||
String uid = "";
|
||||
String location = "";
|
||||
List<dynamic> location;
|
||||
TimeRange availableTime;
|
||||
Int64 price;
|
||||
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 this.name.compareTo(other.name);
|
||||
}
|
||||
}
|
||||
|
||||
class Filter {
|
||||
String? location;
|
||||
Int64? price;
|
||||
List<String>? locations;
|
||||
PriceRange? price;
|
||||
TimeRange? meetingTime;
|
||||
|
||||
Filter(this.location, this.price, this.meetingTime);
|
||||
Filter(this.locations, this.price, this.meetingTime);
|
||||
}
|
||||
|
||||
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', isEqualTo: filter.location)
|
||||
.where('price', isEqualTo: filter.price)
|
||||
.where('start-time',
|
||||
isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
|
||||
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
|
||||
.where('location', arrayContainsAny: filter.locations)
|
||||
.where('price',
|
||||
isGreaterThanOrEqualTo: filter.price?.low,
|
||||
isLessThanOrEqualTo: filter.price?.high);
|
||||
|
||||
final QuerySnapshot snapshot = await query.get();
|
||||
final startTime = filter.meetingTime?.endTime;
|
||||
final endTime = filter.meetingTime?.startTime;
|
||||
|
||||
if (startTime != null && endTime != null) {
|
||||
var docs = snapshot.docs
|
||||
.where((element) =>
|
||||
startTime.compareTo(element["start-time"]) > 0 ||
|
||||
element["start-time"] == (startTime))
|
||||
.where((element) =>
|
||||
endTime.compareTo(element["end-time"]) < 0 ||
|
||||
element["end-time"] == (endTime));
|
||||
for (var doc in docs) {
|
||||
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||
}
|
||||
} else {
|
||||
for (var doc in snapshot.docs) {
|
||||
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||
}
|
||||
}
|
||||
return sellers;
|
||||
}
|
||||
|
@@ -8,33 +8,65 @@ class SellScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SellScreenState extends State<SellScreen> {
|
||||
Map<String, bool> values = {
|
||||
'Busch Dining Hall': false,
|
||||
'Livingston Dining Hall': false,
|
||||
'Brower Dining Hall': false,
|
||||
'Neilson Dining Hall': false,
|
||||
'Cafe West': false,
|
||||
'Cook Cafe': false,
|
||||
'Douglass Cafe': false,
|
||||
'Harvest INFH': false,
|
||||
'Kilmer\'s Market': false,
|
||||
'College Ave Dining Hall': false,
|
||||
'Red Pine Pizza': false,
|
||||
'Rock Cafe': false,
|
||||
'Sbarro': false,
|
||||
'Woody\'s Cafe': false,
|
||||
};
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TimeOfDay _time = TimeOfDay.now();
|
||||
TimeOfDay time = TimeOfDay.now();
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.store_mall_directory, color: Colors.red),
|
||||
const Text('Place'),
|
||||
ListTile(
|
||||
title: Text(_time.format(context)),
|
||||
onTap: () {
|
||||
Future<TimeOfDay?> selectedTime = showTimePicker(
|
||||
context: context,
|
||||
initialTime: _time,
|
||||
);
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints.expand(height: 100),
|
||||
child: ListView(
|
||||
children: values.keys.map((String key) {
|
||||
return CheckboxListTile(
|
||||
title: Text(key),
|
||||
value: values[key],
|
||||
onChanged: (bool? value) {
|
||||
setState(() {
|
||||
selectedTime.then((value) => _time = value!);
|
||||
_time = TimeOfDay(hour: 10, minute: 00);
|
||||
values[key] = value!;
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
LocationDropdown(),
|
||||
Icon(Icons.access_time, color: Colors.red),
|
||||
Expanded(
|
||||
child: const Text('Time'),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(time.format(context)),
|
||||
onTap: () {
|
||||
Future<TimeOfDay?> selectedTime = showTimePicker(
|
||||
context: context,
|
||||
initialTime: time,
|
||||
);
|
||||
setState(() {
|
||||
selectedTime.then((value) => time = value!);
|
||||
time = TimeOfDay(hour: 10, minute: 00);
|
||||
});
|
||||
},
|
||||
),
|
||||
Icon(Icons.attach_money, color: Colors.red),
|
||||
Expanded(
|
||||
child: const Text('Cost'),
|
||||
@@ -45,13 +77,7 @@ class _SellScreenState extends State<SellScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
const List<String> list = <String>[
|
||||
'Brower',
|
||||
'BDH',
|
||||
'LDH',
|
||||
'Neilson',
|
||||
'Woody\'s'
|
||||
];
|
||||
const List<String> list = <String>['Brower', 'BDH', 'LDH', 'Neilson', 'Woody\'s'];
|
||||
|
||||
class LocationDropdown extends StatefulWidget {
|
||||
const LocationDropdown({super.key});
|
||||
|
Reference in New Issue
Block a user