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"
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
android:label="loc_chain_app"
android:icon="@mipmap/ic_launcher">

View File

@ -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());
}

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/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<NavBarWidget> {
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<NavBarWidget> {
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,

View File

@ -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"

View File

@ -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