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:
@@ -11,11 +11,7 @@ Future<void> addUser(String? name, String uid) async {
|
|||||||
final CollectionReference users =
|
final CollectionReference users =
|
||||||
FirebaseFirestore.instance.collection('users');
|
FirebaseFirestore.instance.collection('users');
|
||||||
return await users
|
return await users
|
||||||
.add({
|
.add({'name': name, 'uid': uid, 'swipes': 0, 'seller-id': ""})
|
||||||
'name': name,
|
|
||||||
'uid': uid,
|
|
||||||
'swipes': 0,
|
|
||||||
})
|
|
||||||
.then((value) => print(""))
|
.then((value) => print(""))
|
||||||
.catchError((error) => print("ERROR ADDING DATA: $error"));
|
.catchError((error) => print("ERROR ADDING DATA: $error"));
|
||||||
}
|
}
|
||||||
@@ -76,7 +72,7 @@ class AuthGate extends StatelessWidget {
|
|||||||
final name = user.displayName;
|
final name = user.displayName;
|
||||||
final uid = user.uid;
|
final uid = user.uid;
|
||||||
|
|
||||||
addUser(name, uid);
|
addUser("TOAA", uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ class Seller implements Comparable<Seller> {
|
|||||||
String uid = "";
|
String uid = "";
|
||||||
List<dynamic> location;
|
List<dynamic> location;
|
||||||
TimeRange availableTime;
|
TimeRange availableTime;
|
||||||
int price;
|
double price;
|
||||||
|
|
||||||
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
|
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
|
||||||
|
|
||||||
@@ -56,6 +56,22 @@ List<Seller> fetchNSellers(int n) {
|
|||||||
return sellers;
|
return sellers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addSeller(Seller seller) async {
|
||||||
|
final CollectionReference sellers =
|
||||||
|
FirebaseFirestore.instance.collection('sellers');
|
||||||
|
return await sellers
|
||||||
|
.add({
|
||||||
|
'name': seller.name,
|
||||||
|
'uid': seller.uid,
|
||||||
|
'price': seller.price,
|
||||||
|
'start-time': seller.availableTime.startTime,
|
||||||
|
'end-time': seller.availableTime.endTime,
|
||||||
|
'location': seller.location,
|
||||||
|
})
|
||||||
|
.then((value) => print(""))
|
||||||
|
.catchError((error) => print("ERROR ADDING DATA: $error"));
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Seller>> getSellers(Filter filter) async {
|
Future<List<Seller>> getSellers(Filter filter) async {
|
||||||
CollectionReference users = FirebaseFirestore.instance.collection('sellers');
|
CollectionReference users = FirebaseFirestore.instance.collection('sellers');
|
||||||
List<Seller> sellers = List.empty(growable: true);
|
List<Seller> sellers = List.empty(growable: true);
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
// ignore_for_file: prefer_const_constructors
|
// ignore_for_file: prefer_const_constructors
|
||||||
|
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:currency_text_input_formatter/currency_text_input_formatter.dart';
|
import 'package:currency_text_input_formatter/currency_text_input_formatter.dart';
|
||||||
|
import 'package:ruswipeshare/auth_gate.dart';
|
||||||
import 'package:ruswipeshare/meetings.dart';
|
import 'package:ruswipeshare/meetings.dart';
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
class SellScreen extends StatefulWidget {
|
class SellScreen extends StatefulWidget {
|
||||||
const SellScreen({Key? key}) : super(key: key);
|
const SellScreen({Key? key}) : super(key: key);
|
||||||
@@ -30,13 +34,15 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
String endTime = 'End Time';
|
String endTime = 'End Time';
|
||||||
DateTime endTimeTime = DateTime.now();
|
DateTime endTimeTime = DateTime.now();
|
||||||
bool? is24HoursFormat;
|
bool? is24HoursFormat;
|
||||||
|
double price = 0;
|
||||||
|
final priceController = TextEditingController();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
bool is24HoursFormat = MediaQuery.of(context).alwaysUse24HourFormat;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
|
padding: const EdgeInsets.fromLTRB(0,8,0,0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
@@ -98,10 +104,19 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
context: context,
|
context: context,
|
||||||
initialTime: TimeOfDay.fromDateTime(startTimeTime),
|
initialTime: TimeOfDay.fromDateTime(startTimeTime),
|
||||||
);
|
);
|
||||||
if (picked != null && picked != TimeOfDay.fromDateTime(startTimeTime)) {
|
if (picked != null &&
|
||||||
|
picked != TimeOfDay.fromDateTime(startTimeTime)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
startTimeTime = DateTime.fromMicrosecondsSinceEpoch(picked.hour * 60 * 60 * 1000000 + picked.minute * 60 * 1000000, isUtc: true);
|
startTimeTime = DateTime.fromMicrosecondsSinceEpoch(
|
||||||
startTime = startTimeTime.hour.toString() + ":" + startTimeTime.minute.toString() + ((is24HoursFormat) ? "" : ((startTimeTime.hour > 12) ? "PM" : "AM"));
|
picked.hour * 60 * 60 * 1000000 +
|
||||||
|
picked.minute * 60 * 1000000,
|
||||||
|
isUtc: true);
|
||||||
|
startTime = startTimeTime.hour.toString() +
|
||||||
|
":" +
|
||||||
|
startTimeTime.minute.toString() +
|
||||||
|
((is24HoursFormat)
|
||||||
|
? ""
|
||||||
|
: ((startTimeTime.hour > 12) ? "PM" : "AM"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -113,10 +128,19 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
context: context,
|
context: context,
|
||||||
initialTime: TimeOfDay.fromDateTime(endTimeTime),
|
initialTime: TimeOfDay.fromDateTime(endTimeTime),
|
||||||
);
|
);
|
||||||
if (picked != null && picked != TimeOfDay.fromDateTime(endTimeTime)) {
|
if (picked != null &&
|
||||||
|
picked != TimeOfDay.fromDateTime(endTimeTime)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
endTimeTime = DateTime.fromMicrosecondsSinceEpoch(picked.hour * 60 * 60 * 1000000 + picked.minute * 60 * 1000000, isUtc: true);
|
endTimeTime = DateTime.fromMicrosecondsSinceEpoch(
|
||||||
endTime = endTimeTime.hour.toString() + ":" + endTimeTime.minute.toString() + ((is24HoursFormat) ? "" : ((endTimeTime.hour > 12) ? "PM" : "AM"));
|
picked.hour * 60 * 60 * 1000000 +
|
||||||
|
picked.minute * 60 * 1000000,
|
||||||
|
isUtc: true);
|
||||||
|
endTime = endTimeTime.hour.toString() +
|
||||||
|
":" +
|
||||||
|
endTimeTime.minute.toString() +
|
||||||
|
((is24HoursFormat)
|
||||||
|
? ""
|
||||||
|
: ((endTimeTime.hour > 12) ? "PM" : "AM"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -137,17 +161,36 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
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: 30),
|
||||||
|
controller: priceController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
hintText: 'Price',
|
hintText: 'Price',
|
||||||
hintStyle: TextStyle(color: Colors.white24, fontSize: 30),
|
hintStyle: TextStyle(color: Colors.white24, fontSize: 30),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
List<String> locations = [];
|
||||||
|
User? user = auth.currentUser;
|
||||||
|
values.forEach((key, value) {
|
||||||
|
if (value == true) locations.add(key);
|
||||||
|
});
|
||||||
|
if (user != null) {
|
||||||
|
Seller seller = Seller(
|
||||||
|
"",
|
||||||
|
user.uid,
|
||||||
|
locations,
|
||||||
|
TimeRange(Timestamp.fromDate(startTimeTime),
|
||||||
|
Timestamp.fromDate(endTimeTime)),
|
||||||
|
double.parse(priceController.text));
|
||||||
|
|
||||||
|
print("SIFSIFISFHJIS");
|
||||||
|
print(seller);
|
||||||
|
addSeller(seller);
|
||||||
|
}
|
||||||
|
},
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith((states) => Colors.blue),
|
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