new changes done

This commit is contained in:
saritabirare 2025-02-06 15:44:18 +05:30
parent d101e82096
commit 2c0797b687
50 changed files with 1156 additions and 366 deletions

View File

@ -1,12 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cheminova">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<application <application
android:label="cheminova" android:label="Principal Distributor"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/launcher_icon">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -427,7 +427,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
@ -484,7 +484,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";

View File

@ -1,122 +1 @@
{ {"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 B

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 862 B

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -9,7 +9,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <string>com.example.cheminova</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>

View File

@ -49,7 +49,7 @@ class CartController extends GetxController {
} }
// Update observable values // Update observable values
subtotal.value = subTotal; subtotal.value = subTotal;
gstTotal.value = gstTotalAmount; gstTotal.value = double.parse(gstTotalAmount.toStringAsFixed(2));
grandTotal.value = subtotal.value + gstTotal.value; grandTotal.value = subtotal.value + gstTotal.value;
} }
// Function to increase the quantity of a product in the cart // Function to increase the quantity of a product in the cart
@ -76,6 +76,15 @@ class CartController extends GetxController {
} }
} }
} }
void updateQuantity(Product product, int quantity) {
final existingProduct = cartList.firstWhereOrNull((p) => p.id == product.id);
if (existingProduct != null) {
existingProduct.quantity = quantity;
updateTotalPrice();// Notify listeners
}
}
// Function to remove a product from the cart // Function to remove a product from the cart
void removeFromCart(Product product) { void removeFromCart(Product product) {
// Remove the product from the cart list // Remove the product from the cart list

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:cheminova/models/user_model.dart'; import 'package:cheminova/models/user_model.dart';
import 'package:cheminova/utils/api_urls.dart'; import 'package:cheminova/utils/api_urls.dart';
import 'package:cheminova/utils/common_api_service.dart'; import 'package:cheminova/utils/common_api_service.dart';
@ -33,35 +35,26 @@ class HomeService {
} }
// Function to send FCM token to the server // Function to send FCM token to the server
Future<Map<String, dynamic>?> fcmToken(Map<String, dynamic> data, Future<Map<String, dynamic>?> fcmToken(Map<String, dynamic> data, String? token) async {
String? token) async {
try { try {
final response = await commonApiService<String>( final response = await commonApiService<Map<String, dynamic>>(
// Making a POST request to send the FCM token
url: ApiUrls.fcmUrl, url: ApiUrls.fcmUrl,
method: 'POST', method: 'POST',
body: data, body: data,
// Body data to be sent in the request fromJson: (json) => json as Map<String, dynamic>, // Parse JSON response
fromJson: (json) => json as String,
// Just return the string response
additionalHeaders: { additionalHeaders: {
// Pass the token here
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
// Bearer token for authenticated requests
}, },
); );
if (response != null) { if (response != null) {
// Since the response is a string, wrap it in a Map to avoid type issues return response; // Return parsed response
return {
'message': response
}; // Return the response in a map with 'message' as the key
} }
return null; return null;
} catch (e) { } catch (e) {
showSnackbar(e.toString()); // Handle any errors showSnackbar(e.toString());
return null; return null;
} }
} }
} }

View File

@ -1,27 +1,69 @@
class Brand { class Brand {
final String id; final String id;
final String brandName; final String brandName;
List<BrandImage> images;
Brand({ Brand({
required this.id, required this.id,
required this.brandName, required this.brandName,
required this.images,
}); });
factory Brand.fromJson(Map<String, dynamic> json) { factory Brand.fromJson(Map<String, dynamic> json) {
return Brand( return Brand(
id: json['_id'], id: json['_id'],
brandName: json['brandName'], brandName: json['brandName'],
images: json["image"] != null
? (json["image"] as List).map((e) => BrandImage.fromJson(e)).toList()
: [],
); );
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {
'_id': id, '_id': id,
'brandName': brandName, 'brandName': brandName,
"image": images.map((e) => e.toJson()).toList(),
}; };
} }
@override @override
String toString() { String toString() {
return 'Brand(id: $id, brandName: $brandName,)'; return 'Brand(id: $id, brandName: $brandName,images: $images)';
}
}
class BrandImage {
String publicId;
String url;
String imageId;
BrandImage({
required this.publicId,
required this.url,
required this.imageId,
});
factory BrandImage.fromJson(Map<String, dynamic> json) {
return BrandImage(
publicId: json["public_id"] ?? "",
url: json["url"] ?? "",
imageId: json["_id"] ?? "",
);
}
Map<String, dynamic> toJson() {
return {
"public_id": publicId,
"url": url,
"_id": imageId,
};
}
@override
String toString() {
return "BrandImage(publicId: $publicId, url: $url, imageId: $imageId)";
} }
} }

View File

