mirror of
https://github.com/hackku21/loc-chain-app.git
synced 2026-03-02 03:40:13 +00:00
added the libary
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
28
loc_chain_app/lib/pages/bluetooth.dart
Normal file
28
loc_chain_app/lib/pages/bluetooth.dart
Normal 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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
106
loc_chain_app/lib/pages/settings.dart
Normal file
106
loc_chain_app/lib/pages/settings.dart
Normal 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 :(")));
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user