Commit 59f975ac by Ramesh Babu Puvvadi

added Stock, Sale and View List

parent 25d9c72d
......@@ -156,8 +156,7 @@ class Constants {
context: ctx,
builder: (context) {
return const Center(child: CircularProgressIndicator());
}
);
});
}
static Future<void> dismissAlertDialog1(BuildContext context) async {
......@@ -232,8 +231,7 @@ class Constants {
child: const Text("Cancel"),
onPressed: () {
Navigator.of(context).pop();
}
);
});
AlertDialog alert = AlertDialog(
title: Text(title),
content: Text(message),
......@@ -255,6 +253,35 @@ class Constants {
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) {
Widget okButton = TextButton(
child: const Text("Cancel"),
......
......@@ -166,6 +166,7 @@ class _Home extends State<Home> {
),
const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
......@@ -236,6 +237,7 @@ class _Home extends State<Home> {
),
const Padding(padding: EdgeInsets.only(left: 10, bottom: 10)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
......@@ -324,8 +326,7 @@ class _Home extends State<Home> {
),
padding: const EdgeInsets.all(12),
child: const Column(
mainAxisAlignment: MainAxisAlignment
.end, // Align content at the bottom
mainAxisAlignment: MainAxisAlignment.end, // Align content at the bottom
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
......@@ -869,16 +870,14 @@ class _Home extends State<Home> {
width: MediaQuery.of(context).size.width * 0.90,
child: GestureDetector(
onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// const Identifyproduct()),
// );
Navigator.push(context,
MaterialPageRoute(
builder: (context) =>
const Identifyproduct()),
);
},
child: Container(
margin: const EdgeInsets.only(
left: 20, top: 0, right: 2, bottom: 0),
margin: const EdgeInsets.only(left: 20, top: 0, right: 2, bottom: 0),
width: MediaQuery.of(context).size.width * 0.100,
height: MediaQuery.of(context).size.width * 0.22,
padding: const EdgeInsets.all(5),
......@@ -902,7 +901,7 @@ class _Home extends State<Home> {
height: 42,
), // replace with your image
const Text(
'\t\t\t\t\t\t IDENTIFY PRODUCT',
'\t\t\t\t\t\t DETECT ATTRIBUTES',
style: Constants.buttonsfontStyle,
)
],
......
......@@ -6,13 +6,17 @@ import 'package:http/http.dart' as http;
class RemoteData {
final String loginUrl = 'http://vaman.plutokm.com/login';
final String Uploadimage = 'http://vaman.plutokm.com/vasthram_mobile';
final String Identifystylecode = 'https://vaman.plutokm.com/get_vasthram_style_code';
final String imageupload = 'http://vaman.plutokm.com/vasthram_mobile';
final String identifystylecode = 'https://vaman.plutokm.com/get_vasthram_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 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 = {
'login_id': loginid,
'password': pass,
......@@ -36,16 +40,68 @@ class RemoteData {
}
}
Future<String?> uploadimage(File imagepath, String embedding) async {
Future<String> stockData(String stylecode) async {
print(stylecode);
try {
final request = http.MultipartRequest('POST', Uri.parse('http://vaman.plutokm.com/detect_saree'));
request.files.add(await http.MultipartFile.fromPath('image', imagepath.path));
final request = http.MultipartRequest('POST', Uri.parse(stock));
request.files.add(http.MultipartFile.fromString('stylecode', stylecode));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
print(response.statusCode);
if (response.statusCode == 200) {
return responseString;
} else {
return responseString;
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
return '';
}
Future<String> saleData(String stylecode) async {
print(stylecode);
try {
final request = http.MultipartRequest('POST', Uri.parse(sale));
request.files.add(http.MultipartFile.fromString('stylecode', stylecode));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
print(response.statusCode);
if (response.statusCode == 200) {
return responseString;
} else {
return responseString;
}
} catch (e) {
if (kDebugMode) {
print(e);
}
}
return '';
}
Future<String?> uploadimage(File imagepath, String embedding) async {
try {
final request = http.MultipartRequest(
'POST', Uri.parse('http://vaman.plutokm.com/detect_saree'));
request.files
.add(await http.MultipartFile.fromPath('image', imagepath.path));
var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
print('Response :$responseString');
}
if (response.statusCode == 200) {
return responseString;
} else {
......@@ -59,12 +115,18 @@ class RemoteData {
return '';
}
Future<String?> IdentifyStyleCode(File imagepath, String bodyimagepath) async {
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(await http.MultipartFile.fromString('body_image_path', bodyimagepath));
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));
var response = await request.send();
var responseString = await response.stream.bytesToString();
......@@ -84,15 +146,46 @@ class RemoteData {
return '';
}
Future<String?> registerStyleCode(File imagepath, var embedding, String stylecode) async {
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);
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;
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var response = await request.send();
var responseString = await response.stream.bytesToString();
if (kDebugMode) {
......@@ -113,7 +206,8 @@ class RemoteData {
Future<String?> searchbybarcode(String barcode) async {
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) {
print(res.body);
}
......
......@@ -108,18 +108,9 @@ class _Searchbybarcode extends State<Searchbybarcode> {
bool isInternetConnected =
await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 69, 66, 121),
),
);
}
);
var upload = await RemoteData().searchbybarcode(_barcode.text.trim().toUpperCase());
Constants.Showindicator(context, 'Search Barcode');
var upload = await RemoteData().searchbybarcode(
_barcode.text.trim().toUpperCase());
if (upload != null) {
var jsonResponse = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 1));
......@@ -129,7 +120,7 @@ class _Searchbybarcode extends State<Searchbybarcode> {
if (kDebugMode) {
print('Testing =========>');
}
Navigator.of(context).pop();
// Navigator.of(context).pop();
}
} else {
setDialog('Check your internet connection');
......@@ -148,7 +139,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
end: Alignment.bottomRight,
colors: [
Color.fromARGB(255, 227, 144, 214),
//Color(0xFFC2185B),
Color.fromARGB(255, 125, 174, 251),
],
),
......@@ -157,7 +147,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
child: const Row(
children: [
Text('\t\t'),
// replace with your image
Expanded(
child: Center(
child: Text(
......@@ -211,15 +200,19 @@ class _Searchbybarcode extends State<Searchbybarcode> {
}
void updateUI(Map<String, dynamic> jsonResponse) {
setState(() {
Navigator.of(context).pop();
var newImageUrl = jsonResponse['image_url'];
var status = jsonResponse['status'];
if (status == 'NotFound') {
setDialog(jsonResponse['status']);
} else {
setState(() {
imageUrl = newImageUrl;
var str = _barcode.text;
value = 'BARCODE : $str';
_barcode.clear();
});
});
}
}
void setDialog(String text) {
......
......@@ -8,6 +8,7 @@ import 'package:vasthram/SignUp.dart';
class UserPreferences {
static const String isLoggedInKey = 'isLoggedIn';
static Future<SharedPreferences> getSharedPreferences() async {
return await SharedPreferences.getInstance();
}
......@@ -27,6 +28,7 @@ class SplashScreen extends StatefulWidget {
class SplashScreenState extends State<SplashScreen> {
bool? isLoggedIn = false;
void timeToShowSplashScreenOnScreen() async {
Timer(const Duration(seconds: 5), () async {
if (!mounted) return;
......@@ -39,7 +41,8 @@ class SplashScreenState extends State<SplashScreen> {
if (kDebugMode) {
print('if condition :$isLoggedIn');
}
Navigator.push(context, MaterialPageRoute(builder: (context) => const Home()));
Navigator.push(
context, MaterialPageRoute(builder: (context) => const Home()));
} else {
Navigator.pushAndRemoveUntil(
context,
......@@ -67,19 +70,6 @@ class SplashScreenState extends State<SplashScreen> {
width: MediaQuery.of(context).size.width,
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> {
});
bool isInternetConnected = await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return const Center(
child: CircularProgressIndicator(
color: Color.fromARGB(255, 69, 66, 121),
),
);
});
Constants.Showindicator(context, 'Detecting Saree');
var upload = await RemoteData().uploadimage(imagefile!, '');
print(_stylecode.text);
if (upload != null) {
......@@ -686,12 +677,16 @@ class _Uploadstylecode extends State<Uploadstylecode> {
setState(() {
_base64Image = annotated_image;
});
Constants.Showindicator(context, 'Register Stylecode');
var upload = await RemoteData()
.registerStyleCode(imagefile!, bodyimage, _stylecode.text);
var json = jsonDecode(upload!);
if (upload != null) {
var json = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 1));
getupdate(json);
print(upload);
}
return;
} else {
showDialog(
......@@ -721,6 +716,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
void getupdate(Map<String, dynamic> jsonResponse) {
setState(() {
Navigator.of(context).pop();
setState(() {
isloading = false;
});
isVisible = false;
//{"error_message":"","reg_status":"Success"}
status = jsonResponse['reg_status'];
......@@ -736,10 +735,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
} else {
print('Else Printing ===============>');
setDialog(jsonResponse['error_message']);
setDialog(jsonResponse['reg_status']);
//bytes!.clear();
//bytes1!.clear();
embedding!.clear();
//embedding!.clear();
//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