Skip to content

Commit

Permalink
feat: initialized Oscilloscope Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
AsCress committed Jan 17, 2025
1 parent cab14ed commit 7917e13
Show file tree
Hide file tree
Showing 20 changed files with 1,548 additions and 139 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ migrate_working_dir/
.pub/
/build/

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/xcuserdata/

# Windows
**/windows/flutter/ephemeral/
**/windows/flutter/generated_plugin_registrant.cc
**/windows/flutter/generated_plugin_registrant.h
**/windows/flutter/generated_plugins.cmake

# Linux
**/linux/flutter/ephemeral/
**/linux/flutter/generated_plugin_registrant.cc
**/linux/flutter/generated_plugin_registrant.h
**/linux/flutter/generated_plugins.cmake

# Symbolication related
app.*.symbols

Expand Down
Binary file added assets/images/channel_parameters.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/data_analysis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/timebase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/xymode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pslab/view/connect_device_screen.dart';
import 'package:pslab/view/faq_screen.dart';
import 'package:pslab/view/instruments_screen.dart';
import 'package:pslab/view/oscilloscope_screen.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -26,6 +27,7 @@ class MyApp extends StatelessWidget {
initialRoute: '/',
routes: {
'/': (context) => const InstrumentsScreen(),
'/oscilloscope': (context) => const OscilloscopeScreen(),
'/connectDevice': (context) => const ConnectDeviceScreen(),
'/faq': (context) => const FAQScreen(),
},
Expand Down
12 changes: 12 additions & 0 deletions lib/providers/oscilloscope_state_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class OscilloscopeStateProvider extends ChangeNotifier {
int _selectedIndex = 0;

int get selectedIndex => _selectedIndex;

void updateSelectedIndex(int index) {
_selectedIndex = index;
notifyListeners();
}
}
49 changes: 43 additions & 6 deletions lib/view/instruments_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pslab/constants.dart';
import 'package:pslab/view/widgets/applications_list_item.dart';
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
import 'package:pslab/view/widgets/main_scaffold_widget.dart';

class InstrumentsScreen extends StatefulWidget {
const InstrumentsScreen({super.key});
Expand All @@ -11,9 +12,42 @@ class InstrumentsScreen extends StatefulWidget {
}

class _InstrumentsScreenState extends State<InstrumentsScreen> {
void _onItemTapped(int index) {
switch (index) {
case 0:
Navigator.pushNamed(context, '/oscilloscope');
break;
default:
break;
}
}

@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) {
_setOrientation();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
});
super.initState();
}

void _setOrientation() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
}

@override
void dispose() {
super.dispose();
}

@override
Widget build(BuildContext context) {
return CommonScaffold(
return MainScaffold(
index: 0,
title: 'Instruments',
body: SafeArea(
Expand All @@ -22,10 +56,13 @@ class _InstrumentsScreenState extends State<InstrumentsScreen> {
child: ListView.builder(
itemCount: instrumentHeadings.length,
itemBuilder: (context, index) {
return ApplicationsListItem(
heading: instrumentHeadings[index],
description: instrumentDesc[index],
instrumentIcon: instrumentIcons[index],
return GestureDetector(
onTap: () => _onItemTapped(index),
child: ApplicationsListItem(
heading: instrumentHeadings[index],
description: instrumentDesc[index],
instrumentIcon: instrumentIcons[index],
),
);
},
),
Expand Down
98 changes: 98 additions & 0 deletions lib/view/oscilloscope_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:pslab/view/widgets/channel_parameters_widget.dart';
import 'package:pslab/view/widgets/common_scaffold_widget.dart';
import 'package:pslab/view/widgets/data_analysis_widget.dart';
import 'package:pslab/view/widgets/oscilloscope_screen_tabs.dart';
import 'package:pslab/view/widgets/timebase_trigger_widget.dart';
import 'package:pslab/view/widgets/xyplot_widget.dart';

import '../providers/oscilloscope_state_provider.dart';

class OscilloscopeScreen extends StatefulWidget {
const OscilloscopeScreen({super.key});

@override
State<StatefulWidget> createState() => _OscilloscopeScreenState();
}

class _OscilloscopeScreenState extends State<OscilloscopeScreen> {
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) {
_setLandscapeOrientation();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
});
super.initState();
}

void _setLandscapeOrientation() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
}

@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => OscilloscopeStateProvider()),
],
child: SafeArea(
child: CommonScaffold(
title: 'Oscilloscope',
body: Container(
margin: const EdgeInsets.only(left: 5, top: 5),
child: Row(
children: [
Container(
width: 310.w,
margin: const EdgeInsets.only(right: 5),
child: Column(
children: [
SizedBox(
height: 380.h,
child: LineChart(
LineChartData(
backgroundColor: Colors.black,
titlesData: const FlTitlesData(show: false),
borderData: FlBorderData(show: false),
),
),
),
Expanded(
child: Consumer<OscilloscopeStateProvider>(
builder: (context, provider, _) {
switch (provider.selectedIndex) {
case 0:
return const ChannelParametersWidget();
case 1:
return const TimebaseTriggerWidget();
case 2:
return const DataAnalysisWidget(); // Replace with your widget for Tab 3
case 3:
return const XYPlotWidget();
default:
return const ChannelParametersWidget();
}
},
),
),
],
),
),
const Expanded(
child: OscilloscopeScreenTabs(),
)
],
),
),
),
),
);
}
}
Loading

0 comments on commit 7917e13

Please sign in to comment.