Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/shell/app_shell.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';

import 'desktop_shell.dart';
import 'shell_destination.dart';

class AppShell extends StatelessWidget {
/// Matches Figma desktop artboards (~1700px). Sidebar shell activates at
/// this width; mobile bottom navigation remains below it.
static const double desktopBreakpoint = 1024;

final Widget mobile;
final Widget child;
final ShellDestination selectedDestination;
final ValueChanged<ShellDestination>? onDestinationSelected;

const AppShell({
super.key,
required this.mobile,
required this.child,
this.selectedDestination = ShellDestination.dashboard,
this.onDestinationSelected,
});

static bool isDesktop(BuildContext context) {
return MediaQuery.sizeOf(context).width >= desktopBreakpoint;
}

@override
Widget build(BuildContext context) {
if (isDesktop(context)) {
return DesktopShell(
selectedDestination: selectedDestination,
onDestinationSelected: onDestinationSelected,
child: child,
);
}

return mobile;
}
}
41 changes: 41 additions & 0 deletions lib/shell/desktop_shell.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';

import 'shell_destination.dart';
import 'widgets/shell_navigation_rail.dart';

class DesktopShell extends StatelessWidget {
final Widget child;
final ShellDestination selectedDestination;
final ValueChanged<ShellDestination>? onDestinationSelected;

const DesktopShell({
super.key,
required this.child,
this.selectedDestination = ShellDestination.dashboard,
this.onDestinationSelected,
});

@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;

return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ShellNavigationRail(
selectedDestination: selectedDestination,
onDestinationSelected: onDestinationSelected,
),
VerticalDivider(
width: 1,
thickness: 1,
color: colorScheme.outlineVariant,
),
Expanded(child: child),
],
),
);
}
}
54 changes: 54 additions & 0 deletions lib/shell/shell_destination.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';

enum ShellDestination {
dashboard,
calendar,
workspace,
chat,
profile;

String get label {
switch (this) {
case ShellDestination.dashboard:
return 'Dashboard';
case ShellDestination.calendar:
return 'Calendar';
case ShellDestination.workspace:
return 'Workspace';
case ShellDestination.chat:
return 'Chat';
case ShellDestination.profile:
return 'Profile';
}
}

IconData get icon {
switch (this) {
case ShellDestination.dashboard:
return Icons.dashboard_outlined;
case ShellDestination.calendar:
return Icons.calendar_today_outlined;
case ShellDestination.workspace:
return Icons.work_outline;
case ShellDestination.chat:
return Icons.chat_bubble_outline;
case ShellDestination.profile:
return Icons.person_outline;
}
}

IconData get selectedIcon {
switch (this) {
case ShellDestination.dashboard:
return Icons.dashboard;
case ShellDestination.calendar:
return Icons.calendar_today;
case ShellDestination.workspace:
return Icons.work;
case ShellDestination.chat:
return Icons.chat_bubble;
case ShellDestination.profile:
return Icons.person;
}
}
}
192 changes: 192 additions & 0 deletions lib/shell/widgets/shell_navigation_rail.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import 'package:flutter/material.dart';

import '../shell_destination.dart';

/// Fixed-width sidebar aligned with Figma shell (~288px).
class ShellNavigationRail extends StatelessWidget {
static const double width = 288;

final ShellDestination selectedDestination;
final ValueChanged<ShellDestination>? onDestinationSelected;

const ShellNavigationRail({
super.key,
required this.selectedDestination,
this.onDestinationSelected,
});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;

return SizedBox(
width: width,
child: Material(
color: colorScheme.surface,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(24, 22, 24, 16),
child: Row(
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: colorScheme.primary.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(12),
),
alignment: Alignment.center,
child: Text(
'E',
style: theme.textTheme.titleLarge?.copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(width: 12),
Text(
'Ell-ena',
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
),
),
],
),
),
Divider(
height: 1,
thickness: 1,
color: colorScheme.outlineVariant,
indent: 24,
endIndent: 24,
),
const SizedBox(height: 12),
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 12),
children: [
for (final destination in ShellDestination.values)
_ShellNavItem(
destination: destination,
isSelected: destination == selectedDestination,
onTap: onDestinationSelected == null
? null
: () => onDestinationSelected!(destination),
),
],
),
),
Divider(
height: 1,
thickness: 1,
color: colorScheme.outlineVariant,
indent: 24,
endIndent: 24,
),
Padding(
padding: const EdgeInsets.fromLTRB(24, 16, 24, 24),
child: Row(
children: [
CircleAvatar(
radius: 21,
backgroundColor:
colorScheme.primary.withValues(alpha: 0.15),
child: Icon(
Icons.person,
size: 20,
color: colorScheme.primary,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Account',
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
Text(
'Signed in',
style: theme.textTheme.bodySmall?.copyWith(
color: colorScheme.onSurfaceVariant,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
],
),
),
);
}
}

class _ShellNavItem extends StatelessWidget {
final ShellDestination destination;
final bool isSelected;
final VoidCallback? onTap;

const _ShellNavItem({
required this.destination,
required this.isSelected,
this.onTap,
});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final foregroundColor = isSelected
? colorScheme.primary
: colorScheme.onSurfaceVariant;

return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Material(
color: isSelected
? colorScheme.primary.withValues(alpha: 0.12)
: Colors.transparent,
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
child: Row(
children: [
Icon(
isSelected ? destination.selectedIcon : destination.icon,
size: 24,
color: foregroundColor,
),
const SizedBox(width: 12),
Text(
destination.label,
style: theme.textTheme.bodyLarge?.copyWith(
color: isSelected
? colorScheme.onSurface
: colorScheme.onSurfaceVariant,
fontWeight:
isSelected ? FontWeight.w600 : FontWeight.w500,
),
),
],
),
),
),
),
);
}
}