@@ -4,16 +4,13 @@ import 'shader_control_panel.dart';
44import '../main.dart' ;
55
66/// A responsive layout that adapts the shader view based on screen size.
7- ///
7+ ///
88/// On wide screens (>800px), displays the shader animation and controls side by side.
99/// On narrow screens, stacks them vertically with the animation on top.
1010class ResponsiveShaderLayout extends StatelessWidget {
1111 final ShaderInfo shaderInfo;
1212
13- const ResponsiveShaderLayout ({
14- super .key,
15- required this .shaderInfo,
16- });
13+ const ResponsiveShaderLayout ({super .key, required this .shaderInfo});
1714
1815 @override
1916 Widget build (BuildContext context) {
@@ -40,15 +37,9 @@ class _WideScreenLayout extends StatelessWidget {
4037 Widget build (BuildContext context) {
4138 return Row (
4239 children: [
43- Expanded (
44- flex: 1 ,
45- child: ShaderAnimationView (shaderInfo: shaderInfo),
46- ),
40+ Expanded (flex: 1 , child: ShaderAnimationView (shaderInfo: shaderInfo)),
4741 const VerticalDivider (width: 1 ),
48- Expanded (
49- flex: 1 ,
50- child: ShaderControlPanel (shaderInfo: shaderInfo),
51- ),
42+ Expanded (flex: 1 , child: ShaderControlPanel (shaderInfo: shaderInfo)),
5243 ],
5344 );
5445 }
@@ -61,18 +52,27 @@ class _NarrowScreenLayout extends StatelessWidget {
6152
6253 @override
6354 Widget build (BuildContext context) {
64- return Column (
65- children: [
66- Expanded (
67- flex: 2 ,
68- child: ShaderAnimationView (shaderInfo: shaderInfo),
69- ),
70- const Divider (height: 1 ),
71- Expanded (
72- flex: 1 ,
73- child: ShaderControlPanel (shaderInfo: shaderInfo),
74- ),
75- ],
55+ final screenHeight = MediaQuery .of (context).size.height;
56+ final shaderViewHeight =
57+ screenHeight * 0.4 ; // 40% of screen height for shader view
58+ final controlPanelHeight =
59+ screenHeight * 0.6 ; // 60% of screen height for controls
60+
61+ return SingleChildScrollView (
62+ child: Column (
63+ children: [
64+ SizedBox (
65+ height: shaderViewHeight,
66+ child: ShaderAnimationView (shaderInfo: shaderInfo),
67+ ),
68+ const Divider (height: 1 ),
69+ // Provide a fixed height for the control panel to satisfy Expanded constraints
70+ SizedBox (
71+ height: controlPanelHeight,
72+ child: ShaderControlPanel (shaderInfo: shaderInfo),
73+ ),
74+ ],
75+ ),
7676 );
7777 }
7878}
0 commit comments