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:
259
lib/sell.dart
259
lib/sell.dart
@@ -7,6 +7,7 @@ import 'package:currency_text_input_formatter/currency_text_input_formatter.dart
|
|||||||
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||||
import 'package:ruswipeshare/auth_gate.dart';
|
import 'package:ruswipeshare/auth_gate.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:ruswipeshare/buy.dart';
|
||||||
import 'package:ruswipeshare/meetings.dart';
|
import 'package:ruswipeshare/meetings.dart';
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
@@ -32,9 +33,9 @@ Map<String, bool> values = {
|
|||||||
|
|
||||||
class _SellScreenState extends State<SellScreen> {
|
class _SellScreenState extends State<SellScreen> {
|
||||||
DateFormat dateFormat = DateFormat("HH:mm a");
|
DateFormat dateFormat = DateFormat("HH:mm a");
|
||||||
String startTime = 'Start Time';
|
String startTime = '??:??';
|
||||||
DateTime startTimeTime = DateTime.now();
|
DateTime startTimeTime = DateTime.now();
|
||||||
String endTime = 'End Time';
|
String endTime = '??:??';
|
||||||
DateTime endTimeTime = DateTime.now();
|
DateTime endTimeTime = DateTime.now();
|
||||||
bool? is24HoursFormat;
|
bool? is24HoursFormat;
|
||||||
double price = 0;
|
double price = 0;
|
||||||
@@ -42,39 +43,39 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
||||||
|
dateFormat = is24HoursFormat ? DateFormat("HH:mm a") : DateFormat("HH:mm");
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: true,
|
body: Column(children: [
|
||||||
body: Padding(
|
Container(
|
||||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
padding: EdgeInsets.only(top: 10, left: 10),
|
||||||
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
const Icon(
|
||||||
Icons.store_mall_directory,
|
Icons.store_mall_directory,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
size: 40,
|
size: 40,
|
||||||
),
|
),
|
||||||
Text(
|
const Text(
|
||||||
'Place',
|
'Place',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
ConstrainedBox(
|
),
|
||||||
constraints: const BoxConstraints.expand(height: 250),
|
SizedBox(
|
||||||
|
height: 200,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
physics: BouncingScrollPhysics(),
|
physics: BouncingScrollPhysics(),
|
||||||
itemCount: values.length,
|
itemCount: values.length,
|
||||||
itemBuilder: (context, index) => CheckboxListTile(
|
itemBuilder: (context, index) => CheckboxListTile(
|
||||||
title: Text(values.keys.elementAt(index)),
|
visualDensity: VisualDensity.compact,
|
||||||
|
title: Text(
|
||||||
|
values.keys.elementAt(index),
|
||||||
|
style: TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
value: values.values.elementAt(index),
|
value: values.values.elementAt(index),
|
||||||
onChanged: (bool? value) {
|
onChanged: (bool? value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -83,109 +84,164 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// )
|
||||||
),
|
),
|
||||||
Row(
|
Container(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
padding: EdgeInsets.only(top: 10, left: 10),
|
||||||
children: const [
|
|
||||||
Icon(Icons.access_time, color: Colors.red),
|
|
||||||
Text('Time'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 100,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const Icon(
|
||||||
startTime,
|
Icons.access_time,
|
||||||
style: TextStyle(fontSize: 35),
|
color: Colors.red,
|
||||||
|
size: 40,
|
||||||
),
|
),
|
||||||
Text(
|
const Text(
|
||||||
"to",
|
'Time',
|
||||||
style: TextStyle(fontSize: 20),
|
style: TextStyle(
|
||||||
),
|
fontSize: 30,
|
||||||
Text(
|
|
||||||
endTime,
|
|
||||||
style: TextStyle(fontSize: 35),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Expanded(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(top: 15),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(right: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
InkWell(
|
||||||
onPressed: () async {
|
onTap: () {
|
||||||
DatePicker.showDateTimePicker(context, showTitleActions: true, minTime: DateTime.now(), onChanged: (date) {
|
DatePicker.showDateTimePicker(context,
|
||||||
print('change $date');
|
showTitleActions: true,
|
||||||
}, onConfirm: (date) {
|
minTime: DateTime.now(),
|
||||||
setState(() {
|
onChanged: (date) {}, onConfirm: (date) {
|
||||||
startTimeTime = date;
|
|
||||||
startTime = dateFormat.format(date);
|
|
||||||
print('confirm $date');
|
|
||||||
});
|
|
||||||
}, currentTime: DateTime.now(), locale: LocaleType.en);
|
|
||||||
// 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 {
|
|
||||||
DatePicker.showDateTimePicker(context, showTitleActions: true, minTime: DateTime.now(), onChanged: (date) {
|
|
||||||
print('change $date');
|
|
||||||
}, onConfirm: (date) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
endTimeTime = date;
|
endTimeTime = date;
|
||||||
endTime = dateFormat.format(date);
|
endTime = dateFormat.format(date);
|
||||||
print('confirm $date');
|
|
||||||
});
|
});
|
||||||
}, currentTime: DateTime.now(), locale: LocaleType.en);
|
|
||||||
// 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'),
|
currentTime: DateTime.now(),
|
||||||
|
locale: LocaleType.en);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
border: Border.all(
|
||||||
|
width: 2,
|
||||||
|
color: CustomMaterialColor(240, 240, 240)
|
||||||
|
.mdColor)),
|
||||||
|
child: Text(
|
||||||
|
endTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
" - ",
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
DatePicker.showDateTimePicker(context,
|
||||||
|
showTitleActions: true,
|
||||||
|
minTime: DateTime.now(),
|
||||||
|
onChanged: (date) {}, onConfirm: (date) {
|
||||||
|
setState(() {
|
||||||
|
startTimeTime = date;
|
||||||
|
startTime = dateFormat.format(date);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
currentTime: DateTime.now(),
|
||||||
|
locale: LocaleType.en);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
border: Border.all(
|
||||||
|
width: 2,
|
||||||
|
color: CustomMaterialColor(240, 240, 240)
|
||||||
|
.mdColor)),
|
||||||
|
child: Text(
|
||||||
|
startTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: const [
|
|
||||||
Icon(Icons.attach_money, color: Colors.red),
|
|
||||||
Text('Cost'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, top: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.attach_money,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 40,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
'Money',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(top: 15),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(right: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
border: Border.all(
|
||||||
|
width: 2,
|
||||||
|
color: CustomMaterialColor(240, 240, 240)
|
||||||
|
.mdColor)),
|
||||||
|
child: SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(color: Colors.white, fontSize: 30),
|
style:
|
||||||
|
TextStyle(color: Colors.white, fontSize: 24),
|
||||||
controller: priceController,
|
controller: priceController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
contentPadding: EdgeInsets.zero,
|
||||||
hintText: 'Price',
|
hintText: 'Price',
|
||||||
hintStyle: TextStyle(color: Colors.white24, fontSize: 30),
|
hintStyle: TextStyle(
|
||||||
|
color: Colors.white24, fontSize: 24),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
List<String> locations = [];
|
List<String> locations = [];
|
||||||
User? user = auth.currentUser;
|
User? user = auth.currentUser;
|
||||||
@@ -193,17 +249,22 @@ 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(user.displayName, user.uid, locations, TimeRange(Timestamp.fromDate(startTimeTime), Timestamp.fromDate(endTimeTime)), double.parse(priceController.text));
|
Seller seller = Seller(
|
||||||
|
user.displayName,
|
||||||
|
user.uid,
|
||||||
|
locations,
|
||||||
|
TimeRange(Timestamp.fromDate(startTimeTime),
|
||||||
|
Timestamp.fromDate(endTimeTime)),
|
||||||
|
double.parse(priceController.text));
|
||||||
addSeller(seller);
|
addSeller(seller);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor: MaterialStateColor.resolveWith((states) => Colors.blue),
|
|
||||||
),
|
|
||||||
child: const Text('Submit Sell Request'),
|
child: const Text('Submit Sell Request'),
|
||||||
),
|
),
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user