@ -1,3 +1,121 @@
// import 'package:cheminova/widgets/my_drawer.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_svg/svg.dart';
// import 'package:get/get.dart';
// import 'package:intl/intl.dart';
//
// import '../../controller/annaucement_controller.dart';
// import '../../widgets/comman_background.dart';
// import '../../widgets/common_appbar.dart';
//
// class AnnouncementScreen extends StatefulWidget {
// AnnouncementScreen({super.key});
//
// @override
// State<AnnouncementScreen> createState() => _AnnouncementScreenState();
// }
//
// class _AnnouncementScreenState extends State<AnnouncementScreen> {
// // Initialize the controller
// final AnnouncementController _announcementController = Get.put(AnnouncementController());
//
//
// String formatDate(String apiDate) {
// // Parse the API date string into a DateTime object
// DateTime parsedDate = DateTime.parse(apiDate).toLocal(); // Convert to local time
//
// // Format the date and time according to your specified format
// String formattedDate = DateFormat('EEE MMM dd yyyy').format(parsedDate);
//
// return formattedDate; // Return the formatted date string
// }
//
//
// @override
// Widget build(BuildContext context) {
// // Fetch announcements when the screen is built
// _announcementController.fetchAnnouncements();
//
// return CommonBackground(
// child: Scaffold(
// backgroundColor: Colors.transparent,
// appBar: CommonAppBar(
// actions: [
// IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: SvgPicture.asset('assets/svg/back_arrow.svg'),
// padding: const EdgeInsets.only(right: 20),
// ),
// ],
// title: const Text(
// 'Announcement',
// style: TextStyle(
// fontSize: 20,
// color: Colors.black,
// fontWeight: FontWeight.w400,
// fontFamily: 'Anek',
// ),
// ),
// backgroundColor: Colors.transparent,
// elevation: 0,
// ),
// drawer: MyDrawer(),
// body: Obx(() {
// // Show loading indicator while fetching announcements
// if (_announcementController.isLoading.value) {
// return Center(child: CircularProgressIndicator());
// }
// // Show error message if there was an error
// if (_announcementController.errorMessage.isNotEmpty) {
// return Center(
// child: Text('Error: ${_announcementController.errorMessage}'),
// );
// }
// // Display the list of announcements
// return ListView.builder(
// itemCount: _announcementController.announcements.length,
// itemBuilder: (context, index) {
// final announcementList = _announcementController.announcements[index];
// print("asdf,${announcementList}");
// return Column(
// children: [
// Card(
// child: ListTile(
// //leading:Text(_announcementController.announcements[index].id),
// title: Row(
//
// children: [
// Text("Message :",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 14),),
// Text(announcementList.message.toString(),style: TextStyle(fontSize: 12),),
//
// ],
// ),
// subtitle: Row(
// children: [
// Text("UniqueID :" , style: TextStyle(fontWeight: FontWeight.bold),),
// Text(announcementList.uniqueId.toString()),
// ],
// ),
// trailing: Text(formatDate(announcementList.createdAt.toString()),style: TextStyle(fontSize: 10),),
// ),
//
// ),
//
// ],
// );
// },
// );
// }),
// ),
// );
// }
// }
import 'package:cheminova/widgets/my_drawer.dart'; import 'package:cheminova/widgets/my_drawer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
@ -16,24 +134,15 @@ class AnnouncementScreen extends StatefulWidget {
} }
class _AnnouncementScreenState extends State<AnnouncementScreen> { class _AnnouncementScreenState extends State<AnnouncementScreen> {
// Initialize the controller
final AnnouncementController _announcementController = Get.put(AnnouncementController()); final AnnouncementController _announcementController = Get.put(AnnouncementController());
String formatDate(String apiDate) { String formatDate(String apiDate) {
// Parse the API date string into a DateTime object DateTime parsedDate = DateTime.parse(apiDate).toLocal();
DateTime parsedDate = DateTime.parse(apiDate).toLocal(); // Convert to local time return DateFormat('EEE MMM dd yyyy').format(parsedDate);
// Format the date and time according to your specified format
String formattedDate = DateFormat('EEE MMM dd yyyy').format(parsedDate);
return formattedDate; // Return the formatted date string
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Fetch announcements when the screen is built
_announcementController.fetchAnnouncements(); _announcementController.fetchAnnouncements();
return CommonBackground( return CommonBackground(
@ -63,47 +172,61 @@ class _AnnouncementScreenState extends State<AnnouncementScreen> {
), ),
drawer: MyDrawer(), drawer: MyDrawer(),
body: Obx(() { body: Obx(() {
// Show loading indicator while fetching announcements
if (_announcementController.isLoading.value) { if (_announcementController.isLoading.value) {
return Center(child: CircularProgressIndicator()); return Center(child: CircularProgressIndicator());
} }
// Show error message if there was an error
if (_announcementController.errorMessage.isNotEmpty) { if (_announcementController.errorMessage.isNotEmpty) {
return Center( return Center(
child: Text('Error: ${_announcementController.errorMessage}'), child: Text('Error: ${_announcementController.errorMessage}'),
); );
} }
// Display the list of announcements
return ListView.builder( return ListView.builder(
itemCount: _announcementController.announcements.length, itemCount: _announcementController.announcements.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final announcementList = _announcementController.announcements[index]; final announcementList = _announcementController.announcements[index];
print("asdf,${announcementList}"); return Card(
return Column( margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
children: [
Card(
child: ListTile( child: ListTile(
//leading:Text(_announcementController.announcements[index].id), // leading: CircleAvatar(
title: Row( // backgroundColor: Colors.blue,
// child: Text(
// announcementList.uniqueId.toString().toUpperCase(),
// style: TextStyle(color: Colors.white),
// ),
// ),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("Message :",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 14),), Text(
Text(announcementList.message.toString(),style: TextStyle(fontSize: 12),), "Message:",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
Text(
announcementList.message.toString(),
style: TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
], ],
), ),
subtitle: Row( subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("UniqueID :" , style: TextStyle(fontWeight: FontWeight.bold),), Text(
Text(announcementList.uniqueId.toString()), "UniqueID:",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
announcementList.uniqueId.toString(),
style: TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
], ],
), ),
trailing: Text(formatDate(announcementList.createdAt.toString()),style: TextStyle(fontSize: 10),), trailing: Text(
formatDate(announcementList.createdAt.toString()),
style: TextStyle(fontSize: 10),
), ),
), ),
],
); );
}, },
); );

View File

@ -1,9 +1,12 @@
import 'dart:convert'; import 'dart:convert';
import 'package:cheminova/controller/home_controller.dart'; import 'package:cheminova/controller/home_controller.dart';
import 'package:cheminova/controller/home_service.dart';
import 'package:cheminova/screens/authentication/controller/auth_service.dart'; import 'package:cheminova/screens/authentication/controller/auth_service.dart';
import 'package:cheminova/screens/authentication/login_screen.dart';
import 'package:cheminova/screens/home_screen.dart'; import 'package:cheminova/screens/home_screen.dart';
import 'package:cheminova/utils/show_snackbar.dart'; import 'package:cheminova/utils/show_snackbar.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -15,7 +18,7 @@ import '../../../utils/secure__storage_service.dart';
class AuthController extends GetxController { class AuthController extends GetxController {
final authService = AuthService(); final authService = AuthService();
final Dio _dio = Dio();
final _storageService = SecureStorageService(); final _storageService = SecureStorageService();
@ -28,6 +31,7 @@ class AuthController extends GetxController {
final HomeController _homeController = Get.put(HomeController()); final HomeController _homeController = Get.put(HomeController());
RxBool isLoading = false.obs; RxBool isLoading = false.obs;
@override @override
void onInit(){ void onInit(){
super.onInit(); super.onInit();
@ -35,26 +39,106 @@ class AuthController extends GetxController {
NotificationServices().requestNotificationPermission(); NotificationServices().requestNotificationPermission();
} }
// Function to handle user login // Function to handle user login
// Future<void> login() async {
// isLoading.value = true;
// // Call the login service with email and password
// final response = await authService.login({
// 'email': emailController.text,
// 'password': passwordController.text,
// });
// isLoading.value = false;
// update();
// if (response != null) {
// _homeController.fcmToken();
// showSnackbar("Your Successfully logged In!");
//
// Get.offAll(() => const HomeScreen());
// }
// else if(response == null){
// showSnackbar("Please Enter Valid Email or Password");
// }
// }
Future<void> login() async { Future<void> login() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
isLoading.value = true; isLoading.value = true;
// Call the login service with email and password
// Perform login API request
final response = await authService.login({ final response = await authService.login({
'email': emailController.text, 'email': emailController.text,
'password': passwordController.text, 'password': passwordController.text,
}); });
isLoading.value = false; isLoading.value = false;
update(); update();
if (response != null) {
_homeController.fcmToken();
showSnackbar("Your Successfully logged In!");
if (response != null && response['token'] != null) {
// Save the JWT token to SharedPreferences
String token = response['token'];
await prefs.setString('token', token);
// Fetch the FCM token and send it to the server
final fcmToken = await NotificationServices().getDeviceToken();
print('fcmToken: $fcmToken');
await HomeService().fcmToken({'fcmToken': fcmToken}, token);
showSnackbar("You successfully logged in!");
// Proceed to the HomeScreen after successful login
checkToken(); // Ensure the token is valid and the user is authenticated
Get.offAll(() => const HomeScreen()); Get.offAll(() => const HomeScreen());
} } else {
else if(response == null){ showSnackbar("Please enter a valid email or password");
showSnackbar("Please Enter Valid Email or Password");
} }
} }
Future<void> checkToken() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? token = prefs.getString('token');
if (token != null) {
// Token exists, proceed with the flow (maybe fetch user data or navigate to the home screen)
print('Token found: $token');
// You can also fetch the FCM token if necessary
final fcmToken = await NotificationServices().getDeviceToken();
print('fcmToken: $fcmToken');
// Optionally send the FCM token to the server if needed
// This might be where you're getting the error
await _homeController.fcmToken();
// Navigate to HomeScreen or perform other operations
Get.offAll(() => const HomeScreen());
} else {
// No token found, redirect to login screen
Get.offAll(() => const LoginScreen());
}
}
// Function to validate the token
// Future<bool> isTokenValid(String token) async {
// try {
// final response = await authService.validateToken(token);
// return response['isValid'] ?? false; // Adjust based on your API response
// } catch (e) {
// print("Token validation failed: $e");
// return false;
// }
// }
// Future<(bool, String)> login() async { // Future<(bool, String)> login() async {
// isLoading(true); // isLoading(true);
// try { // try {

View File

@ -1,10 +1,18 @@
import 'package:cheminova/utils/api_urls.dart'; import 'package:cheminova/utils/api_urls.dart';
import 'package:cheminova/utils/common_api_service.dart'; import 'package:cheminova/utils/common_api_service.dart';
import 'package:cheminova/utils/show_snackbar.dart'; import 'package:cheminova/utils/show_snackbar.dart';
import 'package:dio/dio.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import '../../../utils/app_interceptor.dart';
class AuthService { class AuthService {
final Dio _dio;
AuthService() : _dio = Dio(BaseOptions(baseUrl: 'https://api.cnapp.co.in')) {
_dio.interceptors.add(AuthInterceptor());
_dio.interceptors.add(PrettyDioLogger());
}
// Function to handle user login // Function to handle user login
Future<Map<String, dynamic>?> login(Map<String, dynamic> data) async { Future<Map<String, dynamic>?> login(Map<String, dynamic> data) async {
try { try {

View File

@ -26,7 +26,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Accessing the user details from the HomeController // Accessing the user details from the HomeController
final user = homecontroller!.user; final user = homecontroller.user;
return Stack( return Stack(
children: [ children: [
CommonBackground( CommonBackground(

View File

@ -23,7 +23,8 @@ class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
quantity: 100, quantity: 100,
description: 'Description 1', description: 'Description 1',
category: ProductCategory.food, category: ProductCategory.food,
image: 'assets/images/product.png', image: "assets/images/new_product.jpeg",
//'assets/images/product.png',
) )
]; ];
final List<String> _filterList = [ final List<String> _filterList = [

View File

@ -0,0 +1,213 @@
// import 'dart:io';
//
// import 'package:cheminova/screens/kyc/retailer_screen.dart';
// import 'package:cheminova/screens/kyc/upload_document_screen.dart';
// import 'package:cheminova/screens/kyc/verify_document_screen.dart';
// import 'package:cheminova/widgets/my_drawer.dart';
// import 'package:flutter_svg/flutter_svg.dart';
// import 'package:image_picker/image_picker.dart';
// import 'package:flutter/material.dart';
//
// import '../../widgets/comman_background.dart';
// import '../../widgets/common_appbar.dart';
//
//
// class CollectKycScreen extends StatefulWidget {
// const CollectKycScreen({super.key});
//
// @override
// State<CollectKycScreen> createState() => CollectKycScreenState();
// }
//
// class CollectKycScreenState extends State<CollectKycScreen>
// with SingleTickerProviderStateMixin {
// late TabController _tabController;
// bool isLoading = false;
//
// final _pages = [
// // RetailerDetailsScreen(),
// const UploadDocumentScreen(),
// const VerifyDocumentsScreen()
// ];
//
// @override
// void initState() {
// _tabController = TabController(length: 3, vsync: this);
// super.initState();
// }
//
// final locationController = TextEditingController();
// final notesController = TextEditingController();
// final dealerController = TextEditingController();
// final productController = TextEditingController();
// final qualityController = TextEditingController();
// final marketNameController = TextEditingController();
// final districtController = TextEditingController();
// final stateController = TextEditingController();
// final pincodeController = TextEditingController();
// final aadharcardController = TextEditingController();
// final pancardController = TextEditingController();
//
// File? _selfieImage;
// File? _pesticideLicenseImage;
// File? _fertilizerLicenseImage;
//
// final ImagePicker _picker = ImagePicker();
//
// Future<void> _pickImage(ImageSource source, bool isSelfie) async {
// final pickedFile = await _picker.pickImage(source: source);
//
// setState(() {
// if (pickedFile != null) {
// if (isSelfie) {
// _selfieImage = File(pickedFile.path);
// }
// }
// });
// }
//
// Future<void> _pickLicenseImage(ImageSource source, bool isPesticide) async {
// final pickedFile = await _picker.pickImage(source: source);
//
// setState(() {
// if (pickedFile != null) {
// if (isPesticide) {
// _pesticideLicenseImage = File(pickedFile.path);
// } else {
// _fertilizerLicenseImage = File(pickedFile.path);
// }
// }
// });
// }
//
// void _showPicker(BuildContext context, bool isSelfie) {
// showModalBottomSheet(
// context: context,
// builder: (BuildContext bc) {
// return SafeArea(
// child: Wrap(
// children: <Widget>[
// ListTile(
// leading: const Icon(Icons.photo_library),
// title: const Text('Photo Library'),
// onTap: () {
// _pickImage(ImageSource.gallery, isSelfie);
// Navigator.of(context).pop();
// },
// ),
// ListTile(
// leading: const Icon(Icons.photo_camera),
// title: const Text('Camera'),
// onTap: () {
// _pickImage(ImageSource.camera, isSelfie);
// Navigator.of(context).pop();
// },
// ),
// ],
// ),
// );
// },
// );
// }
//
// void _showLicensePicker(BuildContext context, bool isPesticide) {
// showModalBottomSheet(
// context: context,
// builder: (BuildContext bc) {
// return SafeArea(
// child: Wrap(
// children: <Widget>[
// ListTile(
// leading: const Icon(Icons.photo_library),
// title: const Text('Photo Library'),
// onTap: () {
// _pickLicenseImage(ImageSource.gallery, isPesticide);
// Navigator.of(context).pop();
// },
// ),
// ListTile(
// leading: const Icon(Icons.photo_camera),
// title: const Text('Camera'),
// onTap: () {
// _pickLicenseImage(ImageSource.camera, isPesticide);
// Navigator.of(context).pop();
// },
// ),
// ],
// ),
// );
// },
// );
// }
//
// @override
// Widget build(BuildContext context) {
// return Stack(
// children: [
// CommonBackground(
// child: DefaultTabController(
// length: 3,
// child: Scaffold(
// backgroundColor: Colors.transparent,
// appBar: PreferredSize(
// preferredSize: const Size.fromHeight(100),
// child: CommonAppBar(
// actions: [
// IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: SvgPicture.asset("assets/svg/back_arrow.svg"),
// //Image.asset('assets/Back_attendance.png'),
// padding: const EdgeInsets.only(right: 20),
// ),
// ],
// title: const Text(
// 'Collect KYC Data',
// style: TextStyle(
// fontSize: 20,
// color: Colors.black,
// fontWeight: FontWeight.w400,
// fontFamily: 'Anek',
// ),
// ),
// backgroundColor: Colors.transparent,
// elevation: 0,
// bottom: TabBar(
// controller: _tabController,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// dividerColor: Colors.transparent,
// indicatorColor: Colors.yellow,
// labelColor: Colors.white,
// unselectedLabelColor: Colors.black,
// indicatorSize: TabBarIndicatorSize.tab,
// indicator: BoxDecoration(
// color: Colors.blue,
// borderRadius: BorderRadius.circular(10),
// ),
// tabs: const [
// Tab(text: 'Details'),
// Tab(text: 'Documents'),
// Tab(text: 'Verify'),
// ],
// ),
// ),
// ),
// drawer: const MyDrawer(),
// body: TabBarView(
// controller: _tabController,
// physics: const NeverScrollableScrollPhysics(),
// children: _pages,
// ),
// ),
// ),
// ),
// if (isLoading)
// Container(
// color: Colors.black.withOpacity(0.5),
// child: const Center(child: CircularProgressIndicator()),
// ),
// ],
// );
// }
// }

View File

@ -146,7 +146,7 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
//category:product.category, //category:product.category,
category:Category(id: product.category.id, categoryName: product.category.categoryName), category:Category(id: product.category.id, categoryName: product.category.categoryName),
// brand:product.brand, // brand:product.brand,
brand:Brand(id: product.brand.id, brandName: product.brand.brandName), brand:Brand(id: product.brand.id, brandName: product.brand.brandName,images: product.brand.images),
v: 0, addedBy: product.addedBy, v: 0, addedBy: product.addedBy,
); );
}).toList(); }).toList();

View File

@ -234,7 +234,8 @@ Future<void> adduni()async {
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", // Add the image URL here "assets/images/new_product.jpeg",
// "assets/images/product.png", // Add the image URL here
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,

View File

@ -123,7 +123,8 @@ class _CartScreenState extends State<CartScreen> {
), ),
); );
} }
return Column( return SingleChildScrollView(
child: Column(
children: [ children: [
SizedBox( SizedBox(
height: Get.height * 0.02, height: Get.height * 0.02,
@ -141,21 +142,21 @@ class _CartScreenState extends State<CartScreen> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
// "Select All" Checkbox // "Select All" Checkbox
Row( // Row(
children: [ // children: [
Checkbox( // Checkbox(
value: _selectAll, // value: _selectAll,
onChanged: _toggleSelectAll, // onChanged: _toggleSelectAll,
), // ),
Text( // Text(
"Select All", // Label for the select all checkbox // "Select All", // Label for the select all checkbox
style: GoogleFonts.roboto( // style: GoogleFonts.roboto(
fontSize: 16, // fontSize: 16,
fontWeight: FontWeight.w500, // fontWeight: FontWeight.w500,
), // ),
), // ),
], // ],
), // ),
SizedBox( SizedBox(
height: Get.height * 0.6, height: Get.height * 0.6,
child: ListView.builder( child: ListView.builder(
@ -164,17 +165,17 @@ class _CartScreenState extends State<CartScreen> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Row( return Row(
children: [ children: [
Checkbox( // Checkbox(
value: _cartController.selectedProducts.contains( // value: _cartController.selectedProducts.contains(
_cartController.cartList[index]), // Checkbox for individual product selection // _cartController.cartList[index]), // Checkbox for individual product selection
onChanged: (value) { // onChanged: (value) {
_cartController.toggleProductSelection( // _cartController.toggleProductSelection(
_cartController.cartList[index], // _cartController.cartList[index],
value!, // value!,
); // );
_checkIfAllSelected(); // Check if all are selected after each toggle // _checkIfAllSelected(); // Check if all are selected after each toggle
}, // },
), // ),
Expanded( Expanded(
child: ProductCard( child: ProductCard(
productModel: productModel:
@ -263,6 +264,7 @@ class _CartScreenState extends State<CartScreen> {
), ),
), ),
], ],
),
); );
}), }),
), ),

View File

@ -107,7 +107,10 @@ class _ProductDetailScreenState extends State<ProductDetailScreen> {
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
child: Image.asset("assets/images/product.png", fit: BoxFit.cover,), child: Image.asset(
"assets/images/new_product.jpeg",
// "assets/images/product.png",
fit: BoxFit.cover,),
// Image.asset( // Image.asset(
// widget.product.image, // widget.product.image,
// fit: BoxFit.cover, // fit: BoxFit.cover,

View File

@ -224,7 +224,7 @@ class _PartialPendingDialogScreenState extends State<PartialPendingDialogScreen>
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${GstTotalAmounProcessItem}"), Text("${GstTotalAmounProcessItem.toStringAsFixed(2)}"),
], ],
), ),
Row( Row(

View File

@ -486,7 +486,7 @@ class _PartialProcessingDialogScreenState extends State<PartialProcessingDialogS
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${widget.placedOrderList!.gstTotal ?? 0}"), Text("${widget.placedOrderList!.gstTotal.toStringAsFixed(2) ?? 0}"),
], ],
), ),
Row( Row(

View File

@ -1192,7 +1192,7 @@ class _RdOrderCancelledScreenDetailScreenState
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${invoice.gstTotal}"), Text("${invoice.gstTotal.toStringAsFixed(2)}"),
], ],
), ),
@ -1290,7 +1290,8 @@ class _RdOrderCancelledScreenDetailScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", "assets/images/new_product.jpeg",
// "assets/images/product.png",
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -1318,7 +1319,7 @@ class _RdOrderCancelledScreenDetailScreenState
Text("Price: ${orderItem.price}"), Text("Price: ${orderItem.price}"),
Text("Subtotal: ${subTotal}"), Text("Subtotal: ${subTotal}"),
Text("GSt: ${orderItem.gst}%"), Text("GSt: ${orderItem.gst}%"),
Text("GST Amount (₹): ${GstTotalAmount}"), Text("GST Amount (₹): ${GstTotalAmount.toStringAsFixed(2)}"),
Text("Total Amount (₹): ${grandTotal}"), Text("Total Amount (₹): ${grandTotal}"),
], ],
), ),
@ -1386,7 +1387,8 @@ class _RdOrderCancelledScreenDetailScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", "assets/images/new_product.jpeg",
// "assets/images/product.png",
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -1407,7 +1409,7 @@ class _RdOrderCancelledScreenDetailScreenState
Text("Price: ${orderItem.price}"), Text("Price: ${orderItem.price}"),
Text("Subtotal: ${subTotalProcesssItem}"), Text("Subtotal: ${subTotalProcesssItem}"),
Text("Gst: ${orderItem.gst}%"), Text("Gst: ${orderItem.gst}%"),
Text("GST Total: ${GstTotalAmounProcessItem}"), Text("GST Total: ${GstTotalAmounProcessItem.toStringAsFixed(2)}"),
Text("Total Amount: ${grandTotalProcessItem}"), Text("Total Amount: ${grandTotalProcessItem}"),
], ],
), ),

