Files
PeachDeployments/lib/Peach/designs/Responsive.dart
alvocool 38881d1fe1 Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:15:30 +03:00

59 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import '../about/internal/application/TextType.dart';
import 'text/Text.dart';
/// Picks one of three layouts for the current width. Screens are built as
/// `_mobileView` / `_tabletView` / `_desktopView` methods on their State and
/// handed to this widget, rather than as one layout littered with width checks.
class Responsive extends StatelessWidget {
final Widget mobile;
final Widget tablet;
final Widget desktop;
const Responsive({
super.key,
required this.desktop,
required this.mobile,
required this.tablet,
});
/// mobile < 650
static bool isMobile(BuildContext context) =>
MediaQuery.sizeOf(context).width < 650;
/// tablet >= 650
static bool isTablet(BuildContext context) =>
MediaQuery.sizeOf(context).width >= 650;
/// desktop >= 1100
static bool isDesktop(BuildContext context) =>
MediaQuery.sizeOf(context).width >= 1100;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
if (isDesktop(context)) {
return desktop;
} else if (isTablet(context)) {
return tablet;
} else if (isMobile(context)) {
return mobile;
} else {
return SizedBox(
width: double.infinity,
height: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [text("NOT SUPPORTED", 12, TextType.Bold)],
),
);
}
},
);
}
}