117 lines
4.1 KiB
Dart
117 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../core/theme.dart';
|
|
import '../../providers/notification_provider.dart';
|
|
|
|
class BottomNavbar extends StatelessWidget {
|
|
final int currentIndex;
|
|
final Function(int) onTap;
|
|
|
|
const BottomNavbar({
|
|
Key? key,
|
|
required this.currentIndex,
|
|
required this.onTap,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final unreadCount = context.watch<NotificationProvider>().unreadCount;
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.primaryDark,
|
|
borderRadius: const BorderRadius.only(
|
|
topLeft: Radius.circular(AppTheme.radiusLg),
|
|
topRight: Radius.circular(AppTheme.radiusLg),
|
|
),
|
|
boxShadow: AppTheme.shadowLg,
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: const BorderRadius.only(
|
|
topLeft: Radius.circular(AppTheme.radiusLg),
|
|
topRight: Radius.circular(AppTheme.radiusLg),
|
|
),
|
|
child: BottomNavigationBar(
|
|
currentIndex: currentIndex,
|
|
onTap: onTap,
|
|
backgroundColor: AppTheme.primaryDark,
|
|
selectedItemColor: Colors.white,
|
|
unselectedItemColor: Colors.white.withOpacity(0.5),
|
|
showUnselectedLabels: false,
|
|
showSelectedLabels: false,
|
|
type: BottomNavigationBarType.fixed,
|
|
elevation: 0,
|
|
items: [
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.home_outlined),
|
|
activeIcon: Icon(Icons.home),
|
|
label: 'Home',
|
|
),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.calendar_today_outlined),
|
|
activeIcon: Icon(Icons.calendar_today),
|
|
label: 'Calendar',
|
|
),
|
|
const BottomNavigationBarItem(
|
|
icon: Icon(Icons.receipt_long_outlined),
|
|
activeIcon: Icon(Icons.receipt_long),
|
|
label: 'Document',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
const Icon(Icons.notifications_outlined),
|
|
if (unreadCount > 0)
|
|
Positioned(
|
|
right: -4,
|
|
top: -4,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(2),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFef4444),
|
|
shape: BoxShape.circle,
|
|
),
|
|
constraints: const BoxConstraints(minWidth: 14, minHeight: 14),
|
|
child: Text(
|
|
unreadCount > 9 ? '9+' : '$unreadCount',
|
|
style: const TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.bold),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
activeIcon: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
const Icon(Icons.notifications),
|
|
if (unreadCount > 0)
|
|
Positioned(
|
|
right: -4,
|
|
top: -4,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(2),
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFef4444),
|
|
shape: BoxShape.circle,
|
|
),
|
|
constraints: const BoxConstraints(minWidth: 14, minHeight: 14),
|
|
child: Text(
|
|
unreadCount > 9 ? '9+' : '$unreadCount',
|
|
style: const TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.bold),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
label: 'Notifikasi',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|