Commit 59f975ac by Ramesh Babu Puvvadi

added Stock, Sale and View List

parent 25d9c72d
...@@ -153,11 +153,10 @@ class Constants { ...@@ -153,11 +153,10 @@ class Constants {
static showLoader(BuildContext ctx) { static showLoader(BuildContext ctx) {
showDialog( showDialog(
context: ctx, context: ctx,
builder: (context) { builder: (context) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} });
);
} }
static Future<void> dismissAlertDialog1(BuildContext context) async { static Future<void> dismissAlertDialog1(BuildContext context) async {
...@@ -232,8 +231,7 @@ class Constants { ...@@ -232,8 +231,7 @@ class Constants {
child: const Text("Cancel"), child: const Text("Cancel"),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
} });
);
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
title: Text(title), title: Text(title),
content: Text(message), content: Text(message),
...@@ -255,6 +253,35 @@ class Constants { ...@@ -255,6 +253,35 @@ class Constants {
return dropdownItemHeight; return dropdownItemHeight;
} }
static Showindicator(BuildContext context, String loadertext) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const CircularProgressIndicator(
color: Color.fromARGB(255, 69, 66, 121),
),
const SizedBox(height: 16), // Add some spacing
Text(
'$loadertext ...', // Use the dynamic text here
style: const TextStyle(
fontSize: 16,
decoration: TextDecoration.none,
color:
Colors.white, // Set the text color to your preference
),
),
const SizedBox(height: 16),
],
),
);
});
}
showAlertDialog(BuildContext context, bool val) { showAlertDialog(BuildContext context, bool val) {
Widget okButton = TextButton( Widget okButton = TextButton(
child: const Text("Cancel"), child: const Text("Cancel"),
......
...@@ -166,6 +166,7 @@ class _Home extends State<Home> { ...@@ -166,6 +166,7 @@ class _Home extends State<Home> {
), ),
const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)), const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
...@@ -236,6 +237,7 @@ class _Home extends State<Home> { ...@@ -236,6 +237,7 @@ class _Home extends State<Home> {
), ),
const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)), const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
...@@ -324,8 +326,7 @@ class _Home extends State<Home> { ...@@ -324,8 +326,7 @@ class _Home extends State<Home> {
), ),
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: const Column( child: const Column(
mainAxisAlignment: MainAxisAlignment mainAxisAlignment: MainAxisAlignment.end, // Align content at the bottom
.end, // Align content at the bottom
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
...@@ -869,16 +870,14 @@ class _Home extends State<Home> { ...@@ -869,16 +870,14 @@ class _Home extends State<Home> {
width: MediaQuery.of(context).size.width * 0.90, width: MediaQuery.of(context).size.width * 0.90,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
// Navigator.push( Navigator.push(context,
// context, MaterialPageRoute(
// MaterialPageRoute( builder: (context) =>
// builder: (context) => const Identifyproduct()),
// const Identifyproduct()), );
// );
}, },
child: Container( child: Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.only(left: 20, top: 0, right: 2, bottom: 0),
left: 20, top: 0, right: 2, bottom: 0),
width: MediaQuery.of(context).size.width * 0.100, width: MediaQuery.of(context).size.width * 0.100,
height: MediaQuery.of(context).size.width * 0.22, height: MediaQuery.of(context).size.width * 0.22,
padding: const EdgeInsets.all(5), padding: const EdgeInsets.all(5),
...@@ -902,7 +901,7 @@ class _Home extends State<Home> { ...@@ -902,7 +901,7 @@ class _Home extends State<Home> {
height: 42, height: 42,
), // replace with your image ), // replace with your image
const Text( const Text(
'\t\t\t\t\t\t IDENTIFY PRODUCT', '\t\t\t\t\t\t DETECT ATTRIBUTES',
style: Constants.buttonsfontStyle, style: Constants.buttonsfontStyle,
) )
], ],
......
...@@ -6,13 +6,17 @@ import 'package:http/http.dart' as http; ...@@ -6,13 +6,17 @@ import 'package:http/http.dart' as http;
class RemoteData { class RemoteData {
final String loginUrl = 'http://vaman.plutokm.com/login'; final String loginUrl = 'http://vaman.plutokm.com/login';
final String Uploadimage = 'http://vaman.plutokm.com/vasthram_mobile'; final String imageupload = 'http://vaman.plutokm.com/vasthram_mobile';
final String Identifystylecode = 'https://vaman.plutokm.com/get_vasthram_style_code'; final String identifystylecode = 'https://vaman.plutokm.com/get_vasthram_style_code';
final String registerstylecode = 'https://vaman.plutokm.com/register_style_code'; final String registerstylecode = 'https://vaman.plutokm.com/register_style_code';
final String detectattributes = 'https://vaman.plutokm.com/detect_attributes';
final String sale = 'https://vaman.plutokm.com/stylecode_sales_data';
final String stock = 'https://vaman.plutokm.com/stylecode_stock_data';
final String type = 'Content-Type'; final String type = 'Content-Type';
final String appjson = 'application/json'; final String appjson = 'application/json';
Future<String> getLoginRequest (String loginid, String pass, String token) async { Future<String> getLoginRequest(
String loginid, String pass, String token) async {
Map<String, dynamic> body = { Map<String, dynamic> body = {
'login_id': loginid, 'login_id': loginid,
'password': pass, 'password': pass,
...@@ -36,16 +40,19 @@ class RemoteData { ...@@ -36,16 +40,19 @@ class RemoteData {
} }
} }
Future<String?> uploadimage(File imagepath, String embedding) async { Future<String> stockData(String stylecode) async {
print(stylecode);
try { try {
final request = http.MultipartRequest('POST', Uri.parse('http://vaman.plutokm.com/detect_saree')); final request = http.MultipartRequest('POST', Uri.parse(stock));
request.files.add(await http.MultipartFile.fromPath('image', imagepath.path));
request.files.add(http.MultipartFile.fromString('stylecode', stylecode));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding)); //request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send(); var response = await request.send();
var responseString = await response.stream.bytesToString(); var responseString = await response.stream.bytesToString();
if (kDebugMode) { if (kDebugMode) {
print('Response :$responseString'); print('Response :$responseString');
} }
print(response.statusCode);
if (response.statusCode == 200) { if (response.statusCode == 200) {
return responseString; return responseString;
} else { } else {
...@@ -59,18 +66,18 @@ class RemoteData { ...@@ -59,18 +66,18 @@ class RemoteData {
return ''; return '';
} }
Future<String?> IdentifyStyleCode(File imagepath, String bodyimagepath) async { Future<String> saleData(String stylecode) async {
print('Identify Stylecode $bodyimagepath'); print(stylecode);
try { try {
final request = http.MultipartRequest('POST', Uri.parse(Identifystylecode)); final request = http.MultipartRequest('POST', Uri.parse(sale));
request.files.add(await http.MultipartFile.fromPath('image', imagepath.path)); request.files.add(http.MultipartFile.fromString('stylecode', stylecode));
request.files.add(await http.MultipartFile.fromString('body_image_path', bodyimagepath));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding)); //request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send(); var response = await request.send();
var responseString = await response.stream.bytesToString(); var responseString = await response.stream.bytesToString();
if (kDebugMode) { if (kDebugMode) {
print('Response :$responseString'); print('Response :$responseString');
} }
print(response.statusCode);
if (response.statusCode == 200) { if (response.statusCode == 200) {
return responseString; return responseString;
} else { } else {
...@@ -84,16 +91,102 @@ class RemoteData { ...@@ -84,16 +91,102 @@ class RemoteData {
return ''; return '';
} }
Future<String?> registerStyleCode(File imagepath, var embedding, String stylecode) async { Future<String?> uploadimage(File imagepath, String embedding) async {
print('Register Style Code : $stylecode');
try { try {
final request = http.MultipartRequest('POST', Uri.parse(registerstylecode)); final request = http.MultipartRequest(
request.files.add(await http.MultipartFile.fromPath('image', imagepath.path)); 'POST', Uri.parse('http://vaman.plutokm.com/detect_saree'));
request.files.add(http.MultipartFile.fromString('body_image_path', embedding)); request.files
//request.fields('style_code', stylecode); .add(await http.MultipartFile.fromPath('image', imagepath.path));
request.fields['style_code'] = stylecode; var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
if (response.statusCode == 200) {
return responseString;
} else {
return responseString;
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
return '';
}
Future<String?> IdentifyStyleCode(
File imagepath, String bodyimagepath) async {
if (kDebugMode) {
print('Identify Stylecode $bodyimagepath');
}
try {
final request =
http.MultipartRequest('POST', Uri.parse(identifystylecode));
request.files
.add(await http.MultipartFile.fromPath('image', imagepath.path));
request.files
.add(http.MultipartFile.fromString('body_image_path', bodyimagepath));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding)); //request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send(); var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
if (response.statusCode == 200) {
return responseString;
} else {
return responseString;
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
return '';
}
Future<String?> detectAttributes(File imagepath, String image) async {
try {
final request =
http.MultipartRequest('POST', Uri.parse(detectattributes));
request.files
.add(await http.MultipartFile.fromPath('image', imagepath.path));
request.files
.add(http.MultipartFile.fromString('body_image_path', image));
//request.fields['style_code'] = stylecode;
var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
if (response.statusCode == 200) {
return responseString;
} else {
return responseString;
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
return '';
}
Future<String?> registerStyleCode(
File imagepath, var embedding, String stylecode) async {
if (kDebugMode) {
print('Register Style Code : $stylecode');
}
try {
final request =
http.MultipartRequest('POST', Uri.parse(registerstylecode));
request.files
.add(await http.MultipartFile.fromPath('image', imagepath.path));
request.files
.add(http.MultipartFile.fromString('body_image_path', embedding));
request.fields['style_code'] = stylecode;
var response = await request.send();
var responseString = await response.stream.bytesToString(); var responseString = await response.stream.bytesToString();
if (kDebugMode) { if (kDebugMode) {
print('Response :$responseString'); print('Response :$responseString');
...@@ -113,7 +206,8 @@ class RemoteData { ...@@ -113,7 +206,8 @@ class RemoteData {
Future<String?> searchbybarcode(String barcode) async { Future<String?> searchbybarcode(String barcode) async {
var client = http.Client(); var client = http.Client();
var res = await client.get(Uri.parse('https://vaman.plutokm.com/get_vas_barcode_image/$barcode')); var res = await client.get(
Uri.parse('https://vaman.plutokm.com/get_vas_barcode_image/$barcode'));
if (kDebugMode) { if (kDebugMode) {
print(res.body); print(res.body);
} }
......
...@@ -108,18 +108,9 @@ class _Searchbybarcode extends State<Searchbybarcode> { ...@@ -108,18 +108,9 @@ class _Searchbybarcode extends State<Searchbybarcode> {
bool isInternetConnected = bool isInternetConnected =
await Constants.checkInternetConnectivity(); await Constants.checkInternetConnectivity();
if (isInternetConnected) { if (isInternetConnected) {
showDialog( Constants.Showindicator(context, 'Search Barcode');
context: context, var upload = await RemoteData().searchbybarcode(
barrierDismissible: false, _barcode.text.trim().toUpperCase());
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 69, 66, 121),
),
);
}
);
var upload = await RemoteData().searchbybarcode(_barcode.text.trim().toUpperCase());
if (upload != null) { if (upload != null) {
var jsonResponse = jsonDecode(upload); var jsonResponse = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
...@@ -129,7 +120,7 @@ class _Searchbybarcode extends State<Searchbybarcode> { ...@@ -129,7 +120,7 @@ class _Searchbybarcode extends State<Searchbybarcode> {
if (kDebugMode) { if (kDebugMode) {
print('Testing =========>'); print('Testing =========>');
} }
Navigator.of(context).pop(); // Navigator.of(context).pop();
} }
} else { } else {
setDialog('Check your internet connection'); setDialog('Check your internet connection');
...@@ -148,7 +139,6 @@ class _Searchbybarcode extends State<Searchbybarcode> { ...@@ -148,7 +139,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
end: Alignment.bottomRight, end: Alignment.bottomRight,
colors: [ colors: [
Color.fromARGB(255, 227, 144, 214), Color.fromARGB(255, 227, 144, 214),
//Color(0xFFC2185B),
Color.fromARGB(255, 125, 174, 251), Color.fromARGB(255, 125, 174, 251),
], ],
), ),
...@@ -157,7 +147,6 @@ class _Searchbybarcode extends State<Searchbybarcode> { ...@@ -157,7 +147,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
child: const Row( child: const Row(
children: [ children: [
Text('\t\t'), Text('\t\t'),
// replace with your image
Expanded( Expanded(
child: Center( child: Center(
child: Text( child: Text(
...@@ -211,15 +200,19 @@ class _Searchbybarcode extends State<Searchbybarcode> { ...@@ -211,15 +200,19 @@ class _Searchbybarcode extends State<Searchbybarcode> {
} }
void updateUI(Map<String, dynamic> jsonResponse) { void updateUI(Map<String, dynamic> jsonResponse) {
setState(() { Navigator.of(context).pop();
var newImageUrl = jsonResponse['image_url']; var newImageUrl = jsonResponse['image_url'];
var status = jsonResponse['status'];
if (status == 'NotFound') {
setDialog(jsonResponse['status']);
} else {
setState(() { setState(() {
imageUrl = newImageUrl; imageUrl = newImageUrl;
var str = _barcode.text; var str = _barcode.text;
value = 'BARCODE : $str'; value = 'BARCODE : $str';
_barcode.clear(); _barcode.clear();
}); });
}); }
} }
void setDialog(String text) { void setDialog(String text) {
......
...@@ -8,6 +8,7 @@ import 'package:vasthram/SignUp.dart'; ...@@ -8,6 +8,7 @@ import 'package:vasthram/SignUp.dart';
class UserPreferences { class UserPreferences {
static const String isLoggedInKey = 'isLoggedIn'; static const String isLoggedInKey = 'isLoggedIn';
static Future<SharedPreferences> getSharedPreferences() async { static Future<SharedPreferences> getSharedPreferences() async {
return await SharedPreferences.getInstance(); return await SharedPreferences.getInstance();
} }
...@@ -27,6 +28,7 @@ class SplashScreen extends StatefulWidget { ...@@ -27,6 +28,7 @@ class SplashScreen extends StatefulWidget {
class SplashScreenState extends State<SplashScreen> { class SplashScreenState extends State<SplashScreen> {
bool? isLoggedIn = false; bool? isLoggedIn = false;
void timeToShowSplashScreenOnScreen() async { void timeToShowSplashScreenOnScreen() async {
Timer(const Duration(seconds: 5), () async { Timer(const Duration(seconds: 5), () async {
if (!mounted) return; if (!mounted) return;
...@@ -39,7 +41,8 @@ class SplashScreenState extends State<SplashScreen> { ...@@ -39,7 +41,8 @@ class SplashScreenState extends State<SplashScreen> {
if (kDebugMode) { if (kDebugMode) {
print('if condition :$isLoggedIn'); print('if condition :$isLoggedIn');
} }
Navigator.push(context, MaterialPageRoute(builder: (context) => const Home())); Navigator.push(
context, MaterialPageRoute(builder: (context) => const Home()));
} else { } else {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
...@@ -67,19 +70,6 @@ class SplashScreenState extends State<SplashScreen> { ...@@ -67,19 +70,6 @@ class SplashScreenState extends State<SplashScreen> {
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
frameRate: 30, //default is 15 FPS frameRate: 30, //default is 15 FPS
), ),
// decoration: const BoxDecoration(
// //loadingText: Text("Loading"),
// GifView.asset(
// 'assets/images/login.gif',
// height: 350,
// width: 350,
// frameRate: 30, //default is 15 FPS
// ),
// image: DecorationImage(
// image: AssetImage("assets/images/splash.gif"),
// fit: BoxFit.cover,
// ),
// ),
), ),
); );
} }
......
...@@ -117,16 +117,7 @@ class _Uploadstylecode extends State<Uploadstylecode> { ...@@ -117,16 +117,7 @@ class _Uploadstylecode extends State<Uploadstylecode> {
}); });
bool isInternetConnected = await Constants.checkInternetConnectivity(); bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) { if (isInternetConnected) {
showDialog( Constants.Showindicator(context, 'Detecting Saree');
context: context,
barrierDismissible: false,
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 69, 66, 121),
),
);
});
var upload = await RemoteData().uploadimage(imagefile!, ''); var upload = await RemoteData().uploadimage(imagefile!, '');
print(_stylecode.text); print(_stylecode.text);
if (upload != null) { if (upload != null) {
...@@ -686,12 +677,16 @@ class _Uploadstylecode extends State<Uploadstylecode> { ...@@ -686,12 +677,16 @@ class _Uploadstylecode extends State<Uploadstylecode> {
setState(() { setState(() {
_base64Image = annotated_image; _base64Image = annotated_image;
}); });
Constants.Showindicator(context, 'Register Stylecode');
var upload = await RemoteData() var upload = await RemoteData()
.registerStyleCode(imagefile!, bodyimage, _stylecode.text); .registerStyleCode(imagefile!, bodyimage, _stylecode.text);
var json = jsonDecode(upload!); if (upload != null) {
await Future.delayed(const Duration(seconds: 1)); var json = jsonDecode(upload);
getupdate(json); await Future.delayed(const Duration(seconds: 1));
print(upload); getupdate(json);
print(upload);
}
return; return;
} else { } else {
showDialog( showDialog(
...@@ -721,6 +716,10 @@ class _Uploadstylecode extends State<Uploadstylecode> { ...@@ -721,6 +716,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
void getupdate(Map<String, dynamic> jsonResponse) { void getupdate(Map<String, dynamic> jsonResponse) {
setState(() { setState(() {
Navigator.of(context).pop();
setState(() {
isloading = false;
});
isVisible = false; isVisible = false;
//{"error_message":"","reg_status":"Success"} //{"error_message":"","reg_status":"Success"}
status = jsonResponse['reg_status']; status = jsonResponse['reg_status'];
...@@ -736,10 +735,10 @@ class _Uploadstylecode extends State<Uploadstylecode> { ...@@ -736,10 +735,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
} else { } else {
print('Else Printing ===============>'); print('Else Printing ===============>');
setDialog(jsonResponse['error_message']); setDialog(jsonResponse['reg_status']);
//bytes!.clear(); //bytes!.clear();
//bytes1!.clear(); //bytes1!.clear();
embedding!.clear(); //embedding!.clear();
//Navigator.of(context).pop(); //Navigator.of(context).pop();
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment