Skip to content

fix: Adapted widgets for desktop #2765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions lib/view/barometer_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,36 @@ class _BarometerScreenState extends State<BarometerScreen> {
CommonScaffold(
title: barometerTitle,
onGuidePressed: _showInstrumentGuide,
body: SafeArea(
child: Column(
children: [
const Expanded(
flex: 45,
child: BarometerCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
),
),
body: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
final isLargeScreen = constraints.maxWidth > 900;
if (isLargeScreen) {
return Row(
children: [
const Expanded(
flex: 35,
child: BarometerCard(),
),
Expanded(
flex: 65,
child: _buildChartSection(),
),
],
);
} else {
return Column(
children: [
const Expanded(
flex: 45,
child: BarometerCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
);
}
})),
),
if (_showGuide)
InstrumentOverviewDrawer(
Expand Down
44 changes: 30 additions & 14 deletions lib/view/luxmeter_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,36 @@ class _LuxMeterScreenState extends State<LuxMeterScreen> {
CommonScaffold(
title: luxMeterTitle,
onGuidePressed: _showInstrumentGuide,
body: SafeArea(
child: Column(
children: [
const Expanded(
flex: 45,
child: LuxMeterCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
),
),
body: SafeArea(child: LayoutBuilder(builder: (context, constraints) {
final isLargeScreen = constraints.maxWidth > 900;
if (isLargeScreen) {
return Row(
children: [
const Expanded(
flex: 35,
child: LuxMeterCard(),
),
Expanded(
flex: 65,
child: _buildChartSection(),
),
],
);
} else {
return Column(
children: [
const Expanded(
flex: 45,
child: LuxMeterCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
);
}
})),
),
if (_showGuide)
InstrumentOverviewDrawer(
Expand Down
43 changes: 32 additions & 11 deletions lib/view/soundmeter_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,38 @@ class _SoundMeterScreenState extends State<SoundMeterScreen> {
title: soundMeterTitle,
onGuidePressed: _showInstrumentGuide,
body: SafeArea(
child: Column(
children: [
const Expanded(
flex: 45,
child: SoundMeterCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
child: LayoutBuilder(
builder: (context, constraints) {
final isLargeScreen = constraints.maxWidth > 900;

if (isLargeScreen) {
return Row(
children: [
const Expanded(
flex: 35,
child: SoundMeterCard(),
),
Expanded(
flex: 65,
child: _buildChartSection(),
),
],
);
} else {
return Column(
children: [
const Expanded(
flex: 45,
child: SoundMeterCard(),
),
Expanded(
flex: 55,
child: _buildChartSection(),
),
],
);
}
},
),
),
),
Expand Down
129 changes: 55 additions & 74 deletions lib/view/widgets/barometer_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,87 +47,68 @@ class _BarometerCardState extends State<BarometerCard> {
padding: EdgeInsets.all(cardPadding),
child: LayoutBuilder(
builder: (context, constraints) {
return Row(
children: [
Expanded(
flex: screenWidth < 500 ? 40 : 35,
child: Column(
children: [
Expanded(
flex: 75,
child: Instrumentstats(
titleFontSize: titleFontSize,
statFontSize: statFontSize,
maxValue: maxPressure,
minValue: minPressure,
avgValue: avgPressure,
unit: atm,
),
if (isLargeScreen) {
return Column(
children: [
Expanded(
flex: 40,
child: Center(
child: GaugeWidget(
gaugeSize: gaugeSize,
currentValue: currentPressure,
minValue: 0,
maxValue: 2,
unit: atm,
currentValueFontSize: pressureValueFontSize,
),
Expanded(
flex: 25,
child:
_buildAltitudeTile(currentAltitude, statFontSize),
),
],
),
),
Expanded(
flex: 60,
child: Instrumentstats(
titleFontSize: titleFontSize,
statFontSize: statFontSize,
maxValue: maxPressure,
minValue: minPressure,
avgValue: avgPressure,
unit: atm,
currentAltitude: currentAltitude,
),
),
),
Expanded(
flex: screenWidth < 500 ? 60 : 65,
child: GaugeWidget(
gaugeSize: gaugeSize,
currentValue: currentPressure,
minValue: 0,
maxValue: 2,
],
);
} else {
return Row(
children: [
Expanded(
flex: screenWidth < 500 ? 40 : 35,
child: Instrumentstats(
titleFontSize: titleFontSize,
statFontSize: statFontSize,
maxValue: maxPressure,
minValue: minPressure,
avgValue: avgPressure,
unit: atm,
currentValueFontSize: pressureValueFontSize),
),
],
);
currentAltitude: currentAltitude,
),
),
Expanded(
flex: screenWidth < 500 ? 60 : 65,
child: GaugeWidget(
gaugeSize: gaugeSize,
currentValue: currentPressure,
minValue: 0,
maxValue: 2,
unit: atm,
currentValueFontSize: pressureValueFontSize),
),
],
);
}
},
),
),
),
);
}

Widget _buildAltitudeTile(double currentAltitude, double fontSize) {
final screenWidth = MediaQuery.of(context).size.width;
final padding = screenWidth < 400 ? 15.0 : 20.0;

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: Text(
'$altitudeLabel ($meterUnit)',
style: TextStyle(
color: cardContentColor,
fontSize: fontSize,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 4),
Center(
child: Container(
padding: EdgeInsets.symmetric(horizontal: padding, vertical: 3),
decoration: BoxDecoration(
border: Border.all(color: instrumentStatBoxColor),
borderRadius: BorderRadius.circular(6),
),
child: Text(
currentAltitude.toStringAsFixed(2),
style: TextStyle(
color: cardContentColor,
fontSize: fontSize,
fontWeight: FontWeight.bold,
),
),
),
),
],
);
}
}
Loading