99 lines
2.8 KiB
Dart
99 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'firebase_options.dart'; // Pastikan file ini ada dan berisi konfigurasi Firebase Anda
|
|
import 'monitoring_page.dart';
|
|
import 'histori_page.dart';
|
|
import 'realtime_monitoring.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Monitoring Hidroponik',
|
|
theme: ThemeData(primarySwatch: Colors.green),
|
|
home: const BottomNavApp(),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
}
|
|
|
|
class BottomNavApp extends StatefulWidget {
|
|
const BottomNavApp({super.key});
|
|
|
|
@override
|
|
State<BottomNavApp> createState() => _BottomNavAppState();
|
|
}
|
|
|
|
class _BottomNavAppState extends State<BottomNavApp> {
|
|
int _selectedIndex = 0;
|
|
|
|
final List<Widget> _pages = [
|
|
const MonitoringPage(),
|
|
const HistoriPage(),
|
|
const RealtimeMonitoring(),
|
|
];
|
|
|
|
// Tidak perlu lagi _waktu atau _timer di sini karena AppBar utama dihapus.
|
|
// Setiap halaman akan mengelola waktunya sendiri jika diperlukan.
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Jika ada timer atau logika yang hanya terkait dengan AppBar utama,
|
|
// itu bisa dihapus dari sini.
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// Jika ada timer yang diinisialisasi di initState, pastikan dibatalkan di sini.
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// === APPBAR UTAMA DI SINI DIHAPUS SEPENUHNYA ===
|
|
// appBar: AppBar(
|
|
// title: Text(_titles[_selectedIndex]), // Ini akan dihapus
|
|
// centerTitle: true,
|
|
// backgroundColor: Colors.green[700],
|
|
// elevation: 0,
|
|
// ),
|
|
// ===============================================
|
|
body:
|
|
_pages[_selectedIndex], // Body akan menampilkan halaman yang dipilih
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: _selectedIndex,
|
|
selectedItemColor: Colors.green[700],
|
|
unselectedItemColor:
|
|
Colors.grey[600], // Warna untuk item yang tidak terpilih
|
|
backgroundColor: Colors.white, // Warna background BottomNavigationBar
|
|
onTap: (index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
},
|
|
items: const [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.monitor_heart),
|
|
label: 'Monitoring',
|
|
),
|
|
BottomNavigationBarItem(icon: Icon(Icons.history), label: 'Histori'),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.table_chart),
|
|
label: 'Realtime',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|