fix(app): wide Cupertino sidebar, compact run tabs, web-like chat bubbles
This commit is contained in:
@@ -99,22 +99,35 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
CupertinoTabBar(
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return BottomNavigationBarItem(
|
||||
icon: Icon(item.cupertinoIcon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: wide
|
||||
// The web keeps a destination rail on a wide window. A native
|
||||
// Cupertino sidebar list is the same idea with the host's own
|
||||
// controls; the tab bar stays the narrow-window navigation.
|
||||
? Row(
|
||||
children: [
|
||||
_CupertinoSidebar(
|
||||
selected: _selected,
|
||||
onSelected: _select,
|
||||
),
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
CupertinoTabBar(
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return BottomNavigationBarItem(
|
||||
icon: Icon(item.cupertinoIcon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -172,3 +185,48 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
Widget _destinationStack(List<Widget> contents, int index) =>
|
||||
IndexedStack(index: index, children: contents);
|
||||
}
|
||||
|
||||
/// The wide-window Cupertino destination list: the web's 200px rail with the
|
||||
/// host's own grouped list controls.
|
||||
class _CupertinoSidebar extends StatelessWidget {
|
||||
const _CupertinoSidebar({required this.selected, required this.onSelected});
|
||||
|
||||
final AppDestination selected;
|
||||
final ValueChanged<AppDestination> onSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Container(
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
),
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
children: [
|
||||
for (final destination in AppDestination.values)
|
||||
CupertinoListTile(
|
||||
key: ValueKey('shell.destination.${destination.name}'),
|
||||
leading: Icon(destinationDetails(destination).cupertinoIcon),
|
||||
title: Text(destinationDetails(destination).label),
|
||||
trailing: destination == selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_alt,
|
||||
color: theme.primaryColor,
|
||||
)
|
||||
: null,
|
||||
onTap: () => onSelected(destination),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user