View File

@ -298,7 +298,7 @@ class _RdDeliveredDetailsScreenState
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${widget.placedOrderList!.gstTotal}"), Text("${widget.placedOrderList!.gstTotal.toStringAsFixed(2)}"),
], ],
), ),
), ),

View File

@ -459,7 +459,7 @@ class _RdDispatchedDetailsDetailScreenState
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${widget.placedOrderList!.gstTotal}"), Text("${widget.placedOrderList!.gstTotal.toStringAsFixed(2)}"),
], ],
), ),
), ),

View File

@ -407,7 +407,8 @@ class _RdOrderDetailScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", // Add the image URL here "assets/images/new_product.jpeg",
// "assets/images/product.png", // Add the image URL here
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,

View File

@ -440,7 +440,7 @@ class _RdOrderDetailUpdateScreenState
_buildRow("Order Date:", formatDate("${widget.placedOrderList!.createdAt}"), Get.width * 0.04), _buildRow("Order Date:", formatDate("${widget.placedOrderList!.createdAt}"), Get.width * 0.04),
_buildRow("Total Items:", "${widget.placedOrderList!.orderItem!.length}", Get.width * 0.04), _buildRow("Total Items:", "${widget.placedOrderList!.orderItem!.length}", Get.width * 0.04),
_buildRow("Sub Total:", "${widget.placedOrderList!.subtotal}", Get.width * 0.04), _buildRow("Sub Total:", "${widget.placedOrderList!.subtotal}", Get.width * 0.04),
_buildRow("GST:", "${widget.placedOrderList!.gstTotal}", Get.width * 0.04), _buildRow("GST:", "${widget.placedOrderList!.gstTotal.toStringAsFixed(2)}", Get.width * 0.04),
_buildRow("Total Amount:", "${widget.placedOrderList!.grandTotal}", Get.width * 0.04), _buildRow("Total Amount:", "${widget.placedOrderList!.grandTotal}", Get.width * 0.04),
], ],
), ),
@ -472,7 +472,8 @@ class _RdOrderDetailUpdateScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", "assets/images/new_product.jpeg",
// "assets/images/product.png",
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -498,7 +499,7 @@ class _RdOrderDetailUpdateScreenState
Text("Price: ${orderItem.price}"), Text("Price: ${orderItem.price}"),
Text("Subtotal : ${subTotalProcesssItem}"), Text("Subtotal : ${subTotalProcesssItem}"),
Text("GST : ${orderItem.gst}%"), Text("GST : ${orderItem.gst}%"),
Text("GST Amount (₹) : ${GstTotalAmounProcessItem}"), Text("GST Amount (₹) : ${GstTotalAmounProcessItem.toStringAsFixed(2)}"),
Text("Total Amount : ${grandTotalProcessItem}"), Text("Total Amount : ${grandTotalProcessItem}"),
], ],
), ),

