Sellers Filtering

This commit is contained in:
Ashish Bailkeri
2023-02-25 22:27:02 -05:00
parent 26255e6bc5
commit d63f679d0d
14 changed files with 226 additions and 5 deletions

View File

@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

View File

@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

41
ios/Podfile Normal file
View File

@@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

View File

@@ -1,9 +1,26 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutterfire_ui/auth.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'home.dart';
final FirebaseAuth auth = FirebaseAuth.instance;
Future<void> addUser(String? name, String uid) async {
final CollectionReference users =
FirebaseFirestore.instance.collection('users');
return await users
.add({
'name': name,
'uid': uid,
'swipes': 0,
})
.then((value) => print(""))
.catchError((error) => print("ERROR ADDING DATA: $error"));
}
class AuthGate extends StatelessWidget {
const AuthGate({super.key});
@@ -33,7 +50,9 @@ class AuthGate extends StatelessWidget {
subtitleBuilder: (context, action) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: action == AuthAction.signIn ? const Text('Welcome to RUSwipeShare, please sign in!') : const Text('Welcome to RUSwipeShare, please sign up!'),
child: action == AuthAction.signIn
? const Text('Welcome to RUSwipeShare, please sign in!')
: const Text('Welcome to RUSwipeShare, please sign up!'),
);
},
footerBuilder: (context, action) {
@@ -48,6 +67,20 @@ class AuthGate extends StatelessWidget {
);
}
User? user = auth.currentUser;
if (user != null) {
bool isNewUser =
user.metadata.creationTime == user.metadata.lastSignInTime;
if (isNewUser) {
final name = user.displayName;
final uid = user.uid;
addUser(name, uid);
}
}
return const HomeScreen();
},
);

View File

@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'meetings.dart';
class MainScreen extends StatefulWidget {
const MainScreen({ Key? key }) : super(key: key);
const MainScreen({Key? key}) : super(key: key);
@override
_MainScreenState createState() => _MainScreenState();
@@ -12,11 +13,11 @@ class _MainScreenState extends State<MainScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Main Screen"),
title: const Text("Main Beens"),
),
body: const Center(
child: Text("Main Screen"),
child: Text("Main Green"),
),
);
}
}
}

47
lib/meetings.dart Normal file
View File

@@ -0,0 +1,47 @@
import 'dart:ffi';
import 'package:cloud_firestore/cloud_firestore.dart';
class TimeRange {
late DateTime startTime;
late DateTime endTime;
TimeRange(this.startTime, this.endTime);
}
class Seller {
String name = "";
String uid = "";
String location = "";
TimeRange availableTime;
Int64 price;
Seller(this.name, this.uid, this.location, this.availableTime, this.price);
}
class Filter {
String? location;
Int64? price;
TimeRange? meetingTime;
Filter(this.location, this.price, this.meetingTime);
}
Future<List<Seller>> getSellers(Filter filter) async {
CollectionReference users = FirebaseFirestore.instance.collection('sellers');
List<Seller> sellers = List.empty();
final Query query = users
.where('location', isEqualTo: filter.location)
.where('price', isEqualTo: filter.price)
.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"]));
}
return sellers;
}

View File

@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"

View File

@@ -10,6 +10,7 @@ import desktop_webview_auth
import firebase_auth
import firebase_core
import firebase_database
import geolocator_apple
import sign_in_with_apple
import twitter_login
@@ -19,6 +20,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseDatabasePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseDatabasePlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
TwitterLoginPlugin.register(with: registry.registrar(forPlugin: "TwitterLoginPlugin"))
}

40
macos/Podfile Normal file
View File

@@ -0,0 +1,40 @@
platform :osx, '10.14'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end

View File

@@ -277,6 +277,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.3+20"
geolocator:
dependency: "direct main"
description:
name: geolocator
sha256: "5c23f3613f50586c0bbb2b8f970240ae66b3bd992088cf60dd5ee2e6f7dde3a8"
url: "https://pub.dev"
source: hosted
version: "9.0.2"
geolocator_android:
dependency: transitive
description:
name: geolocator_android
sha256: "2ba24690aee0a3e1b6b7bd47c2711a50c874e95e4c758346589d35194adf6d6a"
url: "https://pub.dev"
source: hosted
version: "4.1.7"
geolocator_apple:
dependency: transitive
description:
name: geolocator_apple
sha256: "22b60ca3b8c0f58e6a9688ff855ee39ab813ca3f0c0609a48d282f6631266f2e"
url: "https://pub.dev"
source: hosted
version: "2.2.5"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
sha256: af4d69231452f9620718588f41acc4cb58312368716bfff2e92e770b46ce6386
url: "https://pub.dev"
source: hosted
version: "4.0.7"
geolocator_web:
dependency: transitive
description:
name: geolocator_web
sha256: f68a122da48fcfff68bbc9846bb0b74ef651afe84a1b1f6ec20939de4d6860e1
url: "https://pub.dev"
source: hosted
version: "2.1.6"
geolocator_windows:
dependency: transitive
description:
name: geolocator_windows
sha256: f5911c88e23f48b598dd506c7c19eff0e001645bdc03bb6fecb9f4549208354d
url: "https://pub.dev"
source: hosted
version: "0.1.1"
google_sign_in:
dependency: transitive
description:

View File

@@ -40,6 +40,7 @@ dependencies:
flutterfire_ui: ^0.4.3+20
flutter_dotenv: ^5.0.2
persistent_bottom_nav_bar: any
geolocator: ^9.0.2
dev_dependencies:
flutter_test:

View File

@@ -7,8 +7,11 @@
#include "generated_plugin_registrant.h"
#include <desktop_webview_auth/desktop_webview_auth_plugin.h>
#include <geolocator_windows/geolocator_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
DesktopWebviewAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopWebviewAuthPlugin"));
GeolocatorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("GeolocatorWindows"));
}

View File

@@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
desktop_webview_auth
geolocator_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST