sellers page

This commit is contained in:
2023-02-26 00:58:16 -05:00
parent 4cbe480b01
commit 6b1cd0b36d
2 changed files with 151 additions and 62 deletions

View File

@@ -40,17 +40,13 @@ Future<List<Seller>> getSellers(Filter filter) async {
final Query query = users final Query query = users
.where('location', arrayContainsAny: filter.locations) .where('location', arrayContainsAny: filter.locations)
.where('price', .where('price', isGreaterThanOrEqualTo: filter.price?.low, isLessThanOrEqualTo: filter.price?.high)
isGreaterThanOrEqualTo: filter.price?.low, .where('start-time', isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
isLessThanOrEqualTo: filter.price?.high)
.where('start-time',
isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime); .where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
final QuerySnapshot snapshot = await query.get(); final QuerySnapshot snapshot = await query.get();
for (var doc in snapshot.docs) { for (var doc in snapshot.docs) {
sellers.add(Seller(doc["name"], doc["uid"], doc["location"], sellers.add(Seller(doc["name"], doc["uid"], doc["location"], TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
} }
return sellers; return sellers;
} }

View File

@@ -1,4 +1,7 @@
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:ruswipeshare/meetings.dart';
class SellScreen extends StatefulWidget { class SellScreen extends StatefulWidget {
const SellScreen({Key? key}) : super(key: key); const SellScreen({Key? key}) : super(key: key);
@@ -7,73 +10,157 @@ class SellScreen extends StatefulWidget {
_SellScreenState createState() => _SellScreenState(); _SellScreenState createState() => _SellScreenState();
} }
Map<String, bool> values = {
'Brower Dining Hall': false,
'Cafe West': false,
'Livingston Dining Hall': false,
'Kilmer\'s Market': false,
'Sbarro\'s': false,
'Neilson Dining Hall': false,
'Cook Cafe': false,
'Douglass Cafe': false,
'Harvest INFH': false,
'Red Pine Pizza': false,
};
class _SellScreenState extends State<SellScreen> { class _SellScreenState extends State<SellScreen> {
Map<String, bool> values = { String startTime = 'Start Time';
'Busch Dining Hall': false, DateTime startTimeTime = DateTime.now();
'Livingston Dining Hall': false, String endTime = 'End Time';
'Brower Dining Hall': false, DateTime endTimeTime = DateTime.now();
'Neilson Dining Hall': false, bool? is24HoursFormat;
'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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
TimeOfDay time = TimeOfDay.now(); bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Sell'), title: const Text('Sell'),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
), ),
body: Column( body: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Icon(Icons.store_mall_directory, color: Colors.red), Row(
const Text('Place'), mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.store_mall_directory, color: Colors.red),
Text('Place'),
],
),
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints.expand(height: 100), constraints: const BoxConstraints.expand(height: 250),
child: ListView( child: ListView.builder(
children: values.keys.map((String key) { itemCount: values.length,
return CheckboxListTile( itemBuilder: (context, index) => CheckboxListTile(
title: Text(key), title: Text(values.keys.elementAt(index)),
value: values[key], value: values.values.elementAt(index),
onChanged: (bool? value) { onChanged: (bool? value) {
setState(() { setState(() {
values[key] = value!; values[values.keys.elementAt(index)] = value!;
}); });
}, },
); ),
}).toList(),
), ),
), ),
LocationDropdown(), Row(
Icon(Icons.access_time, color: Colors.red), mainAxisAlignment: MainAxisAlignment.center,
Expanded( children: [
child: const Text('Time'), Icon(Icons.access_time, color: Colors.red),
Text('Time'),
],
), ),
ListTile( SizedBox(
title: Text(time.format(context)), height: 100,
onTap: () { child: Row(
Future<TimeOfDay?> selectedTime = showTimePicker( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
context: context, children: [
initialTime: time, Text(
); startTime,
setState(() { style: TextStyle(fontSize: 35),
selectedTime.then((value) => time = value!); ),
time = TimeOfDay(hour: 10, minute: 00); Text(
}); "to",
}, style: TextStyle(fontSize: 20),
),
Text(
endTime,
style: TextStyle(fontSize: 35),
),
],
),
), ),
Icon(Icons.attach_money, color: Colors.red), Row(
Expanded( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
child: const Text('Cost'), children: [
ElevatedButton(
onPressed: () async {
final TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.fromDateTime(startTimeTime),
);
if (picked != null && picked != TimeOfDay.fromDateTime(startTimeTime)) {
setState(() {
startTimeTime = DateTime.fromMicrosecondsSinceEpoch(picked.hour * 60 * 60 * 1000000 + picked.minute * 60 * 1000000, isUtc: true);
startTime = startTimeTime.hour.toString() + ":" + startTimeTime.minute.toString() + ((is24HoursFormat) ? "" : ((startTimeTime.hour > 12) ? "PM" : "AM"));
});
}
},
child: const Text('Select Start Time'),
),
ElevatedButton(
onPressed: () async {
final TimeOfDay? picked = await showTimePicker(
context: context,
initialTime: TimeOfDay.fromDateTime(endTimeTime),
);
if (picked != null && picked != TimeOfDay.fromDateTime(endTimeTime)) {
setState(() {
endTimeTime = DateTime.fromMicrosecondsSinceEpoch(picked.hour * 60 * 60 * 1000000 + picked.minute * 60 * 1000000, isUtc: true);
endTime = endTimeTime.hour.toString() + ":" + endTimeTime.minute.toString() + ((is24HoursFormat) ? "" : ((endTimeTime.hour > 12) ? "PM" : "AM"));
});
}
},
child: const Text('Select End Time'),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.attach_money, color: Colors.red),
Text('Cost'),
],
),
//make a row with a text selector for min and max swipe cost
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Min price',
),
),
),
SizedBox(
width: 150,
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Max price',
),
),
),
],
),
ElevatedButton(
onPressed: () {},
style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith((states) => Colors.blue),
),
child: const Text('Next'),
), ),
], ],
), ),
@@ -81,8 +168,6 @@ class _SellScreenState extends State<SellScreen> {
} }
} }
const List<String> list = <String>['Brower', 'BDH', 'LDH', 'Neilson', 'Woody\'s'];
class LocationDropdown extends StatefulWidget { class LocationDropdown extends StatefulWidget {
const LocationDropdown({super.key}); const LocationDropdown({super.key});
@@ -90,8 +175,15 @@ class LocationDropdown extends StatefulWidget {
State<LocationDropdown> createState() => _LocationDropdownState(); State<LocationDropdown> createState() => _LocationDropdownState();
} }
const List<String> list = <String>[
'Busch',
'College Ave',
'Cook/Doug',
'Livingston',
];
class _LocationDropdownState extends State<LocationDropdown> { class _LocationDropdownState extends State<LocationDropdown> {
String dropdownValue = list.first; String dropdownValue = 'Busch';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -99,6 +191,7 @@ class _LocationDropdownState extends State<LocationDropdown> {
value: dropdownValue, value: dropdownValue,
onChanged: (String? value) { onChanged: (String? value) {
// This is called when the user selects an item. // This is called when the user selects an item.
setState(() { setState(() {
dropdownValue = value!; dropdownValue = value!;
}); });