Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/ai_agent/ai_service.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:connect/config/app_config.dart';
import 'package:connect/services/points_service.dart';

/// Service class for handling AI-powered chat interactions with Dino agent.
///
Expand Down Expand Up @@ -115,15 +116,18 @@ Always be encouraging and help users get the most out of Connect!
} else if (lowerMessage.contains('find') || lowerMessage.contains('search') || lowerMessage.contains('browse')) {
return 'To find tasks:\n\n1️⃣ Go to the "Browse" tab\n2️⃣ Use filters to narrow down tasks\n3️⃣ Tap on a task to see details\n4️⃣ Make an offer if interested!\n\nYou can also use the map view to see tasks near you! 📍';
} else if (lowerMessage.contains('payment') || lowerMessage.contains('pay') || lowerMessage.contains('money')) {
return 'We use a point-based system for payments! ⭐\n\n• Earn points by completing tasks\n• Use points to post and pay for tasks\n• Platform takes 10% commission\n• Service providers receive 90% of points\n\nNeed help understanding the points system?';
final platformCommissionRate = PointsService.platformCommissionRate;
final providerPayoutRate = PointsService.providerPayoutRate;
return 'We use a point-based system for payments! ⭐\n\n• Earn points by completing tasks\n• Use points to post and pay for tasks\n• Platform takes ${(platformCommissionRate * 100).toStringAsFixed(0)}% commission\n• Service providers receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of points\n\nNeed help understanding the points system?';
} else if (lowerMessage.contains('help') || lowerMessage.contains('support')) {
return 'I\'m here to help! Here are some common topics:\n\n📝 How to post tasks\n🔍 How to find tasks\n💳 Payment setup\n📍 Location services\n📱 App features\n\nWhat would you like to know more about?';
} else if (lowerMessage.contains('feature') || lowerMessage.contains('what can') || lowerMessage.contains('do')) {
return 'Connect is a task marketplace where you can:\n\n✅ Post tasks and get them done\n✅ Find work and earn money\n✅ Connect with local taskers\n✅ Use secure payments\n✅ Track task progress\n✅ Get real-time notifications\n\nPretty cool, right? 😎';
} else if (lowerMessage.contains('thank') || lowerMessage.contains('thanks')) {
return 'You\'re welcome! I\'m always here to help. Don\'t hesitate to ask if you need anything else! 🦕✨';
} else if (lowerMessage.contains('earn') || lowerMessage.contains('money') || lowerMessage.contains('work')) {
return 'Want to earn points? Here\'s how:\n\n⭐ Browse available tasks in your area\n💼 Make competitive offers\n✅ Complete tasks professionally\n💰 Earn points (90% of task value)\n⭐ Build your reputation\n\nStart by checking the Browse tab! 🚀';
final providerPayoutRate = PointsService.providerPayoutRate;
return 'Want to earn points? Here\'s how:\n\n⭐ Browse available tasks in your area\n💼 Make competitive offers\n✅ Complete tasks professionally\n💰 Earn points (${(providerPayoutRate * 100).toStringAsFixed(0)}% of task value)\n⭐ Build your reputation\n\nStart by checking the Browse tab! 🚀';
} else if (lowerMessage.contains('safety') || lowerMessage.contains('secure') || lowerMessage.contains('trust')) {
return 'Your safety is our priority! 🔒\n\n• All users are verified\n• Secure payment system\n• Real-time tracking\n• User ratings and reviews\n• 24/7 support available\n\nFeel free to ask about any safety concerns!';
} else {
Expand Down
15 changes: 15 additions & 0 deletions lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ class AppConfig {
static String get firebaseMacosBundleId =>
_getEnv('FIREBASE_MACOS_BUNDLE_ID', 'com.example.connect');

// Firebase Auth Action URL
/// Generate Firebase auth action URL for email verification
/// Uses the configured Firebase project ID or defaults to firebaseAuthDomain
static String get firebaseAuthActionUrl {
final projectId = firebaseProjectId;
if (projectId.isNotEmpty) {
return 'https://$projectId.firebaseapp.com/__/auth/action';
}
// Fallback to auth domain if available
if (firebaseAuthDomain.isNotEmpty) {
return 'https://$firebaseAuthDomain/__/auth/action';
}
return 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action';
}

// ============================================================================
// GOOGLE MAPS CONFIGURATION
// ============================================================================
Expand Down
13 changes: 7 additions & 6 deletions lib/firebase/fb.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:connect/config/app_config.dart';

class FirebaseAuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;
Expand All @@ -21,12 +22,12 @@ class FirebaseAuthService {
try {
await credential.user!.sendEmailVerification(
ActionCodeSettings(
url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action',
url: AppConfig.firebaseAuthActionUrl,
handleCodeInApp: true,
androidPackageName: 'com.example.connect',
androidPackageName: AppConfig.appPackageName,
androidInstallApp: true,
androidMinimumVersion: '12',
iOSBundleId: 'com.example.connect',
iOSBundleId: AppConfig.firebaseIosBundleId,
),
);
print("Email verification sent successfully to: $email");
Expand Down Expand Up @@ -136,12 +137,12 @@ class FirebaseAuthService {
try {
await user.sendEmailVerification(
ActionCodeSettings(
url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action',
url: AppConfig.firebaseAuthActionUrl,
handleCodeInApp: true,
androidPackageName: 'com.example.connect',
androidPackageName: AppConfig.appPackageName,
androidInstallApp: true,
androidMinimumVersion: '12',
iOSBundleId: 'com.example.connect',
iOSBundleId: AppConfig.firebaseIosBundleId,
),
);
print("Email verification resent successfully to: ${user.email}");
Expand Down
7 changes: 4 additions & 3 deletions lib/loginpage/loginp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:connect/firebase/fb.dart';
import 'package:connect/signuppage/signuppage.dart';
import 'package:connect/profilepage/profile_check_wrapper.dart';
import 'package:connect/core/utils/responsive.dart';
import 'package:connect/config/app_config.dart';

class LoginPage extends StatefulWidget {
const LoginPage({super.key});
Expand Down Expand Up @@ -448,12 +449,12 @@ class _LoginPageState extends State<LoginPage> {
try {
await user.sendEmailVerification(
ActionCodeSettings(
url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action',
url: AppConfig.firebaseAuthActionUrl,
handleCodeInApp: true,
androidPackageName: 'com.example.connect',
androidPackageName: AppConfig.appPackageName,
androidInstallApp: true,
androidMinimumVersion: '12',
iOSBundleId: 'com.example.connect',
iOSBundleId: AppConfig.firebaseIosBundleId,
),
);
if (context.mounted) {
Expand Down
14 changes: 10 additions & 4 deletions lib/profilepage/payment_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,17 @@ class _PaymentSettingsScreenState extends State<PaymentSettingsScreen> {
}

void _showAddPointsDialog() {
final providerPayoutRate = PointsService.providerPayoutRate;
final platformCommissionRate = PointsService.platformCommissionRate;

showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Earn Points', style: GoogleFonts.poppins()),
content: Text(
'Complete tasks as a service provider to earn points!\n\n'
'• Complete a task: Earn 90% of task points\n'
'• Platform commission: 10%\n\n'
'• Complete a task: Earn ${(providerPayoutRate * 100).toStringAsFixed(0)}% of task points\n'
'• Platform commission: ${(platformCommissionRate * 100).toStringAsFixed(0)}%\n\n'
'Points can be used to post tasks and pay for services.',
style: GoogleFonts.poppins(),
),
Expand All @@ -397,6 +400,9 @@ class _PaymentSettingsScreenState extends State<PaymentSettingsScreen> {
}

void _showPointsInfoDialog() {
final providerPayoutRate = PointsService.providerPayoutRate;
final platformCommissionRate = PointsService.platformCommissionRate;

showDialog(
context: context,
builder: (context) => AlertDialog(
Expand All @@ -407,8 +413,8 @@ class _PaymentSettingsScreenState extends State<PaymentSettingsScreen> {
'✓ Points are used instead of money\n'
'✓ Earn points by completing tasks\n'
'✓ Use points to post and pay for tasks\n'
'✓ Platform takes 10% commission\n'
'✓ Service providers receive 90% of points\n\n'
'✓ Platform takes ${(platformCommissionRate * 100).toStringAsFixed(0)}% commission\n'
'✓ Service providers receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of points\n\n'
'This is a point-based economy system for the Connect platform.',
style: GoogleFonts.poppins(),
),
Expand Down
13 changes: 7 additions & 6 deletions lib/signuppage/signuppage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:connect/firebase/fb.dart';
import 'package:connect/profilepage/complete_profile_screen.dart';
import 'package:connect/menupage/mainp.dart';
import 'package:connect/loginpage/loginp.dart'; // Added import for LoginPage
import 'package:connect/config/app_config.dart';
import 'dart:async'; // Added for Timer

class SignupPage extends StatefulWidget {
Expand Down Expand Up @@ -775,12 +776,12 @@ class _SignupPageState extends State<SignupPage> {
try {
await user.sendEmailVerification(
ActionCodeSettings(
url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action',
url: AppConfig.firebaseAuthActionUrl,
handleCodeInApp: true,
androidPackageName: 'com.example.connect',
androidPackageName: AppConfig.appPackageName,
androidInstallApp: true,
androidMinimumVersion: '12',
iOSBundleId: 'com.example.connect',
iOSBundleId: AppConfig.firebaseIosBundleId,
),
);
Navigator.of(context).pop();
Expand Down Expand Up @@ -904,12 +905,12 @@ class _SignupPageState extends State<SignupPage> {
try {
await user.sendEmailVerification(
ActionCodeSettings(
url: 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action',
url: AppConfig.firebaseAuthActionUrl,
handleCodeInApp: true,
androidPackageName: 'com.example.connect',
androidPackageName: AppConfig.appPackageName,
androidInstallApp: true,
androidMinimumVersion: '12',
iOSBundleId: 'com.example.connect',
iOSBundleId: AppConfig.firebaseIosBundleId,
),
);
Navigator.of(context).pop();
Expand Down
18 changes: 12 additions & 6 deletions lib/task_post/payment_confirmation_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ class _PaymentConfirmationScreenState extends State<PaymentConfirmationScreen> {

@override
Widget build(BuildContext context) {
final platformCommission = widget.taskAmount * 0.10;
final providerPayout = widget.taskAmount * 0.90;
// Use configured commission rates from PointsService
final commissionCalculation = PointsService.calculateCommission(widget.taskAmount);
final platformCommission = commissionCalculation['platformCommission']!;
final providerPayout = commissionCalculation['providerPayout']!;

// Get percentage rates for display
final platformCommissionRate = PointsService.platformCommissionRate;
final providerPayoutRate = PointsService.providerPayoutRate;

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -127,14 +133,14 @@ class _PaymentConfirmationScreenState extends State<PaymentConfirmationScreen> {
),
const Divider(),
_buildPaymentRow(
'Platform Commission (10%)',
'Platform Commission (${(platformCommissionRate * 100).toStringAsFixed(0)}%)',
'-${platformCommission.toStringAsFixed(0)} Points',
isTotal: false,
color: Colors.orange,
),
const SizedBox(height: 8),
_buildPaymentRow(
'Provider Payout (90%)',
'Provider Payout (${(providerPayoutRate * 100).toStringAsFixed(0)}%)',
'${providerPayout.toStringAsFixed(0)} Points',
isTotal: false,
color: Colors.green,
Expand Down Expand Up @@ -244,8 +250,8 @@ class _PaymentConfirmationScreenState extends State<PaymentConfirmationScreen> {
Text(
'• Ensure you have sufficient points in your account\n'
'• Points will be deducted immediately\n'
'• Provider will receive 90% of the points\n'
'• Platform commission is 10%',
'• Provider will receive ${(providerPayoutRate * 100).toStringAsFixed(0)}% of the points\n'
'• Platform commission is ${(platformCommissionRate * 100).toStringAsFixed(0)}%',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.orange[800],
Expand Down