Attendence and leave
This commit is contained in:
parent
288d3caa9f
commit
79250d06c3
@ -5,7 +5,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:label="cheminova"
|
||||
android:label="Territory Manager"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
|
3
devtools_options.yaml
Normal file
3
devtools_options.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
@ -13,7 +13,7 @@
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>cheminova</string>
|
||||
<string>Territory Manager</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
|
@ -1,12 +1,9 @@
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
import 'package:cheminova/services/api_urls.dart';
|
||||
import 'package:cheminova/services/secure__storage_service.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AttendanceProvider extends ChangeNotifier {
|
||||
final _storageService = SecureStorageService();
|
||||
|
||||
final _apiClient = ApiClient();
|
||||
bool _isLoading = false;
|
||||
|
||||
@ -34,6 +31,15 @@ class AttendanceProvider extends ChangeNotifier {
|
||||
} else {
|
||||
return (false, response.data['message'].toString());
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
setLoading(false);
|
||||
if (e.response != null && e.response?.data != null) {
|
||||
// Extracting the error message from the Dio response
|
||||
return (false, e.response!.data['message'].toString());
|
||||
} else {
|
||||
// When no response or response data is available
|
||||
return (false, 'Something went wrong');
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
return (false, 'Something want wrong');
|
||||
|
91
lib/provider/mark_leave_provider.dart
Normal file
91
lib/provider/mark_leave_provider.dart
Normal file
@ -0,0 +1,91 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../services/api_client.dart';
|
||||
import '../services/api_urls.dart';
|
||||
|
||||
class MarkLeaveProvider extends ChangeNotifier {
|
||||
final _apiClient = ApiClient();
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
void setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final dateController = TextEditingController(
|
||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
||||
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
|
||||
final locationController = TextEditingController();
|
||||
final notesController = TextEditingController();
|
||||
|
||||
String selectedLeaveType = 'Sick';
|
||||
|
||||
void onLeaveTypeSelected(String leaveType) {
|
||||
selectedLeaveType = leaveType;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Widget buildLeaveTypeOption(String leaveType) {
|
||||
bool isSelected = leaveType == selectedLeaveType;
|
||||
return GestureDetector(
|
||||
onTap: () => onLeaveTypeSelected(leaveType),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
width: 120,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.blue : Colors.white,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
leaveType,
|
||||
style: TextStyle(
|
||||
color: isSelected ? Colors.white : Colors.black,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<(bool, String)> markLeave(String date, String time, String location,
|
||||
String reason, String leaveType) async {
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.post(ApiUrls.markLeaveUrl, data: {
|
||||
"date": date,
|
||||
"time": time,
|
||||
"reason": reason,
|
||||
"leaveType": '$leaveType Leave',
|
||||
"location": location
|
||||
});
|
||||
setLoading(false);
|
||||
if (response.statusCode == 200) {
|
||||
return (true, response.data['message'].toString());
|
||||
} else {
|
||||
return (false, response.data['message'].toString());
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
setLoading(false);
|
||||
if (e.response != null && e.response?.data != null) {
|
||||
// Extracting the error message from the Dio response
|
||||
return (false, e.response!.data['message'].toString());
|
||||
} else {
|
||||
// When no response or response data is available
|
||||
return (false, 'Something went wrong');
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
return (false, 'Something want wrong');
|
||||
}
|
||||
}
|
||||
}
|
@ -43,6 +43,7 @@ class UserProvider extends ChangeNotifier {
|
||||
|
||||
Future<void> clearUserProfile() async {
|
||||
_user = null;
|
||||
await SecureStorageService().delete(key: 'user');
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
155
lib/screens/assign_task_screen.dart
Normal file
155
lib/screens/assign_task_screen.dart
Normal file
@ -0,0 +1,155 @@
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AssignTaskScreen extends StatefulWidget {
|
||||
const AssignTaskScreen({super.key});
|
||||
|
||||
@override
|
||||
State<AssignTaskScreen> createState() => _AssignTaskScreenState();
|
||||
}
|
||||
|
||||
class _AssignTaskScreenState extends State<AssignTaskScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: CommonAppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: const Center(
|
||||
child: Text(
|
||||
'Assign Tasks',
|
||||
style: TextStyle(color: Colors.black87, fontSize: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: CommonBackground(
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20.0).copyWith(top: 15, bottom: 30),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30.0)
|
||||
.copyWith(bottom: 50),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(26.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Assign Tasks',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 200,
|
||||
width: MediaQuery.of(context).size.width / 4.2,
|
||||
child: _customCard(title: "Total Tasks", subtitle: "100"),
|
||||
),
|
||||
SizedBox(
|
||||
height: 200,
|
||||
width: MediaQuery.of(context).size.width / 4.2,
|
||||
child:
|
||||
_customCard(title: "Tasks Pending", subtitle: "100"),
|
||||
),
|
||||
SizedBox(
|
||||
height: 200,
|
||||
width: MediaQuery.of(context).size.width / 4.2,
|
||||
child: _customCard(
|
||||
title: "Reports Submitted", subtitle: "100"),
|
||||
),
|
||||
],
|
||||
),
|
||||
CommonElevatedButton(
|
||||
backgroundColor: const Color(0xff004791),
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'ASSIGN TASKS',
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonElevatedButton(
|
||||
backgroundColor: const Color(0xff004791),
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'VIEW TASK STATUS',
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonElevatedButton(
|
||||
backgroundColor: const Color(0xff004791),
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'MANAGE SCs',
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _customCard({required String title, required String subtitle}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8.0).copyWith(top: 15, bottom: 30),
|
||||
margin: const EdgeInsets.all(4).copyWith(bottom: 30),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.6),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 34,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import 'package:cheminova/provider/user_provider.dart';
|
||||
import 'package:cheminova/screens/assign_task_screen.dart';
|
||||
import 'package:cheminova/screens/calendar_screen.dart';
|
||||
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
||||
import 'package:cheminova/screens/mark_attendence_screen.dart';
|
||||
@ -8,7 +9,6 @@ import 'package:cheminova/screens/summary_screen.dart';
|
||||
import 'package:cheminova/screens/product_sales_data.dart';
|
||||
import 'package:cheminova/screens/update_inventory_screen.dart';
|
||||
import 'package:cheminova/screens/display_sales_screen.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
@ -43,7 +43,7 @@ class _HomePageState extends State<HomePage> {
|
||||
// backgroundImage: AssetImage(
|
||||
// 'assets/profile.png'), // Replace with actual user image
|
||||
// ),
|
||||
const SizedBox(width: 10),
|
||||
// const SizedBox(width: 10),
|
||||
Consumer<UserProvider>(
|
||||
builder: (context, userProvider, child) {
|
||||
return Column(
|
||||
@ -107,7 +107,13 @@ class _HomePageState extends State<HomePage> {
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
_buildCustomCard('Assign Tasks', '', onTap: () {}),
|
||||
_buildCustomCard('Assign Tasks', '', onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const AssignTaskScreen(),
|
||||
));
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:cheminova/provider/login_provider.dart';
|
||||
import 'package:cheminova/screens/forgot_password_screen.dart';
|
||||
import 'package:cheminova/screens/home_screen.dart';
|
||||
import 'package:cheminova/screens/verify_phone_screen.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||
import 'package:cheminova/widgets/common_text_form_field.dart';
|
||||
|
@ -11,6 +11,7 @@ import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MarkAttendanceScreen extends StatefulWidget {
|
||||
const MarkAttendanceScreen({super.key});
|
||||
|
||||
@ -21,7 +22,7 @@ class MarkAttendanceScreen extends StatefulWidget {
|
||||
class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
late AttendanceProvider attendanceProvider;
|
||||
final dateController = TextEditingController(
|
||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
||||
text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
|
||||
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
@ -32,7 +33,7 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
attendanceProvider=AttendanceProvider();
|
||||
attendanceProvider = AttendanceProvider();
|
||||
_getCurrentLocation();
|
||||
}
|
||||
|
||||
@ -65,7 +66,7 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
|
||||
Placemark place = placeMarks[0];
|
||||
setState(() {
|
||||
locationController.text = place.locality??'';
|
||||
locationController.text = place.locality ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
@ -74,7 +75,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
return ChangeNotifierProvider<AttendanceProvider>(
|
||||
create: (_) => attendanceProvider,
|
||||
builder: (context, child) => CommonBackground(
|
||||
child: Scaffold(backgroundColor: Colors.transparent,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
@ -90,7 +92,9 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
fontSize: 28,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0,
|
||||
fontFamily: 'Anek')),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Stack(
|
||||
@ -105,8 +109,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||
padding: const EdgeInsets.all(20.0)
|
||||
.copyWith(top: 30, bottom: 30),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
@ -149,7 +153,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
AttendanceProvider value,
|
||||
Widget? child) =>
|
||||
CommonElevatedButton(
|
||||
backgroundColor: const Color(0xff004791),
|
||||
backgroundColor:
|
||||
const Color(0xff004791),
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
@ -157,16 +162,22 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
onPressed: () {
|
||||
value
|
||||
.markAttendance(
|
||||
dateController.text.trim(),
|
||||
timeController.text.trim(),
|
||||
locationController.text.trim(),
|
||||
notesController.text.trim())
|
||||
dateController.text
|
||||
.trim(),
|
||||
timeController.text
|
||||
.trim(),
|
||||
locationController.text
|
||||
.trim(),
|
||||
notesController.text
|
||||
.trim())
|
||||
.then(
|
||||
(result) {
|
||||
var (status, message) = result;
|
||||
var (status, message) =
|
||||
result;
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text(message)));
|
||||
content:
|
||||
Text(message)));
|
||||
if (status) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
@ -210,17 +221,18 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Consumer<AttendanceProvider>(builder: (context, value, child) {
|
||||
if(value.isLoading){
|
||||
return
|
||||
Container(
|
||||
child: Consumer<AttendanceProvider>(
|
||||
builder: (context, value, child) {
|
||||
if (value.isLoading) {
|
||||
return Container(
|
||||
color: Colors.black12,
|
||||
child: const Center(child: CircularProgressIndicator()));
|
||||
}
|
||||
else{
|
||||
return const SizedBox();
|
||||
}
|
||||
}, ),
|
||||
child:
|
||||
const Center(child: CircularProgressIndicator()));
|
||||
} else {
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/provider/mark_leave_provider.dart';
|
||||
import 'package:cheminova/screens/Attendance_success.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -5,6 +6,7 @@ import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../widgets/common_app_bar.dart';
|
||||
import '../widgets/common_elevated_button.dart';
|
||||
import '../widgets/common_text_form_field.dart';
|
||||
@ -17,11 +19,13 @@ class OnLeaveScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||
late MarkLeaveProvider _markLeaveProvider;
|
||||
|
||||
final dateController = TextEditingController(
|
||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
||||
text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
|
||||
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
|
||||
final locationController = TextEditingController();
|
||||
final notesController = TextEditingController();
|
||||
@ -39,7 +43,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onLeaveTypeSelected(leaveType),
|
||||
child: Container(margin: EdgeInsets.only(bottom: 10),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
width: 120,
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
decoration: BoxDecoration(
|
||||
@ -58,9 +63,11 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_markLeaveProvider = MarkLeaveProvider();
|
||||
_getCurrentLocation();
|
||||
}
|
||||
|
||||
@ -87,8 +94,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||
debugPrint('position--- $position');
|
||||
|
||||
List<Placemark> placeMarks =
|
||||
await placemarkFromCoordinates(position.latitude, position.longitude)
|
||||
.timeout(const Duration(seconds: 10));
|
||||
await placemarkFromCoordinates(position.latitude, position.longitude)
|
||||
.timeout(const Duration(seconds: 10));
|
||||
debugPrint('place mark--- $placeMarks');
|
||||
|
||||
Placemark place = placeMarks[0];
|
||||
@ -99,103 +106,140 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonBackground(
|
||||
child: Scaffold(backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: ()
|
||||
{
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: const Text('On Leave',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CommonTextFormField(
|
||||
title: 'Date',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: dateController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Time',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: timeController),
|
||||
const SizedBox(height: 15),
|
||||
const Text('Leave type',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
const SizedBox(height:3 ),
|
||||
Wrap(direction: Axis.horizontal,
|
||||
children: [
|
||||
buildLeaveTypeOption('Sick'),
|
||||
const SizedBox(width: 10),
|
||||
buildLeaveTypeOption('Personal'),
|
||||
const SizedBox(width: 10),
|
||||
buildLeaveTypeOption('Privilege '),
|
||||
return ChangeNotifierProvider<MarkLeaveProvider>(
|
||||
create: (_) => _markLeaveProvider,
|
||||
builder: (context, child) => CommonBackground(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: const Text('On Leave',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20.0)
|
||||
.copyWith(top: 30, bottom: 30),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CommonTextFormField(
|
||||
title: 'Date',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: dateController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Time',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: timeController),
|
||||
const SizedBox(height: 15),
|
||||
const Text('Leave type',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
const SizedBox(height: 3),
|
||||
Wrap(
|
||||
direction: Axis.horizontal,
|
||||
children: [
|
||||
buildLeaveTypeOption('Sick'),
|
||||
const SizedBox(width: 10),
|
||||
buildLeaveTypeOption('Personal'),
|
||||
const SizedBox(width: 10),
|
||||
buildLeaveTypeOption('Privilege '),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
height: 100,
|
||||
title: 'Reason',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: notesController),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Consumer<MarkLeaveProvider>(
|
||||
builder: (context, value, child) =>
|
||||
CommonElevatedButton(
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'ON LEAVE',
|
||||
backgroundColor:
|
||||
const Color(0xff00784C),
|
||||
onPressed: () {
|
||||
value
|
||||
.markLeave(
|
||||
dateController.text
|
||||
.trim(),
|
||||
timeController.text
|
||||
.trim(),
|
||||
locationController.text
|
||||
.trim(),
|
||||
notesController.text
|
||||
.trim(),
|
||||
selectedLeaveType)
|
||||
.then(
|
||||
(result) {
|
||||
var (status, message) =
|
||||
result;
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
content:
|
||||
Text(message)));
|
||||
if (status) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const AttendanceSuccess()));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),));
|
||||
}),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
height: 100,
|
||||
title: 'Reason',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: notesController),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: CommonElevatedButton(
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'ON LEAVE',
|
||||
backgroundColor: const Color(0xff00784C),
|
||||
onPressed: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const AttendanceSuccess()));
|
||||
|
||||
})
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),),
|
||||
);
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,25 +8,42 @@ class ApiClient {
|
||||
final SecureStorageService _storageService = SecureStorageService();
|
||||
|
||||
ApiClient({String? baseUrl})
|
||||
: _dio = Dio(BaseOptions(
|
||||
: _dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseUrl ?? ApiUrls.baseUrl,
|
||||
connectTimeout: const Duration(seconds: 120),
|
||||
receiveTimeout: const Duration(seconds: 120))) {
|
||||
receiveTimeout: const Duration(seconds: 120),
|
||||
),
|
||||
) {
|
||||
_dio.interceptors.add(
|
||||
InterceptorsWrapper(
|
||||
onRequest: (options, handler) async {
|
||||
String? token = await _storageService.read(key: 'access_token');
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
return handler.next(options);
|
||||
},
|
||||
onResponse: (response, handler) {
|
||||
return handler.next(response);
|
||||
},
|
||||
onError: (DioException e, handler) {
|
||||
return handler.next(e);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
_dio.interceptors
|
||||
.add(LogInterceptor(responseBody: true, requestBody: true));
|
||||
_dio.interceptors.add(PrettyDioLogger());
|
||||
_dio.interceptors
|
||||
.add(InterceptorsWrapper(onRequest: (options, handler) async {
|
||||
String? token = await _storageService.read(key: 'access_token');
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
return handler.next(options);
|
||||
}, onResponse: (response, handler) {
|
||||
return handler.next(response);
|
||||
}, onError: (DioException e, handler) {
|
||||
return handler.next(e);
|
||||
}));
|
||||
_dio.interceptors.add(PrettyDioLogger(
|
||||
requestHeader: true,
|
||||
requestBody: true,
|
||||
responseBody: true,
|
||||
responseHeader: false,
|
||||
error: true,
|
||||
compact: true,
|
||||
maxWidth: 90,
|
||||
));
|
||||
}
|
||||
|
||||
Future<Response> get(String path, {Map<String, dynamic>? queryParameters}) {
|
||||
|
@ -2,7 +2,8 @@ class ApiUrls {
|
||||
static const String baseUrl = 'https://cheminova-api-2.onrender.com/api/';
|
||||
static const String loginUrl = 'territorymanager/login';
|
||||
static const String profileUrl = 'territorymanager/my-profile';
|
||||
static const String markAttendanceUrl = 'v1/markattendance/salescoordinator';
|
||||
static const String markAttendanceUrl = 'v1/markattendance/territorymanager';
|
||||
static const String markLeaveUrl = 'v1/markleave/territorymanager';
|
||||
static const String forgetPasswordUrl = 'territorymanager/forgot-password';
|
||||
static const String changePasswordUrl = 'territorymanager/password/update';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user