Business User api , nointernet added to main

This commit is contained in:
cj201199
2024-07-11 20:01:38 +05:30
parent f8246d33ed
commit 289c368a5a
23 changed files with 888 additions and 194 deletions

View File

@@ -1,11 +1,14 @@
class ApiUrls {
static const baseUrl = "https://regroup.betadelivery.com/api/v1/";
static const getlogin = "${baseUrl}login";
static const forgotpassword = "${baseUrl}forgot-password";
static const verifyotp = "${baseUrl}verify-otp";
static const tellUsBusinessApi = "${baseUrl}tell-us-about-your-business";
static const letUsUnderstandApi = "${baseUrl}update-business-profile-step-1";
static const resetpassword = "${baseUrl}reset-password";
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/controller/MainController.dart';
@@ -9,11 +10,56 @@ class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Obx(() {
return Scaffold(
resizeToAvoidBottomInset: false,
body: mainController.currentTab[mainController.selectedIndex.value],
return WillPopScope(
onWillPop: () async {
_onBackButtonPressed(context);
return true; // Return true to allow the pop action
},
child: Scaffold(
resizeToAvoidBottomInset: false,
body: mainController.currentTab[mainController.selectedIndex.value],
),
);
});
}
Future<bool> _onBackButtonPressed(BuildContext context) async {
bool? exitApp = await showDialog(
context: context,
builder: (context) {
return AlertDialog(
backgroundColor: Color(0xFF222935),
title: const Text('Exit App', style: TextStyle(color: Colors.white)),
content: const Text('Do you really want to close the app?',
style: TextStyle(color: Colors.white)),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(false);
},
child: const Text(
'No',
style: TextStyle(
color: Color(0xFFD90B2E),
),
),
),
TextButton(
onPressed: () {
SystemNavigator.pop();
Navigator.pop(context);
},
child: const Text(
'Yes',
style: TextStyle(
color: Color(0xFFD90B2E),
),
),
)
],
);
},
);
return exitApp ?? false;
}
}

View File

