521 lines
22 KiB
Dart
521 lines
22 KiB
Dart
import 'dart:developer';
|
|
import 'dart:io';
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart' hide MultipartFile, FormData;
|
|
import 'package:glassmorphism/glassmorphism.dart';
|
|
import 'package:regroup/Common/CommonWidget.dart';
|
|
import 'package:regroup/Common/base_manager.dart';
|
|
import 'package:regroup/Common/controller/profileimagecontroller.dart';
|
|
import 'package:regroup/Utils/Common/CommonDropdown.dart';
|
|
import 'package:regroup/Utils/Common/CustomNextButton.dart';
|
|
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
|
|
import 'package:regroup/Utils/Common/ImageUpload.dart';
|
|
import 'package:regroup/Utils/Common/blureffect.dart';
|
|
import 'package:regroup/Utils/Common/sized_box.dart';
|
|
import 'package:regroup/Utils/dialogs.dart';
|
|
import 'package:regroup/Utils/texts.dart';
|
|
import 'package:regroup/onboarding/Signup/view_model/postmethod.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
class TellusaboutIndividual extends StatefulWidget {
|
|
const TellusaboutIndividual({super.key});
|
|
|
|
@override
|
|
State<TellusaboutIndividual> createState() => _TellusaboutIndividualState();
|
|
}
|
|
|
|
class _TellusaboutIndividualState extends State<TellusaboutIndividual> {
|
|
TextEditingController fullNameController = TextEditingController();
|
|
TextEditingController userNameController = TextEditingController();
|
|
TextEditingController datecontroller = TextEditingController();
|
|
TextEditingController locationcontroller = TextEditingController();
|
|
|
|
// String pagename = Get.arguments["pageroute"];
|
|
|
|
|
|
DateTime? _selectedDate;
|
|
final photographController = TextEditingController();
|
|
|
|
final ProfileImageController editProfileImage =
|
|
Get.put(ProfileImageController());
|
|
|
|
Future<void> _selectDate(BuildContext context) async {
|
|
DateTime yesterday = DateTime.now().subtract(Duration(days: 1));
|
|
DateTime eighteenYearsAgo =
|
|
DateTime.now().subtract(Duration(days: 365 * 18));
|
|
|
|
final ThemeData customTheme = Theme.of(context).copyWith(
|
|
colorScheme: const ColorScheme.light(
|
|
primary: Color(0xFFD90B2E),
|
|
surfaceTint: Color(0xFF222935),
|
|
surface: Color(0xFF222935),
|
|
onPrimary: Colors.white,
|
|
onSurface: Colors.white,
|
|
onSecondary: Colors.white),
|
|
textButtonTheme: TextButtonThemeData(
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: Color(0xFFD90B2E),
|
|
),
|
|
));
|
|
|
|
final DateTime? pickedDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: yesterday,
|
|
firstDate: DateTime(1950),
|
|
lastDate: DateTime(2026),
|
|
builder: (BuildContext context, Widget? child) {
|
|
return Theme(
|
|
data: customTheme,
|
|
// ThemeData.light().copyWith(
|
|
// colorScheme: ColorScheme.dark(
|
|
// primary: Color(0XFF222935).withOpacity(0.60),
|
|
// onPrimary: Colors.white, // Change text color
|
|
// ),
|
|
// textButtonTheme: TextButtonThemeData(
|
|
// style: TextButton.styleFrom(
|
|
// foregroundColor: Colors.white, // Change button text color
|
|
// ),
|
|
// ),
|
|
// dialogBackgroundColor: Color(0XFF222935)
|
|
// .withOpacity(0.60), // Change dialog background color
|
|
// ),
|
|
child: child!,
|
|
);
|
|
},
|
|
);
|
|
|
|
if (pickedDate != null) {
|
|
if (pickedDate.isBefore(eighteenYearsAgo)) {
|
|
setState(() {
|
|
_selectedDate = pickedDate;
|
|
datecontroller.text =
|
|
"${_selectedDate!.year.toString().padLeft(2, '0')}-${_selectedDate!.month.toString().padLeft(2, '0')}-${_selectedDate!.day.toString().padLeft(2, '0')}";
|
|
});
|
|
} else {
|
|
setState(() {
|
|
_selectedDate = null;
|
|
datecontroller.text = ''; // Clear the text field
|
|
});
|
|
|
|
Get.snackbar(
|
|
"Error!",
|
|
'User should be 18+',
|
|
duration: const Duration(seconds: 2),
|
|
colorText: Colors.white,
|
|
backgroundColor: Colors.red,
|
|
margin: const EdgeInsets.all(8),
|
|
snackStyle: SnackStyle.FLOATING,
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
);
|
|
// ScaffoldMessenger.of(context).showSnackBar(
|
|
// SnackBar(
|
|
// content: Text('User should be 18+'),
|
|
// ),
|
|
// );
|
|
}
|
|
}
|
|
}
|
|
|
|
final List<String> _gender = ['Male', 'Female', 'Prefer not to say', 'Other'];
|
|
|
|
String _selectedgendertype = '';
|
|
|
|
void _onItemSelected(String value) {
|
|
setState(() {
|
|
_selectedgendertype = value;
|
|
});
|
|
}
|
|
|
|
void TellusUploadData() async {
|
|
utils.loader();
|
|
var imageFile;
|
|
if (editProfileImage.profilePicPath.value.isNotEmpty) {
|
|
imageFile = await MultipartFile.fromFile(
|
|
editProfileImage.profilePicPath.value,
|
|
filename: path.basename(editProfileImage.profilePicPath.value),
|
|
);
|
|
}
|
|
// else {
|
|
// imageFile = await Helper.assetImageToMultipartFile(
|
|
// "assets/images/png/camera.png", "profile");
|
|
// }
|
|
|
|
FormData formData = FormData.fromMap({
|
|
"full_name": fullNameController.text,
|
|
"username": userNameController.text,
|
|
"date_of_birth": datecontroller.text,
|
|
"gender": _selectedgendertype,
|
|
'profile_photo':
|
|
// editProfileImage.profilePicPath.value.isNotEmpty ?
|
|
imageFile,
|
|
// : null,
|
|
'location': locationcontroller.text,
|
|
});
|
|
|
|
print("formData is $formData");
|
|
log(formData.toString());
|
|
final data = await Onboard().PosttellusIndividual(formData);
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
utils.showToast("tell us done Successfully!");
|
|
Get.back();
|
|
// Get.toNamed(RouteName.individualprofilestep1);
|
|
// if (pagename == "nextscreen") {
|
|
Get.toNamed(RouteName.individualactivitystep2);
|
|
|
|
// } else if (pagename == "mainscreen") {
|
|
// Get.toNamed(RouteName.mainscreen);
|
|
// }
|
|
} else {
|
|
Get.back();
|
|
return utils.showToast(data.message);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
|
child: Scaffold(
|
|
backgroundColor: Color.fromARGB(255, 18, 32, 47),
|
|
body: Stack(
|
|
children: [
|
|
// Positioned(top: 70, left: -30, child: CommonBlurLeftSecond()),
|
|
// Positioned(top: 310, right: -30, child: CommonBlurRightSecond()),
|
|
// Positioned(top: 510, left: -30, child: CommonBlurLeftBlue()),
|
|
// GlassmorphicContainer(
|
|
// width: MediaQuery.of(context).size.width,
|
|
// height:
|
|
// // 500.h,
|
|
// MediaQuery.of(context).size.height,
|
|
// borderRadius: 2,
|
|
// blur: 6,
|
|
// alignment: Alignment.bottomLeft,
|
|
// border: 2,
|
|
// linearGradient: LinearGradient(
|
|
// begin: Alignment.topCenter,
|
|
// end: Alignment.bottomCenter,
|
|
// colors: [
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// ],
|
|
// ),
|
|
// borderGradient: LinearGradient(
|
|
// begin: Alignment.topCenter,
|
|
// end: Alignment.bottomCenter,
|
|
// colors: [
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// // Color.fromARGB(255, 18, 32, 47).withOpacity(0.50),
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
|
|
// Color(0XFF222935).withOpacity(0.60),
|
|
// ],
|
|
// ),
|
|
Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage("assets/images/png/Ellipse 1496.png"),
|
|
fit: BoxFit.fill)),
|
|
),
|
|
ListView(physics: ScrollPhysics(), children: [
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// const Spacer(flex: 1),
|
|
sizedBoxHeight(50.h),
|
|
Center(child: text20400white('Tell us about yourself')),
|
|
sizedBoxHeight(10.w),
|
|
Center(
|
|
child: Container(
|
|
width: 154,
|
|
decoration: ShapeDecoration(
|
|
shape: RoundedRectangleBorder(
|
|
side: BorderSide(
|
|
width: 1,
|
|
strokeAlign: BorderSide.strokeAlignCenter,
|
|
color: Color(0xFF858585),
|
|
),
|
|
),
|
|
)),
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
GestureDetector(
|
|
onTap: () {
|
|
ImageUploadBottomSheet().showModal(
|
|
context,
|
|
false,
|
|
(result) {
|
|
print("File path is $result");
|
|
editProfileImage.profilePicPath.value = result;
|
|
var filenameresult = extractFileName(result);
|
|
print("File name is $filenameresult");
|
|
photographController.text = filenameresult;
|
|
},
|
|
);
|
|
},
|
|
child: Center(
|
|
child: Column(
|
|
children: [
|
|
Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
// Outer circle
|
|
Container(
|
|
width: 139.w,
|
|
height: 139.h,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Colors.transparent,
|
|
border: Border.all(
|
|
color:
|
|
Color(0XFFD90B2E).withOpacity(0.50),
|
|
width: 2),
|
|
),
|
|
),
|
|
// Middle circle
|
|
Container(
|
|
width: 119.w,
|
|
height: 119.h,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Colors.transparent,
|
|
border: Border.all(
|
|
color:
|
|
Color(0XFFD90B2E).withOpacity(0.50),
|
|
width: 2),
|
|
),
|
|
),
|
|
// Inner circle
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Colors.transparent,
|
|
border: Border.all(
|
|
color: Color(0XFFD90B2E)
|
|
.withOpacity(0.50),
|
|
width: 2),
|
|
),
|
|
child: Obx(() =>
|
|
// editProfileImage
|
|
// .profilePicPath.value !=
|
|
// ''
|
|
// ?
|
|
editProfileImage
|
|
.profilePicPath.value !=
|
|
''
|
|
? ClipOval(
|
|
child: SizedBox.fromSize(
|
|
size:
|
|
Size.fromRadius(50.r),
|
|
child: Image(
|
|
image: FileImage(
|
|
File(
|
|
editProfileImage
|
|
.profilePicPath
|
|
.value,
|
|
),
|
|
),
|
|
fit: BoxFit.cover,
|
|
width: 200.w,
|
|
height: 200.h,
|
|
),
|
|
),
|
|
)
|
|
: Image.asset(
|
|
"assets/images/png/camera.png")
|
|
// : Image.asset(
|
|
// "assets/images/png/camera.png")
|
|
)),
|
|
// Main button
|
|
],
|
|
),
|
|
const SizedBox(height: 9),
|
|
text16400white('Add profile picture')
|
|
],
|
|
)),
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
text16400white('Full name'),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
textEditingController: fullNameController,
|
|
texttype: TextInputType.text,
|
|
hintText: "Enter your full name",
|
|
leadingIcon:
|
|
// const Icon(Icons.mail_outline),
|
|
Image.asset(
|
|
width: 22.w,
|
|
height: 17.h,
|
|
'assets/images/png/user.png',
|
|
),
|
|
// validatorText: "Enter your full name",
|
|
validator: (value) {
|
|
if (value!.isEmpty) {
|
|
return 'Enter your full name ';
|
|
}
|
|
return null;
|
|
},
|
|
inputFormatters: [
|
|
// LengthLimitingTextInputFormatter(20),
|
|
RemoveEmojiInputFormatter(),
|
|
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]'))
|
|
],
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
text16400white('User name'),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
textEditingController: userNameController,
|
|
texttype: TextInputType.text,
|
|
hintText: "Enter your user name",
|
|
leadingIcon:
|
|
// const Icon(Icons.mail_outline),
|
|
Image.asset(
|
|
width: 22.w,
|
|
height: 17.h,
|
|
'assets/images/png/user.png',
|
|
),
|
|
// validatorText: "Enter your user name",
|
|
validator: (value) {
|
|
if (value!.isEmpty) {
|
|
return 'Enter your user name ';
|
|
}
|
|
return null;
|
|
},
|
|
inputFormatters: [
|
|
// LengthLimitingTextInputFormatter(20),
|
|
RemoveEmojiInputFormatter(),
|
|
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]'))
|
|
],
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
text16400white('Date of birth'),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
textEditingController: datecontroller,
|
|
readonly: true,
|
|
onTap: () {
|
|
_selectDate(context);
|
|
},
|
|
// texttype: TextInputType.text,
|
|
hintText: "Enter your date of birth",
|
|
leadingIcon:
|
|
// const Icon(Icons.mail_outline),
|
|
Image.asset(
|
|
width: 22.w,
|
|
height: 17.h,
|
|
'assets/images/png/dateimage.png',
|
|
),
|
|
// validatorText: "Enter date of birth",
|
|
validator: (value) {
|
|
if (value!.isEmpty) {
|
|
return 'Enter your date of birth';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
text16400white('Gender'),
|
|
sizedBoxHeight(10.h),
|
|
CustomDropDownWidgetSignup(
|
|
header: 'Select gender',
|
|
title: '',
|
|
listData: _gender,
|
|
onItemSelected: _onItemSelected,
|
|
leadingImage:
|
|
Image.asset('assets/images/png/gendericon.png'),
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
Row(
|
|
children: [
|
|
text16400white('Location'),
|
|
sizedBoxWidth(5.w),
|
|
Image.asset('assets/images/png/informationicon.png')
|
|
],
|
|
),
|
|
sizedBoxHeight(10.h),
|
|
CustomTextFormField(
|
|
textEditingController: locationcontroller,
|
|
texttype: TextInputType.text,
|
|
hintText: "Enter your location",
|
|
leadingIcon:
|
|
// const Icon(Icons.mail_outline),
|
|
Image.asset(
|
|
width: 22.w,
|
|
height: 17.h,
|
|
'assets/images/png/location.png',
|
|
),
|
|
// validatorText: "Enter your location",
|
|
validator: (value) {
|
|
if (value!.isEmpty) {
|
|
return 'Enter your location ';
|
|
}
|
|
return null;
|
|
},
|
|
inputFormatters: [
|
|
// LengthLimitingTextInputFormatter(20),
|
|
RemoveEmojiInputFormatter(),
|
|
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]'))
|
|
],
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
CustomButton(
|
|
text: "Continue",
|
|
onPressed: () {
|
|
if (
|
|
// isValid!
|
|
// fullNameController.text.isBlank! &&
|
|
// userNameController.text.isBlank! &&
|
|
// datecontroller.text.isBlank! &&
|
|
// _selectedgendertype.isEmpty &&
|
|
// locationcontroller.text.isBlank! &&
|
|
// editProfileImage.profilePicPath.value ==
|
|
// ''
|
|
fullNameController.text.isBlank! ||
|
|
userNameController.text.isBlank! ||
|
|
datecontroller.text.isBlank! ||
|
|
_selectedgendertype.isEmpty ||
|
|
locationcontroller.text.isBlank! ||
|
|
editProfileImage.profilePicPath.value ==
|
|
'') {
|
|
utils.showToast('Please fill all fields');
|
|
} else {
|
|
TellusUploadData();
|
|
}
|
|
// if (_selectedgendertype.isNotEmpty) {
|
|
// Get.toNamed(RouteName.individualprofilestep1);
|
|
|
|
// // Get.to(() => BusinessPage());
|
|
// } else {
|
|
// // Handle case where no selection is made
|
|
// utils.showToast('Please select an gender type');
|
|
// }
|
|
}),
|
|
sizedBoxHeight(30.h),
|
|
// const Spacer(
|
|
// flex: 3,
|
|
// )
|
|
],
|
|
),
|
|
),
|
|
])
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
}
|