feat(app): add floating shell destination bar
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/adaptive/segmented_bar.dart';
|
||||
import '../ui/adaptive/floating_destination_bar.dart';
|
||||
import 'attention_badge.dart';
|
||||
import 'destination.dart';
|
||||
import 'shell_bar.dart';
|
||||
@@ -161,20 +162,16 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
: Column(
|
||||
children: [
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
// Match CupertinoTabScaffold's native tab-label policy;
|
||||
// content elsewhere still follows the user's scaler.
|
||||
// Keep the host's native tab semantics while giving
|
||||
// the selector the same floating glass treatment as
|
||||
// the top bar.
|
||||
MediaQuery.withNoTextScaling(
|
||||
child: CupertinoTabBar(
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: true,
|
||||
currentIndex: index,
|
||||
onTap: (value) =>
|
||||
_select(AppDestination.values[value]),
|
||||
items: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return BottomNavigationBarItem(
|
||||
icon: _icon(destination, item.cupertinoIcon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
items: _destinationItems(cupertino: true),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -211,19 +208,14 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
],
|
||||
),
|
||||
),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: wide
|
||||
? null
|
||||
: NavigationBar(
|
||||
selectedIndex: index,
|
||||
onDestinationSelected: (value) =>
|
||||
_select(AppDestination.values[value]),
|
||||
destinations: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return NavigationDestination(
|
||||
icon: _icon(destination, item.icon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _destinationItems(),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -231,6 +223,15 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
);
|
||||
}
|
||||
|
||||
List<FloatingDestinationItem> _destinationItems({bool cupertino = false}) =>
|
||||
AppDestination.values.map((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return FloatingDestinationItem(
|
||||
icon: _icon(destination, cupertino ? item.cupertinoIcon : item.icon),
|
||||
label: item.label,
|
||||
);
|
||||
}).toList();
|
||||
|
||||
/// The open screen's own bar: its Back, title and actions, or the tab's
|
||||
/// name with Search.
|
||||
SegmentedBar _segmentedBar(ShellBarSpec? spec, String label) {
|
||||
|
||||
Reference in New Issue
Block a user