Skip to content

Commit

Permalink
version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswanthreddy-007 committed May 6, 2023
2 parents 9e81f49 + fe0650f commit efda4ed
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 68 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
pull_request:
branches:
- testing
- master
push:
branches:
- testing
- master
name: "Build & Release"
jobs:
build:
permissions: write-all
name: Build & Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.7.12'
channel : 'stable'
- run: flutter pub get

- run: flutter build
- run: flutter build appbundle

- name: Push to Releases
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/debug/*,build/ios/iphoneos/app.ipa"
tag: v1.0.${{ github.run_number }}
92 changes: 90 additions & 2 deletions lib/pages/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;


class dashboard extends StatefulWidget {
const dashboard({Key? key}) : super(key: key);
Expand All @@ -8,11 +13,94 @@ class dashboard extends StatefulWidget {
}

class _dashboardState extends State<dashboard> {
final String apiUrl = "http://10.0.2.2:3000/reverse_string";

TextEditingController _controller = TextEditingController();
String _reversedString = '';

Future<void> _reverseString() async {
String input2 = _controller.text;
print(input2);
// String input = 'hello';
final Map<String, String> headers = {
'Content-Type': 'application/json'
};

// Send a POST request to the Flask server with the input string
final response = await http.post(
Uri.parse(apiUrl),
headers: headers,
body: jsonEncode({'input_string': input2}),
);
Map<String, dynamic> data = jsonDecode(response.body);
String reversedString = data['reversed_string'];
// Update the UI with the reversed string
setState(() {
_reversedString = reversedString;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(

body: Center(child: Text('Dashboard',style: TextStyle(fontSize: 70),)),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _controller,
decoration: InputDecoration(
labelText: 'Enter a string',
),
),
SizedBox(height: 16.0),
ElevatedButton(
onPressed: _reverseString,
child: Text('Reverse string'),
),
SizedBox(height: 16.0),
Text(
'Reversed string: $_reversedString',
style: TextStyle(fontSize: 18.0),
),
],
),
),
);
}
}



/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

//
// void main() {
// runApp(MyApp());
// }
//
// class MyApp extends StatefulWidget {
// @override
// _MyAppState createState() => _MyAppState();
// }
//
// class _MyAppState extends State<MyApp> {
//
//
//
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// title: 'String Reversal App',
// home: Scaffold(
// appBar: AppBar(
// title: Text('String Reversal App'),
// ),
//
// ),
// );
// }
// }
//
154 changes: 119 additions & 35 deletions lib/pages/scan.dart
Original file line number Diff line number Diff line change
@@ -1,57 +1,104 @@
// import 'dart:js_util';

import 'dart:convert';
import 'package:crackapp/pages/segmentation.dart';
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:image_picker/image_picker.dart';



import 'package:http/http.dart' as http;

class scan extends StatefulWidget {
const scan({Key? key,}) : super(key: key);



@override
State<scan> createState() => _scanState();}



class _scanState extends State<scan> {

File? image;

Future pickImage() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.gallery);

if(image == null) return;

if (image == null) return;
final imageTemp = File(image.path);

setState(() => this.image = imageTemp);
} on PlatformException catch(e) {
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}

Future pickImageC() async {
try {
final image = await ImagePicker().pickImage(source: ImageSource.camera);

if(image == null) return;

if (image == null) return;
final imageTemp = File(image.path);

setState(() => this.image = imageTemp);
} on PlatformException catch(e) {
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}



final String apiUrl = "https://a48e-203-192-251-182.ngrok.io/imageapi";
// final String apiUrl = "http://10.0.2.2:3000/imageapi";
String? b64;

Future sendImage(File imageFile, BuildContext context) async {
List<int> imageBytes = await imageFile.readAsBytes();
String base64Image = base64.encode(imageBytes);

print(base64Image);
final Map<String, String> headers = {
'Content-Type': 'application/json'
};

final response = await http.post(
Uri.parse(apiUrl),
headers: headers,
body: jsonEncode({'image': base64Image}),
);

if (response.statusCode == 200) {
// handle success

print('output from here');
print(response.body);
this.b64 = response.body;
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => segmentation(b64!)));
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => segmentation(base64String)),
// );

// List<int> bytes = base64.decode(base64String);
// //
// // imageBytes = base64.b64decode(response.body);
// // Uint8List imgbytes = Uint8List.fromList(imageBytes);
// final processed = image!;
// processed.writeAsBytesSync(bytes);
// final imageTemp = File(processed.path);
// setState(() {
// this.image = response.body as File?;
// });
// print(imageTemp==image);
// print('this is image');
// print(image);
// // print(imageTemp);
// setState(() {
//
// });
} else {
// handle error
print('Error sending image: ${response.statusCode}');
}
}

@override
Widget build(BuildContext context) {

var assetsImage = new AssetImage('assets/illustration.png');
var emptyimage = new Image(image: assetsImage, fit: BoxFit.cover);
// SvgPicture.asset("assets/alarm_icon.svg");
Expand All @@ -60,41 +107,78 @@ class _scanState extends State<scan> {
appBar: AppBar(
title: const Text("Image Picker Example"),
),

body: Center(
child: Column(

children: [

SizedBox(height: 10,),
image != null ? Image.file(image!,height: 500,width: 700,): emptyimage,
image != null
? Image.file(image!, height: 500, width: 700,)
: emptyimage,
SizedBox(height: 10,),
MaterialButton(
color: Colors.blue,
child: const Text(
"Pick Image from Gallery",
style: TextStyle(
color: Colors.white70, fontWeight: FontWeight.bold
)
),
onPressed: () {
pickImage();
}

Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
MaterialButton(
color: Colors.lightGreen,

child: const Text(
"Pick Image from Gallery",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 10,
)
),
onPressed: () {
pickImage();
}
),
SizedBox(width: 20,),
MaterialButton(
color: Colors.greenAccent,
child: const Text(
"Pick Image from Camera",
style: TextStyle(
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 10,
)
),
onPressed: () {
pickImageC();
}
),
],

),
),
MaterialButton(
color: Colors.blue,
color: Colors.greenAccent,
child: const Text(
"Pick Image from Camera",
"UPLOAD",
style: TextStyle(
color: Colors.white70, fontWeight: FontWeight.bold
color: Colors.white70,
fontWeight: FontWeight.bold,
fontSize: 10,
)
),
onPressed: () {
pickImageC();
sendImage(image!, context);
}
),

],
),
)
);
}
}



Loading

0 comments on commit efda4ed

Please sign in to comment.