Commit ed221f4f by Ramesh Babu Puvvadi

added horizontal scrolling

parent 7bc02900
......@@ -16,18 +16,18 @@ class Home extends StatefulWidget {
class _Home extends State<Home> {
File? imagefile;
final TextEditingController _barcodevalue = TextEditingController();
final ImagePicker _picker = ImagePicker();
late List<File> arraylist = [];
XFile? image;
bool isloading = false;
var body_color = '';
var body_design_color = '';
var border_color = '';
var border_size = '';
var border_work_color = '';
var status = '';
final PageController _pageController = PageController(initialPage: 0);
List<Widget> pages = [];
Future<void> _getImage(int index) async {
image = await _picker.pickImage(source: ImageSource.camera);
......@@ -45,6 +45,124 @@ class _Home extends State<Home> {
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
Widget build(BuildContext context) {
return Scaffold(
......@@ -77,182 +195,112 @@ class _Home extends State<Home> {
child: Container(
margin: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Column(
children: [
const Padding(padding: EdgeInsets.only(top: 5)),
const Text(
'Capture Image',
style: TextStyle(
fontSize: 18,
color: Colors.black,
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: 5)),
const Text(
'Capture Image',
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
),
),
]),
if (isloading)
const CircularProgressIndicator()
else if (body_color.isNotEmpty ||
body_design_color.isNotEmpty ||
border_color.isNotEmpty ||
border_size.isNotEmpty ||
border_work_color.isNotEmpty)
SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Padding(padding: EdgeInsets.only(bottom: 20)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('Body Color: $body_color\n'),
],
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,
),
),
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')
.showAlertDialog(context, true);
} else {
isloading = true;
bool isInternetConnected =
await Constants.checkInternetConnectivity();
if (isInternetConnected) {
showDialog(
context: context,
builder: (context) {
return const Center(
child: CircularProgressIndicator());
});
var upload = await RemoteData().uploadimage(
imagefile!,
);
if (upload != null) {
setState(() {
isloading = true;
});
var jsonResponse = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 2));
],
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.25,
child: PageView(
controller: _pageController,
children: pages = [
buildPage1(
'Page 1'), // Replace with your content for the first object
buildPage2('Page 2'),
buildPage3(
'Page 3'), // Replace with your content for the second object
// Add more pages for other objects
],
),
),
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')
.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);
setState(() {
isloading = false;
});
}
var upload = await RemoteData().uploadimage(imagefile!);
if (upload != null) {
setState(() {
isloading = true;
});
var jsonResponse = jsonDecode(upload);
await Future.delayed(const Duration(seconds: 2));
Navigator.of(context).pop();
//print(body_color);
// if (jsonResponse['success'] == true) {
// 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);
updateUI(jsonResponse);
setState(() {
isloading = false;
});
}
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> {
void updateUI(Map<String, dynamic> jsonResponse) {
setState(() {
// Update variables based on jsonResponse
body_color = jsonResponse['body_color'];
body_design_color = jsonResponse['body_design_color'];
border_color = jsonResponse['border_color'];
border_size = jsonResponse['border_size'];
border_work_color = jsonResponse['border_work_color'];
});
}
status = jsonResponse['status'];
print(status);
if (status == 'Success') {
print('One :$status');
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 {
// Upload? upload = await RemoteData().getValidBarcode(_barcodevalue.text);
// //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 = '';
// }
// }
border_size = jsonResponse['border_size'];
print('One :$border_size');
void showdialog() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Scan Additional Items?'),
content: const Text(
'This item is already Catloged. Scan Additional Pics of this item? Click No to skip this barcode'),
actions: [
TextButton(
onPressed: () {
// Perform some action
Navigator.of(context).pop();
},
child: const Text('Ok'),
),
TextButton(
onPressed: () {
Navigator.of(context).pop();
_barcodevalue.text = '';
},
child: const Text('No'),
),
],
);
},
);
border_work_color = jsonResponse['border_work_color'];
print('One :$border_work_color');
} else {
print('Two :$status');
Constants.dialogMessage(context, 'Vasthram', 'Could not found image');
body_color = '';
body_design_color = '';
border_color = '';
border_size = '';
border_work_color = '';
}
});
_pageController.jumpToPage(0);
}
}
......@@ -5,12 +5,11 @@ import 'package:http/http.dart' as http;
//8008202992
class RemoteData {
String LoginUrl = 'http://vaman.plutokm.com/login';
String Type = "Content-Type";
String App_json = "application/json";
final String loginUrl = 'http://vaman.plutokm.com/login';
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,
......@@ -27,8 +26,8 @@ class RemoteData {
}
var client = http.Client();
var res = await client.post(Uri.parse(LoginUrl),
headers: {Type: App_json}, body: json.encode(body));
var res = await client.post(Uri.parse(loginUrl),
headers: {type: appjson}, body: json.encode(body));
if (res.statusCode == 200) {
return res.body;
} else {
......@@ -39,7 +38,7 @@ class RemoteData {
Future<String?> uploadimage(File imagepath) async {
try {
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
.add(await http.MultipartFile.fromPath('image', imagepath.path));
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