Skip to content

Commit

Permalink
ajustando home page e tela de bluetooth
Browse files Browse the repository at this point in the history
  • Loading branch information
itMatos committed Sep 9, 2024
1 parent 206e3b7 commit 0ad3716
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 23 deletions.
8 changes: 5 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:zenith_monitor/modules/bluetooth/bluetooth_screen.dart';
import 'package:zenith_monitor/modules/home_page/screen/home_screen.dart';
import 'package:zenith_monitor/utils/services/authentication/google_auth.dart';
import 'package:zenith_monitor/utils/services/firestore_services/firestore_services.dart';
Expand Down Expand Up @@ -96,13 +97,14 @@ class Application extends StatelessWidget {
backgroundColor: Colors.black.withOpacity(0)),
primaryColor: Colors.black,
),
//initialRoute: currentUser != null ? '/home' : '/login',
initialRoute: '/login',
initialRoute: currentUser != null ? '/home' : '/login',
//initialRoute: '/login',
routes: {
'/login': (context) => const LoginScreen(),
'/signup': (context) => const SignUpScreen(),
// '/forgotPwd': (context) => const ForgotMyPassword(),
'/home': (context) => HomeScreen(),
'/home': (context) => HomeScreen(currentUser: currentUser),
'/bluetooth': (context) => BluetoothScreen(),
'/map': (context) => const MapScreen(),
'/configuration': (context) => ConfigurationScreen(),
'/terminal': (context) => const TerminalScreen(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import 'package:url_launcher/url_launcher.dart';

// import './helpers/LineChart.dart';

class MainPage extends StatefulWidget {
class BluetoothMainPage extends StatefulWidget {
@override
MainPageState createState() => MainPageState();
}

class MainPageState extends State<MainPage> {
class MainPageState extends State<BluetoothMainPage> {
BluetoothState _bluetoothState = BluetoothState.UNKNOWN;

String _address = "...";
Expand Down Expand Up @@ -97,7 +97,7 @@ class MainPageState extends State<MainPage> {
const Divider(),
const ListTile(title: Text('General')),
SwitchListTile(
title: const Text('Enable Bluetooth'),
title: const Text('Ativar Bluetooth'),
value: _bluetoothState.isEnabled,
onChanged: (bool value) {
// Do the request and update with the true value then
Expand Down
13 changes: 3 additions & 10 deletions lib/modules/bluetooth/bluetooth_screen.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import 'package:flutter/material.dart';
// import 'package:flutter_blue_plus/flutter_blue_plus.dart';
// import 'package:zenith_monitor/modules/bluetooth/device_caracteristics_screen.dart';
import './MainPage.dart';
import 'BluetoothMainPage.dart';

class BluetoothScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ExampleApplication(),
return Scaffold(
body: BluetoothMainPage(),
);
}
}

class ExampleApplication extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(home: MainPage());
}
}
115 changes: 108 additions & 7 deletions lib/modules/home_page/screen/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,116 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:zenith_monitor/modules/bluetooth/bluetooth_screen.dart';

class HomeScreen extends StatelessWidget {
final User? currentUser;

const HomeScreen({this.currentUser});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Bluetooth App',
theme: ThemeData(
primarySwatch: Colors.blue,
return Scaffold(
appBar: AppBar(
title: const Text('Zenith Monitor'),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
decoration: const BoxDecoration(
color: Colors.blue,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (currentUser != null)
CircleAvatar(
backgroundImage:
NetworkImage(currentUser!.photoURL ?? ''),
radius: 30,
),
const SizedBox(height: 10),
Text(
currentUser != null
? currentUser!.displayName ?? 'Usuário'
: 'Resgate com Bluetooth',
style: const TextStyle(
color: Colors.white,
fontSize: 24,
),
),
const SizedBox(height: 5),
Text(
currentUser != null ? currentUser!.email ?? '' : '',
style: const TextStyle(
color: Colors.white70,
fontSize: 16,
),
),
],
),
),
ListTile(
leading: const Icon(Icons.home),
title: const Text('Home'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Configurações'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: const Icon(Icons.exit_to_app),
title: const Text('Logout'),
onTap: () {
FirebaseAuth.instance.signOut();
Navigator.pop(context);
Navigator.pushReplacementNamed(context, '/login');
},
),
],
),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: ListView(
children: <Widget>[
_buildCard(context, Icons.bluetooth,
'Acompanhar resgate com bluetooth', '/bluetooth'),
_buildCard(context, Icons.map, 'Mapa', '/map'),
_buildCard(
context, Icons.settings, 'Configurações', '/configuration'),
_buildCard(context, Icons.terminal, 'Terminal', '/terminal'),
],
),
),
home: BluetoothScreen(), // Defina a tela inicial como BluetoothScreen
);
}
}
}

Widget _buildCard(
BuildContext context, IconData icon, String label, String route) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 10),
child: ListTile(
contentPadding: const EdgeInsets.all(16),
leading: Icon(icon, size: 50, color: Colors.blue),
title: Text(
label,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
onTap: () {
Navigator.pushNamed(context, route);
},
),
);
}

0 comments on commit 0ad3716

Please sign in to comment.