authentication completed

This commit is contained in:
2025-01-25 18:56:57 +05:30
parent d9ddf69827
commit 9e559bdded
15 changed files with 704 additions and 205 deletions

View File

@@ -620,7 +620,7 @@
"languageVersion": "3.4"
}
],
"generated": "2025-01-24T13:29:48.830847Z",
"generated": "2025-01-25T13:26:28.487764Z",
"generator": "pub",
"generatorVersion": "3.4.4",
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",

View File

@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2025-01-24 18:59:49.009756","version":"3.22.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2025-01-25 18:56:28.677453","version":"3.22.3"}

View File

@@ -5,8 +5,11 @@ class APIURL {
static const String verifyOtp = "${BASE_URL}auth/verify-otp/customer";
static const String login = "${BASE_URL}auth/login/vendor";
static const String customerRegister = "${BASE_URL}auth/register/customer";
static const String createStore = "${BASE_URL}stores";
static const String getStore = "${BASE_URL}stores/";
static const String getAllProduct = "${BASE_URL}products";
static const String updateStore = "${BASE_URL}stores/";
static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor";
static const String verifyForgetPassword =
@@ -18,7 +21,7 @@ class APIURL {
static const String getMe = "${BASE_URL}auth/me";
static const String refresh_token = "${BASE_URL}auth/refresh-token";
static const String createProduct = "${BASE_URL}products";
static const String vendorLogOut = "${BASE_URL}auth/logout/vendor";
static const String customerLogOut = "${BASE_URL}/auth/logout/customer";
static const String uploadImage = "${BASE_URL}images/upload";
static const String deleteProduct = "${BASE_URL}products/";
static const String updateProduct = "${BASE_URL}products/";

View File

@@ -0,0 +1,397 @@
// To parse this JSON data, do
//
// final allProductModel = allProductModelFromJson(jsonString);
import 'dart:convert';
AllProductModel allProductModelFromJson(String str) =>
AllProductModel.fromJson(json.decode(str));
String allProductModelToJson(AllProductModel data) =>
json.encode(data.toJson());
class AllProductModel
{
List<Product>? data;
Meta? meta;
AllProductModel({
this.data,
this.meta,
});
factory AllProductModel.fromJson(Map<String, dynamic> json) =>
AllProductModel(
data: List<Product>.from(json["data"].map((x) => Product.fromJson(x))),
meta: Meta.fromJson(json["meta"]),
);
Map<String, dynamic> toJson() => {
"data": List<dynamic>.from(data!.map((x) => x.toJson())),
"meta": meta!.toJson(),
};
}
class Product {
dynamic id;
dynamic name;
dynamic description;
dynamic additionalInfo;
dynamic brand;
dynamic basePrice;
dynamic discountPrice;
dynamic stock;
dynamic quantity;
dynamic unit;
dynamic slug;
dynamic rating;
bool? isInStock;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic storeId;
dynamic categoryId;
dynamic productTypeId;
dynamic timeSlotId;
Store? store;
Category? category;
dynamic productType;
dynamic timeSlot;
List<ProductImage>? productImages;
List<dynamic>? productTags;
List<dynamic>? zones;
List<ProductReview>? productReview;
Product({
this.id,
this.name,
this.description,
this.additionalInfo,
this.brand,
this.basePrice,
this.discountPrice,
this.stock,
this.quantity,
this.unit,
this.slug,
this.rating,
this.isInStock,
this.isActive,
this.createdAt,
this.updatedAt,
this.storeId,
this.categoryId,
this.productTypeId,
this.timeSlotId,
this.store,
this.category,
this.productType,
this.timeSlot,
this.productImages,
this.productTags,
this.zones,
this.productReview,
});
factory Product.fromJson(Map<String, dynamic> json) => Product(
id: json["id"],
name: json["name"],
description: json["description"],
additionalInfo: json["additionalInfo"],
brand: json["brand"],
basePrice: json["basePrice"],
discountPrice: json["discountPrice"],
stock: json["stock"],
quantity: json["quantity"],
unit: json["unit"],
slug: json["slug"],
rating: json["rating"],
isInStock: json["isInStock"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
storeId: json["storeId"],
categoryId: json["categoryId"],
productTypeId: json["productTypeId"],
timeSlotId: json["timeSlotId"],
store: Store.fromJson(json["store"]),
category: Category.fromJson(json["category"]),
productType: json["productType"],
timeSlot: json["timeSlot"],
productImages: List<ProductImage>.from(
json["productImages"].map((x) => ProductImage.fromJson(x))),
productTags: List<dynamic>.from(json["productTags"].map((x) => x)),
zones: List<dynamic>.from(json["zones"].map((x) => x)),
productReview: List<ProductReview>.from(
json["ProductReview"].map((x) => ProductReview.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"additionalInfo": additionalInfo,
"brand": brand,
"basePrice": basePrice,
"discountPrice": discountPrice,
"stock": stock,
"quantity": quantity,
"unit": unit,
"slug": slug,
"rating": rating,
"isInStock": isInStock,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
"storeId": storeId,
"categoryId": categoryId,
"productTypeId": productTypeId,
"timeSlotId": timeSlotId,
"store": store!.toJson(),
"category": category!.toJson(),
"productType": productType,
"timeSlot": timeSlot,
"productImages":
List<dynamic>.from(productImages!.map((x) => x.toJson())),
"productTags": List<dynamic>.from(productTags!.map((x) => x)),
"zones": List<dynamic>.from(zones!.map((x) => x)),
"ProductReview":
List<dynamic>.from(productReview!.map((x) => x.toJson())),
};
}
class Category {
dynamic id;
dynamic name;
dynamic description;
dynamic image;
dynamic slug;
dynamic level;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic parentCategoryId;
dynamic path;
Category({
this.id,
this.name,
this.description,
this.image,
this.slug,
this.level,
this.isActive,
this.createdAt,
this.updatedAt,
this.parentCategoryId,
this.path,
});
factory Category.fromJson(Map<String, dynamic> json) => Category(
id: json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
slug: json["slug"],
level: json["level"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
parentCategoryId: json["parentCategoryId"],
path: json["path"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"image": image,
"slug": slug,
"level": level,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
"parentCategoryId": parentCategoryId,
"path": path,
};
}
class ProductImage {
dynamic id;
dynamic url;
bool? isDefault;
dynamic productId;
ProductImage({
this.id,
this.url,
this.isDefault,
this.productId,
});
factory ProductImage.fromJson(Map<String, dynamic> json) => ProductImage(
id: json["id"],
url: json["url"],
isDefault: json["isDefault"],
productId: json["productId"],
);
Map<String, dynamic> toJson() => {
"id": id,
"url": url,
"isDefault": isDefault,
"productId": productId,
};
}
class ProductReview {
dynamic id;
dynamic userId;
dynamic productId;
dynamic rating;
dynamic title;
dynamic description;
dynamic likes;
dynamic dislikes;
dynamic helpfulCount;
bool? isVerified;
bool? verifiedPurchase;
dynamic status;
DateTime? createdAt;
DateTime? updatedAt;
ProductReview({
this.id,
this.userId,
this.productId,
this.rating,
this.title,
this.description,
this.likes,
this.dislikes,
this.helpfulCount,
this.isVerified,
this.verifiedPurchase,
this.status,
this.createdAt,
this.updatedAt,
});
factory ProductReview.fromJson(Map<String, dynamic> json) => ProductReview(
id: json["id"],
userId: json["userId"],
productId: json["productId"],
rating: json["rating"],
title: json["title"],
description: json["description"],
likes: json["likes"],
dislikes: json["dislikes"],
helpfulCount: json["helpfulCount"],
isVerified: json["isVerified"],
verifiedPurchase: json["verifiedPurchase"],
status: json["status"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"userId": userId,
"productId": productId,
"rating": rating,
"title": title,
"description": description,
"likes": likes,
"dislikes": dislikes,
"helpfulCount": helpfulCount,
"isVerified": isVerified,
"verifiedPurchase": verifiedPurchase,
"status": status,
"createdAt": createdAt,
"updatedAt": updatedAt,
};
}
class Store {
dynamic id;
dynamic storeName;
dynamic storeDescription;
dynamic officialPhoneNumber;
dynamic storeAddress;
dynamic gstNumber;
dynamic gumastaNumber;
dynamic storePicture;
DateTime? createdAt;
DateTime? updatedAt;
dynamic vendorId;
bool? isActive;
Store({
this.id,
this.storeName,
this.storeDescription,
this.officialPhoneNumber,
this.storeAddress,
this.gstNumber,
this.gumastaNumber,
this.storePicture,
this.createdAt,
this.updatedAt,
this.vendorId,
this.isActive,
});
factory Store.fromJson(Map<String, dynamic> json) => Store(
id: json["id"],
storeName: json["storeName"],
storeDescription: json["storeDescription"],
officialPhoneNumber: json["officialPhoneNumber"],
storeAddress: json["storeAddress"],
gstNumber: json["gstNumber"],
gumastaNumber: json["gumastaNumber"],
storePicture: json["storePicture"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
vendorId: json["vendorId"],
isActive: json["isActive"],
);
Map<String, dynamic> toJson() => {
"id": id,
"storeName": storeName,
"storeDescription": storeDescription,
"officialPhoneNumber": officialPhoneNumber,
"storeAddress": storeAddress,
"gstNumber": gstNumber,
"gumastaNumber": gumastaNumber,
"storePicture": storePicture,
"createdAt": createdAt,
"updatedAt": updatedAt,
"vendorId": vendorId,
"isActive": isActive,
};
}
class Meta {
dynamic total;
dynamic page;
dynamic lastPage;
Meta({
this.total,
this.page,
this.lastPage,
});
factory Meta.fromJson(Map<String, dynamic> json) => Meta(
total: json["total"],
page: json["page"],
lastPage: json["lastPage"],
);
Map<String, dynamic> toJson() => {
"total": total,
"page": page,
"lastPage": lastPage,
};
}

View File

@@ -0,0 +1,128 @@
// To parse this JSON data, do
//
// final registrationResponse = registrationResponseFromJson(jsonString?);
import 'dart:convert';
RegistrationResponse registrationResponseFromJson(String str) =>
RegistrationResponse.fromJson(json.decode(str));
String? registrationResponseToJson(RegistrationResponse data) =>
json.encode(data.toJson());
class RegistrationResponse {
Customer? customer;
String? accessToken;
String? refreshToken;
RegistrationResponse({
this.customer,
this.accessToken,
this.refreshToken,
});
factory RegistrationResponse.fromJson(Map<String?, dynamic> json) =>
RegistrationResponse(
customer: Customer.fromJson(json["customer"]),
accessToken: json["access_token"],
refreshToken: json["refresh_token"],
);
Map<String?, dynamic> toJson() => {
"customer": customer!.toJson(),
"access_token": accessToken,
"refresh_token": refreshToken,
};
}
class Customer {
String? id;
String? email;
String? firstName;
String? lastName;
dynamic name;
dynamic img;
String? authType;
String? role;
String? phone;
dynamic password;
bool? isPhoneVerified;
dynamic vendorType;
dynamic businessId;
bool? isVendorAccountCreated;
bool? isVendorAccountActive;
bool? vendorTermsAccepted;
DateTime? createdAt;
DateTime? updatedAt;
dynamic resetToken;
dynamic resetTokenExpiresAt;
Customer({
this.id,
this.email,
this.firstName,
this.lastName,
this.name,
this.img,
this.authType,
this.role,
this.phone,
this.password,
this.isPhoneVerified,
this.vendorType,
this.businessId,
this.isVendorAccountCreated,
this.isVendorAccountActive,
this.vendorTermsAccepted,
this.createdAt,
this.updatedAt,
this.resetToken,
this.resetTokenExpiresAt,
});
factory Customer.fromJson(Map<String?, dynamic> json) => Customer(
id: json["id"],
email: json["email"],
firstName: json["firstName"],
lastName: json["lastName"],
name: json["name"],
img: json["img"],
authType: json["authType"],
role: json["role"],
phone: json["phone"],
password: json["password"],
isPhoneVerified: json["isPhoneVerified"],
vendorType: json["vendorType"],
businessId: json["businessId"],
isVendorAccountCreated: json["isVendorAccountCreated"],
isVendorAccountActive: json["isVendorAccountActive"],
vendorTermsAccepted: json["vendorTermsAccepted"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
resetToken: json["resetToken"],
resetTokenExpiresAt: json["resetTokenExpiresAt"],
);
Map<String?, dynamic> toJson() => {
"id": id,
"email": email,
"firstName": firstName,
"lastName": lastName,
"name": name,
"img": img,
"authType": authType,
"role": role,
"phone": phone,
"password": password,
"isPhoneVerified": isPhoneVerified,
"vendorType": vendorType,
"businessId": businessId,
"isVendorAccountCreated": isVendorAccountCreated,
"isVendorAccountActive": isVendorAccountActive,
"vendorTermsAccepted": vendorTermsAccepted,
"createdAt": createdAt,
"updatedAt": updatedAt,
"resetToken": resetToken,
"resetTokenExpiresAt": resetTokenExpiresAt,
};
}

View File

@@ -121,15 +121,12 @@ class AuthProvider extends ChangeNotifier {
// //vendorRegister
Future<bool> vendorRegister(BuildContext context) async {
Future<bool> customerRegister(BuildContext context) async {
context.showLoader(show: true);
var data = {
"firstName": await SharedPrefUtils.getFirstName(),
"lastName": await SharedPrefUtils.getLastName(),
"email": await SharedPrefUtils.getEmail(),
"password": await SharedPrefUtils.getPassword(),
"vendorType": "individual",
"firstName": name.text,
"lastName": lastName.text,
"email": email.text,
};
try {

View File

@@ -1,61 +1,21 @@
// import 'package:flutter/material.dart';
// import 'package:vendor_app/src/core/network_services/service_locator.dart';
// import 'package:vendor_app/src/core/utiils_lib/shared_pref_utils.dart';
// import 'package:vendor_app/src/logic/repo/home_repo.dart';
import 'package:flutter/material.dart';
import 'package:grocery_app/src/core/network_services/service_locator.dart';
import 'package:grocery_app/src/logic/repo/home_repo.dart';
// class HomeProvider extends ChangeNotifier {
// final _homeRepo = getIt<HomeRepo>();
class ProductProvider extends ChangeNotifier {
final _homeRepo = getIt<ProductRepo>();
// Future<bool> refreshToken(BuildContext context) async {
// var data = {"refresh_token": "${await SharedPrefUtils.getRefreshToken()}"};
Future<bool> gettAllProduct(BuildContext context) async {
var data = {};
// var result = await _homeRepo.refreshToken(data, context);
// return result.fold(
// (error) {
// print("dkjhsfgjkdfkg");
// return true;
// },
// (response) {
// print("dkjhssfdgdfgdfgfgjkdfkg");
// return true;
// },
// );
// }
// String _userName = '';
// String _phone = '';
// String get userName => _userName;
// String get phone => _phone;
// void setUserName(String name) {
// _userName = name;
// notifyListeners();
// }
// void setPhone(String phoneNumber) {
// _phone = phoneNumber;
// notifyListeners();
// }
// Future<void> getMe() async {
// var data = {};
// try {
// var result = await _homeRepo.getMe(data);
// return result.fold(
// (error) {},
// (response) {
// setUserName(response.firstName);
// setPhone(response.phone);
// SharedPrefUtils.USER_NAME =
// response.firstName + " " + response.lastName;
// SharedPrefUtils.PHONE = response.phone;
// notifyListeners();
// },
// );
// } catch (e) {}
// }
// }
var result = await _homeRepo.getAllProduct(data, context);
return result.fold(
(error) {
return true;
},
(response) {
return true;
},
);
}
}

View File

@@ -5,11 +5,11 @@ import 'package:fpdart/fpdart.dart';
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
import 'package:grocery_app/src/core/utils/response_type_def.dart';
import 'package:grocery_app/src/data/OTPResponseModel.dart';
import 'package:grocery_app/src/data/registration_response.dart';
import 'package:grocery_app/src/data/vendor_otpModel.dart';
import 'package:grocery_app/src/logic/services/auth_service_locator.dart';
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
class AuthRepo {
final AuthServices _authServices;
@@ -30,8 +30,6 @@ class AuthRepo {
}
}
FutureResult<VendorOtpModel> verifyOtp(data) async {
try {
var response = await _authServices.verifyOtp(data);
@@ -39,8 +37,7 @@ class AuthRepo {
final VendorOtpModel vendorOtpModel =
vendorOtpModelFromJson(response.toString());
if (vendorOtpModel.data != null)
{
if (vendorOtpModel.data != null) {
await SharedPrefUtils.setToken(
authToken: vendorOtpModel.data!.accessToken ?? "");
}
@@ -95,6 +92,15 @@ class AuthRepo {
FutureResult<String> customerRegister(data) async {
try {
var response = await _authServices.userRegister(data);
RegistrationResponse registrationResponse =
registrationResponseFromJson(response.toString());
await SharedPrefUtils.setToken(
authToken: registrationResponse.accessToken ?? "");
if (response.statCode) {
print("dsfklgjkfgbfgkfdgjkhkfdjg");
}
final String model = response.toString();
return right(model);
} on DioException catch (e) {
@@ -143,7 +149,4 @@ class AuthRepo {
// return left(error);
// }
// }
}

View File

@@ -1,68 +1,63 @@
// import 'package:dio/dio.dart';
// import 'package:flutter/material.dart';
// import 'package:fpdart/fpdart.dart';
// import 'package:vendor_app/src/core/routes/routes.dart';
// import 'package:vendor_app/src/core/utiils_lib/custom_dio_exception.dart';
// import 'package:vendor_app/src/core/utiils_lib/extensions.dart';
// import 'package:vendor_app/src/core/utiils_lib/response_type_def.dart';
// import 'package:vendor_app/src/core/utiils_lib/shared_pref_utils.dart';
// import 'package:vendor_app/src/data/login_response.dart';
// import 'package:vendor_app/src/data/vendor_model.dart';
// import 'package:vendor_app/src/logic/services/home_locator.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:fpdart/fpdart.dart';
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
import 'package:grocery_app/src/core/utils/response_type_def.dart';
import 'package:grocery_app/src/data/allProduct_model.dart';
import 'package:grocery_app/src/logic/services/home_locator.dart';
// class HomeRepo {
// final HomeService _homeService;
// HomeRepo(this._homeService);
class ProductRepo {
final ProductService _productService;
// FutureResult<String> refreshToken(data, BuildContext context) async {
// try {
// var response = await _homeService.refresh_token(data);
// LoginResponse loginResponse = loginResponseFromJson(response.toString());
ProductRepo(this._productService);
// if (loginResponse.accessToken != null) {
// print("chwckData ${loginResponse.accessToken}");
// await SharedPrefUtils.setToken(
// authToken: loginResponse.accessToken ?? "");
// await SharedPrefUtils.setRefreshToken(
// refresh_token: loginResponse.refreshToken ?? "");
// }
FutureResult<String> getAllProduct(data, BuildContext context) async {
try {
var response = await _productService.getAllProduct(data);
// final String model = response.toString();
AllProductModel loginResponse = allProductModelFromJson(response.toString());
// return right(model);
// } on DioException catch (e)
// {
// context.clearAndPush(routePath: MyRoutes.SELECTACCOUNT);
// var error = CustomDioExceptions.handleError(e);
// return left(error);
// }
// }
// FutureResult<VendorModel> getMe(data) async {
// try {
// var response = await _homeService.getMe(data);
final String model = response.toString();
// final VendorModel vendorModel = vendorModelFromJson(response.toString());
return right(model);
} on DioException catch (e)
{
// if (vendorModel != null)
// {
// SharedPrefUtils.USER_NAME =
// vendorModel.firstName + " " + vendorModel.lastName;
// SharedPrefUtils.PHONE = vendorModel.phone;
// print("dkfjhdkfhkfk ${SharedPrefUtils.USER_NAME}");
// await SharedPrefUtils.setStoreId(storeId: vendorModel.storeId ?? "");
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
// }
// FutureResult<VendorModel> getMe(data) async {
// try {
// var response = await _homeService.getMe(data);
// final String model = response.toString();
// final VendorModel vendorModel = vendorModelFromJson(response.toString());
// return right(vendorModel);
// } on DioException catch (e) {
// var error = CustomDioExceptions.handleError(e);
// return left(error);
// }
// }
// }
// if (vendorModel != null)
// {
// SharedPrefUtils.USER_NAME =
// vendorModel.firstName + " " + vendorModel.lastName;
// SharedPrefUtils.PHONE = vendorModel.phone;
// print("dkfjhdkfhkfk ${SharedPrefUtils.USER_NAME}");
// await SharedPrefUtils.setStoreId(storeId: vendorModel.storeId ?? "");
// }
// final String model = response.toString();
// return right(vendorModel);
// } on DioException catch (e) {
// var error = CustomDioExceptions.handleError(e);
// return left(error);
// }
// }
}

View File

@@ -1,27 +1,34 @@
// import 'dart:convert';
import 'dart:convert';
// import 'package:vendor_app/src/core/constant/api.dart';
// import 'package:vendor_app/src/core/network_services/api_services.dart';
import 'package:grocery_app/src/core/constant/api.dart';
import 'package:grocery_app/src/core/network_services/api_services.dart';
// class HomeService extends ApiService {
// Future getMe(data) async {
// var response = await api.get(APIURL.getMe, data: jsonEncode(data));
// //response.statusCode
class ProductService extends ApiService {
// return response;
// }
Future getMe(data) async {
var response = await api.get(APIURL.getMe, data: jsonEncode(data));
//response.statusCode
// Future refresh_token(data) async
// {
// var response = await api.post(APIURL.refresh_token, data: jsonEncode(data));
// //response.statusCode
return response;
}
// return response;
// }
Future refresh_token(data) async
{
var response = await api.post(APIURL.refresh_token, data: jsonEncode(data));
return response;
}
Future getAllProduct(data) async {
var response = await api.get(APIURL.getAllProduct, data: jsonEncode(data));
return response;
}
// }
}

View File

@@ -20,12 +20,9 @@ class EnterFullNameScreen extends StatefulWidget {
}
class _EnterFullNameScreenState extends State<EnterFullNameScreen> {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
final pageNotifier = Provider.of<AuthProvider>(context, listen: false);
return Scaffold(
@@ -60,7 +57,7 @@ class _EnterFullNameScreenState extends State<EnterFullNameScreen> {
AppTextFieldWidget(
controller: pageNotifier.name,
hintText: APPSTRING.firstNameHint,
onValidate: (value){
onValidate: (value) {
if (value == null || value.isEmpty) {
return 'Please Enter first Name';
}
@@ -70,14 +67,13 @@ class _EnterFullNameScreenState extends State<EnterFullNameScreen> {
AppTextFieldWidget(
controller: pageNotifier.lastName,
hintText: APPSTRING.lastNameHint,
onValidate: (value){
onValidate: (value) {
if (value == null || value.isEmpty) {
return 'Please Enter last Name';
}
return null;
},
),
AppTextFieldWidget(
controller: pageNotifier.email,
hintText: APPSTRING.emailHint,
@@ -88,17 +84,16 @@ class _EnterFullNameScreenState extends State<EnterFullNameScreen> {
return null;
},
),
AppTextFieldWidget(
controller: pageNotifier.address,
hintText: APPSTRING.addressHint,
onValidate: (value) {
if (value == null || value.isEmpty)
{
return 'Please Enter address';
}
return null;
},
),
// AppTextFieldWidget(
// controller: pageNotifier.address,
// hintText: APPSTRING.addressHint,
// onValidate: (value) {
// if (value == null || value.isEmpty) {
// return 'Please Enter address';
// }
// return null;
// },
// ),
],
),
)
@@ -115,15 +110,14 @@ class _EnterFullNameScreenState extends State<EnterFullNameScreen> {
padding: context.bodyAllPadding.copyWith(bottom: 20),
child: Center(
child: InkWell(
onTap: ()
{
onTap: () async {
if (_formKey.currentState?.validate() ?? false) {
final success = await pageNotifier.customerRegister(context);
if (_formKey.currentState?.validate() ?? false)
{
context.clearAndPush( routePath: MyRoutes.BOTTOMNAV);
if (success) {
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
}
}
// Navigator.of(context).push(MaterialPageRoute(
// builder: (context) {

View File

@@ -158,7 +158,8 @@ class _HomeScreenState extends State<HomeScreen> {
mainAxisSpacing: 5,
childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 1.2),
),
itemBuilder: (context, index) {
itemBuilder: (context, index)
{
return InkWell(
onTap: () {},
child: SizedBox(

View File

@@ -27,7 +27,7 @@ class _OnBoardingScreenState extends State<OnBoardingScreen> {
skipFunction() {
SharedPrefUtils.setFreshInstall(isFresh: false).then(
(value) => context.clearAndPush(routePath: MyRoutes.BOTTOMNAV, args: 0),
(value) => context.clearAndPush(routePath: MyRoutes.LOGIN, args: 0),
);
// Navigator.pushReplacement(context, MaterialPageRoute(
@@ -221,10 +221,11 @@ class _OnBoardingScreenState extends State<OnBoardingScreen> {
),
Stack(
children: [
Image.asset(APPASSETS.onBoardMan),
Positioned(
top: 10,
top: 20,
right: 0,
child: InkWell(
child: GestureDetector(
onTap: () {
skipFunction();
},
@@ -236,15 +237,14 @@ class _OnBoardingScreenState extends State<OnBoardingScreen> {
style:
context.customMedium(APPCOLOR.appGreen, 14),
),
const SizedBox(
width: 10,
),
const SizedBox(width: 10),
Container(
height: 35,
width: 35,
decoration: BoxDecoration(
color: APPCOLOR.appGreen,
borderRadius: BorderRadius.circular(90)),
borderRadius: BorderRadius.circular(90),
),
child: const Center(
child: Icon(
Icons.arrow_forward,
@@ -257,7 +257,6 @@ class _OnBoardingScreenState extends State<OnBoardingScreen> {
),
),
),
Image.asset(APPASSETS.onBoardMan),
Positioned(
bottom: 100,
right: 0,

View File

@@ -73,13 +73,13 @@ class _OtpScreenState extends State<OtpScreen> {
OTPTextField(
length: 6,
onChanged: (c) {
if (c.length == 6) {
Navigator.push(context, MaterialPageRoute(
builder: (context) {
return const EnterFullNameScreen();
},
));
}
// if (c.length == 6) {
// Navigator.push(context, MaterialPageRoute(
// builder: (context) {
// return const EnterFullNameScreen();
// },
// ));
// }
},
width: MediaQuery.of(context).size.width,
fieldWidth: 50,
@@ -92,15 +92,16 @@ class _OtpScreenState extends State<OtpScreen> {
onCompleted: (pin) async {
final success = await pageNotifier.verifiOtp(pin, context);
if (success) {
if (success)
{
context.push(MyRoutes.FULLNAME);
} else {
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(
// backgroundColor: Colors.grey,
// content: Text("Failed to send OTP. Please try again."),
// ),
// );
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.grey,
content: Text("Failed to send OTP. Please try again."),
),
);
}
},
),

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/ui/onboarding/on_boarding_screen.dart';
import 'package:grocery_app/utils/constants/assets_constant.dart';
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
@@ -25,7 +26,20 @@ class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
// couting();
Future.delayed(const Duration(seconds: 2), () async {
if (await SharedPrefUtils.isFreshInstall()) {
context.clearAndPush(routePath: MyRoutes.ONBOARDING);
} else
{
print("kdsbfjhdkjfdfghv ${await SharedPrefUtils.getToken()}");
if (await SharedPrefUtils.getToken() == "1" ||
await SharedPrefUtils.getToken() == null) {
// context.clearAndPush(routePath: MyRoutes.SELECTACCOUNT);
} else {
context.clearAndPush(routePath: MyRoutes.BOTTOMNAV);
}
}
});
Future.delayed(const Duration(seconds: 2), () async {
context.clearAndPush(routePath: MyRoutes.ONBOARDING);