last 16-10-2025
This commit is contained in:
commit
7546b7348c
269 files changed
+36404
No files matched your search
@@ -0,0 +1,456 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/consts_widgets/comman_button.dart';
|
||||
import 'package:bookmywages/consts_widgets/comman_textformfiled.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:bookmywages/viewmodel/consts_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class VendorEditProfile extends StatefulWidget {
|
||||
const VendorEditProfile({super.key});
|
||||
|
||||
@override
|
||||
State<VendorEditProfile> createState() => _VendorEditProfileState();
|
||||
}
|
||||
|
||||
class _VendorEditProfileState extends State<VendorEditProfile> {
|
||||
File? _image;
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
final TextEditingController numberController = TextEditingController();
|
||||
final TextEditingController emailController = TextEditingController();
|
||||
final TextEditingController addressController = TextEditingController();
|
||||
|
||||
bool _isProfileDataInitialized = false;
|
||||
|
||||
Future<void> _pickImage() async {
|
||||
final pickedFile = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (pickedFile != null) {
|
||||
setState(() {
|
||||
_image = File(pickedFile.path);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method to validate and construct image URL
|
||||
String? _getValidImageUrl(String? imageUrl) {
|
||||
if (imageUrl == null || imageUrl.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if URL is complete (has a filename)
|
||||
if (imageUrl.endsWith('/') || imageUrl.endsWith('/images/')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure URL is properly formatted
|
||||
if (!imageUrl.startsWith('http')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
// Helper widget for safe network image loading
|
||||
Widget _buildNetworkImage(String? imageUrl, {BoxFit fit = BoxFit.cover}) {
|
||||
final validUrl = _getValidImageUrl(imageUrl);
|
||||
|
||||
if (validUrl == null) {
|
||||
return Image.asset(AppAssets.profile, fit: fit);
|
||||
}
|
||||
|
||||
return Image.network(
|
||||
validUrl,
|
||||
fit: fit,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
print('Error loading image: $error');
|
||||
return Image.asset(AppAssets.profile, fit: fit);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Helper method for CircleAvatar image provider
|
||||
ImageProvider _getAvatarImageProvider(String? imageUrl) {
|
||||
if (_image != null) {
|
||||
return FileImage(_image!);
|
||||
}
|
||||
|
||||
final validUrl = _getValidImageUrl(imageUrl);
|
||||
if (validUrl != null) {
|
||||
return NetworkImage(validUrl);
|
||||
}
|
||||
|
||||
return const AssetImage(AppAssets.profile);
|
||||
}
|
||||
|
||||
final TextStyle gilroyTextStyle = const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 20,
|
||||
height: 1.45,
|
||||
letterSpacing: 0.01,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
nameController.dispose();
|
||||
numberController.dispose();
|
||||
emailController.dispose();
|
||||
addressController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: SafeArea(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: height * 0.4,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(
|
||||
profilegetvendorProvider,
|
||||
);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile = profiles.isNotEmpty
|
||||
? profiles[0]
|
||||
: null;
|
||||
|
||||
if (profile != null &&
|
||||
!_isProfileDataInitialized) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
nameController.text =
|
||||
profile.name ?? '';
|
||||
numberController.text =
|
||||
profile.number ?? '';
|
||||
emailController.text =
|
||||
profile.email ?? '';
|
||||
addressController.text =
|
||||
profile.address ?? '';
|
||||
_isProfileDataInitialized = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return _image == null
|
||||
? _buildNetworkImage(
|
||||
profile?.profilePic1,
|
||||
)
|
||||
: Image.file(
|
||||
_image!,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, _) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error, size: 50),
|
||||
Text('Error loading profile: $error'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
child: CustomPaint(
|
||||
size: Size(width, height * 0.4),
|
||||
painter: RightToLeftFullWidthTrianglePainter(),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: height * 0.03,
|
||||
left: width / 2 - 170,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(
|
||||
profilegetvendorProvider,
|
||||
);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile = profiles.isNotEmpty
|
||||
? profiles[0]
|
||||
: null;
|
||||
return CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
backgroundImage:
|
||||
_getAvatarImageProvider(
|
||||
profile?.profilePic1,
|
||||
),
|
||||
onBackgroundImageError:
|
||||
(error, stackTrace) {
|
||||
print(
|
||||
'Avatar image error: $error',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => const CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
error: (error, _) => const CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
backgroundImage: AssetImage(
|
||||
AppAssets.profile,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: height * 0.08,
|
||||
left: width / 2 - 20,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(
|
||||
profilegetvendorProvider,
|
||||
);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile = profiles.isNotEmpty
|
||||
? profiles[0]
|
||||
: null;
|
||||
if (profile == null) {
|
||||
return Text(
|
||||
'No Profile Data',
|
||||
style: gilroyTextStyle,
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
profile.name ?? 'No Name',
|
||||
style: gilroyTextStyle,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _pickImage,
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.location_city,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
profile.address ??
|
||||
'No address available',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
loading: () =>
|
||||
const CircularProgressIndicator(),
|
||||
error: (error, _) => Text(
|
||||
'Error: $error',
|
||||
style: gilroyTextStyle,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width * 0.05),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Name", style: gilroyTextStyle),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
hintText: "Enter your name",
|
||||
controller: nameController,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text("Mobile Number", style: gilroyTextStyle),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
hintText: "Enter your mobile number",
|
||||
keyboardType: TextInputType.phone,
|
||||
controller: numberController,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text("Address", style: gilroyTextStyle),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
hintText: "Enter your address",
|
||||
controller: addressController,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text("Email", style: gilroyTextStyle),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
hintText: "Enter your email",
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
controller: emailController,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Center(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
return CommanButton(
|
||||
width: width * 0.6,
|
||||
text: "Save",
|
||||
textStyle: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 23,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.01,
|
||||
color: AppColors.secondprimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
try {
|
||||
final repo = ref.read(
|
||||
profileupdatevendorRepositoryProvider,
|
||||
);
|
||||
await repo.updateProfilevendor(
|
||||
url: ConstsApi.upadatevendorprofile,
|
||||
name: nameController.text,
|
||||
number: numberController.text,
|
||||
email: emailController.text,
|
||||
address: addressController.text,
|
||||
imageFile: _image,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Profile updated successfully",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
);
|
||||
|
||||
ref.refresh(profilegetvendorProvider);
|
||||
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 1500),
|
||||
() {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Error updating profile: $e",
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RightToLeftFullWidthTrianglePainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()..color = Colors.white;
|
||||
final path = Path();
|
||||
path.moveTo(size.width, 0);
|
||||
path.lineTo(size.width, size.height);
|
||||
path.lineTo(0, size.height);
|
||||
path.close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
@@ -0,0 +1,833 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:bookmywages/viewmodel/consts_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class VendorProfileMain extends ConsumerStatefulWidget {
|
||||
const VendorProfileMain({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorProfileMain> createState() => _VendorProfileMainState();
|
||||
}
|
||||
|
||||
class _VendorProfileMainState extends ConsumerState<VendorProfileMain> {
|
||||
File? _image;
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
bool _isProfileDataInitialized = false;
|
||||
bool _isUploading = false;
|
||||
|
||||
final TextStyle gilroyTextStyle = const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 20,
|
||||
height: 1.45,
|
||||
letterSpacing: 0.01,
|
||||
);
|
||||
|
||||
// Modified _pickImage method with automatic API upload using existing repository
|
||||
Future<void> _pickImage() async {
|
||||
try {
|
||||
final pickedFile = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (pickedFile != null) {
|
||||
setState(() {
|
||||
_image = File(pickedFile.path);
|
||||
_isUploading = true;
|
||||
});
|
||||
|
||||
// Automatically upload to API using existing repository
|
||||
await _uploadImageToAPI(File(pickedFile.path));
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Error picking image: $e');
|
||||
_showErrorToast('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Upload image using existing ProfileupdateRepository
|
||||
Future<void> _uploadImageToAPI(File imageFile) async {
|
||||
try {
|
||||
// Get current profile data
|
||||
final profileData = ref.read(profilegetvendorProvider);
|
||||
|
||||
await profileData.when(
|
||||
data: (profiles) async {
|
||||
if (profiles.isNotEmpty) {
|
||||
final profile = profiles[0];
|
||||
|
||||
// Get the repository
|
||||
final repository = ref.read(profileupdatevendorRepositoryProvider);
|
||||
|
||||
// Update profile with new image and existing data
|
||||
await repository.updateProfilevendor(
|
||||
url: ConstsApi.upadatevendorprofile,
|
||||
name: profile.name ?? '',
|
||||
number: profile.number ?? '',
|
||||
email: profile.email ?? '',
|
||||
address: profile.address ?? '',
|
||||
imageFile: imageFile,
|
||||
);
|
||||
|
||||
// Refresh profile data to get updated image URL
|
||||
ref.invalidate(profilegetvendorProvider);
|
||||
|
||||
_showSuccessToast('Profile picture updated successfully!');
|
||||
|
||||
// Clear local image since it's now uploaded
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_image = null;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_showErrorToast('No profile data available');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_image = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
loading: () async {
|
||||
_showErrorToast('Profile data is still loading');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_image = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
error: (error, _) async {
|
||||
_showErrorToast('Error getting profile data: $error');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_image = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error uploading image: $e');
|
||||
_showErrorToast('Upload failed: $e');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_image = null;
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isUploading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods for showing toasts
|
||||
void _showSuccessToast(String message) {
|
||||
if (mounted) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showErrorToast(String message) {
|
||||
if (mounted) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method to validate and construct image URL
|
||||
String? _getValidImageUrl(String? imageUrl) {
|
||||
if (imageUrl == null || imageUrl.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if URL is complete (has a filename)
|
||||
if (imageUrl.endsWith('/') || imageUrl.endsWith('/images/')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure URL is properly formatted
|
||||
if (!imageUrl.startsWith('http')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
// Helper widget for safe network image loading
|
||||
Widget _buildNetworkImage(String? imageUrl, {BoxFit fit = BoxFit.cover}) {
|
||||
final validUrl = _getValidImageUrl(imageUrl);
|
||||
|
||||
if (validUrl == null) {
|
||||
return Image.asset(AppAssets.profile, fit: fit);
|
||||
}
|
||||
|
||||
return Image.network(
|
||||
validUrl,
|
||||
fit: fit,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
value:
|
||||
loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
debugPrint('Error loading image: $error');
|
||||
return Image.asset(AppAssets.profile, fit: fit);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Helper method for CircleAvatar image provider
|
||||
ImageProvider _getAvatarImageProvider(String? imageUrl) {
|
||||
if (_image != null) {
|
||||
return FileImage(_image!);
|
||||
}
|
||||
|
||||
final validUrl = _getValidImageUrl(imageUrl);
|
||||
if (validUrl != null) {
|
||||
return NetworkImage(validUrl);
|
||||
}
|
||||
|
||||
return const AssetImage(AppAssets.profile);
|
||||
}
|
||||
|
||||
void _showSignOutDialog() {
|
||||
if (!mounted) return;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Sign Out'),
|
||||
content: const Text('Are you sure you want to sign out?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('userId');
|
||||
await prefs.remove('vendor_id');
|
||||
await prefs.remove('data');
|
||||
|
||||
if (context.mounted) {
|
||||
// context.go(
|
||||
// RouterConts.loginpage,
|
||||
// ); // or use pushReplacement if needed
|
||||
}
|
||||
},
|
||||
child: const Text('Sign Out'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuItem(IconData icon, String title) {
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
icon,
|
||||
size: 23.000513076782227,
|
||||
color: const Color(0xFF3E3E3F),
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 18,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.2,
|
||||
color: Color(0xFF3E3E3F),
|
||||
),
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_forward_ios_rounded),
|
||||
onTap: () async {
|
||||
try {
|
||||
if (title == 'My Profile') {
|
||||
await Get.toNamed(RouterConts.vendoreditprofile);
|
||||
} else if (title == 'Change Password') {
|
||||
// await context.push(RouterConts.changepassword);
|
||||
} else if (title == 'Sign out') {
|
||||
_showSignOutDialog();
|
||||
} else if (title == 'Terms and Conditions') {
|
||||
_showTermsAndConditionsDialog(ref); // Call the new dialog
|
||||
} else if (title == 'Privacy policy') {
|
||||
_showprivacyDialog(ref); // Call the new dialog
|
||||
}
|
||||
// Add other navigation cases as needed
|
||||
} catch (e) {
|
||||
debugPrint('Navigation error: $e');
|
||||
if (mounted) {
|
||||
_showErrorToast('Navigation error: $e');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: height * 0.4,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(profilegetvendorProvider);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile =
|
||||
profiles.isNotEmpty ? profiles[0] : null;
|
||||
|
||||
if (profile != null && !_isProfileDataInitialized) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isProfileDataInitialized = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return _image == null
|
||||
? _buildNetworkImage(profile?.profilePic1)
|
||||
: Image.file(_image!, fit: BoxFit.cover);
|
||||
},
|
||||
loading:
|
||||
() => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error:
|
||||
(error, _) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error, size: 50),
|
||||
Text('Error loading profile: $error'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
child: CustomPaint(
|
||||
size: Size(width, height * 0.4),
|
||||
painter: RightToLeftFullWidthTrianglePainter(),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: height * 0.03,
|
||||
left: width / 2 - 170,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(profilegetvendorProvider);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile =
|
||||
profiles.isNotEmpty ? profiles[0] : null;
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
backgroundImage: _getAvatarImageProvider(
|
||||
profile?.profilePic1,
|
||||
),
|
||||
onBackgroundImageError: (
|
||||
error,
|
||||
stackTrace,
|
||||
) {
|
||||
debugPrint('Avatar image error: $error');
|
||||
},
|
||||
),
|
||||
),
|
||||
// Show upload progress indicator
|
||||
if (_isUploading)
|
||||
Container(
|
||||
width: 136,
|
||||
height: 136,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
loading:
|
||||
() => const CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
error:
|
||||
(error, _) => const CircleAvatar(
|
||||
radius: 68,
|
||||
backgroundColor: Colors.white,
|
||||
child: CircleAvatar(
|
||||
radius: 65,
|
||||
backgroundImage: AssetImage(
|
||||
AppAssets.profile,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: height * 0.08,
|
||||
left: width / 2 - 20,
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final profileData = ref.watch(profilegetvendorProvider);
|
||||
return profileData.when(
|
||||
data: (profiles) {
|
||||
final profile =
|
||||
profiles.isNotEmpty ? profiles[0] : null;
|
||||
if (profile == null) {
|
||||
return Text(
|
||||
'No Profile Data',
|
||||
style: gilroyTextStyle,
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
profile.name ?? 'No Name',
|
||||
style: gilroyTextStyle,
|
||||
),
|
||||
IconButton(
|
||||
onPressed:
|
||||
_isUploading ? null : _pickImage,
|
||||
icon:
|
||||
_isUploading
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child:
|
||||
CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.edit),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.location_city, size: 20),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
profile.address ?? 'No address available',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
loading: () => const CircularProgressIndicator(),
|
||||
error:
|
||||
(error, _) =>
|
||||
Text('Error: $error', style: gilroyTextStyle),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
_buildMenuItem(Icons.person, 'My Profile'),
|
||||
|
||||
_buildMenuItem(Icons.notifications, 'Notification'),
|
||||
_buildMenuItem(Icons.safety_check, 'Privacy policy'),
|
||||
_buildMenuItem(Icons.description, 'Terms and Conditions'),
|
||||
_buildMenuItem(Icons.logout, 'Sign out'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showTermsAndConditionsDialog(WidgetRef ref) {
|
||||
if (!mounted) return;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
||||
child: Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
insetPadding: const EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final termsAsync = ref.watch(termsAndConditionsProvider);
|
||||
|
||||
return termsAsync.when(
|
||||
data:
|
||||
(terms) => Container(
|
||||
width: 389,
|
||||
height: 547,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF959595),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
"Terms & Condition",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: ScrollbarTheme(
|
||||
data: ScrollbarThemeData(
|
||||
thumbColor: WidgetStateProperty.all(
|
||||
AppColors.primary,
|
||||
),
|
||||
trackColor: WidgetStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
trackBorderColor: WidgetStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
thickness: WidgetStateProperty.all(13),
|
||||
radius: const Radius.circular(19),
|
||||
thumbVisibility: WidgetStateProperty.all(
|
||||
true,
|
||||
),
|
||||
),
|
||||
child: Scrollbar(
|
||||
thumbVisibility: true,
|
||||
interactive: true,
|
||||
thickness: 13,
|
||||
radius: const Radius.circular(19),
|
||||
child: ListView(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
terms.data,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 228,
|
||||
height: 51.82,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
const Color(0xFF0066FF),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
22.95,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"OK",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
fontSize: 18.87,
|
||||
height: 23.59 / 18.87,
|
||||
letterSpacing: -0.59,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loading:
|
||||
() => const Center(child: CircularProgressIndicator()),
|
||||
error:
|
||||
(e, _) => Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
"Error: ${e.toString()}",
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showprivacyDialog(WidgetRef ref) {
|
||||
if (!mounted) return;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
||||
child: Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
insetPadding: const EdgeInsets.all(20),
|
||||
child: Center(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final privacyAsync = ref.watch(privacypolicyProvider);
|
||||
|
||||
return privacyAsync.when(
|
||||
data:
|
||||
(terms) => Container(
|
||||
width: 389,
|
||||
height: 547,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF959595),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
"Privacy policy",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Expanded(
|
||||
child: ScrollbarTheme(
|
||||
data: ScrollbarThemeData(
|
||||
thumbColor: WidgetStateProperty.all(
|
||||
AppColors.primary,
|
||||
),
|
||||
trackColor: WidgetStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
trackBorderColor: WidgetStateProperty.all(
|
||||
Colors.transparent,
|
||||
),
|
||||
thickness: WidgetStateProperty.all(13),
|
||||
radius: const Radius.circular(19),
|
||||
thumbVisibility: WidgetStateProperty.all(
|
||||
true,
|
||||
),
|
||||
),
|
||||
child: Scrollbar(
|
||||
thumbVisibility: true,
|
||||
interactive: true,
|
||||
thickness: 13,
|
||||
radius: const Radius.circular(19),
|
||||
child: ListView(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
terms.data,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 228,
|
||||
height: 51.82,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
const Color(0xFF0066FF),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
22.95,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"OK",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
fontSize: 18.87,
|
||||
height: 23.59 / 18.87,
|
||||
letterSpacing: -0.59,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
loading:
|
||||
() => const Center(child: CircularProgressIndicator()),
|
||||
error:
|
||||
(e, _) => Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
"Error: ${e.toString()}",
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RightToLeftFullWidthTrianglePainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()..color = Colors.white;
|
||||
|
||||
final path = Path();
|
||||
path.moveTo(size.width, 0); // top right corner
|
||||
path.lineTo(size.width, size.height); // bottom right corner
|
||||
path.lineTo(0, size.height); // bottom left (tip)
|
||||
path.close();
|
||||
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(CustomPainter oldDelegate) => false;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,516 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:bookmywages/viewmodel/consts_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
final selectedCategoryIndexProvider = StateProvider<int?>((ref) => null);
|
||||
final deleteLoadingProvider = StateProvider<bool>((ref) => false);
|
||||
|
||||
class CategoryManagement extends ConsumerStatefulWidget {
|
||||
const CategoryManagement({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<CategoryManagement> createState() => _CategoryManagementState();
|
||||
}
|
||||
|
||||
class _CategoryManagementState extends ConsumerState<CategoryManagement> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _showDeleteConfirmation(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
String categoryId,
|
||||
String categoryName,
|
||||
) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Delete Category'),
|
||||
content: Text('Are you sure you want to delete "$categoryName"?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed == true && context.mounted) {
|
||||
await _deleteCategory(context, ref, categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _deleteCategory(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
String categoryId,
|
||||
) async {
|
||||
try {
|
||||
ref.read(deleteLoadingProvider.notifier).state = true;
|
||||
|
||||
final repo = ref.read(catDeleteRepositoryProvider);
|
||||
final success = await repo.deleteCategoryManagement(
|
||||
ConstsApi.catmangementdelete,
|
||||
categoryId,
|
||||
);
|
||||
|
||||
ref.read(deleteLoadingProvider.notifier).state = false;
|
||||
|
||||
if (success) {
|
||||
ref.read(selectedCategoryIndexProvider.notifier).state = null;
|
||||
ref.invalidate(vendorcatgoriesProvider);
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Category deleted successfully'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Failed to delete category'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
ref.read(deleteLoadingProvider.notifier).state = false;
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error: ${e.toString()}'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final categoryAsyncValue = ref.watch(vendorcatgoriesProvider);
|
||||
final selectedIndex = ref.watch(selectedCategoryIndexProvider);
|
||||
final isDeleting = ref.watch(deleteLoadingProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: Stack(
|
||||
children: [
|
||||
categoryAsyncValue.when(
|
||||
data: (categories) =>
|
||||
_buildSuccessUI(categories, selectedIndex, isDeleting),
|
||||
loading: () => _buildLoadingUI(),
|
||||
error: (error, _) => _buildErrorUI(error),
|
||||
),
|
||||
if (isDeleting) _buildDeleteOverlay(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSuccessUI(List categories, int? selectedIndex, bool isDeleting) {
|
||||
final filteredCategories = categories
|
||||
.where((c) => c.noOfService! > 0)
|
||||
.toList();
|
||||
|
||||
return CustomScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 196 / 209,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index >= filteredCategories.length) return null;
|
||||
return _buildCategoryCard(
|
||||
filteredCategories[index],
|
||||
index,
|
||||
selectedIndex,
|
||||
isDeleting,
|
||||
);
|
||||
},
|
||||
childCount: filteredCategories.length,
|
||||
addAutomaticKeepAlives: false,
|
||||
addRepaintBoundaries: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 20)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryCard(
|
||||
dynamic category,
|
||||
int index,
|
||||
int? selectedIndex,
|
||||
bool isDeleting,
|
||||
) {
|
||||
final isSelected = selectedIndex == index;
|
||||
|
||||
return RepaintBoundary(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
final current = ref.read(selectedCategoryIndexProvider);
|
||||
ref.read(selectedCategoryIndexProvider.notifier).state =
|
||||
current == index ? null : index;
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 196 / 209,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// Category Image
|
||||
_buildCategoryImage(category.image1.toString()),
|
||||
|
||||
// Action Buttons (Edit/Delete)
|
||||
if (isSelected) _buildActionButtons(category, isDeleting),
|
||||
|
||||
// Name Overlay with Blur
|
||||
_buildImageOverlay(category.name.toString()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryImage(String imageUrl) {
|
||||
return Image.network(
|
||||
imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
loadingBuilder: (context, child, loadingProgress) {
|
||||
if (loadingProgress == null) return child;
|
||||
return Container(
|
||||
color: Colors.grey[300],
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
value: loadingProgress.expectedTotalBytes != null
|
||||
? loadingProgress.cumulativeBytesLoaded /
|
||||
loadingProgress.expectedTotalBytes!
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
errorBuilder: (context, error, stackTrace) => Container(
|
||||
color: Colors.grey[300],
|
||||
child: const Center(
|
||||
child: Icon(Icons.image_not_supported, color: Colors.grey, size: 32),
|
||||
),
|
||||
),
|
||||
cacheWidth: 400,
|
||||
cacheHeight: 400,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButtons(dynamic category, bool isDeleting) {
|
||||
return Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Edit Button
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
RouterConts.vendorservice,
|
||||
arguments: {
|
||||
'id': category.id,
|
||||
'tittle': category
|
||||
.name, // Note: using 'tittle' to match VendorService parameter
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 57,
|
||||
height: 57,
|
||||
alignment: Alignment.center,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.secondprimary,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.edit_document, color: AppColors.primary, size: 20),
|
||||
Text(
|
||||
"edit",
|
||||
style: TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
||||
// Delete Button
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
_showDeleteConfirmation(
|
||||
context,
|
||||
ref,
|
||||
category.id.toString(),
|
||||
category.name.toString(),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 57,
|
||||
height: 57,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: isDeleting ? Colors.grey : Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
isDeleting ? Icons.hourglass_empty : Icons.delete,
|
||||
color: Colors.red,
|
||||
size: 20,
|
||||
),
|
||||
Text(
|
||||
isDeleting ? "wait" : "delete",
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageOverlay(String categoryName) {
|
||||
return Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
||||
child: Container(
|
||||
height: 56,
|
||||
width: 196,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color.fromRGBO(255, 255, 255, 0.54),
|
||||
Color.fromRGBO(153, 153, 153, 0.54),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Center(
|
||||
child: Text(
|
||||
categoryName,
|
||||
style: const TextStyle(
|
||||
color: Colors.black87,
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
height: 1.2,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingUI() {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 196 / 209,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => _buildShimmerCard(),
|
||||
childCount: 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShimmerCard() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.grey[300],
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.grey[300]!,
|
||||
Colors.grey[100]!,
|
||||
Colors.grey[300]!,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 12,
|
||||
left: 12,
|
||||
right: 12,
|
||||
child: Container(
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorUI(Object error) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.error_outline, size: 64, color: Colors.grey[400]),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Oops! Something went wrong',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Please check your connection and try again',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey[500]),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
ref.invalidate(vendorcatgoriesProvider);
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeleteOverlay() {
|
||||
return Container(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
child: const Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(color: Colors.white),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Deleting category...',
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,733 @@
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/model/cancel_booking.dart';
|
||||
import 'package:bookmywages/model/vendor_model/vendor_booking_status.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class VendorBookinglist extends ConsumerStatefulWidget {
|
||||
const VendorBookinglist({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorBookinglist> createState() => _VendorBookinglistState();
|
||||
}
|
||||
|
||||
class _VendorBookinglistState extends ConsumerState<VendorBookinglist> {
|
||||
Map<String, dynamic> getStatusInfo(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return {
|
||||
'text': 'Pending',
|
||||
'color': Colors.orange,
|
||||
'bgColor': Colors.orange.shade100,
|
||||
};
|
||||
case 1:
|
||||
return {
|
||||
'text': 'Scheduled',
|
||||
'color': Colors.green,
|
||||
'bgColor': Colors.green.shade100,
|
||||
};
|
||||
case 2:
|
||||
return {
|
||||
'text': 'Completed',
|
||||
'color': Colors.blue,
|
||||
'bgColor': Colors.blue.shade100,
|
||||
};
|
||||
case 3:
|
||||
return {
|
||||
'text': 'Canceled',
|
||||
'color': Colors.red,
|
||||
'bgColor': Colors.red.shade100,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
'text': 'pending',
|
||||
'color': Colors.blue,
|
||||
'bgColor': Colors.blue.shade100,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Format date from API response
|
||||
String formatDate(String dateStr) {
|
||||
try {
|
||||
final date = DateTime.parse(dateStr);
|
||||
return DateFormat('MMMM dd, yyyy').format(date);
|
||||
} catch (e) {
|
||||
return dateStr;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: ref
|
||||
.watch(vendorbookingdetailsProvider)
|
||||
.when(
|
||||
data: (bookings) {
|
||||
if (bookings.isEmpty) {
|
||||
return const Center(child: Text('No bookings found'));
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: bookings.length,
|
||||
shrinkWrap: true,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
final booking = bookings[index];
|
||||
final statusInfo = getStatusInfo(booking.status ?? 0);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColors.lightGrey),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ID and View order
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 12,
|
||||
left: 12,
|
||||
top: 12,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'ID : ${booking.id}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
||||
// Image, Company, and Status
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child:
|
||||
(booking.images1 != null &&
|
||||
booking.images1!.isNotEmpty)
|
||||
? Image.network(
|
||||
booking.images1!,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (
|
||||
context,
|
||||
error,
|
||||
stackTrace,
|
||||
) {
|
||||
return Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
)
|
||||
: Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(
|
||||
8,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.green,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'Live',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
booking.name ?? 'No data',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16.11,
|
||||
height: 14.5 / 16.11,
|
||||
letterSpacing: 0.01 * 16.11,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
booking.serviceName ?? '',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13.91,
|
||||
height: 1.3,
|
||||
letterSpacing: 0.01 * 13.91,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Container(
|
||||
width:
|
||||
booking.status == 3
|
||||
? 70
|
||||
: booking.status == 1
|
||||
? 85
|
||||
: 77.84,
|
||||
height:
|
||||
booking.status == 3
|
||||
? 25
|
||||
: booking.status == 1
|
||||
? 25
|
||||
: 27.96,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
booking.status == 3
|
||||
? const Color(
|
||||
0xFFFFEEEE,
|
||||
)
|
||||
: booking.status == 1
|
||||
? const Color(
|
||||
0xFFDAE9FF,
|
||||
)
|
||||
: const Color(
|
||||
0xFFE6F7E6,
|
||||
),
|
||||
borderRadius:
|
||||
BorderRadius.circular(6.05),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
booking.status == 3
|
||||
? 'Cancel'
|
||||
: booking.status == 1
|
||||
? 'completed'
|
||||
: booking.status == 4
|
||||
? 'Scheduled'
|
||||
: 'pending',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontSize: 10.92,
|
||||
fontWeight: FontWeight.w400,
|
||||
color:
|
||||
booking.status == 3
|
||||
? const Color(
|
||||
0xFFFF0000,
|
||||
)
|
||||
: booking.status ==
|
||||
1
|
||||
? const Color(
|
||||
0xFF0066FF,
|
||||
)
|
||||
: const Color(
|
||||
0xFF2E8B57,
|
||||
),
|
||||
letterSpacing: 1.0,
|
||||
height: 0.98,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Date :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.serviceDate != null
|
||||
? _formatDate(
|
||||
booking.serviceDate!,
|
||||
)
|
||||
: 'No date',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Time :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.serviceDate != null
|
||||
? DateFormat(
|
||||
'h:mm a',
|
||||
).format(
|
||||
DateTime.parse(
|
||||
booking.serviceDate!,
|
||||
),
|
||||
)
|
||||
: 'No time',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Date / Time / Hours
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Mobile number : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
booking.mobileNumber.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"E-mail ID :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
booking.email.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Address : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
Text(
|
||||
booking.address.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
const Text(
|
||||
"Message : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
Text(
|
||||
booking.message.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (booking.status == 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 42,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
final scaffoldMessenger =
|
||||
ScaffoldMessenger.of(context);
|
||||
|
||||
try {
|
||||
// Prepare data for status update
|
||||
final data = VendorBookingStatus(
|
||||
id: booking.id.toString(),
|
||||
status:
|
||||
"4", // Change to status 1 (confirmed)
|
||||
);
|
||||
|
||||
// Call the provider to update status
|
||||
await ref.read(
|
||||
changebookingProvider(data).future,
|
||||
);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg:
|
||||
'Booking confirmed successfully',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
|
||||
// Refresh the booking list
|
||||
ref.invalidate(
|
||||
vendorbookingdetailsProvider,
|
||||
);
|
||||
} catch (e) {
|
||||
Fluttertoast.showToast(
|
||||
msg:
|
||||
'Failed to confirm booking: $e',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(
|
||||
0xFF0066FF,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
20,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const FittedBox(
|
||||
child: Text(
|
||||
"Confirmed",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0.289,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final data = CancelBookingRequest(
|
||||
id: booking.id.toString(),
|
||||
serviceId: booking.serviceId.toString(),
|
||||
type:
|
||||
booking.type == null
|
||||
? "0"
|
||||
: booking.type.toString(),
|
||||
);
|
||||
|
||||
final scaffoldMessenger =
|
||||
ScaffoldMessenger.of(context);
|
||||
final navigator = Navigator.of(context);
|
||||
|
||||
try {
|
||||
await ref.read(
|
||||
cancelbookingProvider(data).future,
|
||||
);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Booking cancelled successfully',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
|
||||
ref.invalidate(
|
||||
vendorbookingdetailsProvider,
|
||||
);
|
||||
} catch (e) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Failed to cancel booking: $e',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text(
|
||||
'Cancel Booking',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold', // Add this
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400, // 400 is normal weight
|
||||
fontSize: 14.45,
|
||||
height:
|
||||
13 /
|
||||
14.45, // Convert line-height to Flutter's height property
|
||||
letterSpacing: 0.02, // 2% as decimal
|
||||
color: Color(0xff534E4E),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (booking.status == 4)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 42,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(
|
||||
0xFF0066FF,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
20,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const FittedBox(
|
||||
child: Text(
|
||||
"pending",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0.289,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final scaffoldMessenger =
|
||||
ScaffoldMessenger.of(context);
|
||||
|
||||
try {
|
||||
// Prepare data for status update
|
||||
final data = VendorBookingStatus(
|
||||
id: booking.id.toString(),
|
||||
status:
|
||||
"1", // Change to status 1 (confirmed)
|
||||
);
|
||||
|
||||
// Call the provider to update status
|
||||
await ref.read(
|
||||
changebookingProvider(data).future,
|
||||
);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Booking confirmed successfully',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
|
||||
// Refresh the booking list
|
||||
ref.invalidate(
|
||||
vendorbookingdetailsProvider,
|
||||
);
|
||||
} catch (e) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Failed to confirm booking: $e',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text(
|
||||
'complete',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold', // Add this
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400, // 400 is normal weight
|
||||
fontSize: 14.45,
|
||||
height:
|
||||
13 /
|
||||
14.45, // Convert line-height to Flutter's height property
|
||||
letterSpacing: 0.02, // 2% as decimal
|
||||
color: Color(0xff534E4E),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error:
|
||||
(err, stack) =>
|
||||
Center(child: Text('Error loading bookings: $err')),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(String dateString) {
|
||||
try {
|
||||
return DateFormat('dd/MM/yyyy').format(DateTime.parse(dateString));
|
||||
} catch (e) {
|
||||
return dateString; // Fallback: return the original string if parsing fails
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class VendorCancelBooking extends ConsumerWidget {
|
||||
// Changed to ConsumerWidget
|
||||
const VendorCancelBooking({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// Added WidgetRef parameter
|
||||
final bookingAsyncValue = ref.watch(vendorbookingdetailsProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: bookingAsyncValue.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (err, stack) => Center(child: Text('Error: $err')),
|
||||
data: (bookings) {
|
||||
// Filter only canceled bookings (status == 3)
|
||||
final canceledBookings =
|
||||
bookings.where((booking) => booking.status == 3).toList();
|
||||
|
||||
if (canceledBookings.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'No canceled bookings found',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: canceledBookings.length,
|
||||
shrinkWrap: false,
|
||||
itemBuilder: (context, index) {
|
||||
final booking = canceledBookings[index];
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColors.lightGrey),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// Top Row: ID and "View order"
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 12,
|
||||
left: 12,
|
||||
top: 12,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'ID : ${booking.id}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
/// Image, Company, and Status
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child:
|
||||
(booking.images1 != null &&
|
||||
booking.images1!.isNotEmpty)
|
||||
? Image.network(
|
||||
booking.images1!,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (
|
||||
context,
|
||||
error,
|
||||
stackTrace,
|
||||
) {
|
||||
return Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
)
|
||||
: Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.green,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'Live',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
booking.serviceName ?? 'No vendor name',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16.11,
|
||||
height: 14.5 / 16.11,
|
||||
letterSpacing: 0.01 * 16.11,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
booking.categoryName ??
|
||||
'No service name',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13.91,
|
||||
height: 12.52 / 13.91,
|
||||
letterSpacing: 0.01 * 13.91,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 10),
|
||||
Container(
|
||||
width: 70,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFEEEE),
|
||||
borderRadius: BorderRadius.circular(
|
||||
6.05,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontSize: 10.92,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: const Color(0xFFFF0000),
|
||||
letterSpacing: 1.0,
|
||||
height: 0.98,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColors.lightGrey,
|
||||
),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 15,
|
||||
backgroundImage:
|
||||
booking.profilePic1 != null &&
|
||||
booking
|
||||
.profilePic1!
|
||||
.isNotEmpty
|
||||
? NetworkImage(
|
||||
booking.profilePic1!,
|
||||
)
|
||||
: null,
|
||||
child:
|
||||
booking.profilePic1 == null ||
|
||||
booking
|
||||
.profilePic1!
|
||||
.isEmpty
|
||||
? const Icon(
|
||||
Icons.person,
|
||||
size: 20,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
booking.username ??
|
||||
'No data',
|
||||
style: const TextStyle(
|
||||
fontFamily:
|
||||
'Gilroy-Medium',
|
||||
fontWeight:
|
||||
FontWeight.w600,
|
||||
fontSize: 11,
|
||||
height: 10.65 / 11.84,
|
||||
letterSpacing: 0,
|
||||
color: Color(
|
||||
0xFF353434,
|
||||
),
|
||||
),
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
Text(
|
||||
'client',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Regular',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11.84,
|
||||
height: 10.65 / 11.84,
|
||||
letterSpacing: 0,
|
||||
color: Color(0xFF717171),
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Date / Time / Hours
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Date :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.cancelDate != null
|
||||
? _formatDate(booking.cancelDate!)
|
||||
: 'No date',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Time :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.cancelDate != null
|
||||
? DateFormat('h:mm a').format(
|
||||
DateTime.parse(booking.cancelDate!),
|
||||
)
|
||||
: 'No time',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Working hours :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.workingHours ?? 'No hours',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(String dateString) {
|
||||
try {
|
||||
return DateFormat('dd-MM-yyyy').format(DateTime.parse(dateString));
|
||||
} catch (e) {
|
||||
return dateString; // Fallback: return the original string if parsing fails
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class VendorCompletedBooking extends ConsumerWidget {
|
||||
// Changed to ConsumerWidget
|
||||
const VendorCompletedBooking({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// Added WidgetRef parameter
|
||||
final bookingAsyncValue = ref.watch(vendorbookingdetailsProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: bookingAsyncValue.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (err, stack) => Center(child: Text('Error: $err')),
|
||||
data: (bookings) {
|
||||
// Filter only canceled bookings (status == 3)
|
||||
final canceledBookings =
|
||||
bookings.where((booking) => booking.status == 1).toList();
|
||||
|
||||
if (canceledBookings.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'No canceled bookings found',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: canceledBookings.length,
|
||||
shrinkWrap: false,
|
||||
itemBuilder: (context, index) {
|
||||
final booking = canceledBookings[index];
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: AppColors.lightGrey),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// Top Row: ID and "View order"
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
right: 12,
|
||||
left: 12,
|
||||
top: 12,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'ID : ${booking.id}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(),
|
||||
|
||||
/// Image, Company, and Status
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child:
|
||||
(booking.images1 != null &&
|
||||
booking.images1!.isNotEmpty)
|
||||
? Image.network(
|
||||
booking.images1!,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (
|
||||
context,
|
||||
error,
|
||||
stackTrace,
|
||||
) {
|
||||
return Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
)
|
||||
: Image.asset(
|
||||
AppAssets.cleaning,
|
||||
width: 100,
|
||||
height: 110,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 6,
|
||||
left: 6,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.green,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'Live',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
booking.serviceName ?? 'No vendor name',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16.11,
|
||||
height: 14.5 / 16.11,
|
||||
letterSpacing: 0.01 * 16.11,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
booking.categoryName ??
|
||||
'No service name',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 13.91,
|
||||
height: 12.52 / 13.91,
|
||||
letterSpacing: 0.01 * 13.91,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 10),
|
||||
Container(
|
||||
width: 70,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xffFFEEDB),
|
||||
borderRadius: BorderRadius.circular(
|
||||
6.05,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Completed',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontSize: 10.92,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: const Color(0xffFF8515),
|
||||
letterSpacing: 1.0,
|
||||
height: 0.98,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Date :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.serviceDate != null
|
||||
? _formatDate(
|
||||
booking.serviceDate!,
|
||||
)
|
||||
: 'No date',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Time :',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
booking.serviceTime.toString(),
|
||||
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
/// Date / Time / Hours
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"Mobile number : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Text(
|
||||
booking.mobileNumber.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"E-mail ID :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Text(
|
||||
booking.email.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"Address : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 7),
|
||||
Text(
|
||||
booking.address.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
"Message : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 7),
|
||||
Text(
|
||||
booking.message.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14.45,
|
||||
height: 13 / 14.45,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(String dateString) {
|
||||
try {
|
||||
return DateFormat('dd-MM-yyyy').format(DateTime.parse(dateString));
|
||||
} catch (e) {
|
||||
return dateString; // Fallback: return the original string if parsing fails
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class VendorEnquriyList extends ConsumerStatefulWidget {
|
||||
const VendorEnquriyList({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorEnquriyList> createState() => _VendorEnquriyListState();
|
||||
}
|
||||
|
||||
class _VendorEnquriyListState extends ConsumerState<VendorEnquriyList> {
|
||||
int? expandedIndex;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final enquiryListAsync = ref.watch(enquriylistProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: enquiryListAsync.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, stack) => Center(child: Text('Error: $error')),
|
||||
data:
|
||||
(enquiries) => SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
children: List.generate(enquiries.length, (index) {
|
||||
final enquiry = enquiries[index];
|
||||
final isExpanded = expandedIndex == index;
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.secondprimary,
|
||||
borderRadius: BorderRadius.circular(11),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE8E8E8),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x66AEAEAE),
|
||||
offset: Offset(0, 2),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child:
|
||||
(enquiry.images1.isEmpty)
|
||||
? Container(
|
||||
width: 89,
|
||||
height: 64,
|
||||
color: Colors.grey[300],
|
||||
child: Icon(
|
||||
Icons.image,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
)
|
||||
: Image.network(
|
||||
enquiry.images1.first,
|
||||
width: 89,
|
||||
height: 64,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder:
|
||||
(
|
||||
context,
|
||||
error,
|
||||
stackTrace,
|
||||
) => Container(
|
||||
width: 89,
|
||||
height: 64,
|
||||
color: Colors.grey[300],
|
||||
child: Icon(
|
||||
Icons.broken_image,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
enquiry.vendorName ?? 'vendorName',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16,
|
||||
height: 18.14 / 16,
|
||||
letterSpacing: 0.16,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
expandedIndex =
|
||||
isExpanded ? null : index;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
enquiry.serviceName,
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 2,
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontFamily:
|
||||
'Gilroy-Medium',
|
||||
fontWeight:
|
||||
FontWeight.w400,
|
||||
fontSize: 16.11,
|
||||
height: 17.3 / 16.11,
|
||||
letterSpacing: 0.1611,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flex(
|
||||
direction: Axis.horizontal,
|
||||
mainAxisSize:
|
||||
MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
isExpanded
|
||||
? "View Less"
|
||||
: "View More",
|
||||
style: const TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.w600,
|
||||
fontSize: 13.15,
|
||||
height: 5.71 / 13.15,
|
||||
color: Color(
|
||||
0xFFFF3D00,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Icon(
|
||||
isExpanded
|
||||
? Icons
|
||||
.keyboard_arrow_up
|
||||
: Icons
|
||||
.keyboard_arrow_down,
|
||||
color: const Color(
|
||||
0xffFF3D00,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isExpanded)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16.43),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFE8E8E8),
|
||||
width: 0.82,
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0xA9A9A940),
|
||||
blurRadius: 3.29,
|
||||
offset: Offset(0, 0.82),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: "Name : ",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
height: 1.239,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: enquiry.name ?? 'No Name',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
height: 1.239,
|
||||
color: Color(0xFF373636),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
color: AppColors.red,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () async {
|
||||
final shouldDelete = await showDialog(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => AlertDialog(
|
||||
title: const Text(
|
||||
'Delete Enquiry',
|
||||
),
|
||||
content: const Text(
|
||||
'Are you sure you want to delete this enquiry?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed:
|
||||
() => Navigator.of(
|
||||
context,
|
||||
).pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed:
|
||||
() => Navigator.of(
|
||||
context,
|
||||
).pop(true),
|
||||
child: const Text('Delete'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (shouldDelete == true) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Deleting enquiry...',
|
||||
toastLength:
|
||||
Toast
|
||||
.LENGTH_SHORT, // ~2 seconds
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
|
||||
try {
|
||||
final success = await ref.read(
|
||||
enquriydeleteProvider(
|
||||
enquiry.id.toString(),
|
||||
).future,
|
||||
);
|
||||
|
||||
if (success) {
|
||||
// Reset expanded index and refresh the list
|
||||
setState(() {
|
||||
expandedIndex = null;
|
||||
});
|
||||
|
||||
await Future.delayed(
|
||||
const Duration(
|
||||
milliseconds: 300,
|
||||
),
|
||||
);
|
||||
|
||||
ref.invalidate(
|
||||
enquriylistProvider,
|
||||
);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg:
|
||||
'Enquiry deleted successfully',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Failed to delete enquiry',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Error: ${e.toString()}',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_infoText(
|
||||
"Mobile number : ",
|
||||
enquiry.mobile ?? 'No Mobile',
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
_infoText(
|
||||
"E-mail Id : ",
|
||||
enquiry.email ?? 'No Email',
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
_infoText(
|
||||
"Message : ",
|
||||
enquiry.message ?? 'No Message',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _infoText(String label, String value) {
|
||||
return Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: label,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
height: 1.239,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: value,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
height: 1.239,
|
||||
color: Color(0xFF373636),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/category_management.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/vendor_bookinglist.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/vendor_cancel_booking.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/vendor_completed_booking.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/vendor_enquriy_list.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_history/vendor_payment_details.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_maincontoller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class VendorHistoryMainController extends StatefulWidget {
|
||||
final int? initialTabIndex;
|
||||
|
||||
const VendorHistoryMainController({super.key, this.initialTabIndex});
|
||||
|
||||
@override
|
||||
State<VendorHistoryMainController> createState() =>
|
||||
_VendorHistoryMainControllerState();
|
||||
}
|
||||
|
||||
class _VendorHistoryMainControllerState
|
||||
extends State<VendorHistoryMainController>
|
||||
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
int _currentIndex = 0;
|
||||
TabController? _tabController;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
final List<String> tabTitles = [
|
||||
"Booking List", // Index 0
|
||||
"Category Management", // Index 1
|
||||
"Payment Details", // Index 2
|
||||
"Completed Booking", // Index 3
|
||||
"Enquiry List", // Index 4
|
||||
"Cancelation Booking", // Index 5
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Set initial tab index from widget parameter
|
||||
if (widget.initialTabIndex != null &&
|
||||
widget.initialTabIndex! >= 0 &&
|
||||
widget.initialTabIndex! < tabTitles.length) {
|
||||
_currentIndex = widget.initialTabIndex!;
|
||||
}
|
||||
|
||||
// Initialize TabController with the correct initial index
|
||||
_tabController = TabController(
|
||||
length: tabTitles.length,
|
||||
vsync: this,
|
||||
initialIndex: _currentIndex,
|
||||
);
|
||||
|
||||
_tabController!.addListener(() {
|
||||
if (_tabController!.indexIsChanging) {
|
||||
setState(() {
|
||||
_currentIndex = _tabController!.index;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
|
||||
if (_tabController == null) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
|
||||
return PopScope(
|
||||
onPopInvoked: (didPop) {
|
||||
if (didPop) {
|
||||
// Reset main controller index to 0 when going back
|
||||
final indexController = InheritedVendorIndexController.of(context);
|
||||
indexController?.changeIndex(0);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(150.0),
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
title: const Text(
|
||||
"History",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 16.0),
|
||||
alignment: Alignment.centerLeft,
|
||||
height: 65,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
dividerColor: Colors.transparent,
|
||||
indicatorColor: Colors.transparent,
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
tabs: List.generate(
|
||||
tabTitles.length,
|
||||
(index) => _buildCustomTab(
|
||||
tabTitles[index],
|
||||
index == _currentIndex,
|
||||
),
|
||||
),
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: const [
|
||||
VendorBookinglist(), // Index 0
|
||||
CategoryManagement(), // Index 1
|
||||
VendorPaymentDetails(), // Index 2
|
||||
VendorCompletedBooking(), // Index 3
|
||||
VendorEnquriyList(), // Index 4
|
||||
VendorCancelBooking(), // Index 5
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCustomTab(String text, bool isSelected) {
|
||||
return Tab(
|
||||
height: 53,
|
||||
child: Container(
|
||||
width: 180,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AppColors.primary : AppColors.secondprimary,
|
||||
border: Border.all(color: const Color(0xFFDBDBDB)),
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.5,
|
||||
color: isSelected ? AppColors.secondprimary : AppColors.lightgray,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class VendorPaymentDetails extends ConsumerStatefulWidget {
|
||||
const VendorPaymentDetails({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorPaymentDetails> createState() =>
|
||||
_VendorPaymentDetailsState();
|
||||
}
|
||||
|
||||
class _VendorPaymentDetailsState extends ConsumerState<VendorPaymentDetails> {
|
||||
List<dynamic> _localPayments = [];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final paymentAsync = ref.watch(paymentdetailsProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
body: paymentAsync.when(
|
||||
data: (payments) {
|
||||
final filteredPayments = payments.where((p) => p.type == 2).toList();
|
||||
|
||||
// Initialize local copy only once
|
||||
if (_localPayments.isEmpty) {
|
||||
_localPayments = List.from(filteredPayments);
|
||||
}
|
||||
|
||||
if (_localPayments.isEmpty) {
|
||||
return const Center(child: Text("No payment history found."));
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
final refreshed = await ref.refresh(
|
||||
paymentdetailsProvider.future,
|
||||
);
|
||||
setState(() {
|
||||
_localPayments = refreshed.where((p) => p.type == 2).toList();
|
||||
});
|
||||
},
|
||||
child: ListView.builder(
|
||||
itemCount: _localPayments.length,
|
||||
itemBuilder: (context, index) {
|
||||
final payment = _localPayments[index];
|
||||
return Dismissible(
|
||||
key: Key(payment.id.toString()),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
child: const Icon(Icons.delete, color: Colors.white),
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
return await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Confirm Delete"),
|
||||
content: const Text(
|
||||
"Are you sure you want to delete this payment record?",
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text("CANCEL"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text(
|
||||
"DELETE",
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
onDismissed: (direction) async {
|
||||
final scaffold = ScaffoldMessenger.of(context);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Deleting payment...',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
final success = await ref.read(
|
||||
paymentdeleteProvider(payment.id.toString()).future,
|
||||
);
|
||||
|
||||
if (success) {
|
||||
setState(() {
|
||||
_localPayments.removeAt(index);
|
||||
});
|
||||
|
||||
scaffold.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
"${payment.planName} deleted successfully",
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
scaffold.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("Failed to delete payment"),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFCFCFCF),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
width: 130,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF334E95),
|
||||
borderRadius: BorderRadius.circular(12.86),
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 0.43,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x40828282),
|
||||
blurRadius: 1.71,
|
||||
offset: const Offset(0, 2.14),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
payment.planName,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.1371,
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 6.86,
|
||||
height: 6.86,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFF9E369),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_formatDuration(payment.duration),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.0771,
|
||||
color: Colors.white,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 6.86,
|
||||
height: 6.86,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFF9E369),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
payment.description,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.0771,
|
||||
color: Colors.white,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(color: Colors.white),
|
||||
Center(
|
||||
child: Text(
|
||||
_formatPrice(payment.price),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
payment.planName,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 19.9,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.199,
|
||||
color: Colors.black,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Start :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15.61,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
DateFormat('MMM d, y').format(
|
||||
DateTime.parse(
|
||||
payment.createdDate,
|
||||
),
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"End :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15.61,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
DateFormat('MMM d, y').format(
|
||||
DateTime.parse(payment.endDate),
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Time :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15.61,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
DateFormat('hh:mm a').format(
|
||||
DateTime.parse(
|
||||
payment.createdDate,
|
||||
),
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
"Payment :",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15.61,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
_formatPrice(payment.price),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
height: 14.04 / 15.61,
|
||||
letterSpacing: 0.0,
|
||||
color: Color(0xFF636363),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (e, _) => Center(child: Text("Error: ${e.toString()}")),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String _formatDuration(int days) {
|
||||
if (days == 30) return '1 Month';
|
||||
if (days == 60) return '2 Months';
|
||||
if (days == 90) return '3 Months';
|
||||
if (days == 180) return '6 Months';
|
||||
if (days == 365) return '1 Year';
|
||||
return '$days Days';
|
||||
}
|
||||
|
||||
static String _formatPrice(String price) {
|
||||
if (price.startsWith('Rs.')) {
|
||||
return price;
|
||||
}
|
||||
return 'Rs.$price';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class VendorService extends ConsumerStatefulWidget {
|
||||
final int id;
|
||||
final String tittle;
|
||||
const VendorService({super.key, required this.id, required this.tittle});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorService> createState() => _VendorServiceState();
|
||||
}
|
||||
|
||||
class _VendorServiceState extends ConsumerState<VendorService> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vendorServiceAsyncValue = ref.watch(vendorserviceProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
appBar: AppBar(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
leading: const Icon(Icons.arrow_back_ios_new),
|
||||
title: Text(
|
||||
'${widget.tittle} Service List',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 20,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: vendorServiceAsyncValue.when(
|
||||
data: (services) {
|
||||
final filteredServices = services
|
||||
.where((service) => service.category == widget.id)
|
||||
.toList();
|
||||
|
||||
if (filteredServices.isEmpty) {
|
||||
return const Center(child: Text("No services found"));
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: filteredServices.length,
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemBuilder: (context, index) {
|
||||
final service = filteredServices[index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: const Color(0xFFCFCFCF), width: 1),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x66A9A9A9),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: _buildServiceImage(
|
||||
(service.images1.isNotEmpty
|
||||
? service.images1.first
|
||||
: null),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
service.serviceName,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16,
|
||||
height: 1.2,
|
||||
letterSpacing: 0.2,
|
||||
color: Colors.black,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'Name: ${service.serviceName}',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Cat: ${service.categoryName}',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Sub-Cat: ${service.categoryName}',
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
color: Color(0xFF5A5A5A),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: SizedBox(
|
||||
height: 32,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(
|
||||
RouterConts.vendorserviceupload,
|
||||
arguments: service,
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(
|
||||
0xFF0066FF,
|
||||
),
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
20,
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: Color(0xFFAAAAAA),
|
||||
width: 0.5,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: const FittedBox(
|
||||
child: Text(
|
||||
'Edit',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.28,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: SizedBox(
|
||||
height: 32,
|
||||
child: OutlinedButton(
|
||||
onPressed: () async {
|
||||
final result = await ref.read(
|
||||
deleteserviceProvider(
|
||||
service.id.toString(),
|
||||
).future,
|
||||
);
|
||||
if (result) {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Service deleted successfully",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
ref.invalidate(
|
||||
vendorserviceProvider,
|
||||
); // Refresh the service list
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: "Failed to delete service",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.black,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
20,
|
||||
),
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: Color(0xFFAAAAAA),
|
||||
width: 0.5,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
child: const FittedBox(
|
||||
child: Text(
|
||||
'Delete',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.28,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (err, stack) => Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
"Error loading services: $err",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Helper method to handle image loading with error handling
|
||||
Widget _buildServiceImage(String? imagePath) {
|
||||
if (imagePath == null || imagePath.isEmpty) {
|
||||
return Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Icon(Icons.work, size: 40, color: Colors.grey),
|
||||
);
|
||||
}
|
||||
|
||||
final bool isNetworkImage = imagePath.startsWith('http');
|
||||
final bool isValidFilePath =
|
||||
imagePath.startsWith('/') ||
|
||||
(imagePath.startsWith('file://') && imagePath.length > 7);
|
||||
|
||||
if (isNetworkImage) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: imagePath,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Icon(Icons.error, size: 40, color: Colors.red),
|
||||
),
|
||||
);
|
||||
} else if (isValidFilePath) {
|
||||
return Image.file(
|
||||
File(imagePath.replaceFirst('file://', '')),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
print('Error loading image: $error');
|
||||
return Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Icon(Icons.broken_image, size: 40, color: Colors.red),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
print('Invalid image path format: $imagePath');
|
||||
return Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,356 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class VendorController extends ConsumerStatefulWidget {
|
||||
final Widget child;
|
||||
final int? initialBottomIndex;
|
||||
|
||||
const VendorController({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.initialBottomIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorController> createState() => _VendorControllerState();
|
||||
}
|
||||
|
||||
class _VendorControllerState extends ConsumerState<VendorController>
|
||||
with SingleTickerProviderStateMixin {
|
||||
int _selectedIndex = 0;
|
||||
bool _showMenu = false;
|
||||
late AnimationController _animationController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Set bottom navigation index
|
||||
if (widget.initialBottomIndex != null) {
|
||||
_selectedIndex = widget.initialBottomIndex!;
|
||||
} else {
|
||||
// Auto-detect based on current route
|
||||
final currentRoute = Get.currentRoute;
|
||||
if (currentRoute == RouterConts.vendorhomepage) {
|
||||
_selectedIndex = 0;
|
||||
} else if (currentRoute == RouterConts.vendorpackage) {
|
||||
_selectedIndex = 1;
|
||||
} else if (currentRoute == RouterConts.vendorcategory) {
|
||||
_selectedIndex = 2;
|
||||
} else if (currentRoute == RouterConts.vendorhistory) {
|
||||
_selectedIndex = 3;
|
||||
}
|
||||
}
|
||||
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
);
|
||||
}
|
||||
|
||||
void _toggleMenu() {
|
||||
setState(() {
|
||||
_showMenu = !_showMenu;
|
||||
_showMenu
|
||||
? _animationController.forward()
|
||||
: _animationController.reverse();
|
||||
});
|
||||
}
|
||||
|
||||
void _onItemTapped(int index, BuildContext context) {
|
||||
if (_selectedIndex == index) return;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Get.offAllNamed(RouterConts.vendorhomepage);
|
||||
break;
|
||||
case 1:
|
||||
Get.offAllNamed(RouterConts.vendorpackage);
|
||||
break;
|
||||
case 2:
|
||||
Get.offAllNamed(RouterConts.vendorcategory);
|
||||
break;
|
||||
case 3:
|
||||
// Navigate to vendor history with default tab
|
||||
Get.offAllNamed(
|
||||
RouterConts.vendorhistory,
|
||||
arguments: {
|
||||
'historyTab': 0, // Default to first tab
|
||||
},
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void changeSelectedIndex(int index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
// Handle back button press
|
||||
bool _onWillPop() {
|
||||
if (_showMenu) {
|
||||
// If menu is open, close it first
|
||||
_toggleMenu();
|
||||
return false;
|
||||
} else if (_selectedIndex != 0) {
|
||||
// If not on home tab, go to home tab
|
||||
_onItemTapped(0, context);
|
||||
return false;
|
||||
} else {
|
||||
// If on home tab, allow app to exit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if current route should show FAB
|
||||
bool _shouldShowFAB() {
|
||||
final currentRoute = Get.currentRoute;
|
||||
// Hide FAB on edit profile and other specific routes
|
||||
final hideFABRoutes = [
|
||||
'/vendor-edit-profile', // Add your edit profile route here
|
||||
'/profile-edit',
|
||||
// Add other routes where you don't want FAB
|
||||
];
|
||||
|
||||
return !hideFABRoutes.contains(currentRoute);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isKeyboardOpen = MediaQuery.of(context).viewInsets.bottom > 0;
|
||||
final currentRoute = Get.currentRoute;
|
||||
|
||||
return PopScope(
|
||||
canPop: _selectedIndex == 0 && !_showMenu,
|
||||
onPopInvoked: (bool didPop) {
|
||||
if (!didPop) {
|
||||
_onWillPop();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Stack(
|
||||
children: [
|
||||
InheritedVendorIndexController(
|
||||
changeIndex: changeSelectedIndex,
|
||||
child: widget.child,
|
||||
),
|
||||
if (_showMenu && !isKeyboardOpen)
|
||||
AnimatedOpacity(
|
||||
opacity: 1.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: GestureDetector(
|
||||
onTap: _toggleMenu,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 2.0, sigmaY: 2.0),
|
||||
child: Container(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_showMenu && !isKeyboardOpen)
|
||||
Positioned(
|
||||
bottom: 60,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 110),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildMenuOption(
|
||||
icon: Icons.person,
|
||||
label: 'User',
|
||||
color: AppColors.primary,
|
||||
onTap: () {
|
||||
_toggleMenu();
|
||||
Get.offNamed(RouterConts.homescreen);
|
||||
},
|
||||
),
|
||||
_buildMenuOption(
|
||||
icon: Icons.person,
|
||||
label: 'Profile',
|
||||
color: AppColors.primary,
|
||||
onTap: () {
|
||||
_toggleMenu();
|
||||
Get.toNamed(RouterConts.profilemainvendor);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: (isKeyboardOpen || !_shouldShowFAB())
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
// 🔧 FIXED: Dynamic hero tag based on route and timestamp
|
||||
heroTag:
|
||||
"vendor_controller_fab_${currentRoute}_${DateTime.now().millisecondsSinceEpoch}",
|
||||
onPressed: _toggleMenu,
|
||||
shape: const CircleBorder(),
|
||||
backgroundColor: AppColors.primary,
|
||||
child: AnimatedBuilder(
|
||||
animation: _animationController,
|
||||
builder: (context, child) {
|
||||
return Transform.rotate(
|
||||
angle: _animationController.value * 0.75 * math.pi,
|
||||
child: Icon(
|
||||
_animationController.value > 0.5
|
||||
? Icons.close
|
||||
: Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
notchMargin: 8,
|
||||
color: Colors.white,
|
||||
elevation: 8,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_bottomNavItem(0, AppAssets.home),
|
||||
_bottomNavItem(1, AppAssets.package),
|
||||
const Expanded(child: SizedBox()),
|
||||
_bottomNavItem(2, AppAssets.categories),
|
||||
_bottomNavItem(3, AppAssets.history),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _bottomNavItem(int index, String assetPath) {
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () => _onItemTapped(index, context),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset(
|
||||
assetPath,
|
||||
color: _selectedIndex == index ? AppColors.primary : Colors.grey,
|
||||
width: 26,
|
||||
height: 29,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
height: 3,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: _selectedIndex == index
|
||||
? AppColors.primary
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMenuOption({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required Color color,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ScaleTransition(
|
||||
scale: CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Curves.easeOut,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 3,
|
||||
spreadRadius: 1,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: IconButton(
|
||||
icon: Icon(icon, color: Colors.white),
|
||||
onPressed: onTap,
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class InheritedVendorIndexController extends InheritedWidget {
|
||||
final void Function(int) changeIndex;
|
||||
|
||||
const InheritedVendorIndexController({
|
||||
super.key,
|
||||
required this.changeIndex,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
static InheritedVendorIndexController? of(BuildContext context) {
|
||||
return context
|
||||
.dependOnInheritedWidgetOfExactType<InheritedVendorIndexController>();
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(InheritedVendorIndexController oldWidget) {
|
||||
return oldWidget.changeIndex != changeIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/model/package_model.dart';
|
||||
import 'package:bookmywages/model/plan_sucess_model.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/view/vendor_main_screens/vendor_maincontoller.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class VendorPackagePage extends ConsumerStatefulWidget {
|
||||
const VendorPackagePage({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorPackagePage> createState() => _VendorPackagePageState();
|
||||
}
|
||||
|
||||
class _VendorPackagePageState extends ConsumerState<VendorPackagePage> {
|
||||
bool isLoading = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final packageAsyncValue = ref.watch(pacakgeProvider);
|
||||
final indexController = InheritedVendorIndexController.of(context);
|
||||
// Get screen size for responsive calculations
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
final isSmallScreen = screenSize.width < 360;
|
||||
|
||||
return PopScope(
|
||||
onPopInvoked: (didPop) {
|
||||
if (didPop) {
|
||||
// Reset main controller index to 0 when going back
|
||||
final indexController = InheritedVendorIndexController.of(context);
|
||||
indexController?.changeIndex(0);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
"Subscription Plan",
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: isSmallScreen ? 16 : 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
extendBodyBehindAppBar: true,
|
||||
body: Container(
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(AppAssets.background),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
// Added SafeArea to ensure content doesn't overlap with system UI
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
screenSize.width * 0.04, // Responsive horizontal padding
|
||||
vertical:
|
||||
screenSize.height * 0.02, // Responsive vertical padding
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Responsive spacing based on screen height
|
||||
SizedBox(height: screenSize.height * 0.05),
|
||||
Text(
|
||||
"Choose your right plan",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: isSmallScreen
|
||||
? 24
|
||||
: 32, // Smaller font for small screens
|
||||
height: 1.0,
|
||||
letterSpacing: 0.32,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.01),
|
||||
Text(
|
||||
"Make upgrade your plan and get more advantages of services",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: isSmallScreen
|
||||
? 13
|
||||
: 15, // Smaller font for small screens
|
||||
height: 1.71,
|
||||
letterSpacing: 0.15,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.02),
|
||||
packageAsyncValue.when(
|
||||
data: (packages) {
|
||||
final filteredPackages = packages
|
||||
.where((pkg) => pkg.type == 2)
|
||||
.toList();
|
||||
|
||||
// Responsive container height based on screen size
|
||||
return SizedBox(
|
||||
height:
|
||||
screenSize.height *
|
||||
0.3, // 35% of screen height instead of fixed 250
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: filteredPackages.length,
|
||||
itemBuilder: (context, index) {
|
||||
final PackageModel package =
|
||||
filteredPackages[index];
|
||||
|
||||
// Calculate responsive card width (based on screen width)
|
||||
final cardWidth = screenSize.width * 0.75 > 250
|
||||
? 250.0
|
||||
: screenSize.width * 0.75;
|
||||
|
||||
return Container(
|
||||
width: cardWidth,
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: screenSize.width * 0.02,
|
||||
vertical: screenSize.height * 0.01,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF334E95),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF334E95),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x40828282),
|
||||
offset: Offset(0, 5),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(
|
||||
screenSize.width * 0.04,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
package.name,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: isSmallScreen
|
||||
? 16
|
||||
: 18, // Smaller font for small screens
|
||||
height: 1.0,
|
||||
letterSpacing: 0.32,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.01),
|
||||
_buildFeatureRow(
|
||||
package.description,
|
||||
isSmallScreen,
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.02),
|
||||
_buildFeatureRow(
|
||||
getFormattedDuration(package.duration),
|
||||
isSmallScreen,
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.02),
|
||||
_buildFeatureRow(
|
||||
'${package.noOfService} book service',
|
||||
isSmallScreen,
|
||||
),
|
||||
const Divider(color: Colors.white),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
package.price,
|
||||
style: TextStyle(
|
||||
fontSize: isSmallScreen ? 14 : 16,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => _subscribeToPlan(
|
||||
package,
|
||||
indexController,
|
||||
),
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.arrow_forward,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
error: (error, stack) => Center(
|
||||
child: Text(
|
||||
'Error loading packages: $error',
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.01),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Extracted feature row widget for better code organization
|
||||
Widget _buildFeatureRow(String text, bool isSmallScreen) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const CircleAvatar(radius: 8, backgroundColor: Color(0xFFF9E369)),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: isSmallScreen ? 12 : 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _subscribeToPlan(
|
||||
PackageModel package,
|
||||
InheritedVendorIndexController? indexController,
|
||||
) async {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final userId = prefs.getString('vendor_id') ?? '';
|
||||
|
||||
final model = PlanSuccessModel(
|
||||
userId: userId,
|
||||
planId: package.id.toString(),
|
||||
duration: package.duration,
|
||||
type: package.type,
|
||||
);
|
||||
|
||||
final result = await ref
|
||||
.read(planSuccessProvider(model).future)
|
||||
.catchError((e) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Error: ${e.toString()}',
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
if (result) {
|
||||
if (mounted) {
|
||||
// Show success popup
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Success'),
|
||||
content: const Text('Plan subscribed successfully!'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
Get.offNamed(RouterConts.vendorcategory, arguments: 2);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
// Show error popup
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: const Text('Failed to subscribe to plan'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (mounted) {
|
||||
// Show error popup
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to subscribe: ${error.toString()}'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getFormattedDuration(int duration) {
|
||||
if (duration < 30) {
|
||||
return '$duration month';
|
||||
} else {
|
||||
int months = duration ~/ 30;
|
||||
return '$months month';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,374 @@
|
||||
import 'package:bookmywages/consts_widgets/app_assets.dart';
|
||||
import 'package:bookmywages/consts_widgets/app_colors.dart';
|
||||
import 'package:bookmywages/consts_widgets/comman_button.dart';
|
||||
import 'package:bookmywages/consts_widgets/comman_textformfiled.dart';
|
||||
import 'package:bookmywages/model/vendor_model/vendorregister_model.dart';
|
||||
import 'package:bookmywages/routers/consts_router.dart';
|
||||
import 'package:bookmywages/viewmodel/api_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class VendorRegisterPage extends ConsumerStatefulWidget {
|
||||
const VendorRegisterPage({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<VendorRegisterPage> createState() => _VendorRegisterPageState();
|
||||
}
|
||||
|
||||
class _VendorRegisterPageState extends ConsumerState<VendorRegisterPage> {
|
||||
final _nameController = TextEditingController();
|
||||
final _numberController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _locationController = TextEditingController();
|
||||
final _pincodeController = TextEditingController();
|
||||
final _aadharController = TextEditingController();
|
||||
final _panController = TextEditingController();
|
||||
final _licenseController = TextEditingController();
|
||||
final _passportController = TextEditingController();
|
||||
|
||||
String? _nameError;
|
||||
String? _numberError;
|
||||
String? _emailError;
|
||||
|
||||
void _validateName(String value) {
|
||||
setState(() => _nameError = value.isEmpty ? 'Name is required' : null);
|
||||
}
|
||||
|
||||
void _validateNumber(String value) {
|
||||
setState(() {
|
||||
if (value.isEmpty) {
|
||||
_numberError = 'Phone number is required';
|
||||
} else if (!RegExp(r'^[0-9]{10}$').hasMatch(value)) {
|
||||
_numberError = 'Enter a valid 10-digit phone number';
|
||||
} else {
|
||||
_numberError = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _validateEmail(String value) {
|
||||
setState(() {
|
||||
if (value.isEmpty) {
|
||||
_emailError = 'Email is required';
|
||||
} else if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value)) {
|
||||
_emailError = 'Enter a valid email';
|
||||
} else {
|
||||
_emailError = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_numberController.dispose();
|
||||
_emailController.dispose();
|
||||
_locationController.dispose();
|
||||
_pincodeController.dispose();
|
||||
_aadharController.dispose();
|
||||
_panController.dispose();
|
||||
_licenseController.dispose();
|
||||
_passportController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
final double horizontalPadding = screenSize.width * 0.05;
|
||||
final double imageHeight = screenSize.height * 0.45;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.secondprimary,
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
AppAssets.login,
|
||||
width: screenSize.width,
|
||||
height: imageHeight,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(0, -100),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(32.73),
|
||||
border: Border.all(
|
||||
width: 1.09,
|
||||
color: const Color(0xFFA39898),
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
offset: Offset(0, -4),
|
||||
blurRadius: 12.3,
|
||||
color: Color(0x66E0E0E0),
|
||||
),
|
||||
BoxShadow(
|
||||
offset: Offset(0, 4),
|
||||
blurRadius: 4,
|
||||
color: Color(0x66000000),
|
||||
),
|
||||
],
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(screenSize.width * 0.05),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"Vendor Registration",
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontFamily: "Gilroy-ExtraBold",
|
||||
fontWeight: FontWeight.w800,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.64,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _nameController,
|
||||
hintText: 'Enter your name',
|
||||
prefixIcon: const Icon(
|
||||
Icons.person,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
errorText: _nameError,
|
||||
onChanged: _validateName,
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _numberController,
|
||||
hintText: 'Enter your number',
|
||||
prefixIcon: const Icon(
|
||||
Icons.phone_android,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
errorText: _numberError,
|
||||
onChanged: _validateNumber,
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _emailController,
|
||||
hintText: 'Enter your E-mail Id',
|
||||
prefixIcon: const Icon(
|
||||
Icons.email,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
errorText: _emailError,
|
||||
onChanged: _validateEmail,
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _locationController,
|
||||
hintText: 'Location',
|
||||
prefixIcon: const Icon(
|
||||
Icons.location_on,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _pincodeController,
|
||||
hintText: 'Pin code',
|
||||
prefixIcon: const Icon(
|
||||
Icons.pin_drop,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _aadharController,
|
||||
hintText: 'Aadhar card number',
|
||||
prefixIcon: const Icon(
|
||||
Icons.badge,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _panController,
|
||||
hintText: 'Pan card number',
|
||||
prefixIcon: const Icon(
|
||||
Icons.fact_check,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _licenseController,
|
||||
hintText: 'Driving License number',
|
||||
prefixIcon: const Icon(
|
||||
Icons.directions_car,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.03),
|
||||
|
||||
CommonTextFormField(
|
||||
controller: _passportController,
|
||||
hintText: 'Passport number',
|
||||
prefixIcon: const Icon(
|
||||
Icons.flight,
|
||||
color: AppColors.hittext,
|
||||
),
|
||||
),
|
||||
SizedBox(height: screenSize.height * 0.04),
|
||||
|
||||
CommanButton(
|
||||
text: 'Submit',
|
||||
textStyle: const TextStyle(
|
||||
fontFamily: 'Gilroy-Black',
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 20,
|
||||
height: 1.0,
|
||||
color: AppColors.secondprimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
_validateName(_nameController.text);
|
||||
_validateNumber(_numberController.text);
|
||||
_validateEmail(_emailController.text);
|
||||
|
||||
if (_nameError == null &&
|
||||
_numberError == null &&
|
||||
_emailError == null) {
|
||||
final model = VendorRegisterModel(
|
||||
name: _nameController.text.trim(),
|
||||
number: _numberController.text.trim(),
|
||||
email: _emailController.text.trim(),
|
||||
location: _locationController.text.trim(),
|
||||
pincode: _pincodeController.text.trim(),
|
||||
aadharCard: _aadharController.text.trim(),
|
||||
panCard: _panController.text.trim(),
|
||||
drivingLicense: _licenseController.text.trim(),
|
||||
passport: _passportController.text.trim(),
|
||||
);
|
||||
|
||||
try {
|
||||
final response = await ref.read(
|
||||
vendorRegisterFutureProvider(model).future,
|
||||
);
|
||||
print('API Response: $response');
|
||||
|
||||
_showVerificationDialog(context);
|
||||
} catch (e) {
|
||||
print("Registration Error: $e");
|
||||
Fluttertoast.showToast(
|
||||
msg: "Error: $e",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
isPrimary: true,
|
||||
backgroundColor: AppColors.primary,
|
||||
textColor: AppColors.secondprimary,
|
||||
width: 230,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showVerificationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // Prevent closing by tapping outside
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
side: const BorderSide(color: Colors.white, width: 1),
|
||||
),
|
||||
elevation: 10,
|
||||
backgroundColor: Colors.white,
|
||||
child: Container(
|
||||
width: 365,
|
||||
height: 305,
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Verification',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 32,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.32,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Still your account will not verify by Admin, please wait with us.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Bold',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 20.23,
|
||||
height: 1.74,
|
||||
letterSpacing: 0.2023,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF0066FF),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(29.36),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 50,
|
||||
vertical: 15,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
Get.toNamed(RouterConts.homescreen);
|
||||
},
|
||||
child: const Text(
|
||||
'OK',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Black',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 20.29,
|
||||
height: 1.0,
|
||||
letterSpacing: 0.4058,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user