mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-06 08:46:40 +10:00
Correct unread badges for tabs; people first contacts sort option
This commit is contained in:
@@ -6,11 +6,15 @@ import '../l10n/l10n.dart';
|
||||
class QuickSwitchBar extends StatelessWidget {
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onDestinationSelected;
|
||||
final int contactsUnreadCount;
|
||||
final int channelsUnreadCount;
|
||||
|
||||
const QuickSwitchBar({
|
||||
super.key,
|
||||
required this.selectedIndex,
|
||||
required this.onDestinationSelected,
|
||||
this.contactsUnreadCount = 0,
|
||||
this.channelsUnreadCount = 0,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -62,15 +66,30 @@ class QuickSwitchBar extends StatelessWidget {
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
destinations: [
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.people_outline),
|
||||
icon: _buildIconWithBadge(
|
||||
const Icon(Icons.people_outline),
|
||||
contactsUnreadCount,
|
||||
),
|
||||
selectedIcon: _buildIconWithBadge(
|
||||
const Icon(Icons.people),
|
||||
contactsUnreadCount,
|
||||
),
|
||||
label: context.l10n.nav_contacts,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.tag),
|
||||
icon: _buildIconWithBadge(
|
||||
const Icon(Icons.tag),
|
||||
channelsUnreadCount,
|
||||
),
|
||||
selectedIcon: _buildIconWithBadge(
|
||||
const Icon(Icons.tag),
|
||||
channelsUnreadCount,
|
||||
),
|
||||
label: context.l10n.nav_channels,
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: const Icon(Icons.map_outlined),
|
||||
selectedIcon: const Icon(Icons.map),
|
||||
label: context.l10n.nav_map,
|
||||
),
|
||||
],
|
||||
@@ -81,4 +100,16 @@ class QuickSwitchBar extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIconWithBadge(Icon icon, int count) {
|
||||
if (count <= 0) return icon;
|
||||
|
||||
return Badge(
|
||||
label: Text(
|
||||
count > 99 ? '99+' : count.toString(),
|
||||
style: const TextStyle(fontSize: 10),
|
||||
),
|
||||
child: icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user