mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
Auto stash before merge of "master" and "origin/master"
This commit is contained in:
410
lib/buy.dart
410
lib/buy.dart
@@ -24,6 +24,42 @@ final List<String> entries = <String>[
|
|||||||
'Pearl Morse',
|
'Pearl Morse',
|
||||||
'Jana Munguia'
|
'Jana Munguia'
|
||||||
];
|
];
|
||||||
|
final List<double> prices = <double>[
|
||||||
|
1.00,
|
||||||
|
2.00,
|
||||||
|
3.00,
|
||||||
|
4.00,
|
||||||
|
5.00,
|
||||||
|
6.00,
|
||||||
|
7.00,
|
||||||
|
8.00,
|
||||||
|
9.00,
|
||||||
|
10.00,
|
||||||
|
];
|
||||||
|
final List<DateTime> startTime = <DateTime>[
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
];
|
||||||
|
final List<DateTime> endTime = <DateTime>[
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
DateTime.now(),
|
||||||
|
];
|
||||||
final Map<String, String> nameToAsset = {
|
final Map<String, String> nameToAsset = {
|
||||||
'Brower Dining Hall': 'brower.jpg',
|
'Brower Dining Hall': 'brower.jpg',
|
||||||
'Cafe West': 'cafe_west.jpg',
|
'Cafe West': 'cafe_west.jpg',
|
||||||
@@ -38,6 +74,20 @@ final Map<String, String> nameToAsset = {
|
|||||||
'Harvest INFH': 'harvest.jpg',
|
'Harvest INFH': 'harvest.jpg',
|
||||||
'Red Pine Pizza': 'red_pine.jpg'
|
'Red Pine Pizza': 'red_pine.jpg'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Future<int> numberOfSellersAtDiningLocation(String diningLocation) async {
|
||||||
|
var sellers = await getSellers(Filter([diningLocation], null, null));
|
||||||
|
return sellers.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<int>> numberOfSellersAtEachDiningLocation() async {
|
||||||
|
List<int> numSellers = [];
|
||||||
|
for (var diningLocation in entries) {
|
||||||
|
numSellers.add(await numberOfSellersAtDiningLocation(diningLocation));
|
||||||
|
}
|
||||||
|
return numSellers;
|
||||||
|
}
|
||||||
|
|
||||||
final List<List<String>> eatingLocations = [
|
final List<List<String>> eatingLocations = [
|
||||||
<String>['Brower Dining Hall', 'Cafe West'],
|
<String>['Brower Dining Hall', 'Cafe West'],
|
||||||
<String>['Busch Dining Hall', 'Woody\'s Cafe'],
|
<String>['Busch Dining Hall', 'Woody\'s Cafe'],
|
||||||
@@ -46,20 +96,10 @@ final List<List<String>> eatingLocations = [
|
|||||||
'Kilmer\'s Market',
|
'Kilmer\'s Market',
|
||||||
'Sbarro\'s',
|
'Sbarro\'s',
|
||||||
],
|
],
|
||||||
<String>[
|
<String>['Neilson Dining Hall', 'Cook Cafe', 'Douglass Cafe', 'Harvest INFH', 'Red Pine Pizza']
|
||||||
'Neilson Dining Hall',
|
|
||||||
'Cook Cafe',
|
|
||||||
'Douglass Cafe',
|
|
||||||
'Harvest INFH',
|
|
||||||
'Red Pine Pizza'
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
final List<int> colorCodes = <int>[600, 500, 100];
|
final List<int> colorCodes = <int>[600, 500, 100];
|
||||||
final List<String> timeBgAssets = <String>[
|
final List<String> timeBgAssets = <String>['assets/daytime_swipe.jpg', 'assets/afternoon_swipe.jpg', 'assets/nighttime_swipe.jpg'];
|
||||||
'assets/daytime_swipe.jpg',
|
|
||||||
'assets/afternoon_swipe.jpg',
|
|
||||||
'assets/nighttime_swipe.jpg'
|
|
||||||
];
|
|
||||||
|
|
||||||
class BuyScreen extends StatefulWidget {
|
class BuyScreen extends StatefulWidget {
|
||||||
const BuyScreen({Key? key}) : super(key: key);
|
const BuyScreen({Key? key}) : super(key: key);
|
||||||
@@ -69,6 +109,8 @@ class BuyScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BuyScreenState extends State<BuyScreen> {
|
class _BuyScreenState extends State<BuyScreen> {
|
||||||
|
DateFormat dateFormat = DateFormat("HH:mm aa");
|
||||||
|
|
||||||
CampusState _currentState = CampusState.campuses;
|
CampusState _currentState = CampusState.campuses;
|
||||||
List<String> _diningOptions = List.empty();
|
List<String> _diningOptions = List.empty();
|
||||||
List<Seller> _sellersAtDiningHall = [];
|
List<Seller> _sellersAtDiningHall = [];
|
||||||
@@ -83,7 +125,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Row(children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(left: 10, top: 20),
|
padding: EdgeInsets.only(left: 10, top: 35),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Campuses",
|
"Campuses",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -111,8 +153,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
||||||
const BorderRadius.all(Radius.circular(25)),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -142,8 +183,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
||||||
const BorderRadius.all(Radius.circular(25)),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -173,8 +213,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
||||||
const BorderRadius.all(Radius.circular(25)),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -204,8 +243,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
||||||
const BorderRadius.all(Radius.circular(25)),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -237,7 +275,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(children: [
|
body: Column(children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
|
padding: EdgeInsets.fromLTRB(0, 35, 0, 0),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -266,12 +304,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.fromLTRB(4, 4, 4, 8),
|
margin: const EdgeInsets.fromLTRB(4, 4, 4, 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(border: Border.all(color: CustomMaterialColor(240, 240, 240).mdColor, width: 2), borderRadius: const BorderRadius.all(Radius.circular(10))),
|
||||||
border: Border.all(
|
|
||||||
color: CustomMaterialColor(240, 240, 240).mdColor,
|
|
||||||
width: 2),
|
|
||||||
borderRadius:
|
|
||||||
const BorderRadius.all(Radius.circular(10))),
|
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -280,24 +313,20 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
const BorderRadius.all(Radius.circular(10)),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 120,
|
height: 120,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
image: AssetImage("assets/" +
|
image: AssetImage("assets/" + nameToAsset[_diningOptions.elementAt(index)]!),
|
||||||
nameToAsset[
|
|
||||||
_diningOptions.elementAt(index)]!),
|
|
||||||
)),
|
)),
|
||||||
child: BackdropFilter(
|
child: BackdropFilter(
|
||||||
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
|
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(right: 40),
|
padding: const EdgeInsets.only(right: 40),
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
margin: const EdgeInsets.only(
|
margin: const EdgeInsets.only(top: 4, left: 20, bottom: 4),
|
||||||
top: 4, left: 20, bottom: 4),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
_diningOptions[index],
|
_diningOptions[index],
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@@ -318,10 +347,8 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
|
padding: EdgeInsets.fromLTRB(0, 35, 0, 0),
|
||||||
child: Row(
|
child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 8,
|
flex: 8,
|
||||||
fit: FlexFit.tight,
|
fit: FlexFit.tight,
|
||||||
@@ -333,164 +360,183 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
},
|
},
|
||||||
child: const Text("Choose A Different Location")),
|
child: const Text("Choose A Different Location")),
|
||||||
),
|
),
|
||||||
Flexible(
|
Flexible(flex: 2, child: ElevatedButton(onPressed: () {}, child: const Icon(Icons.filter_list)))
|
||||||
flex: 2,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {},
|
|
||||||
child: const Icon(Icons.filter_list)))
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
Row(children: [
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(left: 10, bottom: 10),
|
padding: EdgeInsets.only(left: 10, bottom: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Available Swipes",
|
_selectedLocation,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, bottom: 10),
|
||||||
|
child: Text(
|
||||||
|
"Time: "+dateFormat.format(DateTime.now()),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
]),
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
itemCount: 30,
|
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
List<Seller> sellers = [];
|
var loc = _diningOptions[index];
|
||||||
var loc = _diningOptions[index % _diningOptions.length];
|
|
||||||
|
|
||||||
return FutureBuilder<List<Seller>>(
|
return FutureBuilder<List<Seller>>(
|
||||||
future: getSellers(Filter([loc], null, null)),
|
future: getSellers(Filter([loc], null, null)),
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context, AsyncSnapshot<List<Seller>> snapshot) {
|
||||||
AsyncSnapshot<List<Seller>> snapshot) {
|
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final data = snapshot.data ?? [];
|
final data = snapshot.data ?? [];
|
||||||
String startTimeFmt = DateFormat("h:mm a").format(
|
String startTimeFmt = DateFormat("h:mm a").format(data[index].availableTime.startTime.toDate());
|
||||||
data[index % data.length]
|
|
||||||
.availableTime
|
|
||||||
.startTime
|
|
||||||
.toDate());
|
|
||||||
|
|
||||||
String endTimeFmt = DateFormat("h:mm a").format(
|
String? sellerName = data[index].name;
|
||||||
data[index % data.length]
|
|
||||||
.availableTime
|
|
||||||
.endTime
|
|
||||||
.toDate());
|
|
||||||
|
|
||||||
final price = data[index % data.length].price;
|
String endTimeFmt = DateFormat("h:mm a").format(data[index].availableTime.endTime.toDate());
|
||||||
|
|
||||||
|
final price = data[index].price;
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showSheet(context, index);
|
showSheet(context, index, sellerName, price, data[index].availableTime.startTime.toDate(), data[index % data.length].availableTime.endTime.toDate(),
|
||||||
|
_selectedLocation);
|
||||||
|
// showDialog(
|
||||||
|
// context: context,
|
||||||
|
// builder: (BuildContext context) => Dialog(
|
||||||
|
// backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: const EdgeInsets.all(8.0),
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: <Widget>[
|
||||||
|
// const Text('Transaction Details'),
|
||||||
|
// const SizedBox(height: 15),
|
||||||
|
// TextButton(
|
||||||
|
// onPreslectedd: () {
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// },
|
||||||
|
// child: const Text('Close'),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// )));
|
||||||
|
// // Dialogs.materialDialog(
|
||||||
|
// // color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
// // customView: const TransactionDetails(),
|
||||||
|
// // customViewPosition:
|
||||||
|
// // CustomViewPosition.BEFORE_ACTION,
|
||||||
|
// // msgAlign: TextAlign.center,
|
||||||
|
// // msg:
|
||||||
|
// // 'Please read all the information below before purchasing.\n',
|
||||||
|
// // title: 'Transaction Details',
|
||||||
|
// // context: context,
|
||||||
|
// // actions: [
|
||||||
|
// // IconsOutlineButton(
|
||||||
|
// // onPressed: () {},
|
||||||
|
// // text: 'Cancel',
|
||||||
|
// // iconData: Icons.cancel_outlined,
|
||||||
|
// // color: Theme.of(context).primaryColor,
|
||||||
|
// // textStyle: TextStyle(
|
||||||
|
// // color: CustomMaterialColor(240, 240, 240)
|
||||||
|
// // .mdColor,
|
||||||
|
// // ),
|
||||||
|
// // iconColor: CustomMaterialColor(240, 240, 240)
|
||||||
|
// // .mdColor),
|
||||||
|
// // IconsButton(
|
||||||
|
// // onPressed: () {},
|
||||||
|
// // text: 'Purchase',
|
||||||
|
// // iconData: Icons.done,
|
||||||
|
// // color: Colors.green,
|
||||||
|
// // textStyle: TextStyle(
|
||||||
|
// // color: CustomMaterialColor(240, 240, 240)
|
||||||
|
// // .mdColor,
|
||||||
|
// // ),
|
||||||
|
// // iconColor: CustomMaterialColor(240, 240, 240)
|
||||||
|
// // .mdColor),
|
||||||
|
// // ],
|
||||||
|
// // );
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(border: Border.all(color: CustomMaterialColor(240, 240, 240).mdColor, width: 2), borderRadius: const BorderRadius.all(Radius.circular(10))),
|
||||||
border: Border.all(
|
|
||||||
color:
|
|
||||||
CustomMaterialColor(240, 240, 240)
|
|
||||||
.mdColor,
|
|
||||||
width: 2),
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
Radius.circular(10))),
|
|
||||||
margin: const EdgeInsets.all(4),
|
margin: const EdgeInsets.all(4),
|
||||||
height: 120,
|
height: 120,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
Radius.circular(10)),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
colorFilter: const ColorFilter.mode(
|
colorFilter: const ColorFilter.mode(Colors.black26, BlendMode.darken),
|
||||||
Colors.black26, BlendMode.darken),
|
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
image:
|
image: AssetImage(timeBgAssets[index % 3]),
|
||||||
AssetImage(timeBgAssets[index % 3]),
|
|
||||||
)),
|
)),
|
||||||
child: BackdropFilter(
|
child: BackdropFilter(
|
||||||
filter: ImageFilter.blur(
|
filter: ImageFilter.blur(sigmaX: 2, sigmaY: 2),
|
||||||
sigmaX: 2, sigmaY: 2),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 6,
|
flex: 6,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding: EdgeInsets.only(left: 20),
|
||||||
EdgeInsets.only(left: 20),
|
|
||||||
// color: Colors.red,
|
// color: Colors.red,
|
||||||
margin: const EdgeInsets.only(
|
margin: const EdgeInsets.only(top: 4, left: 4, bottom: 4),
|
||||||
top: 4, left: 4, bottom: 4),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
data?[index % data.length]
|
data?[index].name ?? "Unknown Seller",
|
||||||
.name ??
|
|
||||||
"Unknown Seller",
|
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
overflow:
|
overflow: TextOverflow.ellipsis,
|
||||||
TextOverflow.ellipsis,
|
style: const TextStyle(fontSize: 24),
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24),
|
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.star,
|
Icon(
|
||||||
color:
|
Icons.star,
|
||||||
CustomMaterialColor(
|
color: Colors.yellow,
|
||||||
240,
|
size: 16,
|
||||||
240,
|
),
|
||||||
240)
|
Icon(
|
||||||
.mdColor,
|
Icons.star,
|
||||||
size: 16),
|
color: Colors.yellow,
|
||||||
Icon(Icons.star,
|
size: 16,
|
||||||
color:
|
),
|
||||||
CustomMaterialColor(
|
Icon(
|
||||||
240,
|
Icons.star,
|
||||||
240,
|
color: Colors.yellow,
|
||||||
240)
|
size: 16,
|
||||||
.mdColor,
|
),
|
||||||
size: 16),
|
Icon(
|
||||||
Icon(Icons.star,
|
Icons.star_half,
|
||||||
color:
|
color: Colors.yellow,
|
||||||
CustomMaterialColor(
|
size: 16,
|
||||||
240,
|
),
|
||||||
240,
|
Icon(
|
||||||
240)
|
Icons.star_border,
|
||||||
.mdColor,
|
color: Colors.yellow,
|
||||||
size: 16),
|
size: 16,
|
||||||
Icon(Icons.star_half,
|
),
|
||||||
color:
|
|
||||||
CustomMaterialColor(
|
|
||||||
240,
|
|
||||||
240,
|
|
||||||
240)
|
|
||||||
.mdColor,
|
|
||||||
size: 16),
|
|
||||||
Icon(Icons.star_border,
|
|
||||||
color:
|
|
||||||
CustomMaterialColor(
|
|
||||||
240,
|
|
||||||
240,
|
|
||||||
240)
|
|
||||||
.mdColor,
|
|
||||||
size: 16),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
MainAxisAlignment.end,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"$startTimeFmt - $endTimeFmt",
|
"$startTimeFmt - $endTimeFmt",
|
||||||
textAlign:
|
textAlign: TextAlign.start,
|
||||||
TextAlign.start,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow
|
style: TextStyle(fontSize: 16),
|
||||||
.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -502,8 +548,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding: EdgeInsets.only(right: 15),
|
||||||
EdgeInsets.only(right: 15),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
'\$${price}',
|
'\$${price}',
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
@@ -521,7 +566,12 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
return Text("${snapshot.error}");
|
return Text("${snapshot.error}");
|
||||||
}
|
}
|
||||||
return CircularProgressIndicator();
|
return const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
child: const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -532,7 +582,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> showSheet(BuildContext context, int index) {
|
Future<dynamic> showSheet(BuildContext context, int index, String? sellerName, double SellerPrice, DateTime startTime, DateTime endTime, String sellerLocation) {
|
||||||
return showModalBottomSheet(
|
return showModalBottomSheet(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
context: context,
|
context: context,
|
||||||
@@ -546,7 +596,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
topLeft: Radius.circular(15),
|
topLeft: Radius.circular(15),
|
||||||
topRight: Radius.circular(15),
|
topRight: Radius.circular(15),
|
||||||
),
|
),
|
||||||
color: Colors.black,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -560,7 +610,7 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
"Transaction Details",
|
"Transaction Details",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.black,
|
||||||
fontFamily: 'Proxima',
|
fontFamily: 'Proxima',
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@@ -641,13 +691,75 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.person,
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
sellerName!,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontFamily: 'Proxima',
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.calendar_today,
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
"${dateFormat.format(startTime)} - ${dateFormat.format(endTime)}",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontFamily: 'Proxima',
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.attach_money,
|
||||||
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
SellerPrice.toString(),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontFamily: 'Proxima',
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(
|
||||||
|
Icons.map,
|
||||||
|
color: Colors.orange,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
sellerLocation,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontFamily: 'Proxima',
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Cancel",
|
"Cancel",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
103
lib/sell.dart
103
lib/sell.dart
@@ -19,6 +19,8 @@ class SellScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, bool> values = {
|
Map<String, bool> values = {
|
||||||
|
'Busch Dining Hall': false,
|
||||||
|
'Woody\'s Cafe': false,
|
||||||
'Brower Dining Hall': false,
|
'Brower Dining Hall': false,
|
||||||
'Cafe West': false,
|
'Cafe West': false,
|
||||||
'Livingston Dining Hall': false,
|
'Livingston Dining Hall': false,
|
||||||
@@ -47,7 +49,10 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(children: [
|
body: Column(children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 10, left: 10),
|
padding: EdgeInsets.only(
|
||||||
|
top: 35,
|
||||||
|
left: 10,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -111,29 +116,29 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
DatePicker.showDateTimePicker(context,
|
final TimeOfDay? picked = await showTimePicker(
|
||||||
showTitleActions: true,
|
context: context,
|
||||||
minTime: DateTime.now(),
|
initialTime: TimeOfDay.fromDateTime(startTimeTime),
|
||||||
onChanged: (date) {}, onConfirm: (date) {
|
);
|
||||||
|
if (picked != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
endTimeTime = date;
|
startTimeTime = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, picked.hour, picked.minute);
|
||||||
endTime = dateFormat.format(date);
|
startTime = "${startTimeTime.hour}:${startTimeTime.minute}${(is24HoursFormat) ? "" : ((startTimeTime.hour > 12) ? "PM" : "AM")}";
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
currentTime: DateTime.now(),
|
// DatePicker.showDateTimePicker(context, showTitleActions: true, minTime: DateTime.now(), onChanged: (date) {}, onConfirm: (date) {
|
||||||
locale: LocaleType.en);
|
// setState(() {
|
||||||
|
// startTimeTime = date;
|
||||||
|
// startTime = dateFormat.format(date);
|
||||||
|
// });
|
||||||
|
// }, currentTime: DateTime.now(), locale: LocaleType.en);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(4),
|
padding: EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), border: Border.all(width: 2, color: CustomMaterialColor(240, 240, 240).mdColor)),
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: CustomMaterialColor(240, 240, 240)
|
|
||||||
.mdColor)),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
endTime,
|
startTime,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
),
|
),
|
||||||
@@ -145,29 +150,34 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
style: TextStyle(fontSize: 20),
|
style: TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
DatePicker.showDateTimePicker(context,
|
final TimeOfDay? picked = await showTimePicker(
|
||||||
showTitleActions: true,
|
context: context,
|
||||||
minTime: DateTime.now(),
|
initialTime: TimeOfDay.fromDateTime(endTimeTime),
|
||||||
onChanged: (date) {}, onConfirm: (date) {
|
);
|
||||||
|
if (picked != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
startTimeTime = date;
|
endTimeTime = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, picked.hour, picked.minute);
|
||||||
startTime = dateFormat.format(date);
|
endTime = endTimeTime.hour.toString() + ":" + endTimeTime.minute.toString() + ((is24HoursFormat) ? "" : ((endTimeTime.hour > 12) ? "PM" : "AM"));
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
currentTime: DateTime.now(),
|
// DatePicker.showDateTimePicker(context,
|
||||||
locale: LocaleType.en);
|
// showTitleActions: true,
|
||||||
|
// minTime: DateTime.now(),
|
||||||
|
// onChanged: (date) {}, onConfirm: (date) {
|
||||||
|
// setState(() {
|
||||||
|
// endTimeTime = date;
|
||||||
|
// endTime = dateFormat.format(date);
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// currentTime: DateTime.now(),
|
||||||
|
// locale: LocaleType.en);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(4),
|
padding: EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), border: Border.all(width: 2, color: CustomMaterialColor(240, 240, 240).mdColor)),
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: CustomMaterialColor(240, 240, 240)
|
|
||||||
.mdColor)),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
startTime,
|
endTime,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
),
|
),
|
||||||
@@ -192,7 +202,7 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
size: 40,
|
size: 40,
|
||||||
),
|
),
|
||||||
const Text(
|
const Text(
|
||||||
'Money',
|
'Cost',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
@@ -207,25 +217,18 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(4),
|
padding: EdgeInsets.all(4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0), border: Border.all(width: 2, color: CustomMaterialColor(240, 240, 240).mdColor)),
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: CustomMaterialColor(240, 240, 240)
|
|
||||||
.mdColor)),
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style:
|
style: TextStyle(color: Colors.white, fontSize: 24),
|
||||||
TextStyle(color: Colors.white, fontSize: 24),
|
|
||||||
controller: priceController,
|
controller: priceController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
hintText: 'Price',
|
hintText: 'Price',
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(color: Colors.white24, fontSize: 24),
|
||||||
color: Colors.white24, fontSize: 24),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -249,13 +252,7 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
if (value == true) locations.add(key);
|
if (value == true) locations.add(key);
|
||||||
});
|
});
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
Seller seller = Seller(
|
Seller seller = Seller(user.displayName, user.uid, locations, TimeRange(Timestamp.fromDate(startTimeTime), Timestamp.fromDate(endTimeTime)), double.parse(priceController.text));
|
||||||
user.displayName,
|
|
||||||
user.uid,
|
|
||||||
locations,
|
|
||||||
TimeRange(Timestamp.fromDate(startTimeTime),
|
|
||||||
Timestamp.fromDate(endTimeTime)),
|
|
||||||
double.parse(priceController.text));
|
|
||||||
addSeller(seller);
|
addSeller(seller);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user