106 lines
3.3 KiB
Dart
106 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../widgets/color.dart';
|
|
import '../screen/home/beranda.dart';
|
|
import '../screen/klasifikasi/klasifikasi.dart';
|
|
import '../screen/tentang/tentang.dart';
|
|
|
|
class MainNavigation extends StatefulWidget {
|
|
const MainNavigation({super.key});
|
|
|
|
@override
|
|
State<MainNavigation> createState() => _MainNavigationState();
|
|
}
|
|
|
|
class _MainNavigationState extends State<MainNavigation> {
|
|
int _currentIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final List<Widget> _pages = [
|
|
BerandaScreen(onCobaSekarang: () => setState(() => _currentIndex = 1)),
|
|
const KlasifikasiScreen(),
|
|
const TentangScreen(),
|
|
];
|
|
|
|
return Scaffold(
|
|
extendBody: true,
|
|
body: _pages[_currentIndex],
|
|
|
|
// FAB Tengah (Klasifikasi)
|
|
floatingActionButton: SizedBox(
|
|
height: 65,
|
|
width: 65,
|
|
child: FloatingActionButton(
|
|
// Menghilangkan bayangan saat tidak dipilih agar terlihat lebih bersih (opsional)
|
|
elevation: _currentIndex == 1 ? 4 : 2,
|
|
|
|
// LOGIKA: Cokelat jika dipilih, Putih polos jika tidak
|
|
backgroundColor: _currentIndex == 1
|
|
? AppColors.brownGold
|
|
: AppColors.cardWhite,
|
|
|
|
shape: CircleBorder(
|
|
side: BorderSide(
|
|
// LOGIKA: Garis muncul hanya jika _currentIndex == 1
|
|
// Jika tidak dipilih, gunakan Colors.transparent atau samakan dengan background
|
|
color: _currentIndex == 1
|
|
? AppColors.brownGold
|
|
: Colors.transparent,
|
|
width: 1.5,
|
|
),
|
|
),
|
|
|
|
onPressed: () => setState(() => _currentIndex = 1),
|
|
child: Icon(
|
|
_currentIndex == 1
|
|
? Icons
|
|
.center_focus_strong_rounded // Icon penuh (Bold)
|
|
: Icons.center_focus_strong_outlined, // Icon garis (Outlined)
|
|
// LOGIKA: Putih jika dipilih, Cokelat jika tidak
|
|
color: _currentIndex == 1 ? Colors.white : AppColors.brownGold,
|
|
size: 30,
|
|
),
|
|
),
|
|
),
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
|
bottomNavigationBar: BottomAppBar(
|
|
color: AppColors.cardWhite,
|
|
shape: const CircularNotchedRectangle(),
|
|
notchMargin: 8.0,
|
|
elevation: 10,
|
|
child: SizedBox(
|
|
height: 60,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
// Tombol Beranda
|
|
IconButton(
|
|
onPressed: () => setState(() => _currentIndex = 0),
|
|
icon: Icon(
|
|
_currentIndex == 0 ? Icons.home_rounded : Icons.home_outlined,
|
|
size: 32,
|
|
color: AppColors.brownGold,
|
|
),
|
|
),
|
|
|
|
const SizedBox(width: 40),
|
|
// Tombol Tentang
|
|
IconButton(
|
|
onPressed: () => setState(() => _currentIndex = 2),
|
|
icon: Icon(
|
|
_currentIndex == 2
|
|
? Icons.info_rounded
|
|
: Icons.info_outline_rounded,
|
|
size: 32,
|
|
color: AppColors.brownGold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|