View File

@ -509,7 +509,7 @@ class _RdOrderPendingScreenDetailScreenState
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${invoice.gstTotal}"), Text("${invoice.gstTotal.toStringAsFixed(2)}"),
], ],
), ),
@ -607,7 +607,8 @@ class _RdOrderPendingScreenDetailScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", "assets/images/new_product.jpeg",
// "assets/images/product.png",
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -635,7 +636,7 @@ class _RdOrderPendingScreenDetailScreenState
Text("Price: ${orderItem.price}"), Text("Price: ${orderItem.price}"),
Text("Subtotal: ${subTotal}"), Text("Subtotal: ${subTotal}"),
Text("GSt: ${orderItem.gst}%"), Text("GSt: ${orderItem.gst}%"),
Text("GST Amount (₹): ${GstTotalAmount}"), Text("GST Amount (₹): ${GstTotalAmount.toStringAsFixed(2)}"),
Text("Total Amount (₹): ${grandTotal}"), Text("Total Amount (₹): ${grandTotal}"),
], ],
), ),
@ -703,7 +704,8 @@ class _RdOrderPendingScreenDetailScreenState
child: Row( child: Row(
children: [ children: [
Image.asset( Image.asset(
"assets/images/product.png", "assets/images/new_product.jpeg",
// "assets/images/product.png",
height: 50, height: 50,
width: 50, width: 50,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -724,7 +726,7 @@ class _RdOrderPendingScreenDetailScreenState
Text("Price: ${orderItem.price}"), Text("Price: ${orderItem.price}"),
Text("Subtotal: ${subTotalProcesssItem}"), Text("Subtotal: ${subTotalProcesssItem}"),
Text("Gst: ${orderItem.gst}%"), Text("Gst: ${orderItem.gst}%"),
Text("GST Total: ${GstTotalAmounProcessItem}"), Text("GST Total: ${GstTotalAmounProcessItem.toStringAsFixed(2)}"),
Text("Total Amount: ${grandTotalProcessItem}"), Text("Total Amount: ${grandTotalProcessItem}"),
], ],
), ),

View File

@ -332,7 +332,7 @@ class _RdOrderProcessingDetailScreenState extends State<RdOrderProcessingDetailS
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
Text("${widget.placeInvoiceList!.gstTotal}"), Text("${widget.placeInvoiceList!.gstTotal?.toStringAsFixed(2)}"),
], ],
), ),
), ),

