64 lines
1.7 KiB
Dart
64 lines
1.7 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'sidebar/sidebar_widget.dart';
|
||
|
|
|
||
|
|
/// Breakpoint a partir del cual el sidebar se muestra permanente.
|
||
|
|
const double kSidebarBreakpoint = 800;
|
||
|
|
|
||
|
|
class AppShell extends StatelessWidget {
|
||
|
|
final Widget child;
|
||
|
|
|
||
|
|
const AppShell({super.key, required this.child});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final width = MediaQuery.sizeOf(context).width;
|
||
|
|
|
||
|
|
if (width >= kSidebarBreakpoint) {
|
||
|
|
return _WideLayout(child: child);
|
||
|
|
}
|
||
|
|
return _NarrowLayout(child: child);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// ── Wide: sidebar permanente ───────────────────────────────────────────────
|
||
|
|
|
||
|
|
class _WideLayout extends StatelessWidget {
|
||
|
|
final Widget child;
|
||
|
|
const _WideLayout({required this.child});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Scaffold(
|
||
|
|
body: Row(
|
||
|
|
children: [
|
||
|
|
const SidebarWidget(),
|
||
|
|
VerticalDivider(
|
||
|
|
width: 1,
|
||
|
|
color: Theme.of(context).colorScheme.outlineVariant,
|
||
|
|
),
|
||
|
|
Expanded(child: child),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// ── Narrow: drawer + AppBar ────────────────────────────────────────────────
|
||
|
|
|
||
|
|
class _NarrowLayout extends StatelessWidget {
|
||
|
|
final Widget child;
|
||
|
|
const _NarrowLayout({required this.child});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Scaffold(
|
||
|
|
appBar: AppBar(
|
||
|
|
title: const Text('DeporOS'),
|
||
|
|
centerTitle: false,
|
||
|
|
),
|
||
|
|
drawer: const Drawer(child: SidebarWidget()),
|
||
|
|
body: child,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|