mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
fix: Downloads resetting with multiple active downloads (#606)
feat: Add sync count icon to menu bars
This commit is contained in:
parent
493f40645c
commit
d8f613de07
8 changed files with 105 additions and 67 deletions
|
|
@ -12,9 +12,8 @@ class DestinationModel {
|
|||
final PageRouteInfo? route;
|
||||
final Function()? action;
|
||||
final String? tooltip;
|
||||
final Badge? badge;
|
||||
final Widget? badge;
|
||||
final AdaptiveFab? floatingActionButton;
|
||||
// final FloatingActionButton? floatingActionButton;
|
||||
|
||||
DestinationModel({
|
||||
required this.label,
|
||||
|
|
@ -25,21 +24,10 @@ class DestinationModel {
|
|||
this.tooltip,
|
||||
this.badge,
|
||||
this.floatingActionButton,
|
||||
}) : assert(
|
||||
badge == null || icon == null,
|
||||
'Only one of icon or badge should be provided, not both.',
|
||||
);
|
||||
});
|
||||
|
||||
/// Converts this [DestinationModel] to a [NavigationRailDestination] used in a [NavigationRail].
|
||||
NavigationRailDestination toNavigationRailDestination({EdgeInsets? padding}) {
|
||||
if (badge != null) {
|
||||
return NavigationRailDestination(
|
||||
icon: badge!,
|
||||
label: Text(label),
|
||||
selectedIcon: badge!,
|
||||
padding: padding,
|
||||
);
|
||||
}
|
||||
return NavigationRailDestination(
|
||||
icon: icon!,
|
||||
label: Text(label),
|
||||
|
|
@ -50,13 +38,6 @@ class DestinationModel {
|
|||
|
||||
/// Converts this [DestinationModel] to a [NavigationDrawerDestination] used in a [NavigationDrawer].
|
||||
NavigationDrawerDestination toNavigationDrawerDestination() {
|
||||
if (badge != null) {
|
||||
return NavigationDrawerDestination(
|
||||
icon: badge!,
|
||||
label: Text(label),
|
||||
selectedIcon: badge!,
|
||||
);
|
||||
}
|
||||
return NavigationDrawerDestination(
|
||||
icon: icon!,
|
||||
label: Text(label),
|
||||
|
|
@ -66,13 +47,6 @@ class DestinationModel {
|
|||
|
||||
/// Converts this [DestinationModel] to a [NavigationDestination] used in a [BottomNavigationBar].
|
||||
NavigationDestination toNavigationDestination() {
|
||||
if (badge != null) {
|
||||
return NavigationDestination(
|
||||
icon: badge!,
|
||||
label: label,
|
||||
selectedIcon: badge!,
|
||||
);
|
||||
}
|
||||
return NavigationDestination(
|
||||
icon: icon!,
|
||||
label: label,
|
||||
|
|
@ -87,6 +61,7 @@ class DestinationModel {
|
|||
label: label,
|
||||
selected: selected,
|
||||
navFocusNode: navFocusNode,
|
||||
badge: badge,
|
||||
onPressed: action,
|
||||
horizontal: horizontal,
|
||||
expanded: expanded,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class NavigationButton extends ConsumerStatefulWidget {
|
|||
final String? label;
|
||||
final Widget selectedIcon;
|
||||
final Widget icon;
|
||||
final Widget? badge;
|
||||
final bool navFocusNode;
|
||||
final bool horizontal;
|
||||
final bool expanded;
|
||||
|
|
@ -23,6 +24,7 @@ class NavigationButton extends ConsumerStatefulWidget {
|
|||
required this.label,
|
||||
required this.selectedIcon,
|
||||
required this.icon,
|
||||
this.badge,
|
||||
this.navFocusNode = false,
|
||||
this.horizontal = false,
|
||||
this.expanded = false,
|
||||
|
|
@ -95,9 +97,19 @@ class _NavigationButtonState extends ConsumerState<NavigationButton> {
|
|||
),
|
||||
),
|
||||
widget.customIcon ??
|
||||
AnimatedSwitcher(
|
||||
duration: widget.duration,
|
||||
child: widget.selected ? widget.selectedIcon : widget.icon,
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: widget.duration,
|
||||
child: widget.selected ? widget.selectedIcon : widget.icon,
|
||||
),
|
||||
if (widget.badge != null && !widget.expanded)
|
||||
Transform.translate(
|
||||
offset: const Offset(8, -8),
|
||||
child: widget.badge,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
if (widget.horizontal && widget.expanded) ...[
|
||||
|
|
@ -105,10 +117,17 @@ class _NavigationButtonState extends ConsumerState<NavigationButton> {
|
|||
Expanded(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 80),
|
||||
child: Text(
|
||||
widget.label!,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
widget.label!,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (widget.badge != null) widget.badge!,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -137,9 +156,19 @@ class _NavigationButtonState extends ConsumerState<NavigationButton> {
|
|||
spacing: 8,
|
||||
children: [
|
||||
widget.customIcon ??
|
||||
AnimatedSwitcher(
|
||||
duration: widget.duration,
|
||||
child: widget.selected ? widget.selectedIcon : widget.icon,
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: widget.duration,
|
||||
child: widget.selected ? widget.selectedIcon : widget.icon,
|
||||
),
|
||||
if (widget.badge != null && !widget.expanded)
|
||||
Transform.translate(
|
||||
offset: const Offset(8, -8),
|
||||
child: widget.badge,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.label != null && widget.horizontal && widget.expanded)
|
||||
Flexible(child: Text(widget.label!))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue