Skip to content

Commit

Permalink
Merge pull request #5 from mospolytech-solar-regatta/SR
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
PaderGIN authored Apr 20, 2024
2 parents dbc1ac4 + 40a47cd commit 9b1038e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 74 deletions.
38 changes: 9 additions & 29 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ void main() async {
await windowManager.ensureInitialized();

WindowOptions windowOptions = const WindowOptions(
size: Size(1280, 800),
center: true,
backgroundColor: Color(0xFF20242D),
skipTaskbar: false,
skipTaskbar: true,
titleBarStyle: TitleBarStyle.hidden,
fullScreen: true,
);

windowManager.waitUntilReadyToShow(windowOptions, () async {
Expand Down Expand Up @@ -71,28 +70,9 @@ class MyHomePage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFF20242D),
appBar: AppBar(
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ShowSettingsWidget()),
);
},
child: const Icon(
Icons.settings,
size: 26.0,
),
)),
],
),
body: const Center(
return const Scaffold(
backgroundColor: Color(0xFF20242D),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -110,7 +90,7 @@ class WidgetBlock extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Expanded( // Этот Expanded обеспечивает, что Row займет все доступное горизонтальное пространство
return Expanded(
child: Row(
children: [
Expanded(
Expand All @@ -120,18 +100,18 @@ class WidgetBlock extends StatelessWidget {
TelemetryProperty(('time_to_go'),TextStyle(fontSize: 80.sp, color: const Color(0xFFFFFFFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',), TextStyle(fontSize: 32.sp, color: const Color(0xFF72BBFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',))
]),
),
Expanded( // Обернуть Column в Expanded, чтобы он занимал нужное пространство в Row
Expanded(
child: Column(
children: <Widget>[
Expanded(
flex: 2, // Займет двойную долю пространства по сравнению с другими Expanded виджетами
flex: 2,
child: TelemetryWidget([
TelemetryProperty(('created_at'),TextStyle(fontSize: 24.sp, color: const Color(0xFFFFFFFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',), TextStyle(fontSize: 24.sp, color: const Color(0xFF72BBFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',)),
TelemetryProperty(('distance_travelled'),TextStyle(fontSize: 24.sp, color: const Color(0xFFFFFFFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',), TextStyle(fontSize: 24.sp, color: const Color(0xFF72BBFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',))
]),
),
Expanded(
flex: 5, // Займет одну долю пространства
flex: 5,
child: TelemetryWidget([TelemetryProperty(('motor_revols'), TextStyle(fontSize: 128.sp, color: const Color(0xFFFFFFFF),fontWeight: FontWeight.bold,fontFamily: 'Inter',), TextStyle(fontSize: 50.sp, color: const Color(0xFF72BBFF), fontWeight: FontWeight.bold,fontFamily: 'Inter',))]),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/models/telemetry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TelemetryModel extends ChangeNotifier {

TelemetryModel() {
Timer timer =
Timer.periodic(Duration(seconds: 15), (Timer t) => updateData());
Timer.periodic(const Duration(seconds: 5), (Timer t) => updateData());
store = BoatConnector();
updateData();
getSettings();
Expand Down
6 changes: 6 additions & 0 deletions lib/store/dataModels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class TelemetryMetric {
if (name == 'created_at') {
return DateFormat('hh:mm:ss.SSS').format(createdAt);
}
if (name == 'distance_travelled') {
return distanceTravelled.toStringAsFixed(1);
}
if (name == 'motor_temp') {
return motorTemp.toStringAsFixed(1);
}
return model[name];
}

Expand Down
98 changes: 54 additions & 44 deletions lib/telemetryWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ final Map<String, String> propertyTitleMap = {
'time_to_go': 'time to go',
'motor_revols': 'revolutions'
};

class TelemetryProperty {
String propName;
TextStyle textStyle;
TextStyle titleStyle;


TelemetryProperty(this.propName, this.textStyle, this.titleStyle);
}

Expand All @@ -34,9 +34,10 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
constraints: const BoxConstraints.expand(),
margin: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 8.0,),
vertical: 8.0,
),
child: Card(
color: const Color(0xFF21374A), // обновить цвет фона
color: const Color(0xFF21374A),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expand Down Expand Up @@ -144,8 +145,6 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
);
break;



case 'speed':
subtitle = Column(
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down Expand Up @@ -202,11 +201,13 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
Row(
children: [
Image.asset(
'assets/images/temp.png', // путь к изображению
'assets/images/temp.png',
// путь к изображению
width: 85.w,
height: 136.h,
),
SizedBox(width: 25.w), // Добавьте отступ между картинкой и текстом
SizedBox(width: 25.w),
// Добавьте отступ между картинкой и текстом
Text(
'$value',
style: textStyle,
Expand All @@ -215,8 +216,10 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
],
),
Positioned(
left: 230.w, // Позиция слева от левого края Row
bottom: 18, // Позиция снизу на 10 пикселей
left: 230.w,
// Позиция слева от левого края Row
bottom: 20,
// Позиция снизу на 10 пикселей
child: Text(
'°C',
style: TextStyle(
Expand All @@ -229,17 +232,19 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
],
);
break;
case 'controller_volts':
case 'controller_volts':
subtitle = Stack(
children: [
Row(
children: [
Image.asset(
'assets/images/controller.png', // путь к изображению
'assets/images/controller.png',
// путь к изображению
width: 93.w,
height: 93.h,
),
SizedBox(width: 15.w), // Добавьте отступ между картинкой и текстом
SizedBox(width: 15.w),
// Добавьте отступ между картинкой и текстом
Text(
'$value',
style: textStyle,
Expand All @@ -248,8 +253,10 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
],
),
Positioned(
left: 225.w, // Позиция слева от левого края Row
bottom: 10, // Позиция снизу на 10 пикселей
left: 225.w,
// Позиция слева от левого края Row
bottom: 10,
// Позиция снизу на 10 пикселей
child: Text(
'B',
style: TextStyle(
Expand All @@ -261,17 +268,20 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
),
],
);
break; case 'time_to_go':
break;
case 'time_to_go':
subtitle = Stack(
children: [
Row(
children: [
Image.asset(
'assets/images/batary.png', // путь к изображению
'assets/images/batary.png',
// путь к изображению
width: 108.w,
height: 105.h,
),
SizedBox(width: 15.w), // Добавьте отступ между картинкой и текстом
SizedBox(width: 15.w),
// Добавьте отступ между картинкой и текстом
Text(
'$value',
style: textStyle,
Expand All @@ -280,8 +290,10 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
],
),
Positioned(
left: 240.w, // Позиция слева от левого края Row
bottom: 10, // Позиция снизу на 10 пикселей
left: 240.w,
// Позиция слева от левого края Row
bottom: 10,
// Позиция снизу на 10 пикселей
child: Text(
'Min',
style: TextStyle(
Expand All @@ -295,9 +307,6 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
);
break;




default:
subtitle = Text(
'$value',
Expand All @@ -310,35 +319,36 @@ class _TelemetryWidgetState extends State<TelemetryWidget> {
visualDensity: const VisualDensity(vertical: -4),
title: propName == 'position_lat'
? Center(
child: Text(
'GPS',
style: titleStyle,
),
)
child: Text(
'GPS',
style: titleStyle,
),
)
: propName == 'created_at'
? Center(
child: Text(
'parameters',
style: titleStyle,
),
)
: propName != 'position_lng' && propName != 'lap_point_lat' && propName != 'lap_point_lng' && propName != 'distance_travelled'
? Center(
child: Text(
propertyTitleMap[propName] ?? propName,
style: titleStyle,
),
)
: null,
? Center(
child: Text(
'parameters',
style: titleStyle,
),
)
: propName != 'position_lng' &&
propName != 'lap_point_lat' &&
propName != 'lap_point_lng' &&
propName != 'distance_travelled'
? Center(
child: Text(
propertyTitleMap[propName] ??
propName,
style: titleStyle,
),
)
: null,
subtitle: Center(child: subtitle),
);


}))
],
),
),
);
}
}

0 comments on commit 9b1038e

Please sign in to comment.