Skip to content

Commit

Permalink
qr view added
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinPramodya committed Nov 5, 2020
1 parent 09f23b1 commit ac15082
Show file tree
Hide file tree
Showing 16 changed files with 1,006 additions and 117 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
.history
.svn/

# Visual Studio Code related
.vscode/

# IntelliJ related
*.iml
*.ipr
Expand Down
17 changes: 17 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/opt/jdk-11.0.2
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
6 changes: 6 additions & 0 deletions android/app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
23 changes: 23 additions & 0 deletions android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/app/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "app.ceylon.selftrackingapp"
minSdkVersion 16
minSdkVersion 24
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
48 changes: 18 additions & 30 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.ceylon.selftrackingapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.ceylon.selftrackingapp">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name="io.flutter.app.FlutterApplication"
android:label="MyHealth Sri Lanka"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application android:name="io.flutter.app.FlutterApplication" android:label="MyHealth Sri Lanka" android:icon="@mipmap/ic_launcher" android:usesCleartextTraffic="true">
<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
Expand All @@ -34,22 +27,17 @@
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBQu2WwoTFKJQ1PM4w-hIRkLnEVDtWtFoo"/>
<meta-data android:name="flutterEmbedding" android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBQu2WwoTFKJQ1PM4w-hIRkLnEVDtWtFoo" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" />


<service android:name=".service.LocationTrackingService" android:enabled="true" />
<receiver android:name=".service.LocationReceiver" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.REBOOT"/>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.REBOOT" />
</intent-filter>
</receiver>
</application>
Expand Down
4 changes: 3 additions & 1 deletion assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
"health_information": "Health Information",
"covid_19_information": "Covid-19 Related Complaints",
"pharmacy_list": "Locate Nearest Pharmacy Delivery Service",
"pharmacy_tab": "Pharmacy"
"pharmacy_tab": "Pharmacy",
"scan_qr": "QR Scanner"


}
3 changes: 2 additions & 1 deletion assets/lang/si.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@
"health_information": "වෛද්\u200Dය උපදෙස්",
"covid_19_information": "Covid-19 ආශ්\u200Dරිත පැමිණිලි",
"pharmacy_list": "ආසන්නයේ ඇති ෆාමසි සොයා ගැනීමට",
"pharmacy_tab": "ෆාමසි"
"pharmacy_tab": "ෆාමසි",
"scan_qr": "QR ස්කෑනරය"
}
3 changes: 2 additions & 1 deletion assets/lang/ta.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@
"health_information": "சுகாதார தகவல்",
"covid_19_information": "கோவிட் -19 தொடர்புடைய புகார்கள்",
"pharmacy_list": "அருகிலுள்ள மருத்தக விநியோக சேவையைக் கண்டறிக",
"pharmacy_tab": "மருந்தகம்"
"pharmacy_tab": "மருந்தகம்",
"scan_qr": "QR ஸ்கேனர்"
}
73 changes: 73 additions & 0 deletions lib/page/screen/qr_scan_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:selftrackingapp/page/screen/qr_webview_screen.dart';
import 'package:webview_flutter/webview_flutter.dart';

class QrScanScreen extends StatefulWidget {
@override
_QrScanScreenState createState() => _QrScanScreenState();
}

class _QrScanScreenState extends State<QrScanScreen> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
var qrText = "";
QRViewController controller;

@override
void initState() {
super.initState();
}

@override
void dispose() {
controller?.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
flex: 5,
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
),
Expanded(
flex: 1,
child: Center(
child: IconButton(
icon: Icon(Icons.query_builder),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => QrWebviewScreen(
url: 'https://staysafe.gov.lk/',
)));
},
)),
),
],
),
);
}

void _handleURLButtonPress(BuildContext context, String url) {
Navigator.push(context,
MaterialPageRoute(builder: (context) => QrWebviewScreen(url: url)));
}

void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
setState(() {
qrText = scanData;
_handleURLButtonPress(context, qrText);
});
});
}
}
45 changes: 45 additions & 0 deletions lib/page/screen/qr_webview_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:webview_flutter/webview_flutter.dart';

class QrWebviewScreen extends StatefulWidget {
final String url;

const QrWebviewScreen({Key key, this.url}) : super(key: key);
@override
_QrWebviewScreenState createState() => _QrWebviewScreenState();
}

WebViewController controllerGlobal;

class _QrWebviewScreenState extends State<QrWebviewScreen> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => _exitApp(context),
child: Scaffold(
body: WebView(
initialUrl: widget.url,
),
),
);
}

Future<bool> _exitApp(BuildContext context) async {
print("cal");
if (await controllerGlobal.canGoBack()) {
print("onwill goback");
controllerGlobal.goBack();
} else {
Scaffold.of(context).showSnackBar(
const SnackBar(content: Text("No back history item")),
);
return Future.value(false);
}
}
}
Loading

0 comments on commit ac15082

Please sign in to comment.