diff --git a/android/app/build.gradle b/android/app/build.gradle index 030598a..e98441f 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,12 +19,12 @@ if (project.hasProperty('google-services.json')) { def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { - flutterVersionCode = '22' + flutterVersionCode = '23' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { - flutterVersionName = '1.0.22' + flutterVersionName = '1.0.23' } def keystoreProperties = new Properties() diff --git a/lib/main.dart b/lib/main.dart index 575c12d..82a98a4 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -22,6 +22,7 @@ import 'package:nhance_app_pwa/pages/postEnrollment/policies.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/privacypolicy.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/profile.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/termsofuse.dart'; +import 'package:nhance_app_pwa/pages/postEnrollment/tickets.dart'; import 'package:nhance_app_pwa/pages/postEnrollment/wellness.dart'; import 'package:nhance_app_pwa/pages/session/SetPinBiometric.dart'; import 'package:nhance_app_pwa/pages/session/changePin.dart'; @@ -150,6 +151,7 @@ class MyApp extends StatelessWidget { 'empDetails': (context) => empDetails(), 'addOnsDetails': (context) => addOnsDetails(), 'empReviewDetails': (context) => empReviewDetails(), + 'tickets': (context) => tickets(), }, ); } diff --git a/lib/pages/email_verify.dart b/lib/pages/email_verify.dart index 2c46097..be54ec8 100755 --- a/lib/pages/email_verify.dart +++ b/lib/pages/email_verify.dart @@ -17,9 +17,13 @@ import '../customAppBar/responsive.dart'; import '../customAppBar/toastHelper.dart'; import '../models/environment.dart'; import '../models/platform_helper_mobile.dart' - if (dart.library.html) '../models/platform_helper_other.dart'; +if (dart.library.html) '../models/platform_helper_other.dart'; // import 'dart:html' as html; +import '../pages/helpers/html_stub.dart' +if (dart.library.html) '../pages/helpers/html_web.dart'; + +// import '../pages/helpers/html_stub.dart' if (dart.library.html) 'html_web.dart'; class MyEmailVerify extends StatefulWidget { final String email; @@ -146,7 +150,8 @@ class _MyEmailVerifyState extends State { print('EMAIL PARAMS : ${widget.email} - OTP : $otp'); final response = await http.post( Uri.parse(Environment.apiUrlEnrollment + 'getVerifiedUserData'), - body: json.encode({'email_id': widget.email, 'otp': _otpController.text}), + body: + json.encode({'email_id': widget.email, 'otp': _otpController.text}), headers: { HttpHeaders.contentTypeHeader: 'application/json', }, @@ -210,6 +215,23 @@ class _MyEmailVerifyState extends State { } } + void loginUser({ + required String gpaEmpName, + required String empPrimaryId, + required String empCodeString, + required String client_id, + required String empClientBranchId, + }) { + HtmlHelper.saveLoginData({ + 'gpaEmpName': gpaEmpName, + 'empPrimaryId': empPrimaryId, + 'empCode': empCodeString, + 'client_id': client_id, + 'empClientBranchId': empClientBranchId, + }); + print('Successfully Login'); + } + void postSuccessData(post, data) async { String status = data['status']; String postStatus = post['status']; @@ -237,7 +259,15 @@ class _MyEmailVerifyState extends State { print('Successfully Login'); - // if(kIsWeb) { + loginUser( + gpaEmpName: gpaEmpName, + empPrimaryId: empPrimaryId, + empCodeString: empCodeString, + client_id: client_id, + empClientBranchId: empClientBranchId, + ); + + // if (kIsWeb) { // html.window.localStorage['gpaEmpName'] = gpaEmpName; // html.window.localStorage['empPrimaryId'] = empPrimaryId; // html.window.localStorage['empCode'] = empCodeString; @@ -299,7 +329,7 @@ class _MyEmailVerifyState extends State { // print('Successfully Login'); // } - final SharedPreferences prefs = await SharedPreferences.getInstance(); + final SharedPreferences prefs = await SharedPreferences.getInstance(); final _postToken = prefs.getString('_postToken'); // int skipStatus = prefs.getInt('skipStatus') ?? 1; // final mpinText = prefs.getString('mpinText'); @@ -421,13 +451,13 @@ class _MyEmailVerifyState extends State { final SharedPreferences prefs = await SharedPreferences.getInstance(); empMobileNo = prefs.getString('empMobileNo'); empEmailid = prefs.getString('empEmailid'); - print('empMobileNo $empMobileNo' ); + print('empMobileNo $empMobileNo'); print('empEmailid $empEmailid'); // _token = prefs.getString('token'); var params = {}; if (empMobileNo != null && empMobileNo.isNotEmpty) { params = {'mobile_number': empMobileNo}; - } else if(empEmailid != null && empEmailid.isNotEmpty){ + } else if (empEmailid != null && empEmailid.isNotEmpty) { params = {'email_id': empEmailid}; } @@ -453,14 +483,16 @@ class _MyEmailVerifyState extends State { } if (data['is_biometric_enabled'] != null) { - prefs.setString('is_biometric_enabled', data['is_biometric_enabled']); + prefs.setString( + 'is_biometric_enabled', data['is_biometric_enabled']); } if (data['is_mpin_skipped'] != null) { prefs.setString('is_mpin_skipped', data['is_mpin_skipped']); } - if (data['is_mpin_skipped'] != null && data['is_mpin_skipped'] == '0') { + if (data['is_mpin_skipped'] != null && + data['is_mpin_skipped'] == '0') { Navigator.pushReplacementNamed(context, 'pinPage'); } else { if (_postToken != null && _postToken.isNotEmpty) { @@ -470,7 +502,6 @@ class _MyEmailVerifyState extends State { Navigator.pushReplacementNamed(context, 'empDetails'); } } - } else { Navigator.pushReplacementNamed(context, 'pinSettingPage'); } @@ -492,7 +523,7 @@ class _MyEmailVerifyState extends State { url, headers: { 'Authorization': - 'Bearer $_token', // Add token to the Authorization header + 'Bearer $_token', // Add token to the Authorization header }, ); if (response.statusCode == 200) { @@ -594,484 +625,484 @@ class _MyEmailVerifyState extends State { }, child: Scaffold( body: SingleChildScrollView( - keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, - child: Container( - height: _size.height, - color: Colors.white, - child: Stack( - children: [ - Visibility( - visible: _size.width <= 1100, - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), - bottomRight: Radius.circular(30), - ), - child: Container( - height: _size.height / 3, - width: double.infinity, - color: Color(0xFFFFFCE5), - child: Stack( - children: [ - Column( + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + child: Container( + height: _size.height, + color: Colors.white, + child: Stack( + children: [ + Visibility( + visible: _size.width <= 1100, + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(30), + ), + child: Container( + height: _size.height / 3, + width: double.infinity, + color: Color(0xFFFFFCE5), + child: Stack( children: [ - SizedBox( - height: _size.height / - 6.4), // Adjust the spacing between the rows - Row( - mainAxisAlignment: MainAxisAlignment - .center, // Align to the center + Column( children: [ - Expanded( - flex: Responsive.isDesktop(context) - ? 10 - : 12, - child: Align( - alignment: Responsive.isDesktop(context) - ? Alignment.centerLeft - : Alignment.bottomCenter, - child: Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - ), - ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: GoogleFonts.poppins( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) + ? 10 + : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, ), ), ), - ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) + children: [ + Text( + 'HR Login', + style: GoogleFonts.poppins( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + ], + ), + ), + ), + ), + ], + ), ], ), ], ), - ], + ), ), ), - ), - ), - Container( - margin: marginInsets, - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column( - children: [ - Row( + Container( + margin: marginInsets, + alignment: Alignment.bottomCenter, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( children: [ - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 20, right: 20) - : EdgeInsets.only(left: 0, right: 0), - child: Column( - mainAxisAlignment: + Row( + children: [ + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: Container( + margin: _size.width > 1100 + ? EdgeInsets.only(left: 20, right: 20) + : EdgeInsets.only(left: 0, right: 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Row( - children: [ - Expanded( - flex: 10, - child: Align( - alignment: Responsive + children: [ + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 10, + child: Align( + alignment: Responsive .isDesktop(context) - ? Alignment.centerLeft - : Alignment + ? Alignment.centerLeft + : Alignment .bottomCenter, // Align to the start - child: _size.width <= 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : _size.width > 1100 + child: _size.width <= 1100 ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) : Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - )), - ], - ), - SizedBox(height: 10), - // SizedBox( - // height: Responsive.isDesktop(context) - // ? _size.height * 0.1 - // : 10, - // ), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - "Welcome to Nhance", - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.bold, - ), + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ), + )), + ], ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + SizedBox(height: 10), + // SizedBox( + // height: Responsive.isDesktop(context) + // ? _size.height * 0.1 + // : 10, + // ), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Welcome to Nhance", + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: "Please enter the one-time usage code sent to your mobile number ${widget.email}", - style: TextStyle( - fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Email)", style: TextStyle( fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: + height: 1.5, + color: Color(0xFF000000)), + children: [ + TextSpan( + text: " (Change Email)", + style: TextStyle( + fontSize: 12, + color: Color( + 0xFFE26728)), // Change color as desired + recognizer: TapGestureRecognizer() ..onTap = () { // Navigate to the page where the user can change the phone number Navigator.pushNamed( context, 'login'); }, - ), - ], - ), - ), - ), - SizedBox(height: 15), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: - GoogleFonts.poppins( - color: - Colors.black), - ) - : InkWell( - onTap: () { - _resendOTP(); - }, - child: Text( - "Resend OTP", - style: - GoogleFonts.poppins( - color: Colors - .blue), - ), ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), + ], ), ), - onPressed: () { - if (_formKey.currentState! - .validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP( - _otpController.text); - } - }, - child: Text( - "Submit", - style: GoogleFonts.poppins( - color: Color(0xFFFFFFFF)), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: Pinput( + length: 6, + // defaultPinTheme: defaultPinTheme, + // focusedPinTheme: focusedPinTheme, + // submittedPinTheme: submittedPinTheme, + showCursor: true, + controller: _otpController, ), ), - ), - ), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Column( - // children: [ - // SizedBox(height: 20), - // Text( - // "Benefits of Login", - // style: - // GoogleFonts.poppins( - // fontSize: 20, - // fontWeight: - // FontWeight.bold, - // ), - // ), - // SizedBox(height: 15), - // ], - // )) - // : SizedBox(), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // Expanded( - // flex: 6, - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: 8), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment - // .center, - // children: [ - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // decoration: - // BoxDecoration( - // border: - // Border( - // right: - // BorderSide( - // width: 1, - // color: Colors - // .black, - // ), - // ), - // ), - // child: Column( - // children: [ - // Icon( - // Icons - // .policy, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "View Policy", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // child: Column( - // children: [ - // Icon( - // Icons - // .edit, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "Manage Claims", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ) - // : SizedBox( - // height: Responsive.isDesktop( - // context) - // ? _size.height * 0.1 - // : _size.height * 0.2, - // ), - SizedBox( - height: Responsive.isDesktop(context) - ? _size.height * 0.3 - : _size.height * 0.2, - ), - // SizedBox( - // height: _size.height * 0.1, - // ), - Container( - alignment: Alignment.bottomCenter, - padding: - EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - 'By continuing, you agree with our ', - style: GoogleFonts.poppins( - color: Colors.black, - fontSize: 9, + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align text to the right + children: [ + _isTimerRunning + ? Text( + "Resend OTP in $_secondsRemaining seconds", + style: + GoogleFonts.poppins( + color: + Colors.black), + ) + : InkWell( + onTap: () { + _resendOTP(); + }, + child: Text( + "Resend OTP", + style: + GoogleFonts.poppins( + color: Colors + .blue), + ), + ), + ], ), - children: [ - TextSpan( - text: 'privacy policy ', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFF00989E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), + ), + ), + onPressed: () { + if (_formKey.currentState! + .validate()) { + _formKey.currentState! + .save(); // Save form fields before calling verifyOTP + verifyOTP( + _otpController.text); + } + }, + child: Text( + "Submit", + style: GoogleFonts.poppins( + color: Color(0xFFFFFFFF)), ), ), - TextSpan( - text: 'and ', + ), + ), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Column( + // children: [ + // SizedBox(height: 20), + // Text( + // "Benefits of Login", + // style: + // GoogleFonts.poppins( + // fontSize: 20, + // fontWeight: + // FontWeight.bold, + // ), + // ), + // SizedBox(height: 15), + // ], + // )) + // : SizedBox(), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.center, + // children: [ + // Expanded( + // flex: 6, + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: 8), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .center, + // children: [ + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // decoration: + // BoxDecoration( + // border: + // Border( + // right: + // BorderSide( + // width: 1, + // color: Colors + // .black, + // ), + // ), + // ), + // child: Column( + // children: [ + // Icon( + // Icons + // .policy, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "View Policy", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // child: Column( + // children: [ + // Icon( + // Icons + // .edit, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "Manage Claims", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // ], + // ), + // ) + // : SizedBox( + // height: Responsive.isDesktop( + // context) + // ? _size.height * 0.1 + // : _size.height * 0.2, + // ), + SizedBox( + height: Responsive.isDesktop(context) + ? _size.height * 0.3 + : _size.height * 0.2, + ), + // SizedBox( + // height: _size.height * 0.1, + // ), + Container( + alignment: Alignment.bottomCenter, + padding: + EdgeInsets.symmetric(vertical: 8), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + 'By continuing, you agree with our ', style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), + children: [ + TextSpan( + text: 'privacy policy ', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + TextSpan( + text: 'and ', + style: GoogleFonts.poppins( + color: Colors.black, + fontSize: 9, + ), + ), + TextSpan( + text: 'terms of use', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], ), - TextSpan( - text: 'terms of use', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - ], + ), ), - ), + ], ), - ], + ), ), - ), + if (_size.width > 1100) + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return Image.asset( + 'assets/login_web.jpg', + height: _size.height, + fit: BoxFit.cover, + ); + } else { + return SizedBox(); + } + }, + ), + ), + ], ), - if (_size.width > 1100) - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/login_web.jpg', - height: _size.height, - fit: BoxFit.cover, - ); - } else { - return SizedBox(); - } - }, - ), - ), ], ), - ], + ), ), ), - ), - ), - ], - )), - ))); + ], + )), + ))); } -} +} \ No newline at end of file diff --git a/lib/pages/helpers/botman.dart b/lib/pages/helpers/botman.dart new file mode 100644 index 0000000..f486f2b --- /dev/null +++ b/lib/pages/helpers/botman.dart @@ -0,0 +1 @@ +export 'botman_stub.dart' if (dart.library.js) 'botman_web.dart'; diff --git a/lib/pages/helpers/botman_stub.dart b/lib/pages/helpers/botman_stub.dart new file mode 100644 index 0000000..8e7b78f --- /dev/null +++ b/lib/pages/helpers/botman_stub.dart @@ -0,0 +1,7 @@ +void openBotmanChat() { + // No-op on mobile +} + +void repositionBotman() { + // No-op on mobile +} diff --git a/lib/pages/helpers/botman_web.dart b/lib/pages/helpers/botman_web.dart new file mode 100644 index 0000000..7ba017f --- /dev/null +++ b/lib/pages/helpers/botman_web.dart @@ -0,0 +1,14 @@ +import 'dart:js' as js; +import 'package:flutter/foundation.dart'; + +void openBotmanChat() { + if (kIsWeb) { + js.context.callMethod('openBotmanChat'); + } +} + +void repositionBotman() { + if (kIsWeb) { + js.context.callMethod('repositionBotmanWidget'); + } +} diff --git a/lib/pages/helpers/html_stub.dart b/lib/pages/helpers/html_stub.dart new file mode 100644 index 0000000..6826ae0 --- /dev/null +++ b/lib/pages/helpers/html_stub.dart @@ -0,0 +1,6 @@ +// html_stub.dart +class HtmlHelper { + static void saveLoginData(Map data) { + // No-op for non-web platforms + } +} diff --git a/lib/pages/helpers/html_web.dart b/lib/pages/helpers/html_web.dart new file mode 100644 index 0000000..f7ddf8a --- /dev/null +++ b/lib/pages/helpers/html_web.dart @@ -0,0 +1,16 @@ +// html_web.dart +import 'dart:html' as html; + +class HtmlHelper { + static void saveLoginData(Map data) { + data.forEach((key, value) { + html.window.localStorage[key] = value; + }); + + html.window.dispatchEvent( + html.CustomEvent('userLoggedIn', detail: {'status': 'success'}), + ); + + print("✅ User logged in! LocalStorage values set (web)."); + } +} diff --git a/lib/pages/helpers/mobile_helpers.dart b/lib/pages/helpers/mobile_helpers.dart new file mode 100644 index 0000000..39c418a --- /dev/null +++ b/lib/pages/helpers/mobile_helpers.dart @@ -0,0 +1,3 @@ +void setupBackButtonHandler(Function showDialogCallback) { + // No-op on mobile +} diff --git a/lib/pages/helpers/web_helpers.dart b/lib/pages/helpers/web_helpers.dart new file mode 100644 index 0000000..5c7a090 --- /dev/null +++ b/lib/pages/helpers/web_helpers.dart @@ -0,0 +1,12 @@ +import 'dart:html' as html; + +void setupBackButtonHandler(Function showDialogCallback) { + // Push a dummy state so back button triggers popstate instead of navigating + html.window.history.pushState(null, 'home', html.window.location.href); + + html.window.onPopState.listen((event) { + showDialogCallback(); + // Re-push to prevent leaving + html.window.history.pushState(null, 'home', html.window.location.href); + }); +} diff --git a/lib/pages/postEnrollment/help.dart b/lib/pages/postEnrollment/help.dart index ec33ced..abf9ebf 100755 --- a/lib/pages/postEnrollment/help.dart +++ b/lib/pages/postEnrollment/help.dart @@ -28,6 +28,7 @@ class _helpState extends State { late ApiService apiService; int _currentIndex = 0; bool isActive = true; + int tickets = 1; int closedTrackActive = 1; int allClaimsActive = 0; dynamic _token; @@ -76,8 +77,6 @@ class _helpState extends State { super.dispose(); } - - Future _loadToken() async { print('_loadToken'); final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -399,11 +398,11 @@ class _helpState extends State { child: Row( children: [ Expanded( - flex: 8, + flex: 6, child: Container( width: 300, height: 150, - alignment: Alignment.center, + alignment: Alignment.centerRight, child: ElevatedButton( onPressed: () { var details = { @@ -425,172 +424,143 @@ class _helpState extends State { ), ), )), + SizedBox(width: 10), + Expanded( + flex: 6, + child: Container( + width: 300, + height: 150, + alignment: Alignment.centerLeft, + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed(context, 'tickets'); + }, + child: Text( + 'Raise a Ticket', + style: GoogleFonts.poppins(color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + ), + ), + )), ], ), ), - SizedBox(height: 5), - SizedBox(height: 15), + SizedBox(height: 20), + // SizedBox(height: 15), Container( decoration: BoxDecoration( - color: - Color(0xFFF6FAFF), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25) - : EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - flex: 6, - child: Container( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - isActive = true; - // policyList.clear(); - allClaimsActive = 0; - closedTrackActive = 1; - }); - }, - child: isActive - ? Material( - elevation: 5, - borderRadius: - BorderRadius.circular(10), - color: Colors.white, - child: TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: EdgeInsets.symmetric( - horizontal: Responsive - .isDesktop( - context) - ? 120 - : 50, - vertical: Responsive - .isDesktop( - context) - ? 15 - : 5), - // primary: Color(0xFF000000), - ), - child: Text( - 'All Claims', - style: GoogleFonts.poppins( - fontSize: Responsive - .isDesktop( - context) - ? 18 - : 13, - fontWeight: - FontWeight.w500, - color: Color( - 0xFF000000)), - ), - ), - ) - : Text( - 'All Claims', - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 13, - fontWeight: FontWeight.w400, - color: Color(0xFF636363), - ), - ), - ), - )), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - isActive = false; - // trackClaimsList.clear(); - allClaimsActive = 1; - closedTrackActive = 0; - }); - getTrackClaimsList(); - }, - child: !isActive - ? Material( - elevation: 5, - borderRadius: - BorderRadius.circular(10), - color: Colors.white, - child: TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: EdgeInsets.symmetric( - horizontal: Responsive - .isDesktop( - context) - ? 120 - : 40, - vertical: Responsive - .isDesktop( - context) - ? 15 - : 5), - // primary: Color(0xFF000000), - ), - child: Text( - 'Closed claims', - style: - GoogleFonts.poppins( - fontSize: Responsive - .isDesktop( - context) - ? 18 - : 13, - color: - Color(0xFF000000), - fontWeight: - FontWeight.w500, - ), - ), - ), - ) - : Text( - 'Closed claims', - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 13, - fontWeight: FontWeight.w400, - color: Color(0xFF636363), - ), - ), - ), - )) - ], - ) - ], - ))), - ], + color: Color(0xFFF6FAFF), + borderRadius: BorderRadius.circular(5), ), + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10), + child: Responsive.isDesktop(context) + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: _buildTabButton( + context: context, + title: "All Claims", + isActive: allClaimsActive == 0, + onTap: () { + setState(() { + isActive = true; + allClaimsActive = 0; + closedTrackActive = 1; + tickets = 1; + }); + }, + ), + ), + Expanded( + child: _buildTabButton( + context: context, + title: "Closed claims", + isActive: closedTrackActive == 0, + onTap: () { + setState(() { + isActive = false; + allClaimsActive = 1; + closedTrackActive = 0; + tickets = 1; + }); + getTrackClaimsList(); + }, + ), + ), + Expanded( + child: _buildTabButton( + context: context, + title: "Tickets", + isActive: tickets == 0, + onTap: () { + setState(() { + isActive = false; + allClaimsActive = 1; + closedTrackActive = 1; + tickets = 0; + }); + // getTrackClaimsList(); + }, + ), + ), + ], + ) + : SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + _buildTabButton( + context: context, + title: "All Claims", + isActive: allClaimsActive == 0, + onTap: () { + setState(() { + isActive = true; + allClaimsActive = 0; + closedTrackActive = 1; + tickets = 1; + }); + }, + ), + SizedBox(width: 10), + _buildTabButton( + context: context, + title: "Closed claims", + isActive: closedTrackActive == 0, + onTap: () { + setState(() { + isActive = false; + allClaimsActive = 1; + closedTrackActive = 0; + tickets = 1; + }); + getTrackClaimsList(); + }, + ), + SizedBox(width: 10), + _buildTabButton( + context: context, + title: "Tickets", + isActive: tickets == 0, + onTap: () { + setState(() { + isActive = false; + allClaimsActive = 1; + closedTrackActive = 1; + tickets = 0; + }); + getTrackClaimsList(); + }, + ), + ], + ), + ), ), if (allClaimsActive == 0) if (trackClaimsList == null || trackClaimsList.isEmpty) @@ -1058,6 +1028,56 @@ class _helpState extends State { ]; } + /// Reusable tab button widget + Widget _buildTabButton({ + required BuildContext context, + required String title, + required bool isActive, + required VoidCallback onTap, + }) { + return Container( + width: + Responsive.isDesktop(context) ? null : 120, // fixed width on mobile + child: isActive + ? Material( + elevation: 5, + borderRadius: BorderRadius.circular(10), + color: Colors.white, + child: TextButton( + onPressed: onTap, + style: TextButton.styleFrom( + padding: EdgeInsets.symmetric( + vertical: Responsive.isDesktop(context) ? 15 : 10, + ), + ), + child: Text( + title, + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 18 : 14, + fontWeight: FontWeight.w500, + color: Colors.black, + ), + ), + ), + ) + : GestureDetector( + onTap: onTap, + child: Center( + child: Text( + title, + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) ? 18 : 14, + fontWeight: FontWeight.w400, + color: Color(0xFF636363), + ), + ), + ), + ), + ); + } + List generateClaimsClosedList(List data) { return [ ListView.builder( diff --git a/lib/pages/postEnrollment/home.dart b/lib/pages/postEnrollment/home.dart index ab6409d..00fe291 100755 --- a/lib/pages/postEnrollment/home.dart +++ b/lib/pages/postEnrollment/home.dart @@ -18,14 +18,20 @@ import '../../customAppBar/customFooter.dart'; import '../../customAppBar/responsive.dart'; import '../../customAppBar/tabs.dart'; import '../../customAppBar/toastHelper.dart'; + import 'botman_chat.dart'; import 'botman_ios_chat.dart'; import 'botman_widget_app.dart'; import 'chatbot.dart'; // import 'dart:js' as js; // import 'dart:html' as html; -import 'package:webview_flutter_android/webview_flutter_android.dart'; +import '/pages/helpers/botman_stub.dart' +if (dart.library.html) '/pages/helpers/botman_web.dart'; + +import '/../pages/helpers/mobile_helpers.dart' +if (dart.library.html) '/../pages/helpers/web_helpers.dart'; +import 'package:webview_flutter_android/webview_flutter_android.dart'; class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); @@ -64,6 +70,7 @@ class _HomeState extends State { _currentIndex = index; }); } + late final WebViewController _controller; @override @@ -73,25 +80,28 @@ class _HomeState extends State { _loadToken(); checkEnrollToken(); - // if(kIsWeb){ - // openBotmanChat(); - // - // - // // Push a dummy state so back button triggers popstate instead of navigating - // html.window.history.pushState(null, 'home', html.window.location.href); - // - // html.window.onPopState.listen((event) { - // if (!_dialogShown) { - // _showBackConfirmationDialog(); - // } - // // Re-push to prevent leaving - // html.window.history.pushState(null, 'home', html.window.location.href); - // }); - // } + if (kIsWeb) { + openBotmanChat(); + + setupBackButtonHandler(() { + if (!_dialogShown) _showBackConfirmationDialog(); + }); + + // Push a dummy state so back button triggers popstate instead of navigating + // html.window.history.pushState(null, 'home', html.window.location.href); + + // html.window.onPopState.listen((event) { + // if (!_dialogShown) { + // _showBackConfirmationDialog(); + // } + // // Re-push to prevent leaving + // html.window.history.pushState(null, 'home', html.window.location.href); + // }); + } // if (Platform.isAndroid) { // WebViewPlatform.instance = AndroidWebViewPlatform(); // } - // + // _controller = WebViewController() // ..setJavaScriptMode(JavaScriptMode.unrestricted) // ..loadFlutterAsset('assets/botman_chat.html'); // or loadHtmlString @@ -105,8 +115,8 @@ class _HomeState extends State { // void openBotmanChat() { // print('openBotmanChat'); // if (kIsWeb) { - // js.context.callMethod( - // 'openBotmanChat'); // Correct way to call JS function + // js.context + // .callMethod('openBotmanChat'); // Correct way to call JS function // } // } // @@ -206,7 +216,7 @@ class _HomeState extends State { }); print('check 1'); final response = await apiService.getActiveAndInactivePolicyDetails( - client_id!, empCodeString!, status, client_branch_id,mobileNo); + client_id!, empCodeString!, status, client_branch_id, mobileNo); print('check 1'); if (response['status'] == 'success') { setState(() { @@ -270,9 +280,12 @@ class _HomeState extends State { } String generateSessionId([int length = 15]) { - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + const characters = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; final random = Random.secure(); - return List.generate(length, (index) => characters[random.nextInt(characters.length)]).join(); + return List.generate( + length, (index) => characters[random.nextInt(characters.length)]) + .join(); } @override @@ -288,450 +301,450 @@ class _HomeState extends State { body: Stack(children: [ SingleChildScrollView( child: Container( - padding: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width * - 0.2, // 30% of screen width as horizontal padding - vertical: MediaQuery.of(context).size.height * - 0.03, // 5% of screen height as vertical padding - ) - : EdgeInsets.all(15), - color: Colors.white, - child: Column(children: [ - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - 'Hello, $emp_name!', - textAlign: TextAlign.left, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 20 - : 20, - fontWeight: FontWeight.w500, - color: Color(0xFF000000), - ), - ), - ], - ), - // Text( - // 'Lorem ipsum dolor sit amet', - // textAlign: TextAlign.left, - // style: GoogleFonts.poppins( - // fontSize: - // Responsive.isDesktop(context) ? 12 : 14, - // fontWeight: FontWeight.w400, - // color: Color(0xFF7A7A7A), - // ), - // ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Card( - elevation: 2, - color: Color(0xFFDDF3FF), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), // Set the border radius here - ), - child: ClipRRect( - borderRadius: BorderRadius.circular( - 10), // Apply border radius to the container - child: Column( - children: [ - Container( - decoration: BoxDecoration( - color: Color( - 0xFFDDF3FF), // Set background color for the container - borderRadius: BorderRadius.circular( - 10), // Set border radius for the container - ), - padding: Responsive.isDesktop(context) - ? EdgeInsets.only( - top: 10, bottom: 10, left: 10, right: 10) - : EdgeInsets.only( - top: 10, bottom: 10, left: 10, right: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 7, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - 'Policies for enrollment : $pre_policy_count', - textAlign: TextAlign.center, - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop(context) ? 18 : 12, - fontWeight: FontWeight.w500, - color: Color(0xFF404040), - ), - ), - ], - ), - ), - Expanded( - flex: 5, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - ElevatedButton( - onPressed: isTokenAvailable - ? () { - Navigator.pushNamed( - context, 'empDetails'); - } - : null, - child: Text('View Details'), - ), - ], - ), - ), - ], - ), - ), - ], - ), - ), - ), - SizedBox(height: 15), - if (advertisementImages != null) - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: isLoading - ? Center(child: CircularProgressIndicator()) - : advertisementImages.isEmpty - ? Center(child: Text("No images available")) - : Container( - child: Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: ImageSlideshow( - /// Width of the [ImageSlideshow]. - width: double.infinity, - - /// Height of the [ImageSlideshow]. - height: - Responsive.isDesktop( - context) - ? 200 - : 150, - - /// The page to show when first creating the [ImageSlideshow]. - initialPage: 0, - - /// The color to paint the indicator. - indicatorColor: - Color(0xFFE26728), - - /// The color to paint behind the indicator. - indicatorBackgroundColor: - Colors.grey, - - /// The widgets to display in the [ImageSlideshow]. - children: - advertisementImages - .map( - (imageUrl) => - ClipRRect( - borderRadius: - BorderRadius - .circular( - 8), - child: Image - .network( - imageUrl, - fit: BoxFit - .cover, - ), - ), - ) - .toList(), - - /// Called whenever the page in the center of the viewport changes. - onPageChanged: (value) { - print( - 'Page changed: $value'); - }, - - /// Auto scroll interval. - /// Do not auto scroll with null or 0. - autoPlayInterval: 3000, - - /// Loops back to the first slide. - isLoop: true, - ), - ), - ], - ), - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - SizedBox(height: 15), - Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - 'Your Policies', - textAlign: TextAlign.left, - style: GoogleFonts.poppins( - fontSize: Responsive.isDesktop(context) - ? 18 - : 18, - fontWeight: FontWeight.w500, - color: Color(0xFF000000), - ), - ), - ], - ), - // Text( - // 'Lorem ipsum dolor sit amet', - // textAlign: TextAlign.left, - // style: GoogleFonts.poppins( - // fontSize: - // Responsive.isDesktop(context) ? 12 : 14, - // fontWeight: FontWeight.w400, - // color: Color(0xFF7A7A7A), - // ), - // ), - ], - ))), - ], - ), - ), - SizedBox(height: 15), - Container( - decoration: BoxDecoration( - color: - Color(0xFFEEF5FF), // Set background color for the container - borderRadius: BorderRadius.circular( - 5), // Set border radius for the container - ), padding: Responsive.isDesktop(context) - ? EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25) - : EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 12, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.03, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(15), + color: Colors.white, + child: Column(children: [ + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + 'Hello, $emp_name!', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 20 + : 20, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + ), + ), + ], + ), + // Text( + // 'Lorem ipsum dolor sit amet', + // textAlign: TextAlign.left, + // style: GoogleFonts.poppins( + // fontSize: + // Responsive.isDesktop(context) ? 12 : 14, + // fontWeight: FontWeight.w400, + // color: Color(0xFF7A7A7A), + // ), + // ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Card( + elevation: 2, + color: Color(0xFFDDF3FF), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), // Set the border radius here + ), + child: ClipRRect( + borderRadius: BorderRadius.circular( + 10), // Apply border radius to the container + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFDDF3FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 10), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10) + : EdgeInsets.only( + top: 10, bottom: 10, left: 10, right: 10), + child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, + Expanded( + flex: 7, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + 'Policies for enrollment : $pre_policy_count', + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop(context) ? 18 : 12, + fontWeight: FontWeight.w500, + color: Color(0xFF404040), + ), + ), + ], + ), + ), + Expanded( + flex: 5, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + onPressed: isTokenAvailable + ? () { + Navigator.pushNamed( + context, 'empDetails'); + } + : null, + child: Text('View Details'), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ), + SizedBox(height: 15), + if (advertisementImages != null) + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: isLoading + ? Center(child: CircularProgressIndicator()) + : advertisementImages.isEmpty + ? Center(child: Text("No images available")) + : Container( + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Expanded( - flex: 6, - child: Container( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - isActive = true; - policyList.clear(); - }); - getActiveAndInactivePolicyDetails( - 'Active'); - }, - child: isActive - ? Material( - elevation: 5, - borderRadius: - BorderRadius.circular(10), - color: Colors.white, - child: SizedBox( - width: Responsive.isDesktop( - context) - ? 400 - : 150, // Set the width here - child: TextButton( - onPressed: () {}, - style: - TextButton.styleFrom( - padding: EdgeInsets - .symmetric( - vertical: Responsive - .isDesktop( - context) - ? 12 - : 5, - ), - ), - child: Text( - 'Active', - style: - GoogleFonts.poppins( - fontSize: Responsive - .isDesktop( - context) - ? 18 - : 13, - fontWeight: - FontWeight.w500, - color: - Color(0xFF593AFF), - ), + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: ImageSlideshow( + /// Width of the [ImageSlideshow]. + width: double.infinity, + + /// Height of the [ImageSlideshow]. + height: + Responsive.isDesktop( + context) + ? 200 + : 150, + + /// The page to show when first creating the [ImageSlideshow]. + initialPage: 0, + + /// The color to paint the indicator. + indicatorColor: + Color(0xFFE26728), + + /// The color to paint behind the indicator. + indicatorBackgroundColor: + Colors.grey, + + /// The widgets to display in the [ImageSlideshow]. + children: + advertisementImages + .map( + (imageUrl) => + ClipRRect( + borderRadius: + BorderRadius + .circular( + 8), + child: Image + .network( + imageUrl, + fit: BoxFit + .cover, ), ), - ), - ) - : Text( - 'Active', - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 13, - fontWeight: FontWeight.w400, - color: Color(0xFF636363), - ), - ), - ), - )), - Expanded( - flex: 6, - child: Container( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - isActive = false; - policyList.clear(); - }); - getActiveAndInactivePolicyDetails( - 'Inactive'); - }, - child: !isActive - ? Material( - elevation: 5, - borderRadius: - BorderRadius.circular(10), - color: Colors.white, - child: SizedBox( - width: Responsive.isDesktop( - context) - ? 400 - : 150, // Set the width here - child: TextButton( - onPressed: () {}, - style: - TextButton.styleFrom( - padding: EdgeInsets - .symmetric( - vertical: Responsive - .isDesktop( - context) - ? 12 - : 5, - ), - ), - child: Text( - 'Inactive', - style: - GoogleFonts.poppins( - fontSize: Responsive - .isDesktop( - context) - ? 18 - : 13, - fontWeight: - FontWeight.w500, - color: - Color(0xFF593AFF), - ), - ), - ), - ), - ) - : Text( - 'Inactive', - style: GoogleFonts.poppins( - fontSize: - Responsive.isDesktop( - context) - ? 18 - : 13, - fontWeight: FontWeight.w400, - color: Color(0xFF636363), - ), - ), - ), - )) + ) + .toList(), + + /// Called whenever the page in the center of the viewport changes. + onPageChanged: (value) { + print( + 'Page changed: $value'); + }, + + /// Auto scroll interval. + /// Do not auto scroll with null or 0. + autoPlayInterval: 3000, + + /// Loops back to the first slide. + isLoop: true, + ), + ), + ], + ), + ), + ), ], - ) - ], - ))), - ], - ), - ), - SizedBox(height: 15), - if (policyList != null && policyList.length > 0) - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - ...generateCards(policyList), - ], - ), - SizedBox(height: Responsive.isDesktop(context) ? 40 : 70), - ]), - )), + ), + ), + ), + ), + ], + ), + ), + SizedBox(height: 15), + Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + 'Your Policies', + textAlign: TextAlign.left, + style: GoogleFonts.poppins( + fontSize: Responsive.isDesktop(context) + ? 18 + : 18, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + ), + ), + ], + ), + // Text( + // 'Lorem ipsum dolor sit amet', + // textAlign: TextAlign.left, + // style: GoogleFonts.poppins( + // fontSize: + // Responsive.isDesktop(context) ? 12 : 14, + // fontWeight: FontWeight.w400, + // color: Color(0xFF7A7A7A), + // ), + // ), + ], + ))), + ], + ), + ), + SizedBox(height: 15), + Container( + decoration: BoxDecoration( + color: + Color(0xFFEEF5FF), // Set background color for the container + borderRadius: BorderRadius.circular( + 5), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25) + : EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + flex: 6, + child: Container( + alignment: Alignment.center, + child: GestureDetector( + onTap: () { + setState(() { + isActive = true; + policyList.clear(); + }); + getActiveAndInactivePolicyDetails( + 'Active'); + }, + child: isActive + ? Material( + elevation: 5, + borderRadius: + BorderRadius.circular(10), + color: Colors.white, + child: SizedBox( + width: Responsive.isDesktop( + context) + ? 400 + : 150, // Set the width here + child: TextButton( + onPressed: () {}, + style: + TextButton.styleFrom( + padding: EdgeInsets + .symmetric( + vertical: Responsive + .isDesktop( + context) + ? 12 + : 5, + ), + ), + child: Text( + 'Active', + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 13, + fontWeight: + FontWeight.w500, + color: + Color(0xFF593AFF), + ), + ), + ), + ), + ) + : Text( + 'Active', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 13, + fontWeight: FontWeight.w400, + color: Color(0xFF636363), + ), + ), + ), + )), + Expanded( + flex: 6, + child: Container( + alignment: Alignment.center, + child: GestureDetector( + onTap: () { + setState(() { + isActive = false; + policyList.clear(); + }); + getActiveAndInactivePolicyDetails( + 'Inactive'); + }, + child: !isActive + ? Material( + elevation: 5, + borderRadius: + BorderRadius.circular(10), + color: Colors.white, + child: SizedBox( + width: Responsive.isDesktop( + context) + ? 400 + : 150, // Set the width here + child: TextButton( + onPressed: () {}, + style: + TextButton.styleFrom( + padding: EdgeInsets + .symmetric( + vertical: Responsive + .isDesktop( + context) + ? 12 + : 5, + ), + ), + child: Text( + 'Inactive', + style: + GoogleFonts.poppins( + fontSize: Responsive + .isDesktop( + context) + ? 18 + : 13, + fontWeight: + FontWeight.w500, + color: + Color(0xFF593AFF), + ), + ), + ), + ), + ) + : Text( + 'Inactive', + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 18 + : 13, + fontWeight: FontWeight.w400, + color: Color(0xFF636363), + ), + ), + ), + )) + ], + ) + ], + ))), + ], + ), + ), + SizedBox(height: 15), + if (policyList != null && policyList.length > 0) + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ...generateCards(policyList), + ], + ), + SizedBox(height: Responsive.isDesktop(context) ? 40 : 70), + ]), + )), // Positioned( // bottom: 25, // right: 15, @@ -798,10 +811,10 @@ class _HomeState extends State { color: Color(0x98FFFCE5), // Semi-transparent background child: Center( child: // Your GIF loader widget - Image.asset( - height: 60, - width: 60, - 'assets/nhance-loader.gif'), // Adjust path to your GIF loader + Image.asset( + height: 60, + width: 60, + 'assets/nhance-loader.gif'), // Adjust path to your GIF loader ), ), if (Responsive.isDesktop(context)) @@ -827,17 +840,17 @@ class _HomeState extends State { // ), // ) - Navigator.push( + Navigator.push( context, // MaterialPageRoute(builder: (context) => const BotmanChatPage()), - MaterialPageRoute(builder: (context) => ChatbotWebViewPage( - client_branch_id: client_branch_id, - empCodeString: empCodeString, - empName:empName, - empPrimaryId:empPrimaryId, - client_id:client_id, - ) - ), + MaterialPageRoute( + builder: (context) => ChatbotWebViewPage( + client_branch_id: client_branch_id, + empCodeString: empCodeString, + empName: empName, + empPrimaryId: empPrimaryId, + client_id: client_id, + )), ) }, child: Icon(Icons.chat), @@ -848,31 +861,31 @@ class _HomeState extends State { bottomNavigationBar: Responsive.isDesktop(context) ? null : CustomBottomNavigationBar( - onTabChanged: (index) { - // Add your navigation logic here - // repositionBotman(); - if (index == 0) { - Navigator.pushNamed(context, 'home'); - } else if (index == 1) { - Navigator.pushNamed(context, 'claims'); - } else if (index == 2) { - Navigator.pushNamed(context, 'profile'); - } else if (index == 3) { - Navigator.pushNamed(context, 'help'); - } else if (index == 4) { - Navigator.pushNamed(context, 'wellness'); - } - }, - icons: [ - Icons.home_outlined, - Icons.sticky_note_2_outlined, - Icons.person_outline_outlined, - Icons.headset_mic_outlined, - Icons.health_and_safety_outlined, - ], - labels: ["Home", "Claim", "Profile", "Help", "Wellness"], - initialIndex: 0, // Initial index of the bottom navigation bar - ), + onTabChanged: (index) { + // Add your navigation logic here + // repositionBotman(); + if (index == 0) { + Navigator.pushNamed(context, 'home'); + } else if (index == 1) { + Navigator.pushNamed(context, 'claims'); + } else if (index == 2) { + Navigator.pushNamed(context, 'profile'); + } else if (index == 3) { + Navigator.pushNamed(context, 'help'); + } else if (index == 4) { + Navigator.pushNamed(context, 'wellness'); + } + }, + icons: [ + Icons.home_outlined, + Icons.sticky_note_2_outlined, + Icons.person_outline_outlined, + Icons.headset_mic_outlined, + Icons.health_and_safety_outlined, + ], + labels: ["Home", "Claim", "Profile", "Help", "Wellness"], + initialIndex: 0, // Initial index of the bottom navigation bar + ), ); } @@ -921,7 +934,7 @@ class _HomeState extends State { elevation: 5, shape: RoundedRectangleBorder( borderRadius: - BorderRadius.circular(15.0), // Set border radius here + BorderRadius.circular(15.0), // Set border radius here ), child: Container( decoration: BoxDecoration( @@ -931,12 +944,12 @@ class _HomeState extends State { ), padding: Responsive.isDesktop(context) ? EdgeInsets.only( - top: 15, bottom: 15, left: 15, right: 15) + top: 15, bottom: 15, left: 15, right: 15) : EdgeInsets.only( - top: 10, - bottom: 10, - left: 10, - right: 10), // Add padding to the container + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container child: Row( children: [ Expanded( @@ -946,7 +959,7 @@ class _HomeState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Row( children: [ @@ -954,17 +967,17 @@ class _HomeState extends State { flex: 7, child: Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( policyHeading ?? '', textAlign: TextAlign.left, style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop( - context) - ? 10 - : 10, + Responsive.isDesktop( + context) + ? 10 + : 10, fontWeight: FontWeight.w400, color: Color(0xFF785EFF), ), @@ -976,17 +989,17 @@ class _HomeState extends State { flex: 5, child: Column( crossAxisAlignment: - CrossAxisAlignment.end, + CrossAxisAlignment.end, children: [ Text( 'Expires on $formattedDate', textAlign: TextAlign.right, style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop( - context) - ? 10 - : 10, + Responsive.isDesktop( + context) + ? 10 + : 10, fontWeight: FontWeight.w400, color: Color(0xFF747474), ), @@ -1003,17 +1016,17 @@ class _HomeState extends State { flex: 6, child: Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( policyName ?? '', textAlign: TextAlign.left, style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop( - context) - ? 14 - : 13, + Responsive.isDesktop( + context) + ? 14 + : 13, fontWeight: FontWeight.w500, color: Color(0xFF000000), ), @@ -1025,7 +1038,7 @@ class _HomeState extends State { flex: 5, child: Column( crossAxisAlignment: - CrossAxisAlignment.end, + CrossAxisAlignment.end, children: [ Text( formatToCroresLakhsAndThousands( @@ -1033,10 +1046,10 @@ class _HomeState extends State { textAlign: TextAlign.left, style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop( - context) - ? 14 - : 13, + Responsive.isDesktop( + context) + ? 14 + : 13, fontWeight: FontWeight.w500, color: Color(0xFF000000), ), @@ -1048,13 +1061,13 @@ class _HomeState extends State { flex: 1, child: Container( alignment: - Alignment.centerRight, + Alignment.centerRight, child: Icon( Icons.chevron_right, color: Color( 0xFFE26728), // Replace with your desired icon size: Responsive.isDesktop( - context) + context) ? 30 : 26, ), @@ -1068,17 +1081,17 @@ class _HomeState extends State { flex: 12, child: Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( memberNames ?? '', textAlign: TextAlign.left, style: GoogleFonts.poppins( fontSize: - Responsive.isDesktop( - context) - ? 14 - : 13, + Responsive.isDesktop( + context) + ? 14 + : 13, fontWeight: FontWeight.w400, color: Color(0xFF000000), ), @@ -1109,4 +1122,4 @@ class _HomeState extends State { ), ); } - } +} \ No newline at end of file diff --git a/lib/pages/postEnrollment/tickets.dart b/lib/pages/postEnrollment/tickets.dart new file mode 100644 index 0000000..07d5d5f --- /dev/null +++ b/lib/pages/postEnrollment/tickets.dart @@ -0,0 +1,644 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:intl/intl.dart'; +import 'package:jwt_decode/jwt_decode.dart'; +import 'package:nhance_app_pwa/customAppBar/customAppBar.dart'; +import 'package:nhance_app_pwa/pages/postEnrollment/claimtracklist.dart'; +import 'package:nhance_app_pwa/pages/postEnrollment/service/api_service.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../customAppBar/customFooter.dart'; +import '../../customAppBar/responsive.dart'; +import '../../customAppBar/tabs.dart'; +import '../../customAppBar/toastHelper.dart'; +import 'package:http/http.dart' as http; + +class tickets extends StatefulWidget { + const tickets({Key? key}) : super(key: key); + + @override + State createState() => _ticketsState(); +} + +class _ticketsState extends State { + late ApiService apiService; + bool isLoading = false; + dynamic _token; + dynamic empCodeString; + dynamic empPrimaryId; + dynamic client_id; + List> policyList = []; + dynamic policyDataIsEmpty = 1; + int? fromClaimsPage; + dynamic decodedToken; + List> departmentList = []; + List> policyNumberList = []; + dynamic serviceId; + dynamic policyNumberId; + String? selectedMemberName; + String? selectedServiceName; + String? selectedPolicyNo; + dynamic client_branch_id; + dynamic mobileNo; + dynamic policyTypeCondition; + dynamic client_policy_id; + dynamic selfDetails; + List> employeePolicyList = []; + + // Declare subjectController and bodyController as instance variables + late TextEditingController subjectController; + late TextEditingController messageController; + + final List> serviceList = [ + {"id": 1, "name": "Sales"}, + {"id": 2, "name": "Service"}, + ]; + + List> filteredPoliciesList = []; + + // Create a unique form key for each accordion section + final GlobalKey formKey = GlobalKey(); + + bool isServiceValid = true; + bool isPolicyValid = true; + bool isSubjectValid = true; + + + + @override + void initState() { + super.initState(); + subjectController = TextEditingController(); + messageController = TextEditingController(); + apiService = ApiService(context); // Initialize ApiService here + _loadToken(); + } + + @override + void dispose() { + // Dispose the controllers to avoid memory leaks + subjectController.dispose(); + messageController.dispose(); + super.dispose(); + } + + + + + Future _loadToken() async { + print('_loadToken'); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? token = prefs.getString('_postToken'); + if (token != null && token.isNotEmpty) { + setState(() { + _token = token; + }); + // Decode the JWT token received from the API response + decodedToken = Jwt.parseJwt(token); + print(decodedToken); + mobileNo = decodedToken['mobile']; + client_branch_id = decodedToken['client_branch_id']; + empCodeString = prefs.getString('empCode'); + print(empCodeString); // Check if emp_code is correct + empPrimaryId = prefs.getString('empPrimaryId'); + client_id = prefs.getString('client_id'); + print(client_id); + getActiveAndInactivePolicyDetails(); + getSelfEmployeeProfile(); + } else { + // Token is empty or null, handle accordingly (e.g., navigate to login screen) + ToastHelper.showErrorToast(context, 'Session Out'); + Navigator.pushReplacementNamed(context, 'login'); + } + } + + Future getActiveAndInactivePolicyDetails() async { + if (client_id == null || empCodeString == null) { + return; + } + + try { + // Call both APIs + final responseActive = await apiService.getActiveAndInactivePolicyDetails( + client_id!, empCodeString!, 'Active', client_branch_id,mobileNo + ); + + final responseInactive = await apiService.getActiveAndInactivePolicyDetails( + client_id!, empCodeString!, 'Inactive', client_branch_id,mobileNo + ); + + final bool isActiveSuccess = responseActive['status'] == 'success' && responseActive['data'] != null; + final bool isInactiveSuccess = responseInactive['status'] == 'success' && responseInactive['data'] != null; + + final List> activeData = isActiveSuccess + ? List>.from(responseActive['data']) + : []; + + final List> inactiveData = isInactiveSuccess + ? List>.from(responseInactive['data']) + : []; + + final combinedPolicies = [...activeData, ...inactiveData]; + + setState(() { + policyList = combinedPolicies; + policyDataIsEmpty = combinedPolicies.isEmpty ? 0 : 1; + }); + + print("Merged policyList: $policyList"); + } catch (e) { + print('Error occurred while fetching policies: $e'); + setState(() { + policyDataIsEmpty = 0; + }); + } + } + + Future getSelfEmployeeProfile() async { + print(getSelfEmployeeProfile); + if (client_id == null || empCodeString == null) { + return; + } + print('check 1'); + final response = await apiService.getSelfEmployeeProfileDetails( + client_id!, empCodeString!, client_branch_id!); + print('check 1'); + if (response['status'] == 'success') { + if (response.containsKey('data')) { + setState(() { + selfDetails = response['data']; + print(selfDetails); + }); + } else { + // Handle other status messages if needed + // ToastHelper.showErrorToast( + // context, 'API request failed with status: ${data['status']}'); + print('API request failed with status: ${response['status']}'); + } + } else { + print('API request failed with status: ${response['status']}'); + } + } + + Future sendFormDataToApi() async { + setState(() { + isServiceValid = serviceId != null; + isPolicyValid = policyNumberId != null; + isSubjectValid = subjectController.text.trim().isNotEmpty; + }); + + if (isServiceValid && + isPolicyValid && + isSubjectValid) { + // Proceed to submit + } else { + ToastHelper.showErrorToast(context, 'Please Fill Required Fields'); + return; + } + + setState(() { + isLoading = true; + }); + + final SharedPreferences prefs = await SharedPreferences.getInstance(); + final String? emp_id = prefs.getString('empPrimaryId'); + // print('Check One'); + // print(employeePolicyList[0]['name']); + // print('Help $filteredPoliciesList'); + try { + print('Check One'); + Map formData = { + // 'opener': 'user', + 'emp_id': emp_id, + 'client_policy_id': client_policy_id, + 'ticket_type_id': serviceId, + 'subject': subjectController.text, + 'message': messageController.text, + // 'policy_id': fromClaimsPage == 0 + // ? claimsDetails['client_policy_id'] + // : policyNumberId, + 'emp_code': + decodedToken['emp_code'] != null ? decodedToken['emp_code'] : '', + 'mobile_number': + decodedToken['mobile'] != null ? decodedToken['mobile'] : '', + 'email': decodedToken['email_corporate'] != null + ? decodedToken['email_corporate'] + : '', + 'fullname': decodedToken['name'] != null ? decodedToken['name'] : '', + 'client_id': selfDetails['client_id'], + 'relationship': selfDetails['relationship'], + 'gender': selfDetails['gender'], + + }; + + + if (policyTypeCondition == 1) { + formData['policyholder_name'] = employeePolicyList[0]['name']; + formData['member_name'] = selectedMemberName; + } else { + + formData['policyholder_name'] = employeePolicyList[0]['name']; + formData['member_name'] = selectedMemberName; + } + + // Convert integer values to strings + formData = formData.map((key, value) => MapEntry(key, value.toString())); + + final response = await apiService.sendFormDataToApi(formData); + + if (response['status'] == true) { + ToastHelper.showSuccessToast(context, response['message']); + serviceId = null; + departmentList.clear(); + setState(() { + isLoading = false; + }); + Navigator.pushNamed(context, 'claims'); + print('Form data submitted successfully'); + } else { + print('Failed to submit form data: ${response['status']}'); + } + } catch (e) { + print('Error submitting form data: $e'); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: CustomAppBar(), + body: Stack(children: [ + SingleChildScrollView( + child: Container( + padding: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.2, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0.05, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(10), + color: Colors.white, + child: Column(children: [ + Card( + elevation: 5, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(15.0), // Set border radius here + ), + child: Container( + decoration: BoxDecoration( + color: Colors.white, // Set background color to white + borderRadius: BorderRadius.circular( + 15.0), // Set border radius for Container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), // Add padding to the container + child: Row( + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Color( + 0xFFFFFCE5), // Set background color for the container + borderRadius: BorderRadius.circular( + 10), // Set border radius for the container + ), + padding: Responsive.isDesktop(context) + ? EdgeInsets.only( + top: 20, + bottom: 20, + left: 0, + right: 0) + : EdgeInsets.only( + top: 10, + bottom: 10, + left: 10, + right: 10), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + Navigator.pushNamed( + context,'help'); + }, + child: Icon( + Icons + .chevron_left, // Replace with your desired icon + color: Color(0xFF000000), + size: 30, + ), + ), + ), + Expanded( + flex: 11, + child: Row( + mainAxisAlignment: + Responsive.isDesktop(context) + ? MainAxisAlignment.center + : MainAxisAlignment.start, + children: [ + Text('Raise a Ticket', + textAlign: TextAlign.start, + style: GoogleFonts.poppins( + fontSize: + Responsive.isDesktop( + context) + ? 20 + : 16, + fontWeight: FontWeight.w600, + color: Color(0xFF000000), + ), + ) + ], + ), + ) + ], + ), // Space between rows + // Add more rows as needed + ], + ), + ), + SizedBox(height: 15), + Container( + child: Column( + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + alignment: Alignment.centerLeft, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Form( + key: formKey, + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + buildDropdownField( + 'Service', + (value) { + setState(() { + serviceId = value; + selectedServiceName = serviceList.firstWhere( + (serList) => serList['id'] == value, + orElse: () => {'name': ''}, + )['name']; + isServiceValid = true; + }); + }, + false, + serviceList, + 'name', + serviceId, + valueKey: 'id', + ), + ], + ), + SizedBox(height: 15), + if (selectedServiceName == "Service") + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + buildDropdownField( + 'Policy Number', + (value) { + setState(() { + policyNumberId = value; + isPolicyValid = true; + }); + }, + false, + policyList, + 'policy_no', + policyNumberId, + valueKey: 'policy_no', + ), + if (!isPolicyValid) + Text('Please select a policy', + style: TextStyle(color: Colors.red)), + ], + ), + + SizedBox(height: 15), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildTextField('Subject', + subjectController), + if (!isSubjectValid) + Text('Please enter the Subject', style: TextStyle(color: Colors.red)), + SizedBox(height: 15), + buildTextAreaField( + 'Message', + messageController), + ] + ), + ], + ), + ), + ], + ), + ), + ], + ), + SizedBox(height: 15), + Row( + children: [ + Expanded( + flex: 12, + child: Container( + alignment: Alignment.centerRight, + child: ElevatedButton( + onPressed: () { + // sendFormDataToApi(); + }, + child: Text( + 'Send', + style: GoogleFonts.poppins( + color: Colors.white), + ), + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFFE26728), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular( + 5), + ), + ), + ), + ), + ), + ], + ), + ], + ), + ), + ], + ))), + ], + ), + ), + ), + SizedBox(height: Responsive.isDesktop(context) ? 40 : 60), + ]), + )), + if (isLoading) + Container( + color: Color(0x98FFFCE5), // Semi-transparent background + child: Center( + child: // Your GIF loader widget + Image.asset( + height: 60, + width: 60, + 'assets/nhance-loader.gif'), // Adjust path to your GIF loader + ), + ), + if (Responsive.isDesktop(context)) + Align( + alignment: Alignment.bottomCenter, + child: Container( + width: double.infinity, // Make the footer full width + child: CustomFooter(), + ), + ), + ]), + // floatingActionButton: Responsive.isDesktop(context) + // ? null + // : FloatingActionButton( + // onPressed: () { + // Navigator.pushNamed(context, 'chatbot'); + // }, + // child: Icon(Icons.chat), + // ), + floatingActionButtonLocation: Responsive.isDesktop(context) + ? null + : FloatingActionButtonLocation.miniEndFloat, + bottomNavigationBar: Responsive.isDesktop(context) + ? null + : CustomBottomNavigationBar( + onTabChanged: (index) { + // repositionBotman(); + if (index == 0) { + Navigator.pushNamed(context, 'home'); + } else if (index == 1) { + Navigator.pushNamed(context, 'claims'); + } else if (index == 2) { + Navigator.pushNamed(context, 'profile'); + } else if (index == 3) { + Navigator.pushNamed(context, 'help'); + // Navigator.pushNamed(context, 'help'); + } else if (index == 4) { + Navigator.pushNamed(context, 'wellness'); + } + }, + icons: [ + Icons.home_outlined, + Icons.sticky_note_2_outlined, + Icons.person_outline_outlined, + Icons.headset_mic_outlined, + Icons.health_and_safety_outlined, + ], + labels: [ + "Home", + "Claim", + "Profile", + "Help", + "Wellness", + ], // Initial index of the bottom navigation bar + ), + ); + } + + Widget buildTextField(String label, TextEditingController controller, + [TextInputType keyboardType = TextInputType.text]) { + return TextFormField( + controller: controller, + decoration: InputDecoration(labelText: label), + keyboardType: keyboardType, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter the $label'; + } + return null; + }, + ); + } + + Widget buildTextAreaField(String label, TextEditingController controller) { + return TextFormField( + controller: controller, + decoration: InputDecoration(labelText: label), + maxLines: 5, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter the $label'; + } + return null; + }, + ); + } + + + Widget buildDropdownField( + String label, + void Function(T?) onChanged, + bool readOnly, + List> itemsList, + String displayField, + T? selectedValue, { + String valueKey = 'id', + }) { + return DropdownButtonFormField( + value: selectedValue, + decoration: InputDecoration(labelText: label), + items: itemsList.map>((item) { + return DropdownMenuItem( + value: item[valueKey] as T, // ✅ cast to generic type + child: Text(item[displayField].toString()), // always display as String + ); + }).toList(), + onChanged: readOnly ? null : onChanged, + validator: (value) { + if (value == null) { + return 'Please select a $label'; + } + return null; + }, + ); + } + +} diff --git a/lib/pages/verify.dart b/lib/pages/verify.dart index 7eb1216..6be83eb 100755 --- a/lib/pages/verify.dart +++ b/lib/pages/verify.dart @@ -18,10 +18,13 @@ import '../customAppBar/responsive.dart'; import '../customAppBar/toastHelper.dart'; import '../models/environment.dart'; import '../models/platform_helper_mobile.dart' - if (dart.library.html) '../models/platform_helper_other.dart'; +if (dart.library.html) '../models/platform_helper_other.dart'; // import 'dart:html' as html; +import '../pages/helpers/html_stub.dart' +if (dart.library.html) '../pages/helpers/html_web.dart'; + class MyVerify extends StatefulWidget { final String verificationId; final String mobileNumber; @@ -114,16 +117,12 @@ class _MyVerifyState extends State { super.dispose(); } - - Future initNotification() async { - try { // await _firebaseMessaging.requestPermission(); fCMToken = await FirebaseMessaging.instance.getToken(); print('Token : $fCMToken'); - if (fCMToken != null) { await sendDeviceToken(fCMToken); @@ -294,6 +293,24 @@ class _MyVerifyState extends State { } } + void loginUser({ + required String gpaEmpName, + required String empPrimaryId, + required String empCodeString, + required String client_id, + required String empClientBranchId, + }) { + HtmlHelper.saveLoginData({ + 'gpaEmpName': gpaEmpName, + 'empPrimaryId': empPrimaryId, + 'empCode': empCodeString, + 'client_id': client_id, + 'empClientBranchId': empClientBranchId, + }); + + print('Successfully Login'); + } + void postSuccessData(post, data) async { String status = data['status']; String postStatus = post['status']; @@ -319,7 +336,15 @@ class _MyVerifyState extends State { prefs.setString('emp_status', emp_status); // getClientLogoAndDetails(); - // if(kIsWeb) { + loginUser( + gpaEmpName: gpaEmpName, + empPrimaryId: empPrimaryId, + empCodeString: empCodeString, + client_id: client_id, + empClientBranchId: empClientBranchId, + ); + + // if (kIsWeb) { // html.window.localStorage['gpaEmpName'] = gpaEmpName; // html.window.localStorage['empPrimaryId'] = empPrimaryId; // html.window.localStorage['empCode'] = empCodeString; @@ -454,7 +479,8 @@ class _MyVerifyState extends State { print('credential $credential'); - final userCredential = await FirebaseAuth.instance.signInWithCredential(credential); + final userCredential = + await FirebaseAuth.instance.signInWithCredential(credential); // await FirebaseAuth.instance.signInWithCredential(credential); print('otp firebase check'); @@ -485,7 +511,8 @@ class _MyVerifyState extends State { duration: Duration(seconds: 2), ), ); - ToastHelper.showErrorToast(context, 'OTP expired. Please request a new one.'); + ToastHelper.showErrorToast( + context, 'OTP expired. Please request a new one.'); } else if (e.code == 'invalid-verification-code') { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -493,7 +520,8 @@ class _MyVerifyState extends State { duration: Duration(seconds: 2), ), ); - ToastHelper.showErrorToast(context, 'Invalid OTP entered. Please try again.'); + ToastHelper.showErrorToast( + context, 'Invalid OTP entered. Please try again.'); } else if (e.code == 'session-expired') { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -501,7 +529,8 @@ class _MyVerifyState extends State { duration: Duration(seconds: 2), ), ); - ToastHelper.showErrorToast(context, 'Session expired. Try restarting the verification.'); + ToastHelper.showErrorToast( + context, 'Session expired. Try restarting the verification.'); } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -516,11 +545,11 @@ class _MyVerifyState extends State { // _isLoading = false; // }); print('Error: $e'); - ToastHelper.showErrorToast(context, 'Failed to verify OTP. Please try again.'); + ToastHelper.showErrorToast( + context, 'Failed to verify OTP. Please try again.'); } } - void _resendOTP() { setState(() { _secondsRemaining = 60; @@ -530,20 +559,19 @@ class _MyVerifyState extends State { widget.onResendCode(widget.mobileNumber, widget.resendToken); } - Future checkLoginPin(BuildContext context) async { print('checkLoginPin'); try { final SharedPreferences prefs = await SharedPreferences.getInstance(); empMobileNo = prefs.getString('empMobileNo'); empEmailid = prefs.getString('empEmailid'); - print('empMobileNo $empMobileNo' ); + print('empMobileNo $empMobileNo'); print('empEmailid $empEmailid'); // _token = prefs.getString('token'); var params = {}; if (empMobileNo != null && empMobileNo.isNotEmpty) { params = {'mobile_number': empMobileNo}; - } else if(empEmailid != null && empEmailid.isNotEmpty){ + } else if (empEmailid != null && empEmailid.isNotEmpty) { params = {'email_id': empEmailid}; } @@ -569,14 +597,16 @@ class _MyVerifyState extends State { } if (data['is_biometric_enabled'] != null) { - prefs.setString('is_biometric_enabled', data['is_biometric_enabled']); + prefs.setString( + 'is_biometric_enabled', data['is_biometric_enabled']); } if (data['is_mpin_skipped'] != null) { prefs.setString('is_mpin_skipped', data['is_mpin_skipped']); } - if (data['is_mpin_skipped'] != null && data['is_mpin_skipped'] == '0') { + if (data['is_mpin_skipped'] != null && + data['is_mpin_skipped'] == '0') { Navigator.pushReplacementNamed(context, 'pinPage'); } else { if (_postToken != null && _postToken.isNotEmpty) { @@ -609,7 +639,7 @@ class _MyVerifyState extends State { url, headers: { 'Authorization': - 'Bearer $_token', // Add token to the Authorization header + 'Bearer $_token', // Add token to the Authorization header }, ); if (response.statusCode == 200) { @@ -711,484 +741,484 @@ class _MyVerifyState extends State { }, child: Scaffold( body: SingleChildScrollView( - keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, - child: Container( - height: _size.height, - color: Colors.white, - child: Stack( - children: [ - Visibility( - visible: _size.width <= 1100, - child: ClipRRect( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(30), - bottomRight: Radius.circular(30), - ), - child: Container( - height: _size.height / 3, - width: double.infinity, - color: Color(0xFFFFFCE5), - child: Stack( - children: [ - Column( + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + child: Container( + height: _size.height, + color: Colors.white, + child: Stack( + children: [ + Visibility( + visible: _size.width <= 1100, + child: ClipRRect( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(30), + bottomRight: Radius.circular(30), + ), + child: Container( + height: _size.height / 3, + width: double.infinity, + color: Color(0xFFFFFCE5), + child: Stack( children: [ - SizedBox( - height: _size.height / - 6.4), // Adjust the spacing between the rows - Row( - mainAxisAlignment: MainAxisAlignment - .center, // Align to the center + Column( children: [ - Expanded( - flex: Responsive.isDesktop(context) - ? 10 - : 12, - child: Align( - alignment: Responsive.isDesktop(context) - ? Alignment.centerLeft - : Alignment.bottomCenter, - child: Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - ), - ), - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Expanded( - flex: 2, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - // Add your navigation logic here - // For example, you can use Navigator.push to navigate to another page - Navigator.pushNamed( - context, 'hrLogin'); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align to the end (right) - children: [ - Text( - 'HR Login', - style: GoogleFonts.poppins( - color: Color( - 0xFF000000), // Text color - // Add other text styles as needed - ), - ), - SizedBox(width: 5), - Icon( - Icons - .east, // Icon for customer login - color: Colors - .black, // Adjust color as needed - ), - ], + SizedBox( + height: _size.height / + 6.4), // Adjust the spacing between the rows + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align to the center + children: [ + Expanded( + flex: Responsive.isDesktop(context) + ? 10 + : 12, + child: Align( + alignment: Responsive.isDesktop(context) + ? Alignment.centerLeft + : Alignment.bottomCenter, + child: Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, ), ), ), - ), + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Expanded( + flex: 2, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + // Add your navigation logic here + // For example, you can use Navigator.push to navigate to another page + Navigator.pushNamed( + context, 'hrLogin'); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align to the end (right) + children: [ + Text( + 'HR Login', + style: GoogleFonts.poppins( + color: Color( + 0xFF000000), // Text color + // Add other text styles as needed + ), + ), + SizedBox(width: 5), + Icon( + Icons + .east, // Icon for customer login + color: Colors + .black, // Adjust color as needed + ), + ], + ), + ), + ), + ), + ], + ), ], ), ], ), - ], + ), ), ), - ), - ), - Container( - margin: marginInsets, - alignment: Alignment.bottomCenter, - child: SingleChildScrollView( - child: Form( - key: _formKey, - child: Column( - children: [ - Row( + Container( + margin: marginInsets, + alignment: Alignment.bottomCenter, + child: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( children: [ - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: Container( - margin: _size.width > 1100 - ? EdgeInsets.only(left: 20, right: 20) - : EdgeInsets.only(left: 0, right: 0), - child: Column( - mainAxisAlignment: + Row( + children: [ + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: Container( + margin: _size.width > 1100 + ? EdgeInsets.only(left: 20, right: 20) + : EdgeInsets.only(left: 0, right: 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (!Responsive.isMobile(context) && - !Responsive.isTablet(context)) - Row( - children: [ - Expanded( - flex: 10, - child: Align( - alignment: Responsive + children: [ + if (!Responsive.isMobile(context) && + !Responsive.isTablet(context)) + Row( + children: [ + Expanded( + flex: 10, + child: Align( + alignment: Responsive .isDesktop(context) - ? Alignment.centerLeft - : Alignment + ? Alignment.centerLeft + : Alignment .bottomCenter, // Align to the start - child: _size.width <= 1100 - ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) - : _size.width > 1100 + child: _size.width <= 1100 ? Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ) + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) + : _size.width > 1100 + ? Image.asset( + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ) : Image.asset( - 'assets/nhance_app_logo.png', - width: 150, - height: 150, - ), - )), - ], - ), - SizedBox(height: 10), - // SizedBox( - // height: Responsive.isDesktop(context) - // ? _size.height * 0.1 - // : 10, - // ), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - "Welcome to Nhance", - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.bold, - ), + 'assets/nhance_app_logo.png', + width: 150, + height: 150, + ), + )), + ], ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( + SizedBox(height: 10), + // SizedBox( + // height: Responsive.isDesktop(context) + // ? _size.height * 0.1 + // : 10, + // ), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( horizontal: 150) - : EdgeInsets.symmetric( + : EdgeInsets.symmetric( horizontal: 0), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + "Welcome to Nhance", + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: "Please enter the one-time usage code sent to your mobile number $mobileNumber", - style: TextStyle( - fontSize: 12, - height: 1.5, - color: Color(0xFF000000)), - children: [ - TextSpan( - text: " (Change Number)", style: TextStyle( fontSize: 12, - color: Color( - 0xFFE26728)), // Change color as desired - recognizer: + height: 1.5, + color: Color(0xFF000000)), + children: [ + TextSpan( + text: " (Change Number)", + style: TextStyle( + fontSize: 12, + color: Color( + 0xFFE26728)), // Change color as desired + recognizer: TapGestureRecognizer() ..onTap = () { // Navigate to the page where the user can change the phone number Navigator.pushNamed( context, 'login'); }, - ), - ], - ), - ), - ), - SizedBox(height: 15), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Pinput( - length: 6, - // defaultPinTheme: defaultPinTheme, - // focusedPinTheme: focusedPinTheme, - // submittedPinTheme: submittedPinTheme, - showCursor: true, - controller: _otpController, - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: Row( - mainAxisAlignment: MainAxisAlignment - .end, // Align text to the right - children: [ - _isTimerRunning - ? Text( - "Resend OTP in $_secondsRemaining seconds", - style: - GoogleFonts.poppins( - color: - Colors.black), - ) - : InkWell( - onTap: () { - _resendOTP(); - }, - child: Text( - "Resend OTP", - style: - GoogleFonts.poppins( - color: Colors - .blue), - ), ), - ], - ), - ), - SizedBox(height: 10), - Container( - margin: Responsive.isDesktop(context) - ? EdgeInsets.symmetric( - horizontal: 150) - : EdgeInsets.symmetric( - horizontal: 0), - child: SizedBox( - width: double.infinity, - height: 45, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: - Color(0xFF00989E), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(10), + ], ), ), - onPressed: () { - if (_formKey.currentState! - .validate()) { - _formKey.currentState! - .save(); // Save form fields before calling verifyOTP - verifyOTP( - _otpController.text); - } - }, - child: Text( - "Submit", - style: GoogleFonts.poppins( - color: Color(0xFFFFFFFF)), + ), + SizedBox(height: 15), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: Pinput( + length: 6, + // defaultPinTheme: defaultPinTheme, + // focusedPinTheme: focusedPinTheme, + // submittedPinTheme: submittedPinTheme, + showCursor: true, + controller: _otpController, ), ), - ), - ), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Column( - // children: [ - // SizedBox(height: 20), - // Text( - // "Benefits of Login", - // style: - // GoogleFonts.poppins( - // fontSize: 20, - // fontWeight: - // FontWeight.bold, - // ), - // ), - // SizedBox(height: 15), - // ], - // )) - // : SizedBox(), - // _size.width > 1100 - // ? Container( - // margin: EdgeInsets.symmetric( - // horizontal: 150), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.center, - // children: [ - // Expanded( - // flex: 6, - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: 8), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment - // .center, - // children: [ - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // decoration: - // BoxDecoration( - // border: - // Border( - // right: - // BorderSide( - // width: 1, - // color: Colors - // .black, - // ), - // ), - // ), - // child: Column( - // children: [ - // Icon( - // Icons - // .policy, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "View Policy", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // Expanded( - // child: Container( - // padding: EdgeInsets - // .symmetric( - // vertical: - // 12), - // child: Column( - // children: [ - // Icon( - // Icons - // .edit, - // color: Color( - // 0xFFE26728)), - // SizedBox( - // height: - // 10), - // Text( - // "Manage Claims", - // style: GoogleFonts - // .poppins()), - // ], - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ) - // : SizedBox( - // height: Responsive.isDesktop( - // context) - // ? _size.height * 0.1 - // : _size.height * 0.2, - // ), - SizedBox( - height: Responsive.isDesktop(context) - ? _size.height * 0.3 - : _size.height * 0.2, - ), - // SizedBox( - // height: _size.height * 0.1, - // ), - Container( - alignment: Alignment.bottomCenter, - padding: - EdgeInsets.symmetric(vertical: 8), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: - 'By continuing, you agree with our ', - style: GoogleFonts.poppins( - color: Colors.black, - fontSize: 9, + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: Row( + mainAxisAlignment: MainAxisAlignment + .end, // Align text to the right + children: [ + _isTimerRunning + ? Text( + "Resend OTP in $_secondsRemaining seconds", + style: + GoogleFonts.poppins( + color: + Colors.black), + ) + : InkWell( + onTap: () { + _resendOTP(); + }, + child: Text( + "Resend OTP", + style: + GoogleFonts.poppins( + color: Colors + .blue), + ), + ), + ], ), - children: [ - TextSpan( - text: 'privacy policy ', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, + ), + SizedBox(height: 10), + Container( + margin: Responsive.isDesktop(context) + ? EdgeInsets.symmetric( + horizontal: 150) + : EdgeInsets.symmetric( + horizontal: 0), + child: SizedBox( + width: double.infinity, + height: 45, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: + Color(0xFF00989E), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10), + ), + ), + onPressed: () { + if (_formKey.currentState! + .validate()) { + _formKey.currentState! + .save(); // Save form fields before calling verifyOTP + verifyOTP( + _otpController.text); + } + }, + child: Text( + "Submit", + style: GoogleFonts.poppins( + color: Color(0xFFFFFFFF)), ), ), - TextSpan( - text: 'and ', + ), + ), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Column( + // children: [ + // SizedBox(height: 20), + // Text( + // "Benefits of Login", + // style: + // GoogleFonts.poppins( + // fontSize: 20, + // fontWeight: + // FontWeight.bold, + // ), + // ), + // SizedBox(height: 15), + // ], + // )) + // : SizedBox(), + // _size.width > 1100 + // ? Container( + // margin: EdgeInsets.symmetric( + // horizontal: 150), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment.center, + // children: [ + // Expanded( + // flex: 6, + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: 8), + // child: Row( + // mainAxisAlignment: + // MainAxisAlignment + // .center, + // children: [ + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // decoration: + // BoxDecoration( + // border: + // Border( + // right: + // BorderSide( + // width: 1, + // color: Colors + // .black, + // ), + // ), + // ), + // child: Column( + // children: [ + // Icon( + // Icons + // .policy, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "View Policy", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // Expanded( + // child: Container( + // padding: EdgeInsets + // .symmetric( + // vertical: + // 12), + // child: Column( + // children: [ + // Icon( + // Icons + // .edit, + // color: Color( + // 0xFFE26728)), + // SizedBox( + // height: + // 10), + // Text( + // "Manage Claims", + // style: GoogleFonts + // .poppins()), + // ], + // ), + // ), + // ), + // ], + // ), + // ), + // ), + // ], + // ), + // ) + // : SizedBox( + // height: Responsive.isDesktop( + // context) + // ? _size.height * 0.1 + // : _size.height * 0.2, + // ), + SizedBox( + height: Responsive.isDesktop(context) + ? _size.height * 0.3 + : _size.height * 0.2, + ), + // SizedBox( + // height: _size.height * 0.1, + // ), + Container( + alignment: Alignment.bottomCenter, + padding: + EdgeInsets.symmetric(vertical: 8), + child: RichText( + textAlign: TextAlign.center, + text: TextSpan( + text: + 'By continuing, you agree with our ', style: GoogleFonts.poppins( color: Colors.black, fontSize: 9, ), + children: [ + TextSpan( + text: 'privacy policy ', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + TextSpan( + text: 'and ', + style: GoogleFonts.poppins( + color: Colors.black, + fontSize: 9, + ), + ), + TextSpan( + text: 'terms of use', + style: GoogleFonts.poppins( + color: Color(0xFF00989E), + fontSize: 9, + ), + ), + ], ), - TextSpan( - text: 'terms of use', - style: GoogleFonts.poppins( - color: Color(0xFF00989E), - fontSize: 9, - ), - ), - ], + ), ), - ), + ], ), - ], + ), ), - ), + if (_size.width > 1100) + Expanded( + flex: _size.width < 1100 ? 6 : 12, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints constraints) { + if (constraints.maxWidth > 600) { + return Image.asset( + 'assets/login_web.jpg', + height: _size.height, + fit: BoxFit.cover, + ); + } else { + return SizedBox(); + } + }, + ), + ), + ], ), - if (_size.width > 1100) - Expanded( - flex: _size.width < 1100 ? 6 : 12, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints constraints) { - if (constraints.maxWidth > 600) { - return Image.asset( - 'assets/login_web.jpg', - height: _size.height, - fit: BoxFit.cover, - ); - } else { - return SizedBox(); - } - }, - ), - ), ], ), - ], + ), ), ), - ), - ), - ], - )), - ))); + ], + )), + ))); } -} +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index b442869..41bf945 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,8 +16,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -#version: 1.0.22+22 -version: 1.0.10+11 +#version: 1.0.23+23 +version: 1.0.11+12 environment: sdk: '>=3.3.3 <4.0.0' diff --git a/web/assets/chat-bg.jpg b/web/assets/chat-bg.jpg new file mode 100644 index 0000000..56d8070 Binary files /dev/null and b/web/assets/chat-bg.jpg differ diff --git a/web/index.html b/web/index.html index f3a93f8..65e788b 100755 --- a/web/index.html +++ b/web/index.html @@ -22,8 +22,12 @@