@@ -139,6 +139,7 @@ class NetworkApiServices {
url,
data: data,
options: optionalpar
// (token != null)
? Options(
headers: {
"authorization": basicAuth,
@@ -147,7 +148,8 @@ class NetworkApiServices {
: Options(
headers: {
'authorization': basicAuth,
// 'access-token': token
'access-token':
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3JlZ3JvdXAuYmV0YWRlbGl2ZXJ5LmNvbS9hcGkvdjEvdmVyaWZ5X290cCIsImlhdCI6MTcyMDYwNDQzNSwibmJmIjoxNzIwNjA0NDM1LCJqdGkiOiJIbG5qdFVqcnBXRldlMjBsIiwic3ViIjoiMzciLCJwcnYiOiI0MGJjM2ZkZTM0NjI1N2E4NTA5NTAyZmU2NDIzNTU5YTExMTY0YmQzIn0.rsaasWoorwiRMcJPO_oluIbfvw48h-P6tfEs8fCnzpM"
},
),
);

View File

@@ -116,6 +116,7 @@ class _LoginScreenState extends State<LoginScreen> {
};
final data = await LoginAPI().loginApi(updata);
if (data.status == ResponseStatus.SUCCESS) {
// await global.setname();
Get.snackbar(
"Success!",

View File

@@ -1,3 +1,4 @@
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:regroup/Login/Model/LoginModel.dart';
@@ -7,8 +8,9 @@ class LoginAPI {
LoginAPI();
Future<ResponseData> loginApi(var data) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final response = await NetworkApiServices().postApi(
data, 'https://regroup.betadelivery.com/api/v1/login',
final response = await NetworkApiServices().postApi(data,
ApiUrls.getlogin,
// 'https://regroup.betadelivery.com/api/v1/login',
optionalpar: true
// "auth/login/",

View File

@@ -115,6 +115,7 @@ class _CustomTextFormFieldState extends State<CustomTextFormField> {
enabled: widget.enabled,
enableInteractiveSelection: false,
maxLines: widget.maxlines,
obscureText: obscureText,
controller: widget.textEditingController,
decoration: InputDecoration(

View File

@@ -14,19 +14,22 @@ class NoInternet extends StatefulWidget {
}
class _NoInternetState extends State<NoInternet> {
Future<void> checkInternet() async {
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult.contains(ConnectivityResult.wifi) ||
connectivityResult.contains(ConnectivityResult.mobile) ) {
if (connectivityResult.contains(ConnectivityResult.wifi) ||
connectivityResult.contains(ConnectivityResult.mobile)) {
setState(() {
// _connectionStatus = connectivityResult.toString();
Get.back(result: true);
});
} else {
setState(() {
Get.snackbar("Error", "Your internet is still down!");
Get.snackbar(
"Error",
"Your internet is still down!",
backgroundColor: Colors.white,
);
// _connectionStatus = connectivityResult.toString();
// print(_connectionStatus.toString());
// Get.toNamed(RouteName.nointernet);
@@ -58,13 +61,19 @@ class _NoInternetState extends State<NoInternet> {
sizedBoxHeight(40.h),
Text(
'No Internet !',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white),
),
sizedBoxHeight(15.h),
Text(
'Please Check Your Internet\nConnection',
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white),
),
sizedBoxHeight(20.h),
CustomButton(

View File

@@ -1,17 +1,13 @@
import 'dart:async';
import 'dart:developer';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:regroup/Utils/dialogs.dart';
import 'package:regroup/Utils/Common/NoInternet.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:regroup/resources/routes/routes.dart';
import 'package:statsfl/statsfl.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@@ -30,6 +26,8 @@ Future<void> main() async {
);
}
final streamController = StreamController.broadcast();
class MyApp extends StatefulWidget {
const MyApp({super.key});
@@ -37,7 +35,69 @@ class MyApp extends StatefulWidget {
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
var _connectionStatus = ConnectivityResult.values.toString();
final Connectivity _connectivity = Connectivity();
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
Future<void> checkInternet() async {
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.wifi ||
connectivityResult == ConnectivityResult.mobile) {
setState(() {
_connectionStatus = connectivityResult.toString();
print("has internet");
});
} else {
setState(() {
_connectionStatus = connectivityResult.toString();
print("no internet");
});
}
}
Future<void> initConnectivity() async {
late List<ConnectivityResult> result;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
result = await _connectivity.checkConnectivity();
print("initconnectivitity");
} on PlatformException catch (e) {
print("errrror");
print(e);
return;
}
if (!mounted) {
return Future.value(null);
}
return _updateConnectionStatus(result);
}
Future<void> _updateConnectionStatus(List<ConnectivityResult> result) async {
setState(() {
_connectionStatus = result.toString();
});
// ignore: avoid_print
print('Connectivity changed: $_connectionStatus');
}
@override
void initState() {
initConnectivity();
WidgetsBinding.instance.addObserver(this);
// _connectivitySubscription =
// _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
super.initState();
}
@override
void dispose() {
_connectivitySubscription.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ScreenUtilInit(

View File

@@ -1,10 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonButton.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/onboarding/NewPass/ViewModel/NewPassAPI.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
class NewPassword extends StatefulWidget {
const NewPassword({super.key});
@@ -14,6 +20,77 @@ class NewPassword extends StatefulWidget {
}
class _NewPasswordState extends State<NewPassword> {
TextEditingController newPassController = TextEditingController();
TextEditingController confirmPassController = TextEditingController();
final emailAddress = Get.arguments;
_newpassDone() async {
print('EmailAddress --- $emailAddress');
if (newPassController.text.isBlank! ||
confirmPassController.text.isBlank!) {
Get.snackbar(
'Error',
'Enter your credentials',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else if (!RegExp(r'^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$')
.hasMatch(newPassController.text)) {
Get.snackbar(
'Error',
'Password must contain at least one special character, one capital letter, and one number',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else if (confirmPassController.text != newPassController.text) {
Get.snackbar(
'Error',
'Password does not match',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else {
Map<String, String> updata = {
"email_address": emailAddress,
"password": newPassController.text,
};
final data = await NewtpassAPI().newtpassApi(updata);
if (data.status == ResponseStatus.SUCCESS) {
// btnController.reset();
Get.snackbar(
"Success!",
'Password has been reset successfully!',
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.green,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
Future.delayed(Duration(seconds: 1), () {
Get.toNamed(RouteName.loginScreen);
});
// print('success');
} else {
Get.snackbar(
"Error!",
data.message,
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -48,13 +125,51 @@ class _NewPasswordState extends State<NewPassword> {
sizedBoxHeight(35.h),
text16w400_FCFCFC("Create new password"),
sizedBoxHeight(15.h),
CustomTextFormField(),
CustomTextFormField(
textEditingController: newPassController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Please enter your password';
}
if (!RegExp(
r'^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$')
.hasMatch(val)) {
return 'Enter a valid password';
}
return null;
},
inputFormatters: [
LengthLimitingTextInputFormatter(20),
RemoveEmojiInputFormatter()
],
),
sizedBoxHeight(20.h),
text16w400_FCFCFC("Confirm password"),
sizedBoxHeight(15.h),
CustomTextFormField(),
CustomTextFormField(
textEditingController: confirmPassController,
validator: (val) {
if (val == null || val.isEmpty) {
return 'Please enter your password';
}
if (val != newPassController.text) {
return 'Password does not match';
}
return null;
},
inputFormatters: [
LengthLimitingTextInputFormatter(20),
RemoveEmojiInputFormatter()
],
),
sizedBoxHeight(90.h),
CommonBtn(text: 'Continue'),
CommonBtn(
text: 'Continue',
onTap: () {
_newpassDone();
},
),
])))
]));
}

View File

@@ -0,0 +1,21 @@
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
class NewtpassAPI {
NewtpassAPI();
Future<ResponseData<dynamic>> newtpassApi(var data) async {
final response = await NetworkApiServices().postApi(
data,
ApiUrls.resetpassword,
// "https://regroup.betadelivery.com/api/v1/reset-password",
);
if (response.data['status'] == 'success') {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.SUCCESS);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
}

View File

@@ -3,16 +3,22 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get.dart' hide MultipartFile, FormData;
import 'package:glassmorphism/glassmorphism.dart';
import 'package:regroup/Common/controller/CommonTextFormField.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CustomNextButton.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/Business/ViewModel/TellUsBusinessApi.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
import 'package:dio/dio.dart';
import 'package:path/path.dart' as path;
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
class LetusUnderstand extends StatefulWidget {
const LetusUnderstand({super.key});
@@ -28,6 +34,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
TextEditingController openinghourscontroller = TextEditingController();
TextEditingController websitelinkcontroller = TextEditingController();
TextEditingController googlereviewlinkcontroller = TextEditingController();
TextEditingController tagscontroller = TextEditingController();
bool isValidPhoneNumber(String phoneNumber) {
final RegExp phoneNumberExpression = RegExp(r"^0{10}$");
@@ -35,12 +42,100 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
return !phoneNumberExpression.hasMatch(phoneNumber);
}
List<File?> filePath = [];
List<File?> bannerPath = [];
String logoFile = "";
String bannerFile = "";
bool isImageAdded = false;
bool isbannerAdded = false;
String extractFileName(String filePath) {
return path.basename(filePath);
}
convertFileToMultiPart(String? file) async {
return await MultipartFile.fromFile(
file!,
filename: path.basename(file),
);
}
void _letusUnderstandDone() async {
FormData? updata;
if (busunesscontactcontroller.text.isBlank! ||
emailidcontroller.text.isBlank! ||
businesshandlecontroller.text.isBlank! ||
openinghourscontroller.text.isBlank! ||
websitelinkcontroller.text.isBlank! ||
googlereviewlinkcontroller.text.isBlank! ||
tagscontroller.text.isBlank!) {
Get.snackbar(
'Error',
'Enter your credentials',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else if (logoFile == "") {
utils.showToast('Upload business logo!');
} else if (bannerFile == "") {
utils.showToast('Upload banner image!');
} else {
updata = FormData.fromMap({
"business_contact_number": busunesscontactcontroller.text,
"business_email": emailidcontroller.text,
"business_handle": businesshandlecontroller.text,
"opening_hours": openinghourscontroller.text,
"website_link": websitelinkcontroller.text,
"google_review_link": googlereviewlinkcontroller.text,
"tags": tagscontroller.text,
"business_logo": await convertFileToMultiPart(logoFile),
"banner_image": await convertFileToMultiPart(bannerFile),
});
final data = await BusinessAPI().letUsUnderstandApi(updata);
if (data.status == ResponseStatus.SUCCESS) {
// await global.setname();
Get.snackbar(
"Success!",
'success!',
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.green,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
Get.toNamed(RouteName.individualgroupstep3);
} else if (data.status == ResponseStatus.FAILED) {
Get.snackbar(
"Error!",
data.message,
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
// _controller.isTextFieldEnabled.value = true;
} else {
// btnController.reset();
Get.snackbar(
"Error!",
data.data['message'],
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
// _controller.isTextFieldEnabled.value = true;
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -175,8 +270,10 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
sizedBoxHeight(10.h),
CustomTextFormField(
textEditingController: busunesscontactcontroller,
texttype: TextInputType.text,
texttype: TextInputType.phone,
hintText: "Enter your business contact number",
leadingIcon:
// const Icon(Icons.mail_outline),
Image.asset(
@@ -197,7 +294,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
return null;
},
inputFormatters: [
// LengthLimitingTextInputFormatter(20),
LengthLimitingTextInputFormatter(10),
RemoveEmojiInputFormatter(),
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
],
@@ -277,10 +374,16 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
hintText: "Enter your opening hours",
leadingIcon:
// const Icon(Icons.mail_outline),
Image.asset(
Container(
width: 22.w,
height: 17.h,
'assets/images/png/clock.png',
child: Center(
child: Image.asset(
width: 22.w,
height: 17.h,
'assets/images/png/clock.png',
),
),
),
// validatorText: "Enter your business owner name",
validator: (value) {
@@ -362,7 +465,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
text16400white('Tags'),
sizedBoxHeight(10.h),
CustomTextFormField(
textEditingController: googlereviewlinkcontroller,
textEditingController: tagscontroller,
texttype: TextInputType.text,
hintText: "Enter your Tags",
leadingIcon:
@@ -382,8 +485,8 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
inputFormatters: [
// LengthLimitingTextInputFormatter(20),
RemoveEmojiInputFormatter(),
FilteringTextInputFormatter.allow(
RegExp('[a-zA-ZS0-9 ]')),
// FilteringTextInputFormatter.allow(
// RegExp('[a-zA-ZS0-9 ]')),
],
),
// sizedBoxHeight(10.h),
@@ -394,7 +497,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
filePath.isNotEmpty && isImageAdded
logoFile != "" && isImageAdded
? Container(
width: 169,
height: 115,
@@ -419,7 +522,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
child: Stack(
children: [
Image.file(
filePath[0]!,
File(logoFile),
fit: BoxFit.cover,
width: double.infinity,
),
@@ -431,7 +534,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
child: GestureDetector(
onTap: () {
// Clear the list and show the upload button
filePath.clear();
logoFile = "";
isImageAdded = false;
setState(() {});
},
@@ -469,13 +572,10 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
context,
false,
(result) {
var file = File(result);
// filePath[0] = file;
// filePath.clear();
filePath.add(file);
var filenameresult =
extractFileName(result);
logoFile = result;
isImageAdded = true;
// isImageAdded = true;
setState(() {});
},
);
@@ -525,7 +625,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
),
),
),
bannerPath.isNotEmpty && isbannerAdded
bannerFile != "" && isbannerAdded
? Container(
width: 169,
height: 115,
@@ -550,7 +650,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
child: Stack(
children: [
Image.file(
bannerPath[0]!,
File(bannerFile),
fit: BoxFit.cover,
width: double.infinity,
),
@@ -562,7 +662,7 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
child: GestureDetector(
onTap: () {
// Clear the list and show the upload button
bannerPath.clear();
bannerFile = "";
isbannerAdded = false;
setState(() {});
},
@@ -600,13 +700,10 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
context,
false,
(result) {
var file = File(result);
// filePath[0] = file;
// filePath.clear();
bannerPath.add(file);
var filenameresult =
extractFileName(result);
bannerFile = result;
isbannerAdded = true;
// isImageAdded = true;
setState(() {});
},
);
@@ -659,9 +756,12 @@ class _LetusUnderstandState extends State<LetusUnderstand> {
],
),
sizedBoxHeight(40.h),
CustomButton(text: 'Continue', onPressed: () {
Get.toNamed(RouteName.businessSelectgroupstep2);
})
CustomButton(
text: 'Continue',
onPressed: () {
// Get.toNamed(RouteName.businessSelectgroupstep2);
_letusUnderstandDone();
})
],
),
),

View File

@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CommonDropdown.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/CustomTextformfield.dart';
@@ -10,6 +11,7 @@ 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/Business/ViewModel/TellUsBusinessApi.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
@@ -23,7 +25,7 @@ class TellusaboutBusiness extends StatefulWidget {
class _TellusaboutBusinessState extends State<TellusaboutBusiness> {
TextEditingController businessownerController = TextEditingController();
TextEditingController businessNameController = TextEditingController();
TextEditingController businesslocation = TextEditingController();
TextEditingController businesslocationController = TextEditingController();
final List<String> _businesslist = [
'Retail',
@@ -36,6 +38,7 @@ class _TellusaboutBusinessState extends State<TellusaboutBusiness> {
];
String _selectedbusinesstype = '';
// String business_type = '';
void _onItemSelected(String value) {
setState(() {
@@ -43,6 +46,91 @@ class _TellusaboutBusinessState extends State<TellusaboutBusiness> {
});
}
String getBusinessTypeId(String selectedBusinessType) {
if (selectedBusinessType.contains("Retail")) {
return '1';
} else if (selectedBusinessType.contains("Hospitality")) {
return '2';
} else if (selectedBusinessType.contains("Event provider")) {
return '3';
} else if (selectedBusinessType.contains("Coaching services")) {
return '4';
} else if (selectedBusinessType.contains("Recruitment & Scouting")) {
return '5';
} else if (selectedBusinessType.contains("Healthcare & Wellbeing")) {
return '6';
} else if (selectedBusinessType.contains("Other")) {
return '7';
} else {
return '0';
}
}
void _tellUsBusinessDone() async {
if (businessownerController.text.isBlank! ||
businessNameController.text.isBlank! ||
businesslocationController.text.isBlank!) {
Get.snackbar(
'Error',
'Enter your credentials',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
colorText: Colors.white,
);
} else if (_selectedbusinesstype.isEmpty) {
utils.showToast('Please select a business type');
} else {
String businessTypeId = getBusinessTypeId(_selectedbusinesstype);
Map<String, String> updata = {
"business_name": businessNameController.text,
"business_owner_name": businessownerController.text,
"business_location": businessownerController.text,
"business_type_xid": businessTypeId,
};
final data = await BusinessAPI().tellUsBusinessApi(updata);
if (data.status == ResponseStatus.SUCCESS) {
// await global.setname();
Get.snackbar(
"Success!",
'success!',
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.green,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
Get.toNamed(RouteName.businessletusunderstandstep1);
} else if (data.status == ResponseStatus.FAILED) {
Get.snackbar(
"Error!",
data.message,
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
// _controller.isTextFieldEnabled.value = true;
} else {
// btnController.reset();
Get.snackbar(
"Error!",
data.data['message'],
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
// _controller.isTextFieldEnabled.value = true;
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -172,7 +260,7 @@ class _TellusaboutBusinessState extends State<TellusaboutBusiness> {
text16400white('Business location'),
sizedBoxHeight(10.h),
CustomTextFormField(
textEditingController: businessNameController,
textEditingController: businesslocationController,
texttype: TextInputType.text,
hintText: "Enter your business location",
leadingIcon:
@@ -212,14 +300,15 @@ class _TellusaboutBusinessState extends State<TellusaboutBusiness> {
CustomButton(
text: "Continue",
onPressed: () {
if (_selectedbusinesstype.isNotEmpty) {
Get.toNamed(RouteName.businessletusunderstandstep1);
_tellUsBusinessDone();
// if (_selectedbusinesstype.isNotEmpty) {
// Get.toNamed(RouteName.businessletusunderstandstep1);
// Get.to(() => BusinessPage());
} else {
// Handle case where no selection is made
utils.showToast('Please select an gender type');
}
// // Get.to(() => BusinessPage());
// } else {
// // Handle case where no selection is made
// utils.showToast('Please select an gender type');
// }
}),
sizedBoxHeight(30.h),
// const Spacer(

View File

@@ -0,0 +1,51 @@
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:shared_preferences/shared_preferences.dart';
class BusinessAPI {
BusinessAPI();
Future<ResponseData<dynamic>> tellUsBusinessApi(var data) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final response = await NetworkApiServices().postApi(
data,
ApiUrls.tellUsBusinessApi
// "https://regroup.betadelivery.com/api/v1/tell-us-about-your-business",
// optionalpar: true
);
if (response.status == ResponseStatus.SUCCESS) {
//Map<String, dynamic> responseData = jsonDecode(response.data);
if (response.data['status'] == 'success') {
// LoginModel loginObj = LoginModel.fromJson(response.data);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
return response;
}
Future<ResponseData<dynamic>> letUsUnderstandApi(var data) async {
final response = await NetworkApiServices().postApi(
data,
ApiUrls.letUsUnderstandApi,
// "https://regroup.betadelivery.com/api/v1/update-business-profile-step-1",
);
if (response.status == ResponseStatus.SUCCESS) {
//Map<String, dynamic> responseData = jsonDecode(response.data);
if (response.data['status'] == "success") {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.SUCCESS);
} else {
return ResponseData<dynamic>(
response.data['message'], ResponseStatus.FAILED);
}
}
return response;
}
}

View File

@@ -60,7 +60,8 @@ class _SignupScreenState extends State<SignupScreen> {
Get.toNamed(RouteName.verifyusercreen, arguments: _selectedAccountType);
} else if (_selectedAccountType == 'Business') {
print('business selected');
Get.toNamed(RouteName.verifyusercreen, arguments: _selectedAccountType);
Get.toNamed(RouteName.tellusbusinessscreen,
arguments: _selectedAccountType);
} else {
utils.showToast('Please select an account type');
}

View File

@@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -23,59 +24,10 @@ class VerifyuserScreenState extends StatefulWidget {
}
class _VerifyuserScreenStateState extends State<VerifyuserScreenState> {
// String accounttype = Get.arguments;
String accounttype = Get.arguments;
TextEditingController? pincode = TextEditingController();
final String emailAddress = Get.arguments;
String? principleId;
// principleId = prefs.getString('email').toString();
checkValidation() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
principleId = prefs.getString('principal_xid');
if (pincode!.text.isEmpty) {
utils.showToast('Pin field is empty');
} else {
Map<String, String> updata = {
"iam_principal_xid": principleId.toString(),
"otp": pincode!.text,
};
final data = await ForgotPassAPI().verifyotp(updata);
if (data.status == ResponseStatus.SUCCESS) {
// btnController.success();
// btnController.reset();
Get.snackbar(
"Success!",
'OTP verification successful!',
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.green,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
Future.delayed(Duration(seconds: 1), () {
Get.toNamed(RouteName.newpassword, arguments: emailAddress);
});
// print('success');
} else {
// btnController.error();
// btnController.reset();
Get.snackbar(
"Error!",
data.data['message'],
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
}
}
}
@override
void initState() {
print(emailAddress);
@@ -206,18 +158,17 @@ class _VerifyuserScreenStateState extends State<VerifyuserScreenState> {
CustomButton(
text: 'Continue',
onPressed: () {
// if (pincode!.text.isEmpty) {
// utils.showToast('Pin field is empty');
// } else {
// if (accounttype == 'Individual') {
// print('individual selected');
// Get.toNamed(RouteName.tellusindividualscreen);
// } else if (accounttype == 'Business') {
// print('business selected');
// Get.toNamed(RouteName.tellusbusinessscreen);
// }
// }
checkValidation();
if (pincode!.text.isEmpty) {
utils.showToast('Pin field is empty');
} else {
if (accounttype == 'Individual') {
print('individual selected');
Get.toNamed(RouteName.tellusindividualscreen);
} else if (accounttype == 'Business') {
print('business selected');
Get.toNamed(RouteName.tellusbusinessscreen);
}
}
}),
const Spacer(
// flex: 2,

View File

@@ -20,73 +20,76 @@ class SplashScreen extends StatefulWidget {
class _SplashScreenState extends State<SplashScreen> {
// var _connectionStatus;
final Connectivity _connectivity = Connectivity();
List<ConnectivityResult> _connectionStatus = [ConnectivityResult.none];
// final Connectivity _connectivity = Connectivity();
// List<ConnectivityResult> _connectionStatus = [ConnectivityResult.none];
Future<void> checkInternet() async {
final connectivityResult = await (Connectivity().checkConnectivity());
// Future<void> checkInternet() async {
// final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.wifi ||
connectivityResult == ConnectivityResult.mobile) {
setState(() {
_connectionStatus = connectivityResult;
});
} else {
setState(() {
_connectionStatus = connectivityResult;
// if (connectivityResult == ConnectivityResult.wifi ||
// connectivityResult == ConnectivityResult.mobile) {
// setState(() {
// _connectionStatus = connectivityResult;
// });
// } else {
// setState(() {
// _connectionStatus = connectivityResult;
});
}
}
// });
// }
// }
Future<void> initConnectivity() async {
late List<ConnectivityResult> result;
try {
result = await _connectivity.checkConnectivity();
} on PlatformException catch (e) {
log('Couldn\'t check connectivity status', error: e);
return;
}
// Future<void> initConnectivity() async {
// late List<ConnectivityResult> result;
// try {
// result = await _connectivity.checkConnectivity();
// } on PlatformException catch (e) {
// log('Couldn\'t check connectivity status', error: e);
// return;
// }
if (!mounted) {
return Future.value(null);
}
// if (!mounted) {
// return Future.value(null);
// }
return _updateConnectionStatus(result);
}
// return _updateConnectionStatus(result);
// }
Future<void> _updateConnectionStatus(List<ConnectivityResult> result) async {
setState(() {
_connectionStatus = result;
});
// Future<void> _updateConnectionStatus(List<ConnectivityResult> result) async {
// setState(() {
// _connectionStatus = result;
// });
// ignore: avoid_print
print('Connectivity changed: $_connectionStatus');
}
// // ignore: avoid_print
// print('Connectivity changed: $_connectionStatus');
// }
@override
void initState() {
// TODO: implement initState
super.initState();
initConnectivity();
// initConnectivity();
log(_connectionStatus.toString());
// log(_connectionStatus.toString());
// Future.delayed(Duration(seconds: 2), () async {
// var result = await Get.to(NoInternet());
// if (result != null && result) {
// Timer(const Duration(seconds: 1), () async {
// Get.toNamed(RouteName.onboarding1);
// });
// }
// } else {
// Timer(const Duration(seconds: 2), () async {
// Get.toNamed(RouteName.onboarding1);
// });
// }
// });
Future.delayed(Duration(seconds: 2), () async {
if (_connectionStatus.contains(ConnectivityResult.none)) {
var result = await Get.to(NoInternet());
if (result != null && result) {
Timer(const Duration(seconds: 1), () async {
Get.toNamed(RouteName.onboarding1);
});
}
} else {
Timer(const Duration(seconds: 2), () async {
Get.toNamed(RouteName.onboarding1);
});
}
Timer(const Duration(seconds: 1), () async {
Get.toNamed(RouteName.onboarding1);
});
});
}
@@ -113,11 +116,11 @@ class _SplashScreenState extends State<SplashScreen> {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset("assets/images/svg/mainsplash.svg",
width: 211.w,
height: 211.h,
SvgPicture.asset(
"assets/images/svg/mainsplash.svg",
width: 211.w,
height: 211.h,
)
],
),
),

View File

@@ -0,0 +1,228 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Utils/Common/CommonAppbar.dart';
import 'package:regroup/Utils/Common/CustomNextButton.dart';
import 'package:regroup/Utils/Common/blureffect.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/onboarding/forgotPass/ViewModel/ForgotPassAPI.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ForgotOtp extends StatefulWidget {
const ForgotOtp({super.key});
@override
State<ForgotOtp> createState() => _ForgotOtpState();
}
class _ForgotOtpState extends State<ForgotOtp> {
TextEditingController? pincode = TextEditingController();
final String emailAddress = Get.arguments;
double? principleId;
get utils => null;
// principleId = prefs.getString('email').toString();
checkValidation() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
principleId = prefs.getInt('principal_xid')!.toDouble();
if (pincode!.text.isEmpty) {
utils.showToast('Pin field is empty');
} else {
Map<String, String> updata = {
"iam_principal_xid": principleId.toString(),
"otp": pincode!.text,
};
final data = await ForgotPassAPI().verifyotp(updata);
if (data.status == ResponseStatus.SUCCESS) {
// btnController.success();
// btnController.reset();
Get.snackbar(
"Success!",
'OTP verification successful!',
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.green,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
Future.delayed(Duration(seconds: 1), () {
Get.toNamed(RouteName.newpassword, arguments: emailAddress);
});
// print('success');
} else {
// btnController.error();
// btnController.reset();
Get.snackbar(
"Error!",
data.data['message'],
duration: Duration(seconds: 2),
colorText: Colors.white,
backgroundColor: Colors.red,
margin: EdgeInsets.all(8),
snackStyle: SnackStyle.FLOATING,
snackPosition: SnackPosition.BOTTOM,
);
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromARGB(255, 18, 32, 47),
appBar: CommonAppbar(
titleTxt: '',
),
body: Stack(
children: [
// CommonBlurLeftSecond(),
Positioned(top: 150, right: -30, child: CommonBlurRightSecond()),
Positioned(top: 350, 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),
],
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
sizedBoxHeight(20.h),
text22400white('Check your email'),
sizedBoxHeight(10.h),
text14400white(
'Enter the verification code that we sent to $emailAddress'),
sizedBoxHeight(40.h),
text16400white('Enter code'),
sizedBoxHeight(20.h),
PinCodeTextField(
validator: (value) {
if (value != null && value.isEmpty) {
return "Please Enter verification code";
} else if (value != null && value.length < 4) {
return "OTP length should be at least 4";
}
return null;
},
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
length: 4,
obscureText: false,
animationType: AnimationType.fade,
pinTheme: PinTheme(
selectedFillColor: Color(0xFF434A53),
inactiveFillColor: Color(0xFF434A53),
inactiveColor: Color(0xFF434A53),
activeColor: Color(0xFF434A53),
selectedColor: Color(0xFF434A53),
shape: PinCodeFieldShape.underline,
borderRadius: BorderRadius.circular(5),
fieldHeight: 70,
fieldWidth: 70,
activeFillColor:
// Colors.white
Color(0xFF303030).withOpacity(0.4),
// textStyle: TextStyle(color: Colors.white, fontSize: 20), // Change text color and font size
),
animationDuration: Duration(milliseconds: 300),
enableActiveFill: true,
autovalidateMode: AutovalidateMode.onUserInteraction,
controller: pincode,
onCompleted: (v) {
print("Completed");
},
onChanged: (value) {
print(value);
setState(() {
// currentText = value;
});
},
cursorColor: Colors.white,
textStyle: TextStyle(
color: Colors.white,
fontSize: 20.sp,
fontFamily: 'Helvetica',
),
beforeTextPaste: (text) {
print("Allowing to paste $text");
return true;
},
appContext: context,
),
const Spacer(
flex: 3,
),
CustomButton(
text: 'Continue',
onPressed: () {
// if (pincode!.text.isEmpty) {
// utils.showToast('Pin field is empty');
// } else {
// if (accounttype == 'Individual') {
// print('individual selected');
// Get.toNamed(RouteName.tellusindividualscreen);
// } else if (accounttype == 'Business') {
// print('business selected');
// Get.toNamed(RouteName.tellusbusinessscreen);
// }
// }
checkValidation();
}),
const Spacer(
// flex: 2,
),
],
),
)),
],
),
);;
}
}

View File

@@ -52,9 +52,10 @@ class _ForgotPassState extends State<ForgotPass> {
snackPosition: SnackPosition.BOTTOM,
);
prefs.setString('email', emailController.text);
prefs.setString('principal_xid', resp.data['data']['iam_principal_xid']);
prefs.setInt(
'principal_xid', resp.data['data']['iam_principal_xid']);
Future.delayed(Duration(seconds: 1), () {
Get.toNamed(RouteName.verifyusercreen,
Get.toNamed(RouteName.forgotOtp,
arguments: emailController.text);
});
// print('success');

View File

@@ -1,3 +1,4 @@
import 'package:regroup/Common/api_urls.dart';
import 'package:regroup/Common/base_manager.dart';
import 'package:regroup/Common/controller/data/network/network_api.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -10,7 +11,8 @@ class ForgotPassAPI {
Future<ResponseData<dynamic>> requestotp(var data) async {
final response = await NetworkApiServices().postApi(
data,
"https://regroup.betadelivery.com/api/v1/forgot-password",
ApiUrls.forgotpassword,
// "https://regroup.betadelivery.com/api/v1/forgot-password",
);
if (response.status == ResponseStatus.SUCCESS) {
@@ -30,7 +32,8 @@ class ForgotPassAPI {
Future<ResponseData<dynamic>> verifyotp(var data) async {
final response = await NetworkApiServices().postApi(
data,
"https://regroup.betadelivery.com/api/v1/forgot-password/verify-otp",
ApiUrls.verifyotp,
// "https://regroup.betadelivery.com/api/v1/forgot-password/verify-otp",
);
if (response.status == ResponseStatus.SUCCESS) {

View File

@@ -81,6 +81,8 @@ class RouteName {
static const String addtimeline = '/addtimeline';
static const String verifycode = '/verifycode';
static const String newpassword = '/newpassword';
static const String forgotOtp= '/forgotOtp';
static const String availability = '/availability';

View File

@@ -84,10 +84,10 @@ import 'package:regroup/Feed%20Module/sidemenu/sidemenu.dart';
import 'package:regroup/Utils/Common/NoInternet.dart';
import 'package:regroup/onboarding/NewPass/View/NewPass.dart';
import 'package:regroup/onboarding/Signup/View/Business/step1Letusunderstandbetter.dart';
import 'package:regroup/onboarding/Signup/View/Business/step2Selectgroup.dart';
import 'package:regroup/onboarding/Signup/View/Business/step3SelectCommunity.dart';
import 'package:regroup/onboarding/Signup/View/Business/tellusbusiness.dart';
import 'package:regroup/onboarding/Signup/View/Business/View/step1Letusunderstandbetter.dart';
import 'package:regroup/onboarding/Signup/View/Business/View/step2Selectgroup.dart';
import 'package:regroup/onboarding/Signup/View/Business/View/step3SelectCommunity.dart';
import 'package:regroup/onboarding/Signup/View/Business/View/tellusbusiness.dart';
import 'package:regroup/onboarding/Signup/View/Individual/step1Selectprofile.dart';
import 'package:regroup/onboarding/Signup/View/Individual/step2Selectactivity.dart';
import 'package:regroup/onboarding/Signup/View/Individual/step3Selectyourgroup.dart';
@@ -97,6 +97,7 @@ import 'package:regroup/onboarding/Signup/View/communitycommitment.dart';
import 'package:regroup/onboarding/Signup/View/signupendpage.dart';
import 'package:regroup/onboarding/Signup/View/signupscreen.dart';
import 'package:regroup/onboarding/Signup/View/verifyuser.dart';
import 'package:regroup/onboarding/forgotPass/View/ForgotOtp.dart';
import 'package:regroup/onboarding/forgotPass/View/ForgotPass.dart';
import 'package:regroup/onboarding/onboarding1.dart';
import 'package:regroup/onboarding/splashscreen.dart';
@@ -486,6 +487,10 @@ class AppRoutes {
GetPage(
name: RouteName.newpassword,
page: () => const NewPassword(),
),
GetPage(
name: RouteName.forgotOtp,
page: () => const ForgotOtp(),
),
];
}