added the libary

This commit is contained in:
Thomas Atkins 2021-04-10 13:45:44 -05:00
parent 5bff5a0c42
commit 8ead6cdd2e
7 changed files with 303 additions and 5 deletions

View File

@ -1,5 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loc_chain_app"> package="com.example.loc_chain_app">
<!-- Required for Nearby Connections -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application <application
android:label="loc_chain_app" android:label="loc_chain_app"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:loc_chain_app/widgets/navbar.dart'; import 'package:loc_chain_app/widgets/navbar.dart';
void main() { void main() async {
final prefs = await SharedPreferences.getInstance();
runApp(App()); runApp(App());
} }

View File

@ -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<BluetoothPage> {
final String userName = Random().nextInt(10000).toString();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(),
);
}
}

View File

@ -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<SettingsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ListView(children: <Widget>[
Text(
"Permissions",
),
Wrap(
children: <Widget>[
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: <Widget>[
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 :(")));
}
},
),
],
),
]),
),
);
}
}

View File

@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
import 'package:loc_chain_app/pages/home.dart'; import 'package:loc_chain_app/pages/home.dart';
import 'package:loc_chain_app/pages/keygen.dart'; import 'package:loc_chain_app/pages/keygen.dart';
import '../pages/bluetooth.dart';
import '../pages/settings.dart';
class NavBarWidget extends StatefulWidget { class NavBarWidget extends StatefulWidget {
NavBarWidget({Key key}) : super(key: key); NavBarWidget({Key key}) : super(key: key);
@ -16,9 +19,15 @@ class _NavBarWidgetState extends State<NavBarWidget> {
HomePage( HomePage(
title: 'Home', title: 'Home',
), ),
BluetoothPage(
title: 'Connect',
),
KeygenPage( KeygenPage(
title: 'RSA Configuration', title: 'RSA Configuration',
), ),
SettingsPage(
title: 'Settings',
)
]; ];
void _onItemTapped(int index) => setState(() { void _onItemTapped(int index) => setState(() {
_selectedIndex = index; _selectedIndex = index;
@ -35,11 +44,21 @@ class _NavBarWidgetState extends State<NavBarWidget> {
label: 'Home', label: 'Home',
backgroundColor: Colors.cyan, backgroundColor: Colors.cyan,
), ),
BottomNavigationBarItem(
icon: Icon(Icons.bluetooth),
label: 'Connect',
backgroundColor: Colors.cyan,
),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.lock_rounded), icon: Icon(Icons.lock_rounded),
label: 'RSA Configuration', label: 'RSA Configuration',
backgroundColor: Colors.cyan, backgroundColor: Colors.cyan,
), ),
BottomNavigationBarItem(
icon: Icon(Icons.lock_rounded),
label: 'Settings',
backgroundColor: Colors.cyan,
),
], ],
currentIndex: _selectedIndex, currentIndex: _selectedIndex,
selectedItemColor: Colors.lightBlueAccent, selectedItemColor: Colors.lightBlueAccent,

View File

@ -64,6 +64,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" 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: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -74,6 +88,18 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: matcher:
dependency: transitive dependency: transitive
description: description:
@ -88,6 +114,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" 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: path:
dependency: transitive dependency: transitive
description: description:
@ -95,6 +128,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" 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: pointycastle:
dependency: transitive dependency: transitive
description: description:
@ -102,6 +170,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
rsa_encrypt: rsa_encrypt:
dependency: "direct main" dependency: "direct main"
description: description:
@ -109,6 +184,48 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" 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: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -170,5 +287,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" 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: sdks:
dart: ">=2.12.0-0.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"

View File

@ -18,12 +18,13 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
nearby_connections: ^3.0.0
shared_preferences: ^2.0.5
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.