mobile view full flow

This commit is contained in:
Venba 2024-04-12 08:15:38 +05:30
parent d78c46be9d
commit 20ae302ab8
18 changed files with 8972 additions and 3642 deletions

BIN
assets/mobileViewLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,64 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:adaptive_navbar/adaptive_navbar.dart'; import 'package:adaptive_navbar/adaptive_navbar.dart';
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
import 'package:nhancepolicy/responsive.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:nhancepolicy/responsive.dart';
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
@override @override
Size get preferredSize => Size.fromHeight(kToolbarHeight); Size get preferredSize => Size.fromHeight(kToolbarHeight);
Future<void> logout(BuildContext context) async {
final prefs = await SharedPreferences.getInstance();
final String? hrtoken = prefs.getString('hrtoken');
final String? token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
if (hrtoken != null && hrtoken.isNotEmpty) {
prefs.remove('token');
Navigator.pushNamed(context, 'hrHome');
} else {
await prefs.clear();
Navigator.pushNamed(context, 'phone');
}
} else if (hrtoken != null && hrtoken.isNotEmpty) {
await prefs.clear();
Navigator.pushNamed(context, 'hrLogin');
}
// Navigator.pushNamed(context, "phone");
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final sw = MediaQuery.of(context).size.width; final sw = MediaQuery.of(context).size.width;
return Scaffold( return Scaffold(
backgroundColor: Color(0xFF00989E), // Set background color for AppBar backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: preferredSize, preferredSize: preferredSize,
child: SafeArea( child: SafeArea(
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 16.0), padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(horizontal: 16.0)
: EdgeInsets.symmetric(horizontal: 0),
child: Row( child: Row(
children: [ children: [
// Logo Column // Logo Column
Expanded( Expanded(
flex: 3, flex: Responsive.isDesktop(context) ? 3 : 9,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: Responsive.isDesktop(context)
.spaceEvenly, // Adjust the alignment as needed ? MainAxisAlignment.spaceEvenly
: MainAxisAlignment
.start, // Adjust the alignment as needed
children: [ children: [
Container( Container(
margin: EdgeInsets.only(top: 10, bottom: 10), margin: EdgeInsets.only(top: 10, bottom: 10),
width: 230, width: 230,
height: 230, height: 230,
child: Image.asset( child: Image.asset(
'assets/Group_3.png', 'assets/nhance_client_logo.png',
fit: BoxFit.contain, // Adjust the fit as needed fit: BoxFit.contain, // Adjust the fit as needed
), ),
), ),
@ -49,26 +77,29 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
), ),
// AdaptiveNavBar Column // AdaptiveNavBar Column
Expanded( Expanded(
flex: 9, flex: Responsive.isDesktop(context) ? 9 : 3,
child: AdaptiveNavBar( child: AdaptiveNavBar(
screenWidth: sw, screenWidth: sw,
backgroundColor: Color(0xFF00989E), backgroundColor: Color(0xFFFFFCE5),
leading: leading:
Container(), // Set an empty container as we have the logo separately Container(), // Set an empty container as we have the logo separately
title: Text(''), title: Text(''),
navBarItems: [ navBarItems: [
if (Responsive.isDesktop(context))
NavBarItem( NavBarItem(
text: "", text: "",
onTap: () { onTap: () {
Navigator.pushNamed(context, "routeName"); Navigator.pushNamed(context, "routeName");
}, },
), ),
if (Responsive.isDesktop(context))
NavBarItem( NavBarItem(
text: "", text: "",
onTap: () { onTap: () {
Navigator.pushNamed(context, "routeName"); Navigator.pushNamed(context, "routeName");
}, },
), ),
if (Responsive.isDesktop(context))
NavBarItem( NavBarItem(
text: "", text: "",
onTap: () { onTap: () {
@ -77,8 +108,14 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
), ),
NavBarItem( NavBarItem(
text: "Logout", text: "Logout",
onTap: () { onTap: () async {
Navigator.pushNamed(context, "phone"); logout(context);
// Clear local storage (SharedPreferences)
// final prefs = await SharedPreferences.getInstance();
// prefs.clear();
// ToastHelper.showSuccessToast(
// context, 'Logout Successfully...');
// Navigator.pushNamed(context, "phone");
}, },
), ),
], ],

View File

@ -1,17 +1,212 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:fluttertoast/fluttertoast.dart'; // import 'package:fluttertoast/fluttertoast.dart';
import 'package:toastification/toastification.dart';
class ToastHelper { class ToastHelper {
static void showSuccessToast(BuildContext context, String message) { static void showSuccessToast(BuildContext context, String message) {
_showToast(context, message, Colors.green); toastification.show(
context: context,
type: ToastificationType.success,
style: ToastificationStyle.flatColored,
autoCloseDuration: const Duration(seconds: 2),
title: Text(message),
// you can also use RichText widget for title and description parameters
// description: RichText(
// text: const TextSpan(text: 'This is a sample toast message. ')),
alignment: Alignment.topRight,
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
icon: const Icon(Icons.check),
primaryColor: Colors.green,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x07000000),
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
closeOnClick: false,
pauseOnHover: true,
dragToClose: true,
applyBlurEffect: true,
callbacks: ToastificationCallbacks(
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
onCloseButtonTap: (toastItem) =>
print('Toast ${toastItem.id} close button tapped'),
onAutoCompleteCompleted: (toastItem) =>
print('Toast ${toastItem.id} auto complete completed'),
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
),
);
} }
static void showWarningToast(BuildContext context, String message) { static void showWarningToast(BuildContext context, String message) {
_showToast(context, message, Colors.orange); toastification.show(
context: context,
type: ToastificationType.warning,
style: ToastificationStyle.flatColored,
autoCloseDuration: const Duration(seconds: 2),
title: Text(message),
// you can also use RichText widget for title and description parameters
// description: RichText(
// text: const TextSpan(text: 'This is a sample toast message. ')),
alignment: Alignment.topRight,
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
icon: const Icon(Icons.warning),
primaryColor: Colors.amberAccent,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x07000000),
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
closeOnClick: false,
pauseOnHover: true,
dragToClose: true,
applyBlurEffect: true,
callbacks: ToastificationCallbacks(
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
onCloseButtonTap: (toastItem) =>
print('Toast ${toastItem.id} close button tapped'),
onAutoCompleteCompleted: (toastItem) =>
print('Toast ${toastItem.id} auto complete completed'),
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
),
);
} }
static void showErrorToast(BuildContext context, String message) { static void showErrorToast(BuildContext context, String message) {
_showToast(context, message, Colors.red); toastification.show(
context: context,
type: ToastificationType.error,
style: ToastificationStyle.flatColored,
autoCloseDuration: const Duration(seconds: 2),
title: Text(message),
// you can also use RichText widget for title and description parameters
// description: RichText(
// text: const TextSpan(text: 'This is a sample toast message. ')),
alignment: Alignment.topRight,
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
icon: const Icon(Icons.error),
primaryColor: Colors.redAccent,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x07000000),
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
closeOnClick: false,
pauseOnHover: true,
dragToClose: true,
applyBlurEffect: true,
callbacks: ToastificationCallbacks(
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
onCloseButtonTap: (toastItem) =>
print('Toast ${toastItem.id} close button tapped'),
onAutoCompleteCompleted: (toastItem) =>
print('Toast ${toastItem.id} auto complete completed'),
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
),
);
// _showToast(context, message, Colors.red);
}
static void showInfoToast(BuildContext context, String message) {
toastification.show(
context: context,
type: ToastificationType.info,
style: ToastificationStyle.flatColored,
autoCloseDuration: const Duration(seconds: 2),
title: Text(message),
// you can also use RichText widget for title and description parameters
// description: RichText(
// text: const TextSpan(text: 'This is a sample toast message. ')),
alignment: Alignment.topRight,
direction: TextDirection.ltr,
animationDuration: const Duration(milliseconds: 100),
animationBuilder: (context, animation, alignment, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
icon: const Icon(Icons.info),
primaryColor: Colors.lightBlue,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x07000000),
blurRadius: 16,
offset: Offset(0, 16),
spreadRadius: 0,
)
],
showProgressBar: true,
closeButtonShowType: CloseButtonShowType.onHover,
closeOnClick: false,
pauseOnHover: true,
dragToClose: true,
applyBlurEffect: true,
callbacks: ToastificationCallbacks(
onTap: (toastItem) => print('Toast ${toastItem.id} tapped'),
onCloseButtonTap: (toastItem) =>
print('Toast ${toastItem.id} close button tapped'),
onAutoCompleteCompleted: (toastItem) =>
print('Toast ${toastItem.id} auto complete completed'),
onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'),
),
);
// _showToast(context, message, Colors.red);
} }
static void _showToast(BuildContext context, String message, Color color) { static void _showToast(BuildContext context, String message, Color color) {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,14 @@ import 'package:nhancepolicy/customAppBar/customAppBar.dart';
import 'dart:convert'; import 'dart:convert';
import 'dart:async'; import 'dart:async';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/models/environment.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:universal_html/html.dart' as html; import 'package:universal_html/html.dart' as html;
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:excel/excel.dart'; import 'package:excel/excel.dart';
import 'dart:io';
import 'package:intl/intl.dart';
class excelVerify extends StatefulWidget { class excelVerify extends StatefulWidget {
const excelVerify({Key? key}) : super(key: key); const excelVerify({Key? key}) : super(key: key);
@ -38,6 +41,8 @@ class _excelVerifyState extends State<excelVerify> {
dynamic policyFirstPart; dynamic policyFirstPart;
List<Map<String, dynamic>> originalData = []; // Original data source List<Map<String, dynamic>> originalData = []; // Original data source
List<Map<String, dynamic>> filteredData = []; // Filtered data source List<Map<String, dynamic>> filteredData = []; // Filtered data source
dynamic client_policy_id;
dynamic policy_name;
@override @override
void initState() { void initState() {
@ -52,8 +57,8 @@ class _excelVerifyState extends State<excelVerify> {
Future<void> _loadToken() async { Future<void> _loadToken() async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
final token = prefs.getString('token'); final token = prefs.getString('hrtoken');
if (token != null) { if (token != null && token.isNotEmpty) {
setState(() { setState(() {
_token = token; _token = token;
}); });
@ -61,8 +66,10 @@ class _excelVerifyState extends State<excelVerify> {
clintID = decodedToken['client_id'].toString(); clintID = decodedToken['client_id'].toString();
await getPolicyName(clintID); await getPolicyName(clintID);
} else { } else {
_token = 'null'; // Token is empty or null, handle accordingly (e.g., navigate to login screen)
// Handle the case when token is not available // For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'hrLogin');
} }
} }
@ -86,16 +93,37 @@ class _excelVerifyState extends State<excelVerify> {
setState(() { setState(() {
dataPolicy = List<Map<String, dynamic>>.from(data['data']); dataPolicy = List<Map<String, dynamic>>.from(data['data']);
print(dataPolicy); print(dataPolicy);
getPolicyNameDetails = dataPolicy[0]['policy_name'];
print(getPolicyNameDetails); // Find the object where the 'type' matches the 'policyFirstPart'
getPolicyNo = dataPolicy[0]['client_policy_id']; Map<String, dynamic> matchingPolicy = dataPolicy.firstWhere(
(policy) => policy['type'] == policyFirstPart,
orElse: () => <String,
dynamic>{} // Return an empty map if no matching policy is found
);
print(matchingPolicy);
if (matchingPolicy != null) {
// Matching policy found
print('Matching Policy: $matchingPolicy');
client_policy_id = matchingPolicy['client_policy_id'];
policy_name = matchingPolicy['policy_name'];
} else {
// No matching policy found
print('No matching policy found for $policyFirstPart');
}
// getPolicyNameDetails = dataPolicy[0]['policy_name'];
// print(getPolicyNameDetails);
// getPolicyNo = dataPolicy[0]['client_policy_id'];
}); });
print('Successfully Sent'); print('Successfully Sent');
} else { } else {
ToastHelper.showErrorToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}');
} }
} else { } else {
ToastHelper.showErrorToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}');
} }
} catch (e) { } catch (e) {
@ -108,7 +136,9 @@ class _excelVerifyState extends State<excelVerify> {
} }
void _uploadFile(importPolicyName) async { void _uploadFile(importPolicyName) async {
print('Test');
if (kIsWeb) { if (kIsWeb) {
print('kIsWeb');
final input = html.FileUploadInputElement(); final input = html.FileUploadInputElement();
input.accept = '.xlsx'; input.accept = '.xlsx';
input.click(); input.click();
@ -116,22 +146,26 @@ class _excelVerifyState extends State<excelVerify> {
final file = input.files!.first; final file = input.files!.first;
final reader = html.FileReader(); final reader = html.FileReader();
reader.readAsArrayBuffer(file); reader.readAsArrayBuffer(file);
reader.onLoadEnd.listen((event) async { await reader.onLoadEnd.first; // Wait for the file to be loaded
if (reader.readyState == html.FileReader.DONE) {
Uint8List? fileBytes = reader.result as Uint8List?; Uint8List? fileBytes = reader.result as Uint8List?;
if (fileBytes != null) { if (fileBytes != null) {
// Call function to process Excel data
setState(() { setState(() {
fileName = file.name; fileName = file.name;
}); });
// Save fileBytes to local storage // Save fileBytes to local storage
final jsonString = json.encode(fileBytes); final jsonString = json.encode(fileBytes);
html.window.localStorage['fileBytes'] = jsonString; html.window.localStorage['fileBytes'] = jsonString;
print(fileName); print('File Name: $fileName');
print(fileBytes); print('File Bytes: $fileBytes');
// Call the function to process Excel data here
_processExcelData(fileBytes); _processExcelData(fileBytes);
} }
}
}); });
}); } else {
// Handle non-web platforms here (e.g., show an error message)
print('File upload is only supported on web platforms.');
} }
} }
@ -147,8 +181,8 @@ class _excelVerifyState extends State<excelVerify> {
if (dataArray[0].length == 10) { if (dataArray[0].length == 10) {
for (int i = 0; i < dataArray.length; i++) { for (int i = 0; i < dataArray.length; i++) {
Map<String, dynamic> dataMap = { Map<String, dynamic> dataMap = {
"S.No": dataArray[i][0].value, "Sno": dataArray[i][0].value,
"Emp Code": dataArray[i][1].value, "emp_code": dataArray[i][1].value,
"Name": dataArray[i][2].value, "Name": dataArray[i][2].value,
"DOJ": dataArray[i][3].value, "DOJ": dataArray[i][3].value,
"Gender": dataArray[i][4].value, "Gender": dataArray[i][4].value,
@ -284,11 +318,11 @@ class _excelVerifyState extends State<excelVerify> {
request.files.add(http.MultipartFile.fromBytes('file', fileBytes, request.files.add(http.MultipartFile.fromBytes('file', fileBytes,
filename: fileName)); // Specify filename here filename: fileName)); // Specify filename here
request.fields['client_id'] = clintID; request.fields['client_id'] = clintID;
if (policyFirstPart == 'GPA') { // if (policyFirstPart == 'GPA') {
request.fields['policy_id'] = '1'; request.fields['policy_id'] = client_policy_id;
} else { // } else {
request.fields['policy_id'] = '3'; // request.fields['policy_id'] = '3';
} // }
// Send the request // Send the request
final response = await request.send(); final response = await request.send();
@ -296,11 +330,14 @@ class _excelVerifyState extends State<excelVerify> {
// Check the status code of the response // Check the status code of the response
if (response.statusCode == 200) { if (response.statusCode == 200) {
// ToastHelper.showSuccessToast(context, 'File uploaded successfully'); // ToastHelper.showSuccessToast(context, 'File uploaded successfully');
ToastHelper.showSuccessToast(context, 'Data Successfully Send...');
print('File uploaded successfully'); print('File uploaded successfully');
Navigator.pushNamed(context, 'hrHome'); Navigator.pushNamed(context, 'hrHome');
} else { } else {
// ToastHelper.showSuccessToast( // ToastHelper.showSuccessToast(
// context, 'Failed to upload file: ${response.reasonPhrase}'); // context, 'Failed to upload file: ${response.reasonPhrase}');
ToastHelper.showSuccessToast(
context, 'Failed to send data: ${response.reasonPhrase}');
print('Failed to upload file: ${response.reasonPhrase}'); print('Failed to upload file: ${response.reasonPhrase}');
} }
} }
@ -326,12 +363,9 @@ class _excelVerifyState extends State<excelVerify> {
dynamic importPolicyName = dynamic importPolicyName =
ModalRoute.of(context)!.settings.arguments as String?; ModalRoute.of(context)!.settings.arguments as String?;
List<String> parts = importPolicyName.split(" - "); // List<String> parts = importPolicyName.split(" - ");
policyFirstPart = policyFirstPart = importPolicyName;
parts.isNotEmpty ? parts[0] : ''; // Accessing the first element
print(policyFirstPart); // Output: GMC
print(importPolicyName);
return Scaffold( return Scaffold(
appBar: CustomAppBar(), appBar: CustomAppBar(),
body: SafeArea( body: SafeArea(
@ -357,36 +391,38 @@ class _excelVerifyState extends State<excelVerify> {
currentStep: _currentStep, currentStep: _currentStep,
controlsBuilder: controlsBuilder:
(BuildContext context, ControlsDetails controls) { (BuildContext context, ControlsDetails controls) {
return Positioned( return Container(
bottom: 0, alignment: Alignment.bottomCenter,
right: 0,
left: 0,
child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
if (_currentStep != 0) if (_currentStep != 0)
ElevatedButton( ElevatedButton(
onPressed: controls.onStepCancel, onPressed: () {
controls
.onStepCancel!(); // Call onStepCancel function
},
child: Text( child: Text(
'Cancel', 'Cancel',
style: style: TextStyle(color: Color(0xFFE26728)),
TextStyle(color: Color(0xFFE26728)),
), ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.white, backgroundColor: Colors.white,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
side: BorderSide( side:
color: Color(0xFFE26728)), BorderSide(color: Color(0xFFE26728)),
), ),
), ),
), ),
SizedBox(width: 10), SizedBox(width: 10),
if (_currentStep != 2) if (_currentStep != 2)
ElevatedButton( ElevatedButton(
onPressed: controls.onStepContinue, onPressed: () {
controls
.onStepContinue!(); // Call onStepContinue function
},
child: const Text( child: const Text(
'NEXT', 'NEXT',
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
@ -417,7 +453,6 @@ class _excelVerifyState extends State<excelVerify> {
), ),
], ],
), ),
),
); );
}, },
onStepContinue: _currentStep == 2 onStepContinue: _currentStep == 2
@ -478,7 +513,7 @@ class _excelVerifyState extends State<excelVerify> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
importPolicyName ?? '', policy_name ?? '',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
@ -788,14 +823,18 @@ class _DependenceDataSource0 extends DataTableSource {
@override @override
DataRow getRow(int index) { DataRow getRow(int index) {
final row = _data[index]; final row = _data[index];
// Format date of birth to "July 10, 1996"
String dob = row['dob'] != null ? formatDateString(row['dob']) : 'N/A';
return DataRow(cells: [ return DataRow(cells: [
DataCell(Text(row['SNo'].toString())), DataCell(Text(row['Sno'].toString())),
DataCell(Text(row['EmpCode'].toString())), DataCell(Text(row['emp_code'].toString())),
DataCell(Text(row['Name'].toString())), DataCell(Text(row['Name'].toString())),
DataCell(Text(row['DOJ']?.toString() ?? 'N/A')), DataCell(Text(row['DOJ']?.toString() ?? 'N/A')),
DataCell(Text(row['Gender']?.toString() ?? 'N/A')), DataCell(Text(row['Gender']?.toString() ?? 'N/A')),
DataCell(Text(row['Relation']?.toString() ?? 'N/A')), DataCell(Text(row['Relation']?.toString() ?? 'N/A')),
DataCell(Text(row['DOB']?.toString() ?? 'N/A')), DataCell(Text(dob)),
DataCell(Text(row['Mail']?.toString() ?? 'N/A')), DataCell(Text(row['Mail']?.toString() ?? 'N/A')),
DataCell(Text(row['Mobile']?.toString() ?? 'N/A')), DataCell(Text(row['Mobile']?.toString() ?? 'N/A')),
DataCell(Text(row['SI']?.toString() ?? 'N/A')), DataCell(Text(row['SI']?.toString() ?? 'N/A')),
@ -810,4 +849,13 @@ class _DependenceDataSource0 extends DataTableSource {
@override @override
int get selectedRowCount => 0; int get selectedRowCount => 0;
String formatDateString(String dateString) {
// Parse the date string to DateTime object
DateTime dateTime = DateTime.parse(dateString);
// Format the DateTime object to "July 03, 2024"
String formattedDate = DateFormat.yMMMMd().format(dateTime);
return formattedDate;
}
} }

View File

@ -7,7 +7,6 @@ import 'package:jwt_decode/jwt_decode.dart';
import 'dart:convert'; import 'dart:convert';
import 'dart:async'; import 'dart:async';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:file_picker/file_picker.dart';
import 'package:nhancepolicy/customAppBar/toastHelper.dart'; import 'package:nhancepolicy/customAppBar/toastHelper.dart';
// import 'dart:html' as html; // import 'dart:html' as html;
import 'package:universal_html/html.dart' as html; import 'package:universal_html/html.dart' as html;
@ -15,6 +14,7 @@ import 'dart:typed_data';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:excel/excel.dart'; import 'package:excel/excel.dart';
import 'package:intl/intl.dart';
class MyHrHome extends StatefulWidget { class MyHrHome extends StatefulWidget {
const MyHrHome({Key? key}) : super(key: key); const MyHrHome({Key? key}) : super(key: key);
@ -24,28 +24,33 @@ class MyHrHome extends StatefulWidget {
} }
class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin { class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
Uint8List? _fileBytes;
Uint8List? fileBytes; Uint8List? fileBytes;
late String _token; late String _token;
List<Map<String, dynamic>> getEmpDependenceByClintIdGMC = []; List<Map<String, dynamic>> getEmpDependenceByClintIdGMC = [];
List<Map<String, dynamic>> getEmpDependenceByClintIdGPA = []; List<Map<String, dynamic>> getEmpDependenceByClintIdGPA = [];
List<Map<String, dynamic>> getEmpDependenceByClintIdAddOns = [];
dynamic getPolicyNameDetails0; dynamic getPolicyNameDetails0;
dynamic getPolicyNameDetails1; dynamic getPolicyNameDetails1;
dynamic getPolicyNameDetails2;
dynamic getPolicyNo0; dynamic getPolicyNo0;
dynamic getPolicyNo1; dynamic getPolicyNo1;
dynamic getPolicyNo2;
bool _isLoading = false; bool _isLoading = false;
dynamic clintID; dynamic clintID;
late TabController _tabController; late TabController _tabController;
List<dynamic> dataPolicy = []; List<dynamic> dataPolicy = [];
List<dynamic> reversedDataPolicy = [];
List<Map<String, dynamic>> originalDataGpa = []; // Original data source List<Map<String, dynamic>> originalDataGpa = []; // Original data source
List<Map<String, dynamic>> filteredDataGpa = []; // Filtered data source List<Map<String, dynamic>> filteredDataGpa = []; // Filtered data source
List<Map<String, dynamic>> originalDataGmc = []; // Original data source List<Map<String, dynamic>> originalDataGmc = []; // Original data source
List<Map<String, dynamic>> filteredDataGmc = []; // Filtered data source List<Map<String, dynamic>> filteredDataGmc = []; // Filtered data source
List<Map<String, dynamic>> originalDataAddOns = []; // Original data source
List<Map<String, dynamic>> filteredDataAddOns = [];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_tabController = TabController(length: 2, vsync: this); _tabController = TabController(length: 3, vsync: this);
_loadToken(); _loadToken();
} }
@ -57,17 +62,19 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
Future<void> _loadToken() async { Future<void> _loadToken() async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
final token = prefs.getString('token'); final token = prefs.getString('hrtoken');
if (token != null) { if (token != null && token.isNotEmpty) {
setState(() { setState(() {
_token = token; _token = token;
}); });
Map<String, dynamic>? decodedToken = Jwt.parseJwt(token); Map<String, dynamic>? decodedToken = Jwt.parseJwt(token);
clintID = decodedToken['client_id']; clintID = decodedToken['client_id'];
await getPolicyName(clintID); getPolicyName(clintID);
} else { } else {
_token = 'null'; // Token is empty or null, handle accordingly (e.g., navigate to login screen)
// Handle the case when token is not available // For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'hrLogin');
} }
} }
@ -91,22 +98,52 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
setState(() { setState(() {
dataPolicy = List<Map<String, dynamic>>.from(data['data']); dataPolicy = List<Map<String, dynamic>>.from(data['data']);
print(dataPolicy); print(dataPolicy);
getPolicyNameDetails0 = dataPolicy[0]['policy_name']; reversedDataPolicy = dataPolicy.reversed.toList();
print(getPolicyNameDetails0); // getPolicyNameDetails0 = dataPolicy[0]['policy_name'];
getPolicyNameDetails1 = dataPolicy[1]['policy_name']; // print(getPolicyNameDetails0);
print(getPolicyNameDetails1); // getPolicyNameDetails1 = dataPolicy[1]['policy_name'];
getPolicyNo0 = dataPolicy[0]['client_policy_id']; // print(getPolicyNameDetails1);
print(getPolicyNameDetails1); // getPolicyNameDetails2 = dataPolicy[2]['policy_name'];
getPolicyNo1 = dataPolicy[1]['client_policy_id']; // print(getPolicyNameDetails2);
print(getPolicyNameDetails1); // getPolicyNo0 = dataPolicy[0]['client_policy_id'];
// print(getPolicyNameDetails1);
// getPolicyNo1 = dataPolicy[1]['client_policy_id'];
// print(getPolicyNameDetails1);
// getPolicyNo2 = dataPolicy[2]['client_policy_id'];
// print(getPolicyNameDetails2);
}); });
// Code to execute periodically every 2 seconds // Code to execute periodically every 2 seconds
getEmployeeAndDependenceGPA(clintID, getPolicyNo0); reversedDataPolicy.forEach((policy) {
getEmployeeAndDependenceGMC(clintID, getPolicyNo1); if (policy['type'] == 'GPA') {
String clientPolicyId = policy['client_policy_id'];
String clientId = policy['client_id'];
getEmployeeAndDependenceGPA(clientId, clientPolicyId);
} else if (policy['type'] == 'GMC') {
String clientPolicyId = policy['client_policy_id'];
String clientId = policy['client_id'];
getEmployeeAndDependenceGMC(clientId, clientPolicyId);
} else if (policy['type'] == 'AddOn') {
String clientPolicyId = policy['client_policy_id'];
String clientId = policy['client_id'];
getEmployeeAndDependenceAddOnsSi(clientId, clientPolicyId);
} else if (policy['type'] == 'AddOn-DEPENDENT') {
String clientPolicyId = policy['client_policy_id'];
String clientId = policy['client_id'];
getEmployeeAndDependenceAddOnsDependent(clientId, clientPolicyId);
}
// Extract client_policy_id from the policy object
});
// getEmployeeAndDependenceGPA(clintID, getPolicyNo2);
// getEmployeeAndDependenceGMC(clintID, getPolicyNo1);
// getEmployeeAndDependenceAddOns(clintID, getPolicyNo0);
} else { } else {
ToastHelper.showWarningToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}');
} }
} else { } else {
ToastHelper.showWarningToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}');
} }
} catch (e) { } catch (e) {
@ -118,12 +155,12 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
} }
} }
Future<void> getEmployeeAndDependenceGPA(clintID, getPolicyNo0) async { Future<void> getEmployeeAndDependenceGPA(clintID, getPolicyNo) async {
setState(() { setState(() {
_isLoading = true; _isLoading = true;
}); });
var url = Uri.parse(Environment.apiUrl + var url = Uri.parse(Environment.apiUrl +
'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo0'); 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo');
try { try {
var response = await http.get( var response = await http.get(
url, url,
@ -141,9 +178,13 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
filteredDataGpa = List.from(originalDataGpa); filteredDataGpa = List.from(originalDataGpa);
}); });
} else { } else {
ToastHelper.showWarningToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}');
} }
} else { } else {
ToastHelper.showWarningToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}');
} }
} catch (e) { } catch (e) {
@ -155,12 +196,12 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
} }
} }
Future<void> getEmployeeAndDependenceGMC(clintID, getPolicyNo1) async { Future<void> getEmployeeAndDependenceGMC(clintID, getPolicyNo) async {
setState(() { setState(() {
_isLoading = true; _isLoading = true;
}); });
var url = Uri.parse(Environment.apiUrl + var url = Uri.parse(Environment.apiUrl +
'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo1'); 'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo');
try { try {
var response = await http.get( var response = await http.get(
url, url,
@ -178,9 +219,96 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
filteredDataGmc = List.from(originalDataGmc); filteredDataGmc = List.from(originalDataGmc);
}); });
} else { } else {
ToastHelper.showErrorToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}'); print('API request failed with status: ${data['status']}');
} }
} else { } else {
ToastHelper.showErrorToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}');
}
} catch (e) {
print('Exception occurred: $e');
} finally {
setState(() {
_isLoading = false;
});
}
}
Future<void> getEmployeeAndDependenceAddOnsSi(clintID, getPolicyNo) async {
setState(() {
_isLoading = true;
});
var url = Uri.parse(Environment.apiUrl +
'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo');
try {
var response = await http.get(
url,
headers: {
'Authorization': 'Bearer $_token',
},
);
if (response.statusCode == 200) {
Map<String, dynamic> data = json.decode(response.body);
if (data['status'] == 'success') {
setState(() {
getEmpDependenceByClintIdAddOns =
List<Map<String, dynamic>>.from(data['data']);
originalDataAddOns = getEmpDependenceByClintIdAddOns;
filteredDataAddOns = List.from(originalDataAddOns);
});
} else {
ToastHelper.showErrorToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}');
}
} else {
ToastHelper.showErrorToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}');
}
} catch (e) {
print('Exception occurred: $e');
} finally {
setState(() {
_isLoading = false;
});
}
}
Future<void> getEmployeeAndDependenceAddOnsDependent(
clintID, getPolicyNo) async {
setState(() {
_isLoading = true;
});
var url = Uri.parse(Environment.apiUrl +
'getEmployeeAndDependenceByClientId?client_id=$clintID&client_policy_id=$getPolicyNo');
try {
var response = await http.get(
url,
headers: {
'Authorization': 'Bearer $_token',
},
);
if (response.statusCode == 200) {
Map<String, dynamic> data = json.decode(response.body);
if (data['status'] == 'success') {
setState(() {
getEmpDependenceByClintIdAddOns =
List<Map<String, dynamic>>.from(data['data']);
originalDataAddOns = getEmpDependenceByClintIdAddOns;
filteredDataAddOns = List.from(originalDataAddOns);
});
} else {
ToastHelper.showErrorToast(
context, 'API request failed with status: ${data['status']}');
print('API request failed with status: ${data['status']}');
}
} else {
ToastHelper.showErrorToast(
context, 'Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.statusCode}'); print('Request failed with status: ${response.statusCode}');
} }
} catch (e) { } catch (e) {
@ -195,9 +323,14 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
void _uploadFile(importPolicyName) async { void _uploadFile(importPolicyName) async {
var argumentDetails; var argumentDetails;
if (importPolicyName == 'GPA') { if (importPolicyName == 'GPA') {
argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0; // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails2;
argumentDetails = 'GPA';
} else if (importPolicyName == 'GMC') {
// argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1;
argumentDetails = 'GMC';
} else { } else {
argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails1; // argumentDetails = importPolicyName + ' - ' + getPolicyNameDetails0;
argumentDetails = 'ADDONS';
} }
Navigator.pushNamed(context, 'excelVerify', arguments: argumentDetails); Navigator.pushNamed(context, 'excelVerify', arguments: argumentDetails);
@ -250,8 +383,39 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
}); });
} }
void searchAddOns(String query) {
setState(() {
if (query.isEmpty) {
// If search query is empty, show all data
filteredDataAddOns = List.from(originalDataAddOns);
} else {
// Filter the data based on the search query
filteredDataAddOns = originalDataAddOns.where((item) {
// Implement your filter logic here, for example:
return item['emp_code'].toLowerCase().contains(query.toLowerCase());
}).toList();
}
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (dataPolicy == []) {
return Scaffold(
appBar: CustomAppBar(),
body: SingleChildScrollView(
child: Container(
color: Color(0xFFEFF3F6),
child: Column(
children: [
Center(
child: Text('No Data Available'),
)
],
),
),
));
} else {
return Scaffold( return Scaffold(
appBar: CustomAppBar(), appBar: CustomAppBar(),
body: Container( body: Container(
@ -265,28 +429,45 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
labelColor: Colors.white, // Selected tab color labelColor: Colors.white, // Selected tab color
unselectedLabelColor: Colors.grey, // Unselected tab color unselectedLabelColor: Colors.grey, // Unselected tab color
indicator: BoxDecoration( indicator: BoxDecoration(
color: Color(0xFFE26728), // Background color of selected tab color:
Color(0xFFE26728), // Background color of selected tab
), ),
indicatorSize: TabBarIndicatorSize.label, indicatorSize: TabBarIndicatorSize.label,
controller: _tabController, controller: _tabController,
tabs: [ tabs: reversedDataPolicy != null &&
Tab( reversedDataPolicy.isNotEmpty
child: Container( ? reversedDataPolicy.map((policy) {
width: double.maxFinite, return Tab(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(vertical: 0),
child: Text('GPA-' + (getPolicyNameDetails0 ?? '')),
),
),
Tab(
child: Container( child: Container(
width: double.infinity, width: double.infinity,
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.symmetric(vertical: 0), padding: EdgeInsets.symmetric(vertical: 0),
child: Text('GMC-' + (getPolicyNameDetails1 ?? '')), child: Text(
'${policy['type']}-${policy['policy_name']}'),
), ),
), );
], }).toList()
: [
Tab(text: 'Loading...')
], // Display a loading tab if dataPolicy is null or empty
// tabs: [
// Tab(
// child: Container(
// width: double.maxFinite,
// alignment: Alignment.center,
// padding: EdgeInsets.symmetric(vertical: 0),
// child: Text('GPA-' + (getPolicyNameDetails0 ?? '')),
// ),
// ),
// Tab(
// child: Container(
// width: double.infinity,
// alignment: Alignment.center,
// padding: EdgeInsets.symmetric(vertical: 0),
// child: Text('GMC-' + (getPolicyNameDetails1 ?? '')),
// ),
// ),
// ],
), ),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
@ -330,7 +511,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
BorderRadius.circular(5), BorderRadius.circular(5),
), ),
child: TextField( child: TextField(
textAlignVertical: TextAlignVertical textAlignVertical:
TextAlignVertical
.center, // Center the text vertically .center, // Center the text vertically
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search', hintText: 'Search',
@ -366,15 +548,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
style: TextStyle( style: TextStyle(
color: Colors.white), color: Colors.white),
), ),
style: style: ElevatedButton
ElevatedButton.styleFrom( .styleFrom(
backgroundColor: backgroundColor:
Color(0xFFE26728), Color(0xFFE26728),
shape: shape:
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius
5), .circular(5),
), ),
), ),
), ),
@ -390,7 +572,7 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
children: [ children: [
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
child: _buildDataTableGPA(), child: _buildDataTableGPA(context),
), ),
) )
], ],
@ -437,7 +619,8 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
BorderRadius.circular(5), BorderRadius.circular(5),
), ),
child: TextField( child: TextField(
textAlignVertical: TextAlignVertical textAlignVertical:
TextAlignVertical
.center, // Center the text vertically .center, // Center the text vertically
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search', hintText: 'Search',
@ -473,15 +656,15 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
style: TextStyle( style: TextStyle(
color: Colors.white), color: Colors.white),
), ),
style: style: ElevatedButton
ElevatedButton.styleFrom( .styleFrom(
backgroundColor: backgroundColor:
Color(0xFFE26728), Color(0xFFE26728),
shape: shape:
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius
5), .circular(5),
), ),
), ),
), ),
@ -497,7 +680,116 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
children: [ children: [
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
child: _buildDataTableGMC(), child: _buildDataTableGMC(context),
),
)
],
),
],
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.all(20),
child: _isLoading
? Center(child: CircularProgressIndicator())
: Column(
children: [
Row(
children: [
Expanded(
flex: 10,
child: Container(
alignment: Alignment.centerLeft,
child: Container(
width:
350, // Set your desired width here
height:
40, // Set your desired height here
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color.fromRGBO(
255,
255,
255,
0.5), // Shadow color with opacity
offset: Offset(5,
5), // Shadow position (horizontal, vertical)
blurRadius:
10, // Blur radius
spreadRadius:
0, // Spread radius
),
],
borderRadius:
BorderRadius.circular(5),
),
child: TextField(
textAlignVertical:
TextAlignVertical
.center, // Center the text vertically
decoration: InputDecoration(
hintText: 'Search',
suffixIcon:
Icon(Icons.search),
contentPadding: EdgeInsets.all(
10), // Adjust the horizontal padding
border: OutlineInputBorder(
borderSide: BorderSide(
color: Color(
0xFFf5f5f7)), // Set border color to gray
),
),
onChanged:
searchAddOns, // Call the search method on text change
),
)),
),
// Expanded(
// flex: 2,
// child: Container(
// alignment: Alignment.centerRight,
// child: Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceEvenly,
// children: [
// Expanded(
// child: ElevatedButton(
// onPressed: () =>
// _uploadFile('ADDONS'),
// child: Text(
// 'Import',
// style: TextStyle(
// color: Colors.white),
// ),
// style: ElevatedButton
// .styleFrom(
// backgroundColor:
// Color(0xFFE26728),
// shape:
// RoundedRectangleBorder(
// borderRadius:
// BorderRadius
// .circular(5),
// ),
// ),
// ),
// )
// ],
// ),
// ),
// ),
],
),
SizedBox(height: 20),
Row(
children: [
Expanded(
child: SingleChildScrollView(
child:
_buildDataTableAddOns(context),
), ),
) )
], ],
@ -515,8 +807,9 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
), ),
); );
} }
}
Widget _buildDataTableGPA() { Widget _buildDataTableGPA(context) {
if (filteredDataGpa.isEmpty) { if (filteredDataGpa.isEmpty) {
SizedBox(height: 25); SizedBox(height: 25);
return Text('No available data'); return Text('No available data');
@ -533,13 +826,13 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
DataColumn(label: Text('Gender')), DataColumn(label: Text('Gender')),
DataColumn(label: Text('Mobile No')), DataColumn(label: Text('Mobile No')),
], ],
source: _DependenceDataSource0(filteredDataGpa), source: _DependenceDataSource0(filteredDataGpa, context),
), ),
); );
} }
} }
Widget _buildDataTableGMC() { Widget _buildDataTableGMC(context) {
if (filteredDataGmc.isEmpty) { if (filteredDataGmc.isEmpty) {
SizedBox(height: 25); SizedBox(height: 25);
return Text('No available data'); return Text('No available data');
@ -556,7 +849,30 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
DataColumn(label: Text('Gender')), DataColumn(label: Text('Gender')),
DataColumn(label: Text('Mobile No')), DataColumn(label: Text('Mobile No')),
], ],
source: _DependenceDataSource1(filteredDataGmc), source: _DependenceDataSource1(filteredDataGmc, context),
),
);
}
}
Widget _buildDataTableAddOns(context) {
if (filteredDataAddOns.isEmpty) {
SizedBox(height: 25);
return Text('No available data');
} else {
return Card(
elevation: 0, // Set elevation to 0 for no shadow
child: PaginatedDataTable(
rowsPerPage: 5, // Adjust rows per page as needed
columns: [
DataColumn(label: Text('Employee ID')),
DataColumn(label: Text('Name')),
DataColumn(label: Text('Relationship')),
DataColumn(label: Text('Date of Birth')),
DataColumn(label: Text('Gender')),
DataColumn(label: Text('Mobile No')),
],
source: _DependenceDataSource2(filteredDataAddOns, context),
), ),
); );
} }
@ -565,19 +881,41 @@ class _MyHrHomeState extends State<MyHrHome> with TickerProviderStateMixin {
class _DependenceDataSource0 extends DataTableSource { class _DependenceDataSource0 extends DataTableSource {
final List<Map<String, dynamic>> _data; final List<Map<String, dynamic>> _data;
_DependenceDataSource0(this._data); final BuildContext context;
_DependenceDataSource0(this._data, this.context);
@override @override
DataRow getRow(int index) { DataRow getRow(int index) {
final row = _data[index]; final row = _data[index];
return DataRow(cells: [ Color rowColor = Colors.transparent;
DataCell(Text(row['emp_code'].toString())), TextStyle textStyle = TextStyle(color: Colors.black);
DataCell(Text(row['name'].toString())), bool isClickable = false;
DataCell(Text(row['relationship'].toString())),
DataCell(Text(row['dob'] ?? 'N/A')), if (row['relationship'] == 'Self') {
DataCell(Text(row['gender'] ?? 'N/A')), rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows
DataCell(Text(row['mobile'] ?? 'N/A')), textStyle = TextStyle(color: Colors.black);
]); isClickable = true; // Making 'Self' rows clickable
}
// Format date of birth to "July 10, 1996"
String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A';
return DataRow(
color: MaterialStateColor.resolveWith(
(states) => rowColor), // Setting row background color
cells: [
DataCell(
Text(row['emp_code'].toString(), style: textStyle),
onTap: isClickable
? () => _navigateToAnotherPage(row)
: null, // Navigation only for 'Self' rows
),
DataCell(Text(row['name'].toString(), style: textStyle)),
DataCell(Text(row['relationship'].toString(), style: textStyle)),
DataCell(Text(dob, style: textStyle)),
DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)),
DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)),
],
);
} }
@override @override
@ -588,22 +926,56 @@ class _DependenceDataSource0 extends DataTableSource {
@override @override
int get selectedRowCount => 0; int get selectedRowCount => 0;
void _navigateToAnotherPage(row) {
print(row['mobile']);
// Navigation logic here
Navigator.pushNamed(context, 'empDetails',
arguments: {'mobile': row['mobile']});
}
String _formatDate(String date) {
DateTime parsedDate = DateTime.parse(date);
String formattedDate = DateFormat.yMMMMd().format(parsedDate);
return formattedDate;
}
} }
class _DependenceDataSource1 extends DataTableSource { class _DependenceDataSource1 extends DataTableSource {
final List<Map<String, dynamic>> _data; final List<Map<String, dynamic>> _data;
_DependenceDataSource1(this._data); final BuildContext context;
_DependenceDataSource1(this._data, this.context);
@override @override
DataRow getRow(int index) { DataRow getRow(int index) {
final row = _data[index]; final row = _data[index];
return DataRow(cells: [ Color rowColor = Colors.transparent;
DataCell(Text(row['emp_code'].toString())), TextStyle textStyle = TextStyle(color: Colors.black);
DataCell(Text(row['name'].toString())), bool isClickable = false;
DataCell(Text(row['relationship'].toString())),
DataCell(Text(row['dob'] ?? 'N/A')), if (row['relationship'] == 'Self') {
DataCell(Text(row['gender'] ?? 'N/A')), rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows
DataCell(Text(row['mobile'] ?? 'N/A')), textStyle = TextStyle(color: Colors.black);
isClickable = true; // Making 'Self' rows clickable
}
// Format date of birth to "July 10, 1996"
String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A';
return DataRow(
color: MaterialStateColor.resolveWith((states) => rowColor),
cells: [
DataCell(
Text(row['emp_code'].toString(), style: textStyle),
onTap: isClickable
? () => _navigateToAnotherPage(row)
: null, // Navigation only for 'Self' rows
),
DataCell(Text(row['name'].toString(), style: textStyle)),
DataCell(Text(row['relationship'].toString(), style: textStyle)),
DataCell(Text(dob, style: textStyle)),
DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)),
DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)),
]); ]);
} }
@ -615,6 +987,78 @@ class _DependenceDataSource1 extends DataTableSource {
@override @override
int get selectedRowCount => 0; int get selectedRowCount => 0;
void _navigateToAnotherPage(row) {
print(row);
Navigator.pushNamed(context, 'empDetails',
arguments: {'mobile': row['mobile']});
}
String _formatDate(String date) {
DateTime parsedDate = DateTime.parse(date);
String formattedDate = DateFormat.yMMMMd().format(parsedDate);
return formattedDate;
}
}
class _DependenceDataSource2 extends DataTableSource {
final List<Map<String, dynamic>> _data;
final BuildContext context;
_DependenceDataSource2(this._data, this.context);
@override
DataRow getRow(int index) {
final row = _data[index];
Color rowColor = Colors.transparent;
TextStyle textStyle = TextStyle(color: Colors.black);
bool isClickable = false;
if (row['relationship'] == 'Self') {
rowColor = Color(0xFFFFF1DD); // Setting background color for 'Self' rows
textStyle = TextStyle(color: Colors.black);
isClickable = true; // Making 'Self' rows clickable
}
// Format date of birth to "July 10, 1996"
String dob = row['dob'] != null ? _formatDate(row['dob']) : 'N/A';
return DataRow(
color: MaterialStateColor.resolveWith((states) => rowColor),
cells: [
DataCell(
Text(row['emp_code'].toString(), style: textStyle),
onTap: isClickable
? () => _navigateToAnotherPage(row)
: null, // Navigation only for 'Self' rows
),
DataCell(Text(row['name'].toString(), style: textStyle)),
DataCell(Text(row['relationship'].toString(), style: textStyle)),
DataCell(Text(dob, style: textStyle)),
DataCell(Text(row['gender'] ?? 'N/A', style: textStyle)),
DataCell(Text(row['mobile'] ?? 'N/A', style: textStyle)),
]);
}
@override
bool get isRowCountApproximate => false;
@override
int get rowCount => _data.length;
@override
int get selectedRowCount => 0;
void _navigateToAnotherPage(row) {
print(row);
Navigator.pushNamed(context, 'empDetails',
arguments: {'mobile': row['mobile']});
}
String _formatDate(String date) {
DateTime parsedDate = DateTime.parse(date);
String formattedDate = DateFormat.yMMMMd().format(parsedDate);
return formattedDate;
}
} }
// Sample Data class representing each element in the array // Sample Data class representing each element in the array

