mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
sellers page
This commit is contained in:
@@ -40,17 +40,13 @@ Future<List<Seller>> getSellers(Filter filter) async {
|
||||
|
||||
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('price', isGreaterThanOrEqualTo: filter.price?.low, isLessThanOrEqualTo: filter.price?.high)
|
||||
.where('start-time', isGreaterThanOrEqualTo: filter.meetingTime?.startTime)
|
||||
.where('end-time', isLessThanOrEqualTo: filter.meetingTime?.endTime);
|
||||
|
||||
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;
|
||||
}
|
||||
|
203
lib/sell.dart
203
lib/sell.dart
@@ -1,4 +1,7 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ruswipeshare/meetings.dart';
|
||||
|
||||
class SellScreen extends StatefulWidget {
|
||||
const SellScreen({Key? key}) : super(key: key);
|
||||
@@ -7,73 +10,157 @@ class SellScreen extends StatefulWidget {
|
||||
_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> {
|
||||
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,
|
||||
};
|
||||
String startTime = 'Start Time';
|
||||
DateTime startTimeTime = DateTime.now();
|
||||
String endTime = 'End Time';
|
||||
DateTime endTimeTime = DateTime.now();
|
||||
bool? is24HoursFormat;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TimeOfDay time = TimeOfDay.now();
|
||||
bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sell'),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Icon(Icons.store_mall_directory, color: Colors.red),
|
||||
const Text('Place'),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.store_mall_directory, color: Colors.red),
|
||||
Text('Place'),
|
||||
],
|
||||
),
|
||||
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(() {
|
||||
values[key] = value!;
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
constraints: const BoxConstraints.expand(height: 250),
|
||||
child: ListView.builder(
|
||||
itemCount: values.length,
|
||||
itemBuilder: (context, index) => CheckboxListTile(
|
||||
title: Text(values.keys.elementAt(index)),
|
||||
value: values.values.elementAt(index),
|
||||
onChanged: (bool? value) {
|
||||
setState(() {
|
||||
values[values.keys.elementAt(index)] = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
LocationDropdown(),
|
||||
Icon(Icons.access_time, color: Colors.red),
|
||||
Expanded(
|
||||
child: const Text('Time'),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.access_time, color: Colors.red),
|
||||
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);
|
||||
});
|
||||
},
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text(
|
||||
startTime,
|
||||
style: TextStyle(fontSize: 35),
|
||||
),
|
||||
Text(
|
||||
"to",
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Text(
|
||||
endTime,
|
||||
style: TextStyle(fontSize: 35),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.attach_money, color: Colors.red),
|
||||
Expanded(
|
||||
child: const Text('Cost'),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
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 {
|
||||
const LocationDropdown({super.key});
|
||||
|
||||
@@ -90,8 +175,15 @@ class LocationDropdown extends StatefulWidget {
|
||||
State<LocationDropdown> createState() => _LocationDropdownState();
|
||||
}
|
||||
|
||||
const List<String> list = <String>[
|
||||
'Busch',
|
||||
'College Ave',
|
||||
'Cook/Doug',
|
||||
'Livingston',
|
||||
];
|
||||
|
||||
class _LocationDropdownState extends State<LocationDropdown> {
|
||||
String dropdownValue = list.first;
|
||||
String dropdownValue = 'Busch';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -99,6 +191,7 @@ class _LocationDropdownState extends State<LocationDropdown> {
|
||||
value: dropdownValue,
|
||||
onChanged: (String? value) {
|
||||
// This is called when the user selects an item.
|
||||
|
||||
setState(() {
|
||||
dropdownValue = value!;
|
||||
});
|
||||
|
Reference in New Issue
Block a user