@@ -3,29 +3,152 @@ import 'data.dart';
33import 'charts.dart' ;
44import 'datarecording.dart' ;
55
6+ //https://stackoverflow.com/questions/50887790/flutter-changing-the-current-tab-in-tab-bar-view-using-a-button
67
7- class Home extends StatelessWidget {
8- const Home ({key});
8+ class HomePage extends StatefulWidget {
9+ HomePage ({key});
10+
11+ @override
12+ _HomePageState createState () => new _HomePageState ();
13+ }
14+
15+ class _HomePageState extends State <HomePage >
16+ with SingleTickerProviderStateMixin {
17+ late TabController _tabController;
18+
19+ @override
20+ void initState () {
21+ super .initState ();
22+ _tabController = new TabController (vsync: this , length: 4 );
23+ }
24+
25+ @override
26+ void dispose () {
27+ _tabController.dispose ();
28+ super .dispose ();
29+ }
930
1031 @override
1132 Widget build (BuildContext context) {
33+
34+ var style = TextStyle (fontSize: 35 , color: Colors .white);
35+
1236 return MaterialApp (
1337 home: DefaultTabController (
14- length: 3 ,
38+ length: 4 ,
1539 child: Scaffold (
1640 appBar: AppBar (
17- bottom: const TabBar (
18- tabs: [
41+ bottom: TabBar (
42+ controller: _tabController,
43+ tabs: const [
44+ Tab (icon: Icon (Icons .home)),
1945 Tab (icon: Icon (Icons .sensors)),
2046 Tab (icon: Icon (Icons .show_chart_rounded)),
2147 Tab (icon: Icon (Icons .access_alarm)),
2248 ],
2349 ),
2450 title: const Text ('DSS: Demo app' ),
25- backgroundColor: Colors .redAccent ,
51+ backgroundColor: Theme . of (context).colorScheme.secondary ,
2652 ),
27- body: TabBarView (
53+ body: TabBarView (
54+ controller: _tabController,
2855 children: [
56+ Container (
57+ child: Column (
58+ mainAxisAlignment: MainAxisAlignment .center,
59+ crossAxisAlignment: CrossAxisAlignment .center,
60+ children: [
61+ SizedBox (
62+ height: 150 , //height of button
63+ width: double .infinity,
64+ child: ElevatedButton (
65+ onPressed: () {
66+ _tabController.animateTo (1 );
67+ },
68+ style: ElevatedButton .styleFrom (
69+ backgroundColor: Theme .of (context).colorScheme.primary,
70+ ),
71+ child: Container (
72+ child: RichText (
73+ text: TextSpan (
74+ text: 'Show AI Model\n ' ,
75+ style: style,
76+ children: const < TextSpan > [
77+ TextSpan (
78+ text:
79+ 'Here the absolute values of the accelerometer in x, y and z direction can be found, as well as the predicted class und FPS rate.' ,
80+ style: TextStyle (
81+ fontSize: 15 , color: Colors .white)),
82+ ],
83+ ),
84+ textAlign: TextAlign .center),
85+ ),
86+ ),
87+ ),
88+ const SizedBox (
89+ height: 20 ,
90+ width: 20 ,
91+ ),
92+ SizedBox (
93+ height: 150 , //height of button
94+ width: double .infinity,
95+ child: ElevatedButton (
96+ onPressed: () {
97+ _tabController.animateTo (2 );
98+ },
99+ style: ElevatedButton .styleFrom (
100+ backgroundColor: Theme .of (context).colorScheme.primary,
101+ ),
102+ child: Container (
103+ child: RichText (
104+ text: TextSpan (
105+ text: 'Visualize Data\n ' ,
106+ style: style,
107+ children: const < TextSpan > [
108+ TextSpan (
109+ text:
110+ 'Here a real-time chart of the accelerometer values in x, y and z direction, as well as the FPS rate, can be found.' ,
111+ style: TextStyle (
112+ fontSize: 15 , color: Colors .white)),
113+ ],
114+ ),
115+ textAlign: TextAlign .center),
116+ ),
117+ ),
118+ ),
119+ const SizedBox (
120+ height: 20 ,
121+ width: 20 ,
122+ ),
123+ SizedBox (
124+ height: 150 , //height of button
125+ width: double .infinity,
126+ child: ElevatedButton (
127+ onPressed: () {
128+ _tabController.animateTo (3 );
129+ },
130+ style: ElevatedButton .styleFrom (
131+ backgroundColor: Theme .of (context).colorScheme.primary,
132+ ),
133+ child: Container (
134+ child: RichText (
135+ text: TextSpan (
136+ text: 'Record Data\n ' ,
137+ style: style,
138+ children: const < TextSpan > [
139+ TextSpan (
140+ text:
141+ 'Here the accelerometer data can be recorded and afterward sent to a server. ' ,
142+ style: TextStyle (
143+ fontSize: 15 , color: Colors .white)),
144+ ],
145+ ),
146+ textAlign: TextAlign .center),
147+ ),
148+ ),
149+ ),
150+ ],
151+ )),
29152 const DataStream (),
30153 const Charts (),
31154 DataRecordingPage (),
@@ -36,4 +159,3 @@ class Home extends StatelessWidget {
36159 );
37160 }
38161}
39-
0 commit comments