View File

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/models/environment.dart';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
@ -44,10 +45,12 @@ class _MyPhoneState extends State<MyHrLogin> {
bool userVerification = data['data']['user_verification']; bool userVerification = data['data']['user_verification'];
return userVerification; return userVerification;
} else { } else {
ToastHelper.showErrorToast(context, 'Failed to verify mobile number');
throw Exception('Failed to verify mobile number'); throw Exception('Failed to verify mobile number');
} }
} catch (e) { } catch (e) {
print('Error: $e'); print('Error: $e');
ToastHelper.showErrorToast(context, 'Error: $e');
return false; return false;
} }
} }
@ -60,14 +63,11 @@ class _MyPhoneState extends State<MyHrLogin> {
bool isValid = await verifyMobileNumber(enteredMobileNumber); bool isValid = await verifyMobileNumber(enteredMobileNumber);
if (isValid) { if (isValid) {
ToastHelper.showSuccessToast(context, 'Mobile No Verified...');
Navigator.pushNamed(context, 'hrVerify', Navigator.pushNamed(context, 'hrVerify',
arguments: enteredMobileNumber); arguments: enteredMobileNumber);
} else { } else {
ScaffoldMessenger.of(context).showSnackBar( ToastHelper.showErrorToast(context, 'Invalid mobile number');
SnackBar(
content: Text('Invalid mobile number'),
),
);
} }
} }
} }
@ -118,6 +118,109 @@ class _MyPhoneState extends State<MyHrLogin> {
height: _size.height / 3, height: _size.height / 3,
width: double.infinity, width: double.infinity,
color: Color(0xFF00989E), color: Color(0xFF00989E),
child: Stack(
children: [
Positioned(
top: 40, // Adjust top position as needed
left: 10, // Align to the right
child: MouseRegion(
cursor: SystemMouseCursors.click,
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, 'phone');
},
child: Row(
children: [
Icon(
Icons.west, // Icon for customer login
color: Colors
.black, // Adjust color as needed
),
SizedBox(width: 5),
Text(
'Customer Login',
style: TextStyle(
color: Color(0xFF000000), // Text color
// Add other text styles as needed
),
),
],
),
),
),
),
),
Column(
children: [
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(
_size.width <= 1100
? 'assets/mobileViewLogo.png'
: 'assets/Nhance-Logo-Final 1.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: TextStyle(
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
),
],
),
),
),
),
],
),
],
),
],
),
), ),
), ),
), ),
@ -154,10 +257,12 @@ class _MyPhoneState extends State<MyHrLogin> {
child: Container( child: Container(
margin: _size.width > 1100 margin: _size.width > 1100
? EdgeInsets.only(left: 20, right: 20) ? EdgeInsets.only(left: 20, right: 20)
: null, : EdgeInsets.only(left: 0, right: 0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
if (!Responsive.isMobile(context) &&
!Responsive.isTablet(context))
Row( Row(
children: [ children: [
Expanded( Expanded(
@ -223,8 +328,10 @@ class _MyPhoneState extends State<MyHrLogin> {
), ),
SizedBox(height: 15), SizedBox(height: 15),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -243,8 +350,10 @@ class _MyPhoneState extends State<MyHrLogin> {
height: 15, height: 15,
), ),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -266,8 +375,10 @@ class _MyPhoneState extends State<MyHrLogin> {
), ),
Container( Container(
height: 55, height: 55,
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
width: 1, color: Colors.grey), width: 1, color: Colors.grey),
@ -334,8 +445,10 @@ class _MyPhoneState extends State<MyHrLogin> {
height: 20, height: 20,
), ),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
height: 45, height: 45,
@ -455,7 +568,10 @@ class _MyPhoneState extends State<MyHrLogin> {
), ),
) )
: SizedBox( : SizedBox(
height: _size.height * 0.2, height:
Responsive.isDesktop(context)
? _size.height * 0.1
: _size.height * 0.2,
), ),
SizedBox( SizedBox(
height: _size.height * 0.1, height: _size.height * 0.1,

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
import 'package:nhancepolicy/models/environment.dart'; import 'package:nhancepolicy/models/environment.dart';
import 'package:pinput/pinput.dart'; import 'package:pinput/pinput.dart';
import 'dart:async'; import 'dart:async';
@ -70,23 +71,27 @@ class _MyVerifyState extends State<MyHrVerify> {
if (response.statusCode == 200) { if (response.statusCode == 200) {
// Handle successful response // Handle successful response
ScaffoldMessenger.of(context).showSnackBar( ToastHelper.showSuccessToast(context, 'OTP resent successfully.');
SnackBar( // ScaffoldMessenger.of(context).showSnackBar(
content: Text('OTP resent successfully.'), // SnackBar(
), // content: Text('OTP resent successfully.'),
); // ),
// );
} else { } else {
// Handle other response status codes // Handle other response status codes
ToastHelper.showErrorToast(context, 'Failed to resend OTP');
throw Exception('Failed to resend OTP'); throw Exception('Failed to resend OTP');
} }
} catch (e) { } catch (e) {
// Handle API call errors // Handle API call errors
print('Error: $e'); print('Error: $e');
ScaffoldMessenger.of(context).showSnackBar( ToastHelper.showErrorToast(
SnackBar( context, 'Failed to resend OTP. Please try again.');
content: Text('Failed to resend OTP. Please try again.'), // ScaffoldMessenger.of(context).showSnackBar(
), // SnackBar(
); // content: Text('Failed to resend OTP. Please try again.'),
// ),
// );
} }
} }
@ -110,32 +115,41 @@ class _MyVerifyState extends State<MyHrVerify> {
print(status); print(status);
if (status == 'success') { if (status == 'success') {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('token', data['data']); prefs.setString('hrtoken', data['data']);
// Store data in local storage (if needed) final hrtoken = prefs.getString('hrtoken');
// SharedPreferences prefs = await SharedPreferences.getInstance(); if (hrtoken != null && hrtoken.isNotEmpty) {
// await prefs.setString('userData', json.encode(data['data'])); ToastHelper.showSuccessToast(context, 'Successfully Login');
// Redirect to another page
Navigator.pushNamed(context, 'hrHome'); Navigator.pushNamed(context, 'hrHome');
} else { } else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'hrLogin');
}
// Redirect to another page
} else {
ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again.');
// Show a Snackbar if the OTP is invalid // Show a Snackbar if the OTP is invalid
ScaffoldMessenger.of(context).showSnackBar( // ScaffoldMessenger.of(context).showSnackBar(
SnackBar( // SnackBar(
content: Text('Invalid OTP. Please try again.'), // content: Text('Invalid OTP. Please try again.'),
), // ),
); // );
} }
} else { } else {
ToastHelper.showErrorToast(context, 'Failed to verify OTP');
throw Exception('Failed to verify OTP'); throw Exception('Failed to verify OTP');
} }
} catch (e) { } catch (e) {
print('Error: $e'); print('Error: $e');
ToastHelper.showErrorToast(
context, 'Failed to verify OTP. Please try again.');
// Show a Snackbar if there's an error while verifying OTP // Show a Snackbar if there's an error while verifying OTP
ScaffoldMessenger.of(context).showSnackBar( // ScaffoldMessenger.of(context).showSnackBar(
SnackBar( // SnackBar(
content: Text('Failed to verify OTP. Please try again.'), // content: Text('Failed to verify OTP. Please try again.'),
), // ),
); // );
} }
} }
@ -194,57 +208,112 @@ class _MyVerifyState extends State<MyHrVerify> {
); );
return Scaffold( return Scaffold(
// extendBodyBehindAppBar: true, body: SingleChildScrollView(
// appBar: AppBar( keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
// backgroundColor: Colors.transparent, child: Container(
// leading: IconButton( height: _size.height,
// onPressed: () { color: Colors.white,
// Navigator.pop(context); child: Stack(
// }, children: [
// icon: Icon(
// Icons.arrow_back_ios_rounded,
// color: Colors.black,
// ),
// ),
// elevation: 0,
// ),
body: Stack(children: [
// First half of the screen with background color
Visibility( Visibility(
visible: _size.width <= visible: _size.width <= 1100,
1100, // Show only for screen width less than or equal to 1100 (mobile view)
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30), // Adjust border radius as needed bottomLeft: Radius.circular(30),
bottomRight: bottomRight: Radius.circular(30),
Radius.circular(30), // Adjust border radius as needed
), ),
child: Container( child: Container(
height: _size.height / 3, // One-third of the screen height height: _size.height / 3,
width: double.infinity, // Full width width: double.infinity,
color: Color(0xFF00989E), // Your desired background color color: Color(0xFF00989E),
child: Stack(
children: [
Column(
children: [
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(
_size.width <= 1100
? 'assets/mobileViewLogo.png'
: 'assets/Nhance-Logo-Final 1.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: TextStyle(
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
),
],
),
),
),
),
],
),
],
),
],
),
), ),
), ),
), ),
// Second half of the screen with the content
Container( Container(
margin: marginInsets, // Adjust bottom margin margin: marginInsets,
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column(children: [ child: Column(
Row(children: [ children: [
if (_size.width > Row(
1100) // Render Expanded column only if screen width is greater than 600 (tablet or larger) children: [
if (_size.width > 1100)
Expanded( Expanded(
flex: _size.width < 1100 flex: _size.width < 1100 ? 6 : 12,
? 6
: 12, // Take 6 parts out of 12
child: LayoutBuilder( child: LayoutBuilder(
builder: (BuildContext context, builder: (BuildContext context,
BoxConstraints constraints) { BoxConstraints constraints) {
// Only show the image column if screen width is greater than 600 (tablet or larger)
if (constraints.maxWidth > 600) { if (constraints.maxWidth > 600) {
return Image.asset( return Image.asset(
'assets/hrLogin.jpg', 'assets/hrLogin.jpg',
@ -252,7 +321,7 @@ class _MyVerifyState extends State<MyHrVerify> {
fit: BoxFit.fill, fit: BoxFit.fill,
); );
} else { } else {
return SizedBox(); // If screen width is smaller, return an empty SizedBox return SizedBox();
} }
}, },
), ),
@ -261,18 +330,27 @@ class _MyVerifyState extends State<MyHrVerify> {
flex: _size.width < 1100 ? 6 : 12, flex: _size.width < 1100 ? 6 : 12,
child: Container( child: Container(
margin: _size.width > 1100 margin: _size.width > 1100
? EdgeInsets.only(left: 150, right: 150) ? EdgeInsets.only(left: 20, right: 20)
: null, : EdgeInsets.only(left: 0, right: 0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
_size.width <= 1100 if (!Responsive.isMobile(context) &&
!Responsive.isTablet(context))
Row(
children: [
Expanded(
flex: 8,
child: Align(
alignment: Alignment
.centerRight, // Align to the start
child: _size.width <= 1100
? Image.asset( ? Image.asset(
'assets/Nhance-Logo-Final-mobile.png', 'assets/Nhance-Logo-Final-mobile.png',
width: 150, width: 150,
height: 150, height: 150,
) )
: _size.width <= 1100 : _size.width > 1100
? Image.asset( ? Image.asset(
'assets/Nhance-Logo-Final 1.png', 'assets/Nhance-Logo-Final 1.png',
width: 150, width: 150,
@ -283,17 +361,36 @@ class _MyVerifyState extends State<MyHrVerify> {
width: 150, width: 150,
height: 150, height: 150,
), ),
SizedBox( )),
height: _size.width <= 1100 ? 50 : 0, ],
), ),
SizedBox(height: 10),
Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text( Text(
"Welcome to Nhance", "Welcome to Nhance",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold,
),
),
],
),
), ),
SizedBox(height: 10), SizedBox(height: 10),
RichText( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
text: text:
@ -319,8 +416,14 @@ class _MyVerifyState extends State<MyHrVerify> {
], ],
), ),
), ),
SizedBox(height: 30), ),
Pinput( SizedBox(height: 15),
Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Pinput(
length: 6, length: 6,
// defaultPinTheme: defaultPinTheme, // defaultPinTheme: defaultPinTheme,
// focusedPinTheme: focusedPinTheme, // focusedPinTheme: focusedPinTheme,
@ -328,9 +431,14 @@ class _MyVerifyState extends State<MyHrVerify> {
showCursor: true, showCursor: true,
controller: _otpController, controller: _otpController,
), ),
SizedBox(height: 15), ),
SizedBox(height: 0), SizedBox(height: 10),
Row( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment
.end, // Align text to the right .end, // Align text to the right
children: [ children: [
@ -352,8 +460,14 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
], ],
), ),
),
SizedBox(height: 10), SizedBox(height: 10),
SizedBox( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: SizedBox(
width: double.infinity, width: double.infinity,
height: 45, height: 45,
child: ElevatedButton( child: ElevatedButton(
@ -365,7 +479,8 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
), ),
onPressed: () { onPressed: () {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!
.validate()) {
_formKey.currentState! _formKey.currentState!
.save(); // Save form fields before calling verifyOTP .save(); // Save form fields before calling verifyOTP
verifyOTP(_otpController.text); verifyOTP(_otpController.text);
@ -373,37 +488,22 @@ class _MyVerifyState extends State<MyHrVerify> {
}, },
child: Text( child: Text(
"Submit", "Submit",
style: style: TextStyle(
TextStyle(color: Color(0xFFFFFFFF)), color: Color(0xFFFFFFFF)),
),
), ),
), ),
), ),
// Row(
// children: [
// TextButton(
// onPressed: () {
// Navigator.pushNamedAndRemoveUntil(
// context,
// 'phone',
// (route) => false,
// );
// },
// child: Text("Edit Phone Number?",
// style: TextStyle(
// color: Color(0xFFE26728))),
// ),
// ],
// ),
SizedBox( SizedBox(
height: _size.width <= 1100 ? 0 : 0, height: _size.width <= 1100 ? 0 : 0,
), // Added SizedBox ),
_size.width > 1100 _size.width > 1100
? // Conditionally rendering based on screen width ? Container(
Column( margin: EdgeInsets.symmetric(
horizontal: 150),
child: Column(
children: [ children: [
SizedBox( SizedBox(height: 30),
height: 15), // Added SizedBox
Text( Text(
"Benefits of Login", "Benefits of Login",
style: TextStyle( style: TextStyle(
@ -413,10 +513,12 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
SizedBox(height: 15), SizedBox(height: 15),
], ],
) ))
: SizedBox(), // Added SizedBox : SizedBox(),
_size.width > 1100 _size.width > 1100
? Container( ? Container(
margin: EdgeInsets.symmetric(
horizontal: 150),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -424,9 +526,9 @@ class _MyVerifyState extends State<MyHrVerify> {
Expanded( Expanded(
flex: 6, flex: 6,
child: Container( child: Container(
padding: EdgeInsets.symmetric( padding:
EdgeInsets.symmetric(
vertical: 8), vertical: 8),
// color: Colors.grey[200],
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment MainAxisAlignment
@ -436,11 +538,13 @@ class _MyVerifyState extends State<MyHrVerify> {
child: Container( child: Container(
padding: EdgeInsets padding: EdgeInsets
.symmetric( .symmetric(
vertical: 12), vertical:
12),
decoration: decoration:
BoxDecoration( BoxDecoration(
border: Border( border: Border(
right: BorderSide( right:
BorderSide(
width: 1, width: 1,
color: Colors color: Colors
.black, .black,
@ -449,7 +553,9 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
child: Column( child: Column(
children: [ children: [
Icon(Icons.policy, Icon(
Icons
.policy,
color: Color( color: Color(
0xFFE26728)), 0xFFE26728)),
SizedBox( SizedBox(
@ -464,7 +570,8 @@ class _MyVerifyState extends State<MyHrVerify> {
child: Container( child: Container(
padding: EdgeInsets padding: EdgeInsets
.symmetric( .symmetric(
vertical: 12), vertical:
12),
child: Column( child: Column(
children: [ children: [
Icon(Icons.edit, Icon(Icons.edit,
@ -486,14 +593,18 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
) )
: SizedBox( : SizedBox(
height: _size.height * 0.2, height:
Responsive.isDesktop(context)
? _size.height * 0.1
: _size.height * 0.2,
), ),
SizedBox( SizedBox(
height: _size.height * 0.1, height: _size.height * 0.1,
), ),
Container( Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
padding: EdgeInsets.symmetric(vertical: 8), padding:
EdgeInsets.symmetric(vertical: 8),
child: RichText( child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
@ -531,10 +642,17 @@ class _MyVerifyState extends State<MyHrVerify> {
), ),
], ],
), ),
),
),
],
),
],
),
),
),
),
],
)), )),
]) ));
]))))
]),
);
} }
} }

View File

@ -1,6 +1,3 @@
import 'dart:js';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:nhancepolicy/addons.dart'; import 'package:nhancepolicy/addons.dart';
import 'package:nhancepolicy/empReview.dart'; import 'package:nhancepolicy/empReview.dart';

View File

@ -45,9 +45,11 @@ class _MyPhoneState extends State<MyPhone> {
bool userVerification = data['data']['user_verification']; bool userVerification = data['data']['user_verification'];
return userVerification; return userVerification;
} else { } else {
ToastHelper.showErrorToast(context, 'Failed to verify mobile number');
throw Exception('Failed to verify mobile number'); throw Exception('Failed to verify mobile number');
} }
} catch (e) { } catch (e) {
ToastHelper.showErrorToast(context, '$e');
print('Error: $e'); print('Error: $e');
return false; return false;
} }
@ -61,9 +63,10 @@ class _MyPhoneState extends State<MyPhone> {
bool isValid = await verifyMobileNumber(enteredMobileNumber); bool isValid = await verifyMobileNumber(enteredMobileNumber);
if (isValid) { if (isValid) {
ToastHelper.showSuccessToast(context, 'Mobile No Verified..');
Navigator.pushNamed(context, 'verify', arguments: enteredMobileNumber); Navigator.pushNamed(context, 'verify', arguments: enteredMobileNumber);
} else { } else {
// ToastHelper.showErrorToast(context, 'Invalid mobile number'); ToastHelper.showErrorToast(context, 'Invalid mobile number..');
print('Invalid mobile number'); print('Invalid mobile number');
} }
} }
@ -115,6 +118,106 @@ class _MyPhoneState extends State<MyPhone> {
height: _size.height / 3, height: _size.height / 3,
width: double.infinity, width: double.infinity,
color: Color(0xFF00989E), color: Color(0xFF00989E),
child: Stack(
children: [
// Positioned(
// top: 40, // Adjust top position as needed
// right: 10, // Align to the right
// 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(
// children: [
// Text(
// 'HR Login',
// style: TextStyle(
// 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
// ),
// ],
// ),
// ),
// ),
// ),
Column(
children: [
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(
_size.width <= 1100
? 'assets/mobileViewLogo.png'
: 'assets/Nhance-Logo-Final 1.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: TextStyle(
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
),
],
),
),
),
),
],
),
],
),
],
),
), ),
), ),
), ),
@ -133,17 +236,22 @@ class _MyPhoneState extends State<MyPhone> {
child: Container( child: Container(
margin: _size.width > 1100 margin: _size.width > 1100
? EdgeInsets.only(left: 20, right: 20) ? EdgeInsets.only(left: 20, right: 20)
: null, : EdgeInsets.only(left: 0, right: 0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
if (!Responsive.isMobile(context) &&
!Responsive.isTablet(context))
Row( Row(
children: [ children: [
Expanded( Expanded(
flex: 10, flex: 10,
child: Align( child: Align(
alignment: Alignment alignment: Responsive.isDesktop(
.centerLeft, // Align to the start context)
? Alignment.centerLeft
: Alignment
.bottomCenter, // Align to the start
child: _size.width <= 1100 child: _size.width <= 1100
? Image.asset( ? Image.asset(
'assets/Nhance-Logo-Final-mobile.png', 'assets/Nhance-Logo-Final-mobile.png',
@ -165,7 +273,8 @@ class _MyPhoneState extends State<MyPhone> {
Expanded( Expanded(
flex: 2, flex: 2,
child: Align( child: Align(
alignment: Alignment.centerRight, alignment:
Alignment.centerRight,
child: MouseRegion( child: MouseRegion(
cursor: cursor:
SystemMouseCursors.click, SystemMouseCursors.click,
@ -202,8 +311,10 @@ class _MyPhoneState extends State<MyPhone> {
), ),
SizedBox(height: 15), SizedBox(height: 15),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -222,8 +333,10 @@ class _MyPhoneState extends State<MyPhone> {
height: 15, height: 15,
), ),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -245,8 +358,10 @@ class _MyPhoneState extends State<MyPhone> {
), ),
Container( Container(
height: 55, height: 55,
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
width: 1, color: Colors.grey), width: 1, color: Colors.grey),
@ -313,8 +428,10 @@ class _MyPhoneState extends State<MyPhone> {
height: 20, height: 20,
), ),
Container( Container(
margin: margin: Responsive.isDesktop(context)
EdgeInsets.symmetric(horizontal: 150), ? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
height: 45, height: 45,
@ -434,7 +551,10 @@ class _MyPhoneState extends State<MyPhone> {
), ),
) )
: SizedBox( : SizedBox(
height: _size.height * 0.2, height:
Responsive.isDesktop(context)
? _size.height * 0.1
: _size.height * 0.2,
), ),
SizedBox( SizedBox(
height: _size.height * 0.1, height: _size.height * 0.1,

View File

@ -24,6 +24,10 @@ class _MyVerifyState extends State<MyVerify> {
late Timer _timer; late Timer _timer;
int _secondsRemaining = 30; int _secondsRemaining = 30;
bool _isTimerRunning = false; bool _isTimerRunning = false;
dynamic empCodeString;
dynamic empPrimaryId;
dynamic gpaEmpName;
dynamic client_id;
@override @override
void initState() { void initState() {
@ -74,6 +78,7 @@ class _MyVerifyState extends State<MyVerify> {
ToastHelper.showSuccessToast(context, 'OTP resent successfully'); ToastHelper.showSuccessToast(context, 'OTP resent successfully');
} else { } else {
// Handle other response status codes // Handle other response status codes
ToastHelper.showErrorToast(context, 'Failed to resend OTP');
throw Exception('Failed to resend OTP'); throw Exception('Failed to resend OTP');
} }
} catch (e) { } catch (e) {
@ -105,23 +110,47 @@ class _MyVerifyState extends State<MyVerify> {
if (status == 'success') { if (status == 'success') {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('token', data['data']); prefs.setString('token', data['data']);
// Store data in local storage (if needed)
// SharedPreferences prefs = await SharedPreferences.getInstance(); // Decode the JWT token received from the API response
// await prefs.setString('userData', json.encode(data['data'])); Map<String, dynamic>? decodedToken = Jwt.parseJwt(data['data']);
// ToastHelper.showSuccessToast(context, 'Successfully Login'); print(decodedToken);
empCodeString = decodedToken['emp_code'].toString();
prefs.setString('empCode', empCodeString);
empPrimaryId = decodedToken['id'];
prefs.setString('empPrimaryId', empPrimaryId);
gpaEmpName = decodedToken['name'].toString();
prefs.setString('gpaEmpName', gpaEmpName);
client_id = decodedToken['client_id'];
prefs.setString('client_id', client_id);
print('Successfully Login'); print('Successfully Login');
// Redirect to another page // Redirect to another page
Navigator.pushNamed(context, 'empDetails'); final token = prefs.getString('token');
if (token != null && token.isNotEmpty) {
ToastHelper.showSuccessToast(context, 'Successfully Login');
Navigator.pushReplacementNamed(context, 'empDetails',
arguments: {'mobile': ''});
} else { } else {
// Token is empty or null, handle accordingly (e.g., navigate to login screen)
// For now, let's navigate to the login screen
ToastHelper.showErrorToast(context, 'Session Out');
Navigator.pushReplacementNamed(context, 'phone');
}
} else {
ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
// Show a Snackbar if the OTP is invalid // Show a Snackbar if the OTP is invalid
// ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again'); // ToastHelper.showErrorToast(context, 'Invalid OTP. Please try again');
print('Invalid OTP. Please try again'); print('Invalid OTP. Please try again');
} }
} else { } else {
ToastHelper.showErrorToast(context, 'Failed to verify OTP');
throw Exception('Failed to verify OTP'); throw Exception('Failed to verify OTP');
} }
} catch (e) { } catch (e) {
print('Error: $e'); print('Error: $e');
ToastHelper.showErrorToast(
context, 'Failed to verify OTP. Please try again.');
// Show a Snackbar if there's an error while verifying OTP // Show a Snackbar if there's an error while verifying OTP
// ToastHelper.showErrorToast( // ToastHelper.showErrorToast(
// context, 'Failed to verify OTP. Please try again.'); // context, 'Failed to verify OTP. Please try again.');
@ -184,63 +213,134 @@ class _MyVerifyState extends State<MyVerify> {
); );
return Scaffold( return Scaffold(
// extendBodyBehindAppBar: true, body: SingleChildScrollView(
// appBar: AppBar( keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
// backgroundColor: Colors.transparent, child: Container(
// leading: IconButton( height: _size.height,
// onPressed: () { color: Colors.white,
// Navigator.pop(context); child: Stack(
// }, children: [
// icon: Icon(
// Icons.arrow_back_ios_rounded,
// color: Colors.black,
// ),
// ),
// elevation: 0,
// ),
body: Stack(children: [
// First half of the screen with background color
Visibility( Visibility(
visible: _size.width <= visible: _size.width <= 1100,
1100, // Show only for screen width less than or equal to 1100 (mobile view)
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30), // Adjust border radius as needed bottomLeft: Radius.circular(30),
bottomRight: bottomRight: Radius.circular(30),
Radius.circular(30), // Adjust border radius as needed
), ),
child: Container( child: Container(
height: _size.height / 3, // One-third of the screen height height: _size.height / 3,
width: double.infinity, // Full width width: double.infinity,
color: Color(0xFF00989E), // Your desired background color color: Color(0xFF00989E),
child: Stack(
children: [
Column(
children: [
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(
_size.width <= 1100
? 'assets/mobileViewLogo.png'
: 'assets/Nhance-Logo-Final 1.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: TextStyle(
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
),
],
),
),
),
),
],
),
],
),
],
),
), ),
), ),
), ),
// Second half of the screen with the content
Container( Container(
margin: marginInsets, // Adjust bottom margin margin: marginInsets,
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column(children: [ child: Column(
Row(children: [ children: [
Row(
children: [
Expanded( Expanded(
flex: _size.width < 1100 ? 6 : 12, flex: _size.width < 1100 ? 6 : 12,
child: Container( child: Container(
margin: _size.width > 1100 margin: _size.width > 1100
? EdgeInsets.only(left: 150, right: 150) ? EdgeInsets.only(left: 20, right: 20)
: null, : EdgeInsets.only(left: 0, right: 0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
_size.width <= 1100 if (!Responsive.isMobile(context) &&
!Responsive.isTablet(context))
Row(
children: [
Expanded(
flex: 10,
child: Align(
alignment: Responsive.isDesktop(
context)
? Alignment.centerLeft
: Alignment
.bottomCenter, // Align to the start
child: _size.width <= 1100
? Image.asset( ? Image.asset(
'assets/Nhance-Logo-Final-mobile.png', 'assets/Nhance-Logo-Final-mobile.png',
width: 150, width: 150,
height: 150, height: 150,
) )
: _size.width <= 1100 : _size.width > 1100
? Image.asset( ? Image.asset(
'assets/Nhance-Logo-Final 1.png', 'assets/Nhance-Logo-Final 1.png',
width: 150, width: 150,
@ -251,17 +351,36 @@ class _MyVerifyState extends State<MyVerify> {
width: 150, width: 150,
height: 150, height: 150,
), ),
SizedBox( )),
height: _size.width <= 1100 ? 50 : 0, ],
), ),
SizedBox(height: 10),
Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text( Text(
"Welcome to Nhance", "Welcome to Nhance",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold,
),
),
],
),
), ),
SizedBox(height: 10), SizedBox(height: 10),
RichText( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
text: text:
@ -287,8 +406,14 @@ class _MyVerifyState extends State<MyVerify> {
], ],
), ),
), ),
SizedBox(height: 30), ),
Pinput( SizedBox(height: 15),
Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Pinput(
length: 6, length: 6,
// defaultPinTheme: defaultPinTheme, // defaultPinTheme: defaultPinTheme,
// focusedPinTheme: focusedPinTheme, // focusedPinTheme: focusedPinTheme,
@ -296,9 +421,14 @@ class _MyVerifyState extends State<MyVerify> {
showCursor: true, showCursor: true,
controller: _otpController, controller: _otpController,
), ),
SizedBox(height: 15), ),
SizedBox(height: 0), SizedBox(height: 10),
Row( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment
.end, // Align text to the right .end, // Align text to the right
children: [ children: [
@ -320,8 +450,14 @@ class _MyVerifyState extends State<MyVerify> {
), ),
], ],
), ),
),
SizedBox(height: 10), SizedBox(height: 10),
SizedBox( Container(
margin: Responsive.isDesktop(context)
? EdgeInsets.symmetric(
horizontal: 150)
: EdgeInsets.symmetric(horizontal: 0),
child: SizedBox(
width: double.infinity, width: double.infinity,
height: 45, height: 45,
child: ElevatedButton( child: ElevatedButton(
@ -333,7 +469,8 @@ class _MyVerifyState extends State<MyVerify> {
), ),
), ),
onPressed: () { onPressed: () {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!
.validate()) {
_formKey.currentState! _formKey.currentState!
.save(); // Save form fields before calling verifyOTP .save(); // Save form fields before calling verifyOTP
verifyOTP(_otpController.text); verifyOTP(_otpController.text);
@ -341,37 +478,19 @@ class _MyVerifyState extends State<MyVerify> {
}, },
child: Text( child: Text(
"Submit", "Submit",
style: style: TextStyle(
TextStyle(color: Color(0xFFFFFFFF)), color: Color(0xFFFFFFFF)),
),
), ),
), ),
), ),
// Row(
// children: [
// TextButton(
// onPressed: () {
// Navigator.pushNamedAndRemoveUntil(
// context,
// 'phone',
// (route) => false,
// );
// },
// child: Text("Edit Phone Number?",
// style: TextStyle(
// color: Color(0xFFE26728))),
// ),
// ],
// ),
SizedBox(
height: _size.width <= 1100 ? 0 : 0,
), // Added SizedBox
_size.width > 1100 _size.width > 1100
? // Conditionally rendering based on screen width ? Container(
Column( margin: EdgeInsets.symmetric(
horizontal: 150),
child: Column(
children: [ children: [
SizedBox( SizedBox(height: 30),
height: 15), // Added SizedBox
Text( Text(
"Benefits of Login", "Benefits of Login",
style: TextStyle( style: TextStyle(
@ -381,10 +500,12 @@ class _MyVerifyState extends State<MyVerify> {
), ),
SizedBox(height: 15), SizedBox(height: 15),
], ],
) ))
: SizedBox(), // Added SizedBox : SizedBox(),
_size.width > 1100 _size.width > 1100
? Container( ? Container(
margin: EdgeInsets.symmetric(
horizontal: 150),
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
@ -392,9 +513,9 @@ class _MyVerifyState extends State<MyVerify> {
Expanded( Expanded(
flex: 6, flex: 6,
child: Container( child: Container(
padding: EdgeInsets.symmetric( padding:
EdgeInsets.symmetric(
vertical: 8), vertical: 8),
// color: Colors.grey[200],
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment MainAxisAlignment
@ -404,11 +525,13 @@ class _MyVerifyState extends State<MyVerify> {
child: Container( child: Container(
padding: EdgeInsets padding: EdgeInsets
.symmetric( .symmetric(
vertical: 12), vertical:
12),
decoration: decoration:
BoxDecoration( BoxDecoration(
border: Border( border: Border(
right: BorderSide( right:
BorderSide(
width: 1, width: 1,
color: Colors color: Colors
.black, .black,
@ -417,7 +540,9 @@ class _MyVerifyState extends State<MyVerify> {
), ),
child: Column( child: Column(
children: [ children: [
Icon(Icons.policy, Icon(
Icons
.policy,
color: Color( color: Color(
0xFFE26728)), 0xFFE26728)),
SizedBox( SizedBox(
@ -432,7 +557,8 @@ class _MyVerifyState extends State<MyVerify> {
child: Container( child: Container(
padding: EdgeInsets padding: EdgeInsets
.symmetric( .symmetric(
vertical: 12), vertical:
12),
child: Column( child: Column(
children: [ children: [
Icon(Icons.edit, Icon(Icons.edit,
@ -454,14 +580,18 @@ class _MyVerifyState extends State<MyVerify> {
), ),
) )
: SizedBox( : SizedBox(
height: _size.height * 0.2, height:
Responsive.isDesktop(context)
? _size.height * 0.1
: _size.height * 0.2,
), ),
SizedBox( SizedBox(
height: _size.height * 0.1, height: _size.height * 0.1,
), ),
Container( Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
padding: EdgeInsets.symmetric(vertical: 8), padding:
EdgeInsets.symmetric(vertical: 8),
child: RichText( child: RichText(
textAlign: TextAlign.center, textAlign: TextAlign.center,
text: TextSpan( text: TextSpan(
@ -499,17 +629,14 @@ class _MyVerifyState extends State<MyVerify> {
), ),
], ],
), ),
)), ),
if (_size.width > ),
1100) // Render Expanded column only if screen width is greater than 600 (tablet or larger) if (_size.width > 1100)
Expanded( Expanded(
flex: _size.width < 1100 flex: _size.width < 1100 ? 6 : 12,
? 6
: 12, // Take 6 parts out of 12
child: LayoutBuilder( child: LayoutBuilder(
builder: (BuildContext context, builder: (BuildContext context,
BoxConstraints constraints) { BoxConstraints constraints) {
// Only show the image column if screen width is greater than 600 (tablet or larger)
if (constraints.maxWidth > 600) { if (constraints.maxWidth > 600) {
return Image.asset( return Image.asset(
'assets/login_web.jpg', 'assets/login_web.jpg',
@ -517,14 +644,20 @@ class _MyVerifyState extends State<MyVerify> {
fit: BoxFit.fill, fit: BoxFit.fill,
); );
} else { } else {
return SizedBox(); // If screen width is smaller, return an empty SizedBox return SizedBox();
} }
}, },
), ),
), ),
]) ],
])))) ),
]), ],
); ),
),
),
),
],
)),
));
} }
} }

View File

@ -48,6 +48,8 @@ dependencies:
data_tables: ^1.4.0 data_tables: ^1.4.0
universal_html: ^2.2.4 universal_html: ^2.2.4
excel: ^4.0.3 excel: ^4.0.3
intl: ^0.19.0
toastification: ^1.2.1
dev_dependencies: dev_dependencies:

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -32,14 +32,47 @@
<title>nhancepolicy</title> <title>nhancepolicy</title>
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<style>
.content {
width: 10%;
height: 10vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #FFFCE5; /* Overlay background color with opacity */
display: flex;
justify-content: center;
align-items: center;
}
/* Styles for the loading indicator */
.indicator {
width: 5vw;
}
</style>
<script> <script>
// The value below is injected by flutter build, do not touch. // The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null; const serviceWorkerVersion = null;
</script> </script>
<!-- This script adds the flutter initialization JS code --> <!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script> <script src="flutter.js" defer></script>
</head> </head>
<body> <body style="overflow:hidden">
<div id="loading_indicator" class="container overlay">
<img class="indicator" src="assets/nhance-loader.gif">
</div>
<script> <script>
window.addEventListener('load', function(ev) { window.addEventListener('load', function(ev) {
// Download main.dart.js // Download main.dart.js
@ -55,5 +88,15 @@
}); });
}); });
</script> </script>
<script>
window.onLoad = function(){
setTimeout(function () {
var loadingIndicator = document.getElementById("loading_indicator");
if(loadingIndicator){
loadingIndicator.remove();
}
},10000);
};
</script>
</body> </body>
</html> </html>