From 8ead6cdd2e8e2184db0a4a9411d88bb6575b990b Mon Sep 17 00:00:00 2001 From: Thomas Atkins Date: Sat, 10 Apr 2021 13:45:44 -0500 Subject: [PATCH] added the libary --- .../android/app/src/main/AndroidManifest.xml | 9 ++ loc_chain_app/lib/main.dart | 5 +- loc_chain_app/lib/pages/bluetooth.dart | 28 ++++ loc_chain_app/lib/pages/settings.dart | 106 ++++++++++++++ loc_chain_app/lib/widgets/navbar.dart | 19 +++ loc_chain_app/pubspec.lock | 134 +++++++++++++++++- loc_chain_app/pubspec.yaml | 7 +- 7 files changed, 303 insertions(+), 5 deletions(-) create mode 100644 loc_chain_app/lib/pages/bluetooth.dart create mode 100644 loc_chain_app/lib/pages/settings.dart diff --git a/loc_chain_app/android/app/src/main/AndroidManifest.xml b/loc_chain_app/android/app/src/main/AndroidManifest.xml index 72d9860..84dd268 100644 --- a/loc_chain_app/android/app/src/main/AndroidManifest.xml +++ b/loc_chain_app/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,14 @@ + + + + + + + + + diff --git a/loc_chain_app/lib/main.dart b/loc_chain_app/lib/main.dart index 7684568..6cc3c53 100644 --- a/loc_chain_app/lib/main.dart +++ b/loc_chain_app/lib/main.dart @@ -1,7 +1,10 @@ import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:loc_chain_app/widgets/navbar.dart'; -void main() { +void main() async { + final prefs = await SharedPreferences.getInstance(); + runApp(App()); } diff --git a/loc_chain_app/lib/pages/bluetooth.dart b/loc_chain_app/lib/pages/bluetooth.dart new file mode 100644 index 0000000..1118430 --- /dev/null +++ b/loc_chain_app/lib/pages/bluetooth.dart @@ -0,0 +1,28 @@ +import 'dart:io'; +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:nearby_connections/nearby_connections.dart'; + +class BluetoothPage extends StatefulWidget { + BluetoothPage({Key key, this.title}) : super(key: key); + final String title; + + @override + _BluetoothPageState createState() => _BluetoothPageState(); +} + +class _BluetoothPageState extends State { + final String userName = Random().nextInt(10000).toString(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center(), + ); + } +} diff --git a/loc_chain_app/lib/pages/settings.dart b/loc_chain_app/lib/pages/settings.dart new file mode 100644 index 0000000..31fe246 --- /dev/null +++ b/loc_chain_app/lib/pages/settings.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:nearby_connections/nearby_connections.dart'; + +class SettingsPage extends StatefulWidget { + SettingsPage({Key key, this.title}) : super(key: key); + final String title; + + @override + _SettingsPageState createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: ListView(children: [ + Text( + "Permissions", + ), + Wrap( + children: [ + ElevatedButton( + child: Text("checkLocationPermission"), + onPressed: () async { + if (await Nearby().checkLocationPermission()) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("Location permissions granted :)"))); + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("Location permissions not granted :("))); + } + }, + ), + ElevatedButton( + child: Text("askLocationPermission"), + onPressed: () async { + if (await Nearby().askLocationPermission()) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("Location Permission granted :)"))); + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("Location permissions not granted :("))); + } + }, + ), + ElevatedButton( + child: Text("checkExternalStoragePermission"), + onPressed: () async { + if (await Nearby().checkExternalStoragePermission()) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: + Text("External Storage permissions granted :)"))); + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text( + "External Storage permissions not granted :("))); + } + }, + ), + ElevatedButton( + child: Text("askExternalStoragePermission"), + onPressed: () { + Nearby().askExternalStoragePermission(); + }, + ), + ], + ), + Divider(), + Text("Location Enabled"), + Wrap( + children: [ + ElevatedButton( + child: Text("checkLocationEnabled"), + onPressed: () async { + if (await Nearby().checkLocationEnabled()) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("Location is ON :)"))); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("Location is OFF :("))); + } + }, + ), + ElevatedButton( + child: Text("enableLocationServices"), + onPressed: () async { + if (await Nearby().enableLocationServices()) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("Location Service Enabled :)"))); + } else { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("Enabling Location Service Failed :("))); + } + }, + ), + ], + ), + ]), + ), + ); + } +} diff --git a/loc_chain_app/lib/widgets/navbar.dart b/loc_chain_app/lib/widgets/navbar.dart index 51c3b07..68e8bdd 100644 --- a/loc_chain_app/lib/widgets/navbar.dart +++ b/loc_chain_app/lib/widgets/navbar.dart @@ -2,6 +2,9 @@ import 'package:flutter/material.dart'; import 'package:loc_chain_app/pages/home.dart'; import 'package:loc_chain_app/pages/keygen.dart'; +import '../pages/bluetooth.dart'; +import '../pages/settings.dart'; + class NavBarWidget extends StatefulWidget { NavBarWidget({Key key}) : super(key: key); @@ -16,9 +19,15 @@ class _NavBarWidgetState extends State { HomePage( title: 'Home', ), + BluetoothPage( + title: 'Connect', + ), KeygenPage( title: 'RSA Configuration', ), + SettingsPage( + title: 'Settings', + ) ]; void _onItemTapped(int index) => setState(() { _selectedIndex = index; @@ -35,11 +44,21 @@ class _NavBarWidgetState extends State { label: 'Home', backgroundColor: Colors.cyan, ), + BottomNavigationBarItem( + icon: Icon(Icons.bluetooth), + label: 'Connect', + backgroundColor: Colors.cyan, + ), BottomNavigationBarItem( icon: Icon(Icons.lock_rounded), label: 'RSA Configuration', backgroundColor: Colors.cyan, ), + BottomNavigationBarItem( + icon: Icon(Icons.lock_rounded), + label: 'Settings', + backgroundColor: Colors.cyan, + ), ], currentIndex: _selectedIndex, selectedItemColor: Colors.lightBlueAccent, diff --git a/loc_chain_app/pubspec.lock b/loc_chain_app/pubspec.lock index 9c104f8..ed20eee 100644 --- a/loc_chain_app/pubspec.lock +++ b/loc_chain_app/pubspec.lock @@ -64,6 +64,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -74,6 +88,18 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: @@ -88,6 +114,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + nearby_connections: + dependency: "direct main" + description: + name: nearby_connections + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" path: dependency: transitive description: @@ -95,6 +128,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" pointycastle: dependency: transitive description: @@ -102,6 +170,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.1" rsa_encrypt: dependency: "direct main" description: @@ -109,6 +184,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -170,5 +287,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/loc_chain_app/pubspec.yaml b/loc_chain_app/pubspec.yaml index 5469f50..1473eb4 100644 --- a/loc_chain_app/pubspec.yaml +++ b/loc_chain_app/pubspec.yaml @@ -18,13 +18,14 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - - + nearby_connections: ^3.0.0 + shared_preferences: ^2.0.5 + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2