View File

@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'authentication/controller/auth_controller.dart';
class SplashScreen extends StatefulWidget { class SplashScreen extends StatefulWidget {
const SplashScreen({super.key}); const SplashScreen({super.key});
@ -16,8 +18,9 @@ class _SplashScreenState extends State<SplashScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
Timer(const Duration(seconds: 2), () { Future.delayed(Duration(seconds: 2), () {
Get.offAll(() => const LoginScreen()); final authController = Get.put(AuthController());
authController.checkToken();
}); });
} }

View File

@ -0,0 +1,31 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AuthInterceptor extends Interceptor {
@override
void onRequest(
RequestOptions options, RequestInterceptorHandler handler) async {
final prefs = await SharedPreferences.getInstance();
final token = prefs.getString('token');
if (token != null) {
debugPrint('token-->\n $token\n');
options.headers['Authorization'] = 'Bearer $token';
}
handler.next(options);
}
@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
// Handle the response if needed
handler.next(response);
}
@override
void onError(DioException err, ErrorInterceptorHandler handler) async {
if (err.response?.statusCode == 401) {}
return handler.next(err);
}
}

View File

@ -1,3 +1,212 @@
// import 'package:cheminova/controller/home_controller.dart';
// import 'package:cheminova/models/user_model.dart';
// import 'package:cheminova/screens/authentication/change_password_screen.dart';
// import 'package:cheminova/screens/authentication/login_screen.dart';
// import 'package:cheminova/screens/authentication/profile_screen.dart';
// import 'package:cheminova/screens/home_screen.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
//
// class MyDrawer extends StatefulWidget {
// final UserModel? userModel;
//
// MyDrawer({super.key, this.userModel});
//
// @override
// State<MyDrawer> createState() => _MyDrawerState();
// }
//
// class _MyDrawerState extends State<MyDrawer> {
// final homecontroller = Get.put(HomeController()); // Initialize HomeController
// @override
// Widget build(BuildContext context) {
// final user = homecontroller.user; // Get the current user from HomeController
// return Drawer(
// child: ListView(
// padding: EdgeInsets.zero,
// children: <Widget>[
// SizedBox(
// height: 150,
// // Drawer header displaying user information
// child: DrawerHeader(
// decoration: const BoxDecoration(
// color: Colors.black87,
// ),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Text(
// user?.name ?? "username",
// style: const TextStyle(
// color: Colors.white,
// fontSize: 18,
// ),
// ),
// Text(
// user?.uniqueId ?? 'Employee ID',
// style: const TextStyle(
// color: Colors.white,
// fontSize: 20,
// ),
// ),
// ],
// ),
// ),
// ),
// // Navigation tile for Home
// ListTile(
// leading: const Icon(Icons.home),
// title: const Text('Home'),
// onTap: () {
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(builder: (context) => const HomeScreen()),
// (route) => false, // Remove all previous routes
// );
// },
// ),
// // Navigation tile for Profile
// ListTile(
// leading: const Icon(Icons.account_circle),
// title: const Text('Profile'),
// onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => ProfileScreen()),
// );
// },
// ),
// // Navigation tile for Change Password
// ListTile(
// leading: const Icon(Icons.settings),
// title: const Text('Change Password'),
// onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => ChangePasswordScreen()),
// );
// },
// ),
// // Navigation tile for Logout
// ListTile(
// leading: const Icon(Icons.exit_to_app),
// title: const Text('Logout'),
// onTap: () {
// logoutBox(context);
// },
// ),
//
//
//
//
// SizedBox(
// height: 700,
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Center(
// child: Text(
// 'Version 2.0.0',
// style: TextStyle(color: Colors.grey[600], fontSize: 12),
// ),
// ),
// ),
// ),
// ],
// ),
// );
// }
// }
// // Function to display logout confirmation dialog
// Future logoutBox(BuildContext context) {
// Size size = MediaQuery.of(context).size;
// return showDialog(
// context: context,
// builder: (BuildContext context) {
// return AlertDialog(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(6.0),
// ),
// backgroundColor: Colors.white,
// alignment: Alignment.center,
// title: const Text('Are you sure you want to log out?'),
// titleTextStyle: const TextStyle(
// fontSize: 20, fontWeight: FontWeight.w400, color: Colors.black),
// actionsAlignment: MainAxisAlignment.center,
// actionsPadding: const EdgeInsets.only(left: 10, right: 10, bottom: 20),
// actions: [
// Row(
// children: [
// Expanded(
// child: SizedBox(
// height: (size.height / 50.52) * 2,
// child: ElevatedButton(
// style: ButtonStyle(
// elevation: MaterialStateProperty.all(0),
// backgroundColor: MaterialStateProperty.all<Color>(
// Colors.black),
// shape: MaterialStateProperty.all<RoundedRectangleBorder>(
// RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(6.0),
// )),
// ),
// onPressed: () async {
// Navigator.pop(context);
// },
// child: const Text(
// "No",
// style: TextStyle(
// fontSize: 17,
// color: Colors.white,
// fontWeight: FontWeight.w500),
// ),
// ),
// ),
// ),
// const SizedBox(width: 5),
// Expanded(
// child: SizedBox(
// height: (size.height / 50.52) * 2,
// child: ElevatedButton(
// style: ButtonStyle(
// elevation: MaterialStateProperty.all(0),
// backgroundColor:
// MaterialStateProperty.all<Color>(Colors.white),
// shape:
// MaterialStateProperty.all<RoundedRectangleBorder>(
// RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(6.0),
// side: const BorderSide(
// color: Colors.purple, width: 1))),
// ),
// onPressed: () async {
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(
// builder: (context) => LoginScreen()),
// (route) => false,
// );
// },
// child: const Text(
// "Yes",
// style: TextStyle(
// fontSize: 17,
// color: Colors.purple,
// fontWeight: FontWeight.w500),
// ),
// ),
// ),
// ),
// ],
// )
// ],
// );
// },
// );
// }
import 'package:cheminova/controller/home_controller.dart'; import 'package:cheminova/controller/home_controller.dart';
import 'package:cheminova/models/user_model.dart'; import 'package:cheminova/models/user_model.dart';
import 'package:cheminova/screens/authentication/change_password_screen.dart'; import 'package:cheminova/screens/authentication/change_password_screen.dart';
@ -6,6 +215,7 @@ import 'package:cheminova/screens/authentication/profile_screen.dart';
import 'package:cheminova/screens/home_screen.dart'; import 'package:cheminova/screens/home_screen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
class MyDrawer extends StatefulWidget { class MyDrawer extends StatefulWidget {
final UserModel? userModel; final UserModel? userModel;
@ -18,17 +228,34 @@ class MyDrawer extends StatefulWidget {
class _MyDrawerState extends State<MyDrawer> { class _MyDrawerState extends State<MyDrawer> {
final homecontroller = Get.put(HomeController()); // Initialize HomeController final homecontroller = Get.put(HomeController()); // Initialize HomeController
String _appVersion = '';
@override
void initState() {
super.initState();
_getAppVersion();
}
Future<void> _getAppVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform(
);
setState(() {
_appVersion = packageInfo.version; // 1.0.0
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final user = homecontroller.user; // Get the current user from HomeController final user = homecontroller.user; // Get the current user from HomeController
return Drawer( return Drawer(
child: ListView( child: Column(
padding: EdgeInsets.zero,
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 150, height: 150,
width: double.infinity,
// Drawer header displaying user information // Drawer header displaying user information
child: DrawerHeader( child: DrawerHeader(
//padding: EdgeInsets.zero,
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Colors.black87, color: Colors.black87,
), ),
@ -36,6 +263,7 @@ class _MyDrawerState extends State<MyDrawer> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text( Text(
user?.name ?? "username", user?.name ?? "username",
style: const TextStyle( style: const TextStyle(
@ -96,11 +324,23 @@ class _MyDrawerState extends State<MyDrawer> {
logoutBox(context); logoutBox(context);
}, },
), ),
// Spacer to push the version text to the bottom
const Spacer(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(
'Version: $_appVersion',
style: TextStyle(color: Colors.grey[600], fontSize: 12),
),
),
),
], ],
), ),
); );
} }
} }
// Function to display logout confirmation dialog // Function to display logout confirmation dialog
Future logoutBox(BuildContext context) { Future logoutBox(BuildContext context) {
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
@ -188,3 +428,4 @@ Future logoutBox(BuildContext context) {
}, },
); );
} }

