From a2e24e0ec70c176efa2c9241a47dfdc433d5cfcc Mon Sep 17 00:00:00 2001 From: Lange99 Date: Sun, 8 Nov 2020 13:02:31 +0100 Subject: [PATCH] Pagina di aggiunta chiavi tramite stringa --- android/app/build.gradle | 2 +- lib/NfcKeyManager.dart | 4 +++ lib/Pages/AddKeyPage.dart | 51 +++++++++++++++++++++++++++++++++++++++ lib/main.dart | 44 --------------------------------- 4 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 lib/Pages/AddKeyPage.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index 6db249b..71e3fb8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.nfc_app" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/NfcKeyManager.dart b/lib/NfcKeyManager.dart index eae7369..cd05668 100644 --- a/lib/NfcKeyManager.dart +++ b/lib/NfcKeyManager.dart @@ -11,6 +11,10 @@ class NfcManager { availableKey.add(message.id); } + void addReadableId(String s) async { + availableKey.add(s); + } + /* Metodo che ritorna: -> 1 se posso leggere il tag diff --git a/lib/Pages/AddKeyPage.dart b/lib/Pages/AddKeyPage.dart new file mode 100644 index 0000000..2812967 --- /dev/null +++ b/lib/Pages/AddKeyPage.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:nfc_app/NfcKeyManager.dart'; + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + + NfcManager manager; + TextEditingController controller; + + @override + void initState() { + super.initState(); + manager = new NfcManager(); + controller = new TextEditingController(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Add Key')), + body: Container( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Text('Add new readable key:'), + ), + Flexible( + child: TextField(controller: controller,) + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [RaisedButton( + child: Text('Login'), + onPressed: () {manager.addReadableId(controller.value.text); print(controller.value.text);}, + ) + ], + ) + ], + ) + + ), + + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index e4111bd..b27b251 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,57 +12,13 @@ class MyApp extends StatelessWidget { title: "Nfc", theme: ThemeData(primarySwatch: Colors.blue), - ); } } -class MainPage extends StatelessWidget { - - @override - Widget build(BuildContext context) { - return Scaffold( - - ); - } -} -class AddKey extends StatelessWidget { - AddKey(NfcManager manager); -@override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text('Add Key')), - body: Container( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - child: Text('Add new readable key:'), - ), - Flexible( - child: TextField() - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [RaisedButton( - child: Text('Login'), - onPressed: () => {}, //manager.addReadable(), - ) - ], - ) - ], - ) - - ), - - ); - } - -}