Skip to content

Commit dc62635

Browse files
AsCressmarcnause
authored andcommitted
fix: multimeter layout fixes
1 parent 53f4102 commit dc62635

File tree

5 files changed

+60
-44
lines changed

5 files changed

+60
-44
lines changed

lib/l10n/app_localizations_en.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ class AppLocalizationsEn extends AppLocalizations {
10581058
String get temperatureSensorUnavailableMessage =>
10591059
'Ambient temperature sensor is not available on this device';
10601060

1061+
@override
10611062
String get sharingMessage => 'Sharing PSLab Data';
10621063

10631064
@override

lib/main.dart

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_screenutil/flutter_screenutil.dart';
23
import 'package:provider/provider.dart';
34
import 'package:pslab/l10n/app_localizations.dart';
45
import 'package:pslab/providers/board_state_provider.dart';
@@ -46,39 +47,44 @@ class MyApp extends StatelessWidget {
4647
@override
4748
Widget build(BuildContext context) {
4849
_preCacheImages(context);
49-
return MaterialApp(
50-
debugShowCheckedModeBanner: false,
50+
return ScreenUtilInit(
51+
designSize: const Size(360, 690),
5152
builder: (context, child) {
52-
registerAppLocalizations(AppLocalizations.of(context)!);
53-
getIt<BoardStateProvider>().initialize();
54-
return child!;
55-
},
56-
theme: AppTheme.lightTheme,
57-
darkTheme: AppTheme.darkTheme,
58-
themeMode: ThemeMode.system,
59-
localizationsDelegates: AppLocalizations.localizationsDelegates,
60-
supportedLocales: AppLocalizations.supportedLocales,
61-
initialRoute: '/',
62-
routes: {
63-
'/': (context) => const InstrumentsScreen(),
64-
'/oscilloscope': (context) => const OscilloscopeScreen(),
65-
'/multimeter': (context) => const MultimeterScreen(),
66-
'/waveGenerator': (context) => const WaveGeneratorScreen(),
67-
'/logicAnalyzer': (context) => const LogicAnalyzerScreen(),
68-
'/powerSource': (context) => const PowerSourceScreen(),
69-
'/connectDevice': (context) => const ConnectDeviceScreen(),
70-
'/faq': (context) => FAQScreen(),
71-
'/settings': (context) => const SettingsScreen(),
72-
'/aboutUs': (context) => const AboutUsScreen(),
73-
'/softwareLicenses': (context) => SoftwareLicensesScreen(),
74-
'/accelerometer': (context) => const AccelerometerScreen(),
75-
'/gyroscope': (context) => const GyroscopeScreen(),
76-
'/roboticArm': (context) => const RoboticArmScreen(),
77-
'/luxmeter': (context) => const LuxMeterScreen(),
78-
'/barometer': (context) => const BarometerScreen(),
79-
'/soundmeter': (context) => const SoundMeterScreen(),
80-
'/thermometer': (context) => const ThermometerScreen(),
81-
'/sensors': (context) => const SensorsScreen()
53+
return MaterialApp(
54+
debugShowCheckedModeBanner: false,
55+
builder: (context, child) {
56+
registerAppLocalizations(AppLocalizations.of(context)!);
57+
getIt<BoardStateProvider>().initialize();
58+
return child!;
59+
},
60+
theme: AppTheme.lightTheme,
61+
darkTheme: AppTheme.darkTheme,
62+
themeMode: ThemeMode.system,
63+
localizationsDelegates: AppLocalizations.localizationsDelegates,
64+
supportedLocales: AppLocalizations.supportedLocales,
65+
initialRoute: '/',
66+
routes: {
67+
'/': (context) => const InstrumentsScreen(),
68+
'/oscilloscope': (context) => const OscilloscopeScreen(),
69+
'/multimeter': (context) => const MultimeterScreen(),
70+
'/waveGenerator': (context) => const WaveGeneratorScreen(),
71+
'/logicAnalyzer': (context) => const LogicAnalyzerScreen(),
72+
'/powerSource': (context) => const PowerSourceScreen(),
73+
'/connectDevice': (context) => const ConnectDeviceScreen(),
74+
'/faq': (context) => FAQScreen(),
75+
'/settings': (context) => const SettingsScreen(),
76+
'/aboutUs': (context) => const AboutUsScreen(),
77+
'/softwareLicenses': (context) => SoftwareLicensesScreen(),
78+
'/accelerometer': (context) => const AccelerometerScreen(),
79+
'/gyroscope': (context) => const GyroscopeScreen(),
80+
'/roboticArm': (context) => const RoboticArmScreen(),
81+
'/luxmeter': (context) => const LuxMeterScreen(),
82+
'/barometer': (context) => const BarometerScreen(),
83+
'/soundmeter': (context) => const SoundMeterScreen(),
84+
'/thermometer': (context) => const ThermometerScreen(),
85+
'/sensors': (context) => const SensorsScreen()
86+
},
87+
);
8288
},
8389
);
8490
}

lib/view/multimeter_screen.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,16 @@ class _MultimeterScreenState extends State<MultimeterScreen> {
194194
),
195195
],
196196
),
197-
MultimeterKnob(),
197+
Positioned(
198+
left: 0,
199+
top: 0,
200+
right: 0,
201+
bottom: 0,
202+
child: Align(
203+
alignment: Alignment.center,
204+
child: MultimeterKnob(),
205+
),
206+
),
198207
],
199208
),
200209
),

lib/view/widgets/multimeter_knob.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:math';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_screenutil/flutter_screenutil.dart';
45
import 'package:provider/provider.dart';
56
import 'package:pslab/l10n/app_localizations.dart';
67
import 'package:pslab/providers/locator.dart';
@@ -247,8 +248,9 @@ class _MultimeterKnobState extends State<MultimeterKnob> {
247248
children: [
248249
CustomPaint(
249250
painter: InnerDialFillPainter(),
250-
child: Container(
251-
width: 300,
251+
child: SizedBox(
252+
width: 300.w,
253+
height: 300.h,
252254
),
253255
),
254256
GestureDetector(
@@ -267,17 +269,18 @@ class _MultimeterKnobState extends State<MultimeterKnob> {
267269
color: pointerColor,
268270
),
269271
child: SizedBox(
270-
width: 430,
271-
height: 450,
272+
width: 360.w,
273+
height: 360.h,
272274
),
273275
),
274276
),
275277
IgnorePointer(
276278
ignoring: true,
277279
child: CustomPaint(
278280
painter: InnerDialPainter(),
279-
child: Container(
280-
width: 300,
281+
child: SizedBox(
282+
height: 300.h,
283+
width: 300.w,
281284
),
282285
),
283286
),
@@ -287,11 +290,7 @@ class _MultimeterKnobState extends State<MultimeterKnob> {
287290
painter: RadialLabelPainter(
288291
labels: knobMarker,
289292
labelColors: knobLabelColors,
290-
radius: 112,
291-
),
292-
child: SizedBox(
293-
width: 430,
294-
height: 450,
293+
radius: 112.r,
295294
),
296295
),
297296
)

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies:
6868
share_plus: ^11.0.0
6969
path_provider: ^2.1.5
7070
file_picker: ^10.2.4
71+
flutter_screenutil: ^5.9.3
7172

7273

7374
dev_dependencies:

0 commit comments

Comments
 (0)