Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
58
lib/Peach/designs/Responsive.dart
Normal file
58
lib/Peach/designs/Responsive.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
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)],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user