View File

@ -12,8 +12,10 @@ import firebase_core
import firebase_crashlytics import firebase_crashlytics
import firebase_messaging import firebase_messaging
import flutter_local_notifications import flutter_local_notifications
import package_info_plus
import path_provider_foundation import path_provider_foundation
import shared_preferences_foundation import shared_preferences_foundation
import sqflite
import syncfusion_pdfviewer_macos import syncfusion_pdfviewer_macos
import url_launcher_macos import url_launcher_macos
@ -25,8 +27,10 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin")) FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin"))
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
SyncfusionFlutterPdfViewerPlugin.register(with: registry.registrar(forPlugin: "SyncfusionFlutterPdfViewerPlugin")) SyncfusionFlutterPdfViewerPlugin.register(with: registry.registrar(forPlugin: "SyncfusionFlutterPdfViewerPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
} }

View File

@ -9,6 +9,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.44" version: "1.3.44"
archive:
dependency: transitive
description:
name: archive
sha256: "6199c74e3db4fbfbd04f66d739e72fe11c8a8957d5f219f1f4482dbde6420b5a"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -41,6 +49,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
sha256: "7c1183e361e5c8b0a0f21a28401eecdbde252441106a9816400dd4c2b2424916"
url: "https://pub.dev"
source: hosted
version: "3.4.1"
cached_network_image_platform_interface:
dependency: transitive
description:
name: cached_network_image_platform_interface
sha256: "35814b016e37fbdc91f7ae18c8caf49ba5c88501813f73ce8a07027a395e2829"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
cached_network_image_web:
dependency: transitive
description:
name: cached_network_image_web
sha256: "980842f4e8e2535b8dbd3d5ca0b1f0ba66bf61d14cc3a17a9b4788a3685ba062"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -49,6 +81,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
url: "https://pub.dev"
source: hosted
version: "2.0.3"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
url: "https://pub.dev"
source: hosted
version: "0.4.2"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -302,14 +350,22 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_lints: flutter_cache_manager:
dependency: "direct dev" dependency: transitive
description: description:
name: flutter_lints name: flutter_cache_manager
sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.4.1"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
sha256: bfa04787c85d80ecb3f8777bde5fc10c3de809240c48fa061a2c2bf15ea5211c
url: "https://pub.dev"
source: hosted
version: "0.14.3"
flutter_local_notifications: flutter_local_notifications:
dependency: "direct main" dependency: "direct main"
description: description:
@ -424,6 +480,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.2" version: "4.0.2"
image:
dependency: transitive
description:
name: image
sha256: "8346ad4b5173924b5ddddab782fc7d8a6300178c8b1dc427775405a01701c4a6"
url: "https://pub.dev"
source: hosted
version: "4.5.2"
image_picker: image_picker:
dependency: "direct main" dependency: "direct main"
description: description:
@ -504,6 +568,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.1" version: "0.7.1"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
url: "https://pub.dev"
source: hosted
version: "4.9.0"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
@ -528,14 +600,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
lints:
dependency: transitive
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "3.0.0"
logger: logger:
dependency: "direct main" dependency: "direct main"
description: description:
@ -576,6 +640,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.6" version: "1.0.6"
octo_image:
dependency: transitive
description:
name: octo_image
sha256: "34faa6639a78c7e3cbe79be6f9f96535867e879748ade7d17c9b1ae7536293bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
package_info_plus:
dependency: "direct main"
description:
name: package_info_plus
sha256: "739e0a5c3c4055152520fa321d0645ee98e932718b4c8efeeb51451968fe0790"
url: "https://pub.dev"
source: hosted
version: "8.1.3"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: a5ef9986efc7bf772f2696183a3992615baa76c1ffb1189318dd8803778fb05b
url: "https://pub.dev"
source: hosted
version: "3.0.2"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -672,6 +760,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.8" version: "2.1.8"
posix:
dependency: transitive
description:
name: posix
sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a
url: "https://pub.dev"
source: hosted
version: "6.0.1"
pretty_dio_logger: pretty_dio_logger:
dependency: "direct main" dependency: "direct main"
description: description:
@ -680,6 +776,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.0" version: "1.4.0"
rxdart:
dependency: transitive
description:
name: rxdart
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
url: "https://pub.dev"
source: hosted
version: "0.28.0"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@ -757,6 +861,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.0" version: "7.0.0"
sqflite:
dependency: transitive
description:
name: sqflite
sha256: a43e5a27235518c03ca238e7b4732cf35eabe863a369ceba6cbefa537a66f16d
url: "https://pub.dev"
source: hosted
version: "2.3.3+1"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4"
url: "https://pub.dev"
source: hosted
version: "2.5.4"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -845,6 +965,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "26.2.14" version: "26.2.14"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558"
url: "https://pub.dev"
source: hosted
version: "3.1.0+1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@ -1029,6 +1157,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.5.0" version: "6.5.0"
yaml:
dependency: transitive
description:
name: yaml
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
url: "https://pub.dev"
source: hosted
version: "3.1.3"
sdks: sdks:
dart: ">=3.4.1 <4.0.0" dart: ">=3.4.1 <4.0.0"
flutter: ">=3.22.0" flutter: ">=3.22.0"

View File

@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1 version: 2.0.1+1
environment: environment:
sdk: ">=3.4.1 <4.0.0" sdk: ">=3.4.1 <4.0.0"
@ -56,17 +56,28 @@ dependencies:
firebase_analytics: ^11.2.1 firebase_analytics: ^11.2.1
flutter_secure_storage: ^4.2.1 flutter_secure_storage: ^4.2.1
pretty_dio_logger: ^1.4.0 pretty_dio_logger: ^1.4.0
package_info_plus: ^8.1.3
cached_network_image: ^3.4.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_launcher_icons: ^0.14.3
flutter_launcher_icons:
android: "launcher_icon"
ios: true
image_path: "assets/images/app-icon-principal-distributor.png"
# The "flutter_lints" package below contains a set of recommended lints to # The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is # encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your # activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^3.0.0 flutter_lints: ^3.0.0
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec