Skip to content

Commit 92134e4

Browse files
fix: Adapted widgets for desktop (#2765)
1 parent ae18bf1 commit 92134e4

File tree

8 files changed

+524
-346
lines changed

8 files changed

+524
-346
lines changed

lib/view/barometer_screen.dart

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,36 @@ class _BarometerScreenState extends State<BarometerScreen> {
7979
CommonScaffold(
8080
title: barometerTitle,
8181
onGuidePressed: _showInstrumentGuide,
82-
body: SafeArea(
83-
child: Column(
84-
children: [
85-
const Expanded(
86-
flex: 45,
87-
child: BarometerCard(),
88-
),
89-
Expanded(
90-
flex: 55,
91-
child: _buildChartSection(),
92-
),
93-
],
94-
),
95-
),
82+
body: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
83+
final isLargeScreen = constraints.maxWidth > 900;
84+
if (isLargeScreen) {
85+
return Row(
86+
children: [
87+
const Expanded(
88+
flex: 35,
89+
child: BarometerCard(),
90+
),
91+
Expanded(
92+
flex: 65,
93+
child: _buildChartSection(),
94+
),
95+
],
96+
);
97+
} else {
98+
return Column(
99+
children: [
100+
const Expanded(
101+
flex: 45,
102+
child: BarometerCard(),
103+
),
104+
Expanded(
105+
flex: 55,
106+
child: _buildChartSection(),
107+
),
108+
],
109+
);
110+
}
111+
})),
96112
),
97113
if (_showGuide)
98114
InstrumentOverviewDrawer(

lib/view/luxmeter_screen.dart

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,36 @@ class _LuxMeterScreenState extends State<LuxMeterScreen> {
9191
CommonScaffold(
9292
title: luxMeterTitle,
9393
onGuidePressed: _showInstrumentGuide,
94-
body: SafeArea(
95-
child: Column(
96-
children: [
97-
const Expanded(
98-
flex: 45,
99-
child: LuxMeterCard(),
100-
),
101-
Expanded(
102-
flex: 55,
103-
child: _buildChartSection(),
104-
),
105-
],
106-
),
107-
),
94+
body: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
95+
final isLargeScreen = constraints.maxWidth > 900;
96+
if (isLargeScreen) {
97+
return Row(
98+
children: [
99+
const Expanded(
100+
flex: 35,
101+
child: LuxMeterCard(),
102+
),
103+
Expanded(
104+
flex: 65,
105+
child: _buildChartSection(),
106+
),
107+
],
108+
);
109+
} else {
110+
return Column(
111+
children: [
112+
const Expanded(
113+
flex: 45,
114+
child: LuxMeterCard(),
115+
),
116+
Expanded(
117+
flex: 55,
118+
child: _buildChartSection(),
119+
),
120+
],
121+
);
122+
}
123+
})),
108124
),
109125
if (_showGuide)
110126
InstrumentOverviewDrawer(

lib/view/soundmeter_screen.dart

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,38 @@ class _SoundMeterScreenState extends State<SoundMeterScreen> {
5858
title: soundMeterTitle,
5959
onGuidePressed: _showInstrumentGuide,
6060
body: SafeArea(
61-
child: Column(
62-
children: [
63-
const Expanded(
64-
flex: 45,
65-
child: SoundMeterCard(),
66-
),
67-
Expanded(
68-
flex: 55,
69-
child: _buildChartSection(),
70-
),
71-
],
61+
child: LayoutBuilder(
62+
builder: (context, constraints) {
63+
final isLargeScreen = constraints.maxWidth > 900;
64+
65+
if (isLargeScreen) {
66+
return Row(
67+
children: [
68+
const Expanded(
69+
flex: 35,
70+
child: SoundMeterCard(),
71+
),
72+
Expanded(
73+
flex: 65,
74+
child: _buildChartSection(),
75+
),
76+
],
77+
);
78+
} else {
79+
return Column(
80+
children: [
81+
const Expanded(
82+
flex: 45,
83+
child: SoundMeterCard(),
84+
),
85+
Expanded(
86+
flex: 55,
87+
child: _buildChartSection(),
88+
),
89+
],
90+
);
91+
}
92+
},
7293
),
7394
),
7495
),

lib/view/widgets/barometer_card.dart

Lines changed: 55 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -47,87 +47,68 @@ class _BarometerCardState extends State<BarometerCard> {
4747
padding: EdgeInsets.all(cardPadding),
4848
child: LayoutBuilder(
4949
builder: (context, constraints) {
50-
return Row(
51-
children: [
52-
Expanded(
53-
flex: screenWidth < 500 ? 40 : 35,
54-
child: Column(
55-
children: [
56-
Expanded(
57-
flex: 75,
58-
child: Instrumentstats(
59-
titleFontSize: titleFontSize,
60-
statFontSize: statFontSize,
61-
maxValue: maxPressure,
62-
minValue: minPressure,
63-
avgValue: avgPressure,
64-
unit: atm,
65-
),
50+
if (isLargeScreen) {
51+
return Column(
52+
children: [
53+
Expanded(
54+
flex: 40,
55+
child: Center(
56+
child: GaugeWidget(
57+
gaugeSize: gaugeSize,
58+
currentValue: currentPressure,
59+
minValue: 0,
60+
maxValue: 2,
61+
unit: atm,
62+
currentValueFontSize: pressureValueFontSize,
6663
),
67-
Expanded(
68-
flex: 25,
69-
child:
70-
_buildAltitudeTile(currentAltitude, statFontSize),
71-
),
72-
],
64+
),
65+
),
66+
Expanded(
67+
flex: 60,
68+
child: Instrumentstats(
69+
titleFontSize: titleFontSize,
70+
statFontSize: statFontSize,
71+
maxValue: maxPressure,
72+
minValue: minPressure,
73+
avgValue: avgPressure,
74+
unit: atm,
75+
currentAltitude: currentAltitude,
76+
),
7377
),
74-
),
75-
Expanded(
76-
flex: screenWidth < 500 ? 60 : 65,
77-
child: GaugeWidget(
78-
gaugeSize: gaugeSize,
79-
currentValue: currentPressure,
80-
minValue: 0,
81-
maxValue: 2,
78+
],
79+
);
80+
} else {
81+
return Row(
82+
children: [
83+
Expanded(
84+
flex: screenWidth < 500 ? 40 : 35,
85+
child: Instrumentstats(
86+
titleFontSize: titleFontSize,
87+
statFontSize: statFontSize,
88+
maxValue: maxPressure,
89+
minValue: minPressure,
90+
avgValue: avgPressure,
8291
unit: atm,
83-
currentValueFontSize: pressureValueFontSize),
84-
),
85-
],
86-
);
92+
currentAltitude: currentAltitude,
93+
),
94+
),
95+
Expanded(
96+
flex: screenWidth < 500 ? 60 : 65,
97+
child: GaugeWidget(
98+
gaugeSize: gaugeSize,
99+
currentValue: currentPressure,
100+
minValue: 0,
101+
maxValue: 2,
102+
unit: atm,
103+
currentValueFontSize: pressureValueFontSize),
104+
),
105+
],
106+
);
107+
}
87108
},
88109
),
89110
),
90111
),
91112
);
92113
}
93-
94-
Widget _buildAltitudeTile(double currentAltitude, double fontSize) {
95-
final screenWidth = MediaQuery.of(context).size.width;
96-
final padding = screenWidth < 400 ? 15.0 : 20.0;
97-
98-
return Column(
99-
crossAxisAlignment: CrossAxisAlignment.start,
100-
mainAxisSize: MainAxisSize.min,
101-
children: [
102-
Center(
103-
child: Text(
104-
'$altitudeLabel ($meterUnit)',
105-
style: TextStyle(
106-
color: cardContentColor,
107-
fontSize: fontSize,
108-
fontWeight: FontWeight.w600,
109-
),
110-
),
111-
),
112-
const SizedBox(height: 4),
113-
Center(
114-
child: Container(
115-
padding: EdgeInsets.symmetric(horizontal: padding, vertical: 3),
116-
decoration: BoxDecoration(
117-
border: Border.all(color: instrumentStatBoxColor),
118-
borderRadius: BorderRadius.circular(6),
119-
),
120-
child: Text(
121-
currentAltitude.toStringAsFixed(2),
122-
style: TextStyle(
123-
color: cardContentColor,
124-
fontSize: fontSize,
125-
fontWeight: FontWeight.bold,
126-
),
127-
),
128-
),
129-
),
130-
],
131-
);
132-
}
133114
}

0 commit comments

Comments
 (0)