Attendence and leave
This commit is contained in:
parent
288d3caa9f
commit
79250d06c3
@ -5,7 +5,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="cheminova"
|
android:label="Territory Manager"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<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>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>cheminova</string>
|
<string>Territory Manager</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import 'package:cheminova/services/api_client.dart';
|
import 'package:cheminova/services/api_client.dart';
|
||||||
import 'package:cheminova/services/api_urls.dart';
|
import 'package:cheminova/services/api_urls.dart';
|
||||||
import 'package:cheminova/services/secure__storage_service.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AttendanceProvider extends ChangeNotifier {
|
class AttendanceProvider extends ChangeNotifier {
|
||||||
final _storageService = SecureStorageService();
|
|
||||||
|
|
||||||
final _apiClient = ApiClient();
|
final _apiClient = ApiClient();
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
|
||||||
@ -34,6 +31,15 @@ class AttendanceProvider extends ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
return (false, response.data['message'].toString());
|
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) {
|
} catch (e) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return (false, 'Something want wrong');
|
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 {
|
Future<void> clearUserProfile() async {
|
||||||
_user = null;
|
_user = null;
|
||||||
|
await SecureStorageService().delete(key: 'user');
|
||||||
notifyListeners();
|
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/provider/user_provider.dart';
|
||||||
|
import 'package:cheminova/screens/assign_task_screen.dart';
|
||||||
import 'package:cheminova/screens/calendar_screen.dart';
|
import 'package:cheminova/screens/calendar_screen.dart';
|
||||||
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
||||||
import 'package:cheminova/screens/mark_attendence_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/product_sales_data.dart';
|
||||||
import 'package:cheminova/screens/update_inventory_screen.dart';
|
import 'package:cheminova/screens/update_inventory_screen.dart';
|
||||||
import 'package:cheminova/screens/display_sales_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:cheminova/widgets/common_drawer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cheminova/widgets/common_background.dart';
|
import 'package:cheminova/widgets/common_background.dart';
|
||||||
@ -43,7 +43,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
// backgroundImage: AssetImage(
|
// backgroundImage: AssetImage(
|
||||||
// 'assets/profile.png'), // Replace with actual user image
|
// 'assets/profile.png'), // Replace with actual user image
|
||||||
// ),
|
// ),
|
||||||
const SizedBox(width: 10),
|
// const SizedBox(width: 10),
|
||||||
Consumer<UserProvider>(
|
Consumer<UserProvider>(
|
||||||
builder: (context, userProvider, child) {
|
builder: (context, userProvider, child) {
|
||||||
return Column(
|
return Column(
|
||||||
@ -107,7 +107,13 @@ class _HomePageState extends State<HomePage> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
_buildCustomCard('Assign Tasks', '', onTap: () {}),
|
_buildCustomCard('Assign Tasks', '', onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const AssignTaskScreen(),
|
||||||
|
));
|
||||||
|
}),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 5,
|
height: 5,
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:cheminova/provider/login_provider.dart';
|
import 'package:cheminova/provider/login_provider.dart';
|
||||||
import 'package:cheminova/screens/forgot_password_screen.dart';
|
import 'package:cheminova/screens/forgot_password_screen.dart';
|
||||||
import 'package:cheminova/screens/home_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_background.dart';
|
||||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||||
import 'package:cheminova/widgets/common_text_form_field.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:geolocator/geolocator.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class MarkAttendanceScreen extends StatefulWidget {
|
class MarkAttendanceScreen extends StatefulWidget {
|
||||||
const MarkAttendanceScreen({super.key});
|
const MarkAttendanceScreen({super.key});
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ class MarkAttendanceScreen extends StatefulWidget {
|
|||||||
class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
||||||
late AttendanceProvider attendanceProvider;
|
late AttendanceProvider attendanceProvider;
|
||||||
final dateController = TextEditingController(
|
final dateController = TextEditingController(
|
||||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
|
||||||
|
|
||||||
final timeController =
|
final timeController =
|
||||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||||
@ -32,7 +33,7 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
attendanceProvider=AttendanceProvider();
|
attendanceProvider = AttendanceProvider();
|
||||||
_getCurrentLocation();
|
_getCurrentLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
|
|
||||||
Placemark place = placeMarks[0];
|
Placemark place = placeMarks[0];
|
||||||
setState(() {
|
setState(() {
|
||||||
locationController.text = place.locality??'';
|
locationController.text = place.locality ?? '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +75,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
return ChangeNotifierProvider<AttendanceProvider>(
|
return ChangeNotifierProvider<AttendanceProvider>(
|
||||||
create: (_) => attendanceProvider,
|
create: (_) => attendanceProvider,
|
||||||
builder: (context, child) => CommonBackground(
|
builder: (context, child) => CommonBackground(
|
||||||
child: Scaffold(backgroundColor: Colors.transparent,
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
appBar: CommonAppBar(
|
appBar: CommonAppBar(
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -90,7 +92,9 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0,
|
fontFamily: 'Anek')),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
),
|
),
|
||||||
drawer: const CommonDrawer(),
|
drawer: const CommonDrawer(),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
@ -105,8 +109,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding: const EdgeInsets.all(20.0)
|
||||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
.copyWith(top: 30, bottom: 30),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 20.0),
|
margin: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.white),
|
border: Border.all(color: Colors.white),
|
||||||
@ -149,7 +153,8 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
AttendanceProvider value,
|
AttendanceProvider value,
|
||||||
Widget? child) =>
|
Widget? child) =>
|
||||||
CommonElevatedButton(
|
CommonElevatedButton(
|
||||||
backgroundColor: const Color(0xff004791),
|
backgroundColor:
|
||||||
|
const Color(0xff004791),
|
||||||
borderRadius: 30,
|
borderRadius: 30,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: kToolbarHeight - 10,
|
height: kToolbarHeight - 10,
|
||||||
@ -157,16 +162,22 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
value
|
value
|
||||||
.markAttendance(
|
.markAttendance(
|
||||||
dateController.text.trim(),
|
dateController.text
|
||||||
timeController.text.trim(),
|
.trim(),
|
||||||
locationController.text.trim(),
|
timeController.text
|
||||||
notesController.text.trim())
|
.trim(),
|
||||||
|
locationController.text
|
||||||
|
.trim(),
|
||||||
|
notesController.text
|
||||||
|
.trim())
|
||||||
.then(
|
.then(
|
||||||
(result) {
|
(result) {
|
||||||
var (status, message) = result;
|
var (status, message) =
|
||||||
|
result;
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
.showSnackBar(SnackBar(
|
.showSnackBar(SnackBar(
|
||||||
content: Text(message)));
|
content:
|
||||||
|
Text(message)));
|
||||||
if (status) {
|
if (status) {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
@ -210,17 +221,18 @@ class _MarkAttendanceScreenState extends State<MarkAttendanceScreen> {
|
|||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Consumer<AttendanceProvider>(builder: (context, value, child) {
|
child: Consumer<AttendanceProvider>(
|
||||||
if(value.isLoading){
|
builder: (context, value, child) {
|
||||||
return
|
if (value.isLoading) {
|
||||||
Container(
|
return Container(
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
child: const Center(child: CircularProgressIndicator()));
|
child:
|
||||||
}
|
const Center(child: CircularProgressIndicator()));
|
||||||
else{
|
} else {
|
||||||
return const SizedBox();
|
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/screens/Attendance_success.dart';
|
||||||
import 'package:cheminova/widgets/common_drawer.dart';
|
import 'package:cheminova/widgets/common_drawer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -5,6 +6,7 @@ import 'package:cheminova/widgets/common_background.dart';
|
|||||||
import 'package:geocoding/geocoding.dart';
|
import 'package:geocoding/geocoding.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import '../widgets/common_app_bar.dart';
|
import '../widgets/common_app_bar.dart';
|
||||||
import '../widgets/common_elevated_button.dart';
|
import '../widgets/common_elevated_button.dart';
|
||||||
import '../widgets/common_text_form_field.dart';
|
import '../widgets/common_text_form_field.dart';
|
||||||
@ -17,8 +19,10 @@ class OnLeaveScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
||||||
|
late MarkLeaveProvider _markLeaveProvider;
|
||||||
|
|
||||||
final dateController = TextEditingController(
|
final dateController = TextEditingController(
|
||||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
|
||||||
|
|
||||||
final timeController =
|
final timeController =
|
||||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||||
@ -39,7 +43,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => onLeaveTypeSelected(leaveType),
|
onTap: () => onLeaveTypeSelected(leaveType),
|
||||||
child: Container(margin: EdgeInsets.only(bottom: 10),
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 10),
|
||||||
width: 120,
|
width: 120,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -58,9 +63,11 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_markLeaveProvider = MarkLeaveProvider();
|
||||||
_getCurrentLocation();
|
_getCurrentLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,16 +106,19 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CommonBackground(
|
return ChangeNotifierProvider<MarkLeaveProvider>(
|
||||||
child: Scaffold(backgroundColor: Colors.transparent,
|
create: (_) => _markLeaveProvider,
|
||||||
|
builder: (context, child) => CommonBackground(
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
appBar: CommonAppBar(
|
appBar: CommonAppBar(
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: ()
|
onPressed: () {
|
||||||
{
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20),
|
icon: Image.asset('assets/Back_attendance.png'),
|
||||||
|
padding: const EdgeInsets.only(right: 20),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
title: const Text('On Leave',
|
title: const Text('On Leave',
|
||||||
@ -116,7 +126,9 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0,
|
fontFamily: 'Anek')),
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
),
|
),
|
||||||
drawer: const CommonDrawer(),
|
drawer: const CommonDrawer(),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
@ -129,8 +141,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding: const EdgeInsets.all(20.0)
|
||||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
.copyWith(top: 30, bottom: 30),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.white),
|
border: Border.all(color: Colors.white),
|
||||||
@ -157,8 +169,9 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontFamily: 'Anek')),
|
fontFamily: 'Anek')),
|
||||||
const SizedBox(height:3 ),
|
const SizedBox(height: 3),
|
||||||
Wrap(direction: Axis.horizontal,
|
Wrap(
|
||||||
|
direction: Axis.horizontal,
|
||||||
children: [
|
children: [
|
||||||
buildLeaveTypeOption('Sick'),
|
buildLeaveTypeOption('Sick'),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@ -177,25 +190,56 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: CommonElevatedButton(
|
child: Consumer<MarkLeaveProvider>(
|
||||||
|
builder: (context, value, child) =>
|
||||||
|
CommonElevatedButton(
|
||||||
borderRadius: 30,
|
borderRadius: 30,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: kToolbarHeight - 10,
|
height: kToolbarHeight - 10,
|
||||||
text: 'ON LEAVE',
|
text: 'ON LEAVE',
|
||||||
backgroundColor: const Color(0xff00784C),
|
backgroundColor:
|
||||||
|
const Color(0xff00784C),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const AttendanceSuccess()));
|
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(),));
|
||||||
|
}),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,25 +8,42 @@ class ApiClient {
|
|||||||
final SecureStorageService _storageService = SecureStorageService();
|
final SecureStorageService _storageService = SecureStorageService();
|
||||||
|
|
||||||
ApiClient({String? baseUrl})
|
ApiClient({String? baseUrl})
|
||||||
: _dio = Dio(BaseOptions(
|
: _dio = Dio(
|
||||||
|
BaseOptions(
|
||||||
baseUrl: baseUrl ?? ApiUrls.baseUrl,
|
baseUrl: baseUrl ?? ApiUrls.baseUrl,
|
||||||
connectTimeout: const Duration(seconds: 120),
|
connectTimeout: const Duration(seconds: 120),
|
||||||
receiveTimeout: const Duration(seconds: 120))) {
|
receiveTimeout: const Duration(seconds: 120),
|
||||||
_dio.interceptors
|
),
|
||||||
.add(LogInterceptor(responseBody: true, requestBody: true));
|
) {
|
||||||
_dio.interceptors.add(PrettyDioLogger());
|
_dio.interceptors.add(
|
||||||
_dio.interceptors
|
InterceptorsWrapper(
|
||||||
.add(InterceptorsWrapper(onRequest: (options, handler) async {
|
onRequest: (options, handler) async {
|
||||||
String? token = await _storageService.read(key: 'access_token');
|
String? token = await _storageService.read(key: 'access_token');
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
options.headers['Authorization'] = 'Bearer $token';
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
}
|
}
|
||||||
return handler.next(options);
|
return handler.next(options);
|
||||||
}, onResponse: (response, handler) {
|
},
|
||||||
|
onResponse: (response, handler) {
|
||||||
return handler.next(response);
|
return handler.next(response);
|
||||||
}, onError: (DioException e, handler) {
|
},
|
||||||
|
onError: (DioException e, handler) {
|
||||||
return handler.next(e);
|
return handler.next(e);
|
||||||
}));
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
_dio.interceptors
|
||||||
|
.add(LogInterceptor(responseBody: true, requestBody: true));
|
||||||
|
_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}) {
|
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 baseUrl = 'https://cheminova-api-2.onrender.com/api/';
|
||||||
static const String loginUrl = 'territorymanager/login';
|
static const String loginUrl = 'territorymanager/login';
|
||||||
static const String profileUrl = 'territorymanager/my-profile';
|
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 forgetPasswordUrl = 'territorymanager/forgot-password';
|
||||||
static const String changePasswordUrl = 'territorymanager/password/update';
|
static const String changePasswordUrl = 'territorymanager/password/update';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user