diff --git a/android/gradle.properties b/android/gradle.properties index 2bd6f4f..1441b1d 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,2 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true diff --git a/assets/images/ic_scan.png b/assets/images/ic_scan.png new file mode 100644 index 0000000..d1bcd39 Binary files /dev/null and b/assets/images/ic_scan.png differ diff --git a/assets/images/incubatepng.png b/assets/images/incubatepng.png new file mode 100644 index 0000000..6079a5a Binary files /dev/null and b/assets/images/incubatepng.png differ diff --git a/assets/images/indiapngg.png b/assets/images/indiapngg.png new file mode 100644 index 0000000..3f57e35 Binary files /dev/null and b/assets/images/indiapngg.png differ diff --git a/lib/constant/Constant.dart b/lib/constant/Constant.dart new file mode 100644 index 0000000..77d6cdd --- /dev/null +++ b/lib/constant/Constant.dart @@ -0,0 +1 @@ +final String HOME_SCREEN="/HOME_SCREEN"; \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 5a7af45..e2c0ca7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,111 +1,19 @@ import 'package:flutter/material.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, - ), - home: MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - _MyHomePageState createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.display1, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} +import 'package:qrgenerator/screen/HomeScreen.dart'; +import 'package:qrgenerator/screen/SplashScreen.dart'; + +import 'constant/Constant.dart'; + +void main() => runApp( + MaterialApp( + debugShowCheckedModeBanner: false, + theme: ThemeData( + primarySwatch: Colors.blue, + ), + title: 'QR GENERATOR', + routes: { + HOME_SCREEN: (BuildContext context) => HomeScreen(), + }, + home: SplashScreen(), + ), +); diff --git a/lib/screen/HomeScreen.dart b/lib/screen/HomeScreen.dart new file mode 100644 index 0000000..1ef3ed2 --- /dev/null +++ b/lib/screen/HomeScreen.dart @@ -0,0 +1,165 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter/services.dart'; +import 'package:qr_utils/qr_utils.dart'; + + +class HomeScreen extends StatefulWidget { + @override + State createState() { + return _HomeScreenState(); + } +} + +class _HomeScreenState extends State { + Image _image; + + final GlobalKey _scaffoldKey = new GlobalKey(); + + TextEditingController _controller = new TextEditingController(); + + @override + initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + backgroundColor: const Color(0xFFF6F8FA), + appBar: AppBar( + elevation: 0.1, // Check Platform if android + backgroundColor: const Color(0xFFF6F8FA), + title: new Center( + child: new Text( + 'QR GENERATOR', + style: TextStyle( + color: Colors.red, + fontStyle: FontStyle.normal, + fontWeight: FontWeight.bold + ), + textAlign: TextAlign.center, + ), + ), + ), + body: Container( + color: const Color(0xFFF6F8FA), + margin: EdgeInsets.only(top: 20.0, left: 30.0, right: 30.0), + child: ListView( + children: [ + Center( + child: Container( + height: 220.0, + decoration: new BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: new BorderRadius.all( + new Radius.circular(16.0), + ), + ), + child: Center( + child: _image != null ? _buildGeneratedQR() : _getDummyQR(), + ), + ), + ), + Center( + child: Container( + margin: EdgeInsets.only(top: 20.0), + width: double.infinity, + child: new TextField( + controller: _controller, + decoration: new InputDecoration( + labelText: 'Text to Generate Bar QR-Code', + border: new OutlineInputBorder( + borderRadius: BorderRadius.circular(5.0) + ), + filled: true, + hintText: "Enter text e.g IncubateIndia", + fillColor: Colors.white70), + ), + ), + ), + InkWell( + onTap: () => _generateQR(_controller.text), + child: new Center( + child: Container( + margin: EdgeInsets.only(top: 30.0), + width: 180.0, + height: 48.0, + decoration: new BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.red, + borderRadius: new BorderRadius.all( + new Radius.circular(24.0), + ), + ), + child: Center( + child: Text( + 'GENERATE', + style: TextStyle( + color: Colors.white, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } + + Widget _buildGeneratedQR() { + return Container( + width: 200.0, + height: 200.0, + child: _image, + ); + } + + Widget _getDummyQR() { + return new Opacity( + opacity: 0.5, + child: Image.asset( + 'assets/images/ic_scan.png', + width: 140.0, + height: 140.0, + fit: BoxFit.cover, + ), + ); + } + + void showSnackBar(String message) { + final snackBar = SnackBar( + content: Text(message), + action: SnackBarAction( + label: 'OK', + onPressed: () {}, + ), + ); + + _scaffoldKey.currentState.showSnackBar(snackBar); + } + + Future _generateQR(String content) async { + if (content.trim().length == 0) { + _scaffoldKey.currentState + .showSnackBar(SnackBar(content: Text('Please enter qr content'))); + setState(() { + _image = null; + }); + return; + } + Image image; + try { + image = await QrUtils.generateQR(content); + } on PlatformException { + image = null; + } + setState(() { + _image = image; + }); + } +} diff --git a/lib/screen/SplashScreen.dart b/lib/screen/SplashScreen.dart new file mode 100644 index 0000000..202acdc --- /dev/null +++ b/lib/screen/SplashScreen.dart @@ -0,0 +1,82 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:qrgenerator/constant/Constant.dart'; + +class SplashScreen extends StatefulWidget { + @override + SplashScreenState createState() => new SplashScreenState(); +} + +class SplashScreenState extends State + with SingleTickerProviderStateMixin { + var _visible = true; + + AnimationController animationController; + Animation animation; + + startTime() async { + var _duration = new Duration(seconds: 3); + return new Timer(_duration, navigationPage); + } + + void navigationPage() { + Navigator.of(context).pushReplacementNamed(HOME_SCREEN); + } + + @override + void initState() { + super.initState(); + animationController = new AnimationController( + vsync: this, + duration: new Duration(seconds: 2), + ); + animation = + new CurvedAnimation(parent: animationController, curve: Curves.easeOut); + + animation.addListener(() => this.setState(() {})); + animationController.forward(); + + setState(() { + _visible = !_visible; + }); + startTime(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Stack( + fit: StackFit.expand, + children: [ + new Column( + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 30.0), + child: new Image.asset( + 'assets/images/indiapngg.png', + height: 65.0, + width: 85.0, + fit: BoxFit.scaleDown, + ), + ) + ], + ), + new Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Image.asset( + 'assets/images/incubatepng.png', + width: animation.value * 250, + height: animation.value * 250, + ), + ], + ), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 034e169..3549b9f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,27 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" boolean_selector: dependency: transitive description: @@ -29,6 +43,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -46,20 +74,27 @@ packages: description: flutter source: sdk version: "0.0.0" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" path: dependency: transitive description: @@ -74,6 +109,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" + qr_utils: + dependency: "direct main" + description: + name: qr_utils + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" quiver: dependency: transitive description: @@ -127,7 +176,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -142,5 +191,12 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.4.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ae2cc10..94f0849 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 + qr_utils: ^0.1.1 dev_dependencies: flutter_test: @@ -45,6 +46,11 @@ flutter: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg + assets: + - assets/images/incubatepng.png + - assets/images/indiapngg.png + - assets/images/ic_scan.png + # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.