mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
stripe kill me
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutterfire_ui/auth.dart';
|
import 'package:flutterfire_ui/auth.dart';
|
||||||
import 'package:firebase_database/firebase_database.dart';
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
import 'home.dart';
|
import 'home.dart';
|
||||||
@@ -12,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"));
|
||||||
}
|
}
|
||||||
@@ -77,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
150
lib/buy.dart
150
lib/buy.dart
@@ -39,10 +39,20 @@ final List<List<String>> eatingLocations = [
|
|||||||
'Kilmer\'s Market',
|
'Kilmer\'s Market',
|
||||||
'Sbarro\'s',
|
'Sbarro\'s',
|
||||||
],
|
],
|
||||||
<String>['Neilson Dining Hall', 'Cook Cafe', 'Douglass Cafe', 'Harvest INFH', 'Red Pine Pizza']
|
<String>[
|
||||||
|
'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>['assets/daytime_swipe.jpg', 'assets/afternoon_swipe.jpg', 'assets/nighttime_swipe.jpg'];
|
final List<String> timeBgAssets = <String>[
|
||||||
|
'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);
|
||||||
@@ -62,6 +72,17 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Row(children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, top: 20),
|
||||||
|
child: Text(
|
||||||
|
"Campuses",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: GridView.count(
|
child: GridView.count(
|
||||||
@@ -81,7 +102,8 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(25)),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -111,7 +133,8 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(25)),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -141,7 +164,8 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(25)),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -171,7 +195,8 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(25)),
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(25)),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -213,6 +238,17 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
},
|
},
|
||||||
child: const Text("Choose A Different Location")),
|
child: const Text("Choose A Different Location")),
|
||||||
),
|
),
|
||||||
|
Row(children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, bottom: 10),
|
||||||
|
child: Text(
|
||||||
|
"Swipe Locations",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
@@ -220,8 +256,13 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(4),
|
margin: const EdgeInsets.fromLTRB(4, 4, 4, 8),
|
||||||
decoration: BoxDecoration(border: Border.all(color: CustomMaterialColor(240, 240, 240).mdColor, width: 2), borderRadius: const BorderRadius.all(Radius.circular(10))),
|
decoration: BoxDecoration(
|
||||||
|
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(() {
|
||||||
@@ -230,20 +271,24 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
borderRadius:
|
||||||
|
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/" + nameToAsset[_diningOptions.elementAt(index)]!),
|
image: AssetImage("assets/" +
|
||||||
|
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(top: 4, left: 20, bottom: 4),
|
margin: const EdgeInsets.only(
|
||||||
|
top: 4, left: 20, bottom: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
_diningOptions[index],
|
_diningOptions[index],
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@@ -265,21 +310,38 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
|
padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
child: Row(
|
||||||
Flexible(
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
flex: 8,
|
children: [
|
||||||
fit: FlexFit.tight,
|
Flexible(
|
||||||
child: ElevatedButton(
|
flex: 8,
|
||||||
onPressed: () {
|
fit: FlexFit.tight,
|
||||||
setState(() {
|
child: ElevatedButton(
|
||||||
_currentState = CampusState.campuses;
|
onPressed: () {
|
||||||
});
|
setState(() {
|
||||||
},
|
_currentState = CampusState.campuses;
|
||||||
child: const Text("Choose A Different Location")),
|
});
|
||||||
),
|
},
|
||||||
Flexible(flex: 2, child: ElevatedButton(onPressed: () {}, child: const Icon(Icons.filter_list)))
|
child: const Text("Choose A Different Location")),
|
||||||
]),
|
),
|
||||||
|
Flexible(
|
||||||
|
flex: 2,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {},
|
||||||
|
child: const Icon(Icons.filter_list)))
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
|
Row(children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 10, bottom: 10),
|
||||||
|
child: Text(
|
||||||
|
"Available Swipes",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
physics: const BouncingScrollPhysics(),
|
physics: const BouncingScrollPhysics(),
|
||||||
@@ -348,15 +410,23 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
// // );
|
// // );
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(border: Border.all(color: CustomMaterialColor(240, 240, 240).mdColor, width: 2), borderRadius: const BorderRadius.all(Radius.circular(10))),
|
decoration: BoxDecoration(
|
||||||
|
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(Radius.circular(10)),
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(10)),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
colorFilter: const ColorFilter.mode(Colors.black26, BlendMode.darken),
|
colorFilter: const ColorFilter.mode(
|
||||||
|
Colors.black26, BlendMode.darken),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
image: AssetImage(timeBgAssets[index % 3]),
|
image: AssetImage(timeBgAssets[index % 3]),
|
||||||
)),
|
)),
|
||||||
@@ -369,15 +439,18 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(left: 20),
|
padding: EdgeInsets.only(left: 20),
|
||||||
// color: Colors.red,
|
// color: Colors.red,
|
||||||
margin: const EdgeInsets.only(top: 4, left: 4, bottom: 4),
|
margin: const EdgeInsets.only(
|
||||||
|
top: 4, left: 4, bottom: 4),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
entries[index % entries.length],
|
entries[index % entries.length],
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(fontSize: 20),
|
style:
|
||||||
|
const TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: const [
|
children: const [
|
||||||
@@ -385,18 +458,22 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
Icon(Icons.star, size: 16),
|
Icon(Icons.star, size: 16),
|
||||||
Icon(Icons.star, size: 16),
|
Icon(Icons.star, size: 16),
|
||||||
Icon(Icons.star_half, size: 16),
|
Icon(Icons.star_half, size: 16),
|
||||||
Icon(Icons.star_border, size: 16),
|
Icon(Icons.star_border,
|
||||||
|
size: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
children: const [
|
children: const [
|
||||||
Text(
|
Text(
|
||||||
'88:88PM - 88:88PM',
|
'88:88PM - 88:88PM',
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow:
|
||||||
style: TextStyle(fontSize: 16),
|
TextOverflow.ellipsis,
|
||||||
|
style:
|
||||||
|
TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -597,7 +674,8 @@ class _TransactionDetailsState extends State<TransactionDetails> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class CustomMaterialColor {
|
|
||||||
|
class CustomMaterialColor {
|
||||||
final int r;
|
final int r;
|
||||||
final int g;
|
final int g;
|
||||||
final int b;
|
final int b;
|
||||||
|
@@ -9,9 +9,10 @@ import 'auth_gate.dart';
|
|||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||||
Stripe.publishableKey = "pk_test_51MfY7PFVdcWv896FKvDhgKabYeDq4AnoFcWxCAg4hquj6TBAsN0kznXPVyKA7M1pMq5PsieGQwsx6QY5ld5ZQzJ500rVCMPPXp";
|
Stripe.publishableKey =
|
||||||
|
"pk_test_51MfY7PFVdcWv896FKvDhgKabYeDq4AnoFcWxCAg4hquj6TBAsN0kznXPVyKA7M1pMq5PsieGQwsx6QY5ld5ZQzJ500rVCMPPXp";
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@@ -20,23 +21,29 @@ class MyApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: CustomMaterialColor(205, 0, 48).mdColor,
|
primarySwatch: CustomMaterialColor(205, 0, 48).mdColor,
|
||||||
scaffoldBackgroundColor: Colors.black87,
|
scaffoldBackgroundColor: Colors.black87,
|
||||||
fontFamily: GoogleFonts.figtree().fontFamily,
|
fontFamily: GoogleFonts.figtree().fontFamily,
|
||||||
textTheme: Theme.of(context).textTheme.apply(
|
textTheme: Theme.of(context).textTheme.apply(
|
||||||
bodyColor: CustomMaterialColor(240, 240, 240).mdColor,
|
bodyColor: CustomMaterialColor(240, 240, 240).mdColor,
|
||||||
displayColor: CustomMaterialColor(240, 240, 240).mdColor,
|
displayColor: CustomMaterialColor(240, 240, 240).mdColor,
|
||||||
),
|
),
|
||||||
textButtonTheme: TextButtonThemeData(
|
textButtonTheme: TextButtonThemeData(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
textStyle: MaterialStatePropertyAll(TextStyle(
|
textStyle: MaterialStatePropertyAll(TextStyle(
|
||||||
color: CustomMaterialColor(240, 240, 240).mdColor))))),
|
color: CustomMaterialColor(240, 240, 240).mdColor)))),
|
||||||
|
checkboxTheme: CheckboxThemeData(
|
||||||
|
fillColor: MaterialStatePropertyAll(
|
||||||
|
CustomMaterialColor(240, 240, 240).mdColor),
|
||||||
|
checkColor: MaterialStatePropertyAll(Colors.black),
|
||||||
|
),
|
||||||
|
),
|
||||||
home: const AuthGate(),
|
home: const AuthGate(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomMaterialColor {
|
class CustomMaterialColor {
|
||||||
final int r;
|
final int r;
|
||||||
final int g;
|
final int g;
|
||||||
final int b;
|
final int b;
|
||||||
|
@@ -17,11 +17,11 @@ class PriceRange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Seller implements Comparable<Seller> {
|
class Seller implements Comparable<Seller> {
|
||||||
String name = "";
|
String? name = "Unknown 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);
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ class Seller implements Comparable<Seller> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
int compareTo(Seller other) {
|
int compareTo(Seller other) {
|
||||||
return name.compareTo(other.name);
|
return price.compareTo(other.price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +44,34 @@ class Filter {
|
|||||||
Filter(this.locations, this.price, this.meetingTime);
|
Filter(this.locations, this.price, this.meetingTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Seller> fetchNSellers(int n) {
|
||||||
|
List<Seller> sellers = List.empty(growable: true);
|
||||||
|
CollectionReference users = FirebaseFirestore.instance.collection('sellers');
|
||||||
|
users.get().then((value) => () {
|
||||||
|
for (var doc in value.docs) {
|
||||||
|
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||||
|
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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);
|
||||||
@@ -55,9 +83,26 @@ Future<List<Seller>> getSellers(Filter filter) async {
|
|||||||
isLessThanOrEqualTo: filter.price?.high);
|
isLessThanOrEqualTo: filter.price?.high);
|
||||||
|
|
||||||
final QuerySnapshot snapshot = await query.get();
|
final QuerySnapshot snapshot = await query.get();
|
||||||
for (var doc in snapshot.docs) {
|
final startTime = filter.meetingTime?.endTime;
|
||||||
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
final endTime = filter.meetingTime?.startTime;
|
||||||
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
|
||||||
|
if (startTime != null && endTime != null) {
|
||||||
|
var docs = snapshot.docs
|
||||||
|
.where((element) =>
|
||||||
|
startTime.compareTo(element["start-time"]) > 0 ||
|
||||||
|
element["start-time"] == (startTime))
|
||||||
|
.where((element) =>
|
||||||
|
endTime.compareTo(element["end-time"]) < 0 ||
|
||||||
|
element["end-time"] == (endTime));
|
||||||
|
for (var doc in docs) {
|
||||||
|
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||||
|
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var doc in snapshot.docs) {
|
||||||
|
sellers.add(Seller(doc["name"], doc["uid"], doc["location"],
|
||||||
|
TimeRange(doc["start-time"], doc["end-time"]), doc["price"]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sellers;
|
return sellers;
|
||||||
}
|
}
|
||||||
|
150
lib/sell.dart
150
lib/sell.dart
@@ -1,7 +1,14 @@
|
|||||||
// 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:flutter_datetime_picker/flutter_datetime_picker.dart';
|
||||||
|
import 'package:ruswipeshare/auth_gate.dart';
|
||||||
|
import 'package:intl/intl.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);
|
||||||
@@ -24,28 +31,47 @@ Map<String, bool> values = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class _SellScreenState extends State<SellScreen> {
|
class _SellScreenState extends State<SellScreen> {
|
||||||
|
DateFormat dateFormat = DateFormat("HH:mm a");
|
||||||
String startTime = 'Start Time';
|
String startTime = 'Start Time';
|
||||||
DateTime startTimeTime = DateTime.now();
|
DateTime startTimeTime = DateTime.now();
|
||||||
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(
|
||||||
body: Column(
|
resizeToAvoidBottomInset: true,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
body: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
||||||
|
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: const [
|
Expanded(
|
||||||
Icon(Icons.store_mall_directory, color: Colors.red),
|
child: Row(
|
||||||
Text('Place'),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.store_mall_directory,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 40,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Place',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: const BoxConstraints.expand(height: 250),
|
constraints: const BoxConstraints.expand(height: 250),
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
physics: BouncingScrollPhysics(),
|
||||||
itemCount: values.length,
|
itemCount: values.length,
|
||||||
itemBuilder: (context, index) => CheckboxListTile(
|
itemBuilder: (context, index) => CheckboxListTile(
|
||||||
title: Text(values.keys.elementAt(index)),
|
title: Text(values.keys.elementAt(index)),
|
||||||
@@ -90,49 +116,49 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final TimeOfDay? picked = await showTimePicker(
|
DatePicker.showDateTimePicker(context, showTitleActions: true, minTime: DateTime.now(), onChanged: (date) {
|
||||||
context: context,
|
print('change $date');
|
||||||
initialTime: TimeOfDay.fromDateTime(startTimeTime),
|
}, onConfirm: (date) {
|
||||||
);
|
|
||||||
if (picked != null &&
|
|
||||||
picked != TimeOfDay.fromDateTime(startTimeTime)) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
startTimeTime = DateTime.fromMicrosecondsSinceEpoch(
|
startTimeTime = date;
|
||||||
picked.hour * 60 * 60 * 1000000 +
|
startTime = dateFormat.format(date);
|
||||||
picked.minute * 60 * 1000000,
|
print('confirm $date');
|
||||||
isUtc: true);
|
|
||||||
startTime = startTimeTime.hour.toString() +
|
|
||||||
":" +
|
|
||||||
startTimeTime.minute.toString() +
|
|
||||||
((is24HoursFormat)
|
|
||||||
? ""
|
|
||||||
: ((startTimeTime.hour > 12) ? "PM" : "AM"));
|
|
||||||
});
|
});
|
||||||
}
|
}, 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'),
|
child: const Text('Select Start Time'),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final TimeOfDay? picked = await showTimePicker(
|
DatePicker.showDateTimePicker(context, showTitleActions: true, minTime: DateTime.now(), onChanged: (date) {
|
||||||
context: context,
|
print('change $date');
|
||||||
initialTime: TimeOfDay.fromDateTime(endTimeTime),
|
}, onConfirm: (date) {
|
||||||
);
|
|
||||||
if (picked != null &&
|
|
||||||
picked != TimeOfDay.fromDateTime(endTimeTime)) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
endTimeTime = DateTime.fromMicrosecondsSinceEpoch(
|
endTimeTime = date;
|
||||||
picked.hour * 60 * 60 * 1000000 +
|
endTime = dateFormat.format(date);
|
||||||
picked.minute * 60 * 1000000,
|
print('confirm $date');
|
||||||
isUtc: true);
|
|
||||||
endTime = endTimeTime.hour.toString() +
|
|
||||||
":" +
|
|
||||||
endTimeTime.minute.toString() +
|
|
||||||
((is24HoursFormat)
|
|
||||||
? ""
|
|
||||||
: ((endTimeTime.hour > 12) ? "PM" : "AM"));
|
|
||||||
});
|
});
|
||||||
}
|
}, 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'),
|
child: const Text('Select End Time'),
|
||||||
),
|
),
|
||||||
@@ -146,23 +172,37 @@ class _SellScreenState extends State<SellScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: InputDecoration(
|
keyboardType: TextInputType.number,
|
||||||
border: OutlineInputBorder(),
|
textAlign: TextAlign.center,
|
||||||
hintText: 'Max price',
|
style: TextStyle(color: Colors.white, fontSize: 30),
|
||||||
),
|
controller: priceController,
|
||||||
),
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
hintText: 'Price',
|
||||||
|
hintStyle: TextStyle(color: Colors.white24, fontSize: 30),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {},
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor:
|
|
||||||
MaterialStateColor.resolveWith((states) => Colors.blue),
|
|
||||||
),
|
),
|
||||||
child: const Text('Next'),
|
|
||||||
),
|
),
|
||||||
],
|
ElevatedButton(
|
||||||
|
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.displayName, user.uid, locations, TimeRange(Timestamp.fromDate(startTimeTime), Timestamp.fromDate(endTimeTime)), double.parse(priceController.text));
|
||||||
|
addSeller(seller);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateColor.resolveWith((states) => Colors.blue),
|
||||||
|
),
|
||||||
|
child: const Text('Submit Sell Request'),
|
||||||
|
),
|
||||||
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
20
pubspec.lock
20
pubspec.lock
@@ -50,7 +50,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
cloud_firestore:
|
cloud_firestore:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cloud_firestore
|
name: cloud_firestore
|
||||||
sha256: "65f148d9f5b4f389320abb45847120cf5e46094c1a8cbc64934ffc1e29688596"
|
sha256: "65f148d9f5b4f389320abb45847120cf5e46094c1a8cbc64934ffc1e29688596"
|
||||||
@@ -105,6 +105,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
|
currency_text_input_formatter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: currency_text_input_formatter
|
||||||
|
sha256: "9ff3299b37e73ba76a5a40c645ecd234acba7d54bc8e34f60aeedec2c39b0e6e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.9"
|
||||||
desktop_webview_auth:
|
desktop_webview_auth:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -246,6 +254,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.5"
|
version: "3.0.5"
|
||||||
|
flutter_datetime_picker:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_datetime_picker
|
||||||
|
sha256: "8e695c63c769350e541951227c2775190ec73ceda774a315b1dc9a99d5facfe5"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.1"
|
||||||
flutter_dotenv:
|
flutter_dotenv:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -446,7 +462,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.2"
|
version: "4.0.2"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
|
sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91"
|
||||||
|
@@ -45,9 +45,12 @@ dependencies:
|
|||||||
flutter_stripe: any
|
flutter_stripe: any
|
||||||
material_dialogs: any
|
material_dialogs: any
|
||||||
google_fonts: ^4.0.3
|
google_fonts: ^4.0.3
|
||||||
|
cloud_firestore: any
|
||||||
|
currency_text_input_formatter: ^2.1.9
|
||||||
http: any
|
http: any
|
||||||
webview_flutter: any
|
webview_flutter: any
|
||||||
url_launcher: ^6.1.7
|
url_launcher: ^6.1.7
|
||||||
|
flutter_datetime_picker: ^1.5.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -100,3 +103,5 @@ flutter:
|
|||||||
#
|
#
|
||||||
# For details regarding fonts from package dependencies,
|
# For details regarding fonts from package dependencies,
|
||||||
# see https://flutter.dev/custom-fonts/#from-packages
|
# see https://flutter.dev/custom-fonts/#from-packages
|
||||||
|
dependency_overrides:
|
||||||
|
intl: 0.17.0
|
Reference in New Issue
Block a user