Commit ed221f4f by Ramesh Babu Puvvadi

added horizontal scrolling

parent 7bc02900
...@@ -16,18 +16,18 @@ class Home extends StatefulWidget { ...@@ -16,18 +16,18 @@ class Home extends StatefulWidget {
class _Home extends State<Home> { class _Home extends State<Home> {
File? imagefile; File? imagefile;
final TextEditingController _barcodevalue = TextEditingController();
final ImagePicker _picker = ImagePicker(); final ImagePicker _picker = ImagePicker();
late List<File> arraylist = []; late List<File> arraylist = [];
XFile? image; XFile? image;
bool isloading = false; bool isloading = false;
var body_color = ''; var body_color = '';
var body_design_color = ''; var body_design_color = '';
var border_color = ''; var border_color = '';
var border_size = ''; var border_size = '';
var border_work_color = ''; var border_work_color = '';
var status = '';
final PageController _pageController = PageController(initialPage: 0);
List<Widget> pages = [];
Future<void> _getImage(int index) async { Future<void> _getImage(int index) async {
image = await _picker.pickImage(source: ImageSource.camera); image = await _picker.pickImage(source: ImageSource.camera);
...@@ -45,6 +45,124 @@ class _Home extends State<Home> { ...@@ -45,6 +45,124 @@ class _Home extends State<Home> {
super.initState(); super.initState();
} }
Widget buildPage2(String title) {
return Center(
child: Container(
color: const Color.fromRGBO(222, 221, 220, 1),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
if (body_color.isNotEmpty ||
body_design_color.isNotEmpty ||
border_color.isNotEmpty ||
border_size.isNotEmpty ||
border_work_color.isNotEmpty)
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Padding(padding: EdgeInsets.only(bottom: 20)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Body Design Color: $body_design_color\n'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Color: $border_color\n'),
],
),
],
)
else
const SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(bottom: 20)),
Text('\n'),
Text('\n'),
],
),
),
],
),
),
);
}
Widget buildPage3(String title) {
return Container(
color: Color.fromARGB(255, 240, 200, 159),
);
}
Widget buildPage1(String title) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (body_color.isNotEmpty ||
body_design_color.isNotEmpty ||
border_color.isNotEmpty ||
border_size.isNotEmpty ||
border_work_color.isNotEmpty)
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Padding(padding: EdgeInsets.only(bottom: 20)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Body Color: $body_color\n'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Body Design Color: $body_design_color\n'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Color: $border_color\n'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Size: $border_size\n'),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Work Color: $border_work_color\n'),
],
),
],
)
else
const SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(bottom: 20)),
Text('\n'),
Text('\n'),
Text('\n'),
Text('\n'),
Text('\n'),
],
),
),
],
),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -77,182 +195,112 @@ class _Home extends State<Home> { ...@@ -77,182 +195,112 @@ class _Home extends State<Home> {
child: Container( child: Container(
margin: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [ children: [
Column( const Padding(padding: EdgeInsets.only(top: 5)),
children: [ const Text(
const Padding(padding: EdgeInsets.only(top: 5)), 'Capture Image',
const Text( style: TextStyle(
'Capture Image', fontSize: 18,
style: TextStyle( color: Colors.black,
fontSize: 18, fontStyle: FontStyle.normal,
color: Colors.black, fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal, ),
fontWeight: FontWeight.bold),
),
const Padding(padding: EdgeInsets.only(top: 15)),
GestureDetector(
onTap: () {
_getImage(0);
},
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.94,
height: MediaQuery.of(context).size.height * 0.50,
child: imagefile != null
? Image.file(
imagefile!,
fit: BoxFit.cover,
)
: Image.asset(
'assets/images/camera.png',
width: MediaQuery.of(context).size.width *
0.80,
height:
MediaQuery.of(context).size.height *
0.60,
),
),
),
],
), ),
]), const Padding(padding: EdgeInsets.only(top: 15)),
if (isloading) GestureDetector(
const CircularProgressIndicator() onTap: () {
else if (body_color.isNotEmpty || _getImage(0);
body_design_color.isNotEmpty || },
border_color.isNotEmpty || child: SizedBox(
border_size.isNotEmpty || width: MediaQuery.of(context).size.width * 0.94,
border_work_color.isNotEmpty) height: MediaQuery.of(context).size.height * 0.50,
SizedBox( child: imagefile != null
child: Column( ? Image.file(
mainAxisAlignment: MainAxisAlignment.start, imagefile!,
children: [ fit: BoxFit.cover,
const Padding(padding: EdgeInsets.only(bottom: 20)), )
Row( : Image.asset(
mainAxisAlignment: MainAxisAlignment.start, 'assets/images/camera.png',
children: [ width:
Text('Body Color: $body_color\n'), MediaQuery.of(context).size.width * 0.80,
], height:
MediaQuery.of(context).size.height * 0.60,
),
), ),
Row( ),
mainAxisAlignment: MainAxisAlignment.start, ],
children: [
Text('Body Design Color: $body_design_color\n'),
]),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Color: $border_color\n'),
]),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Size: $border_size\n'),
]),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Border Work Color: $border_work_color\n'),
]),
],
),
)
else
const SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(padding: EdgeInsets.only(bottom: 20)),
Text('\n'),
Text('\n'),
Text('\n'),
Text('\n'),
Text('\n'),
],
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
backgroundColor: const Color.fromARGB(255, 170, 57, 230),
minimumSize: const Size.fromHeight(50),
), ),
onPressed: () async { ],
if (imagefile == null) { ),
Constants('Vasthram', 'Please Capture Image') SizedBox(
.showAlertDialog(context, true); height: MediaQuery.of(context).size.height * 0.25,
} else { child: PageView(
isloading = true; controller: _pageController,
bool isInternetConnected = children: pages = [
await Constants.checkInternetConnectivity(); buildPage1(
if (isInternetConnected) { 'Page 1'), // Replace with your content for the first object
showDialog( buildPage2('Page 2'),
context: context, buildPage3(
builder: (context) { 'Page 3'), // Replace with your content for the second object
return const Center( // Add more pages for other objects
child: CircularProgressIndicator()); ],
}); ),
),
var upload = await RemoteData().uploadimage( ElevatedButton(
imagefile!, style: ElevatedButton.styleFrom(
); padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
if (upload != null) { backgroundColor: const Color.fromARGB(255, 170, 57, 230),
setState(() { minimumSize: const Size.fromHeight(50),
isloading = true; ),
}); onPressed: () async {
var jsonResponse = jsonDecode(upload); if (imagefile == null) {
await Future.delayed(const Duration(seconds: 2)); Constants('Vasthram', 'Please Capture Image')
.showAlertDialog(context, true);
} else {
isloading = true;
bool isInternetConnected =
await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
builder: (context) {
return const Center(
child: CircularProgressIndicator(),
);
},
);
updateUI(jsonResponse); var upload = await RemoteData().uploadimage(imagefile!);
setState(() { if (upload != null) {
isloading = false; setState(() {
}); isloading = true;
} });
var jsonResponse = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 2));
Navigator.of(context).pop(); updateUI(jsonResponse);
//print(body_color); setState(() {
// if (jsonResponse['success'] == true) { isloading = false;
// if (imagefile != null) { });
// imagefile?.delete();
// imagefile = null;
// }
// setState(() {
// //body_color;
// //body_design_color;
// //border_color;
// //border_size;
// //border_work_color;
// Navigator.of(context).pop();
// imagefile != null
// ? Image.file(
// imagefile!,
// //width: 160.0,
// //height: 200.0,
// )
// : Image.asset(
// 'assets/images/camera.png',
// width: MediaQuery.of(context).size.width *
// 0.80,
// height: MediaQuery.of(context).size.height *
// 0.70,
// );
// //Constants.showAlertDialog1('Upload Image', jsonResponse['message']));
// });
// } else {
// Navigator.of(context).pop();
// }
} else {
Constants('Vasthram', 'Check your internet connection')
.showAlertDialog(context, true);
} }
Navigator.of(context).pop();
} else {
Constants('Vasthram', 'Check your internet connection')
.showAlertDialog(context, true);
} }
}, }
child: const Text('Upload Image'), },
), child: const Text('Upload Image'),
]), ),
],
),
), ),
), ),
); );
...@@ -261,53 +309,32 @@ class _Home extends State<Home> { ...@@ -261,53 +309,32 @@ class _Home extends State<Home> {
void updateUI(Map<String, dynamic> jsonResponse) { void updateUI(Map<String, dynamic> jsonResponse) {
setState(() { setState(() {
// Update variables based on jsonResponse // Update variables based on jsonResponse
body_color = jsonResponse['body_color']; status = jsonResponse['status'];
body_design_color = jsonResponse['body_design_color']; print(status);
border_color = jsonResponse['border_color']; if (status == 'Success') {
border_size = jsonResponse['border_size']; print('One :$status');
border_work_color = jsonResponse['border_work_color']; body_color = jsonResponse['body_color'];
}); print('One :$body_color');
} body_design_color = jsonResponse['body_design_color'];
print('One :$body_design_color');
border_color = jsonResponse['border_color'];
print('One :$border_color');
// void getUpdate(String text) async { border_size = jsonResponse['border_size'];
// Upload? upload = await RemoteData().getValidBarcode(_barcodevalue.text); print('One :$border_size');
// //print('Response Data :${upload?.success}');
// if (upload?.success == 1) {
// } else if (upload?.success == 2) {
// _showDialog();
// } else if (upload?.success == 0) {
// //print(upload!.msg);
// Constants('Multiple Images', upload!.msg).showAlertDialog(context);
// _barcodevalue.text = '';
// }
// }
void showdialog() { border_work_color = jsonResponse['border_work_color'];
showDialog( print('One :$border_work_color');
context: context, } else {
builder: (BuildContext context) { print('Two :$status');
return AlertDialog( Constants.dialogMessage(context, 'Vasthram', 'Could not found image');
title: const Text('Scan Additional Items?'), body_color = '';
content: const Text( body_design_color = '';
'This item is already Catloged. Scan Additional Pics of this item? Click No to skip this barcode'), border_color = '';
actions: [ border_size = '';
TextButton( border_work_color = '';
onPressed: () { }
// Perform some action });
Navigator.of(context).pop(); _pageController.jumpToPage(0);
},
child: const Text('Ok'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
_barcodevalue.text = '';
},
child: const Text('No'),
),
],
);
},
);
} }
} }
...@@ -5,12 +5,11 @@ import 'package:http/http.dart' as http; ...@@ -5,12 +5,11 @@ import 'package:http/http.dart' as http;
//8008202992 //8008202992
class RemoteData { class RemoteData {
String LoginUrl = 'http://vaman.plutokm.com/login'; final String loginUrl = 'http://vaman.plutokm.com/login';
String Type = "Content-Type"; final String type = "Content-Type";
String App_json = "application/json"; final String appjson = "application/json";
Future<String> getLoginRequest( Future<String> getLoginRequest(String loginid, String pass, String token) async {
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,
...@@ -27,8 +26,8 @@ class RemoteData { ...@@ -27,8 +26,8 @@ class RemoteData {
} }
var client = http.Client(); var client = http.Client();
var res = await client.post(Uri.parse(LoginUrl), var res = await client.post(Uri.parse(loginUrl),
headers: {Type: App_json}, body: json.encode(body)); headers: {type: appjson}, body: json.encode(body));
if (res.statusCode == 200) { if (res.statusCode == 200) {
return res.body; return res.body;
} else { } else {
...@@ -39,7 +38,7 @@ class RemoteData { ...@@ -39,7 +38,7 @@ class RemoteData {
Future<String?> uploadimage(File imagepath) async { Future<String?> uploadimage(File imagepath) async {
try { try {
final request = http.MultipartRequest( final request = http.MultipartRequest(
'POST', Uri.parse('http://192.168.65.123:5155/vasthram_mobile')); 'POST', Uri.parse('http://vaman.plutokm.com/vasthram_mobile'));
request.files request.files
.add(await http.MultipartFile.fromPath('image', imagepath.path)); .add(await http.MultipartFile.fromPath('image', imagepath.path));
var response = await request.send(); var response = await request.send();
......
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