@@ -28,6 +28,7 @@ class _ExerciseStoreHomePageState extends State<ExerciseStoreHomePage> with Sing
28
28
DateTime _selectedDay = DateTime .now ();
29
29
late TabController _tabController;
30
30
final PageController _pageController = PageController ();
31
+ final PageStorageBucket bucket = PageStorageBucket ();
31
32
32
33
@override
33
34
void initState () {
@@ -108,88 +109,91 @@ class _ExerciseStoreHomePageState extends State<ExerciseStoreHomePage> with Sing
108
109
],
109
110
),
110
111
),
111
- body: PageView (
112
- controller: _pageController,
113
- physics: const NeverScrollableScrollPhysics (), // Disable swipe gesture
114
- onPageChanged: (index) {
115
- _tabController.animateTo (index);
116
- },
117
- children: [
118
- // Log Exercise Tab
119
- Padding (
120
- padding: const EdgeInsets .all (16.0 ),
121
- child: ExerciseSetter (
122
- onExerciseAdded: () {
123
- setState (() {});
124
- },
112
+ body: PageStorage (
113
+ bucket: bucket,
114
+ child: PageView (
115
+ controller: _pageController,
116
+ physics: const NeverScrollableScrollPhysics (), // Disable swipe gesture
117
+ onPageChanged: (index) {
118
+ _tabController.animateTo (index);
119
+ },
120
+ children: [
121
+ // Log Exercise Tab
122
+ Padding (
123
+ padding: const EdgeInsets .all (16.0 ),
124
+ child: ExerciseSetter (
125
+ onExerciseAdded: () {
126
+ setState (() {});
127
+ },
128
+ ),
125
129
),
126
- ),
127
- // Summary Tab
128
- SummaryTab (
129
- selectedDay : _selectedDay ,
130
- onDateSelected : _onDateSelected ,
131
- ),
132
- // Visualize Data Tab
133
- Padding (
134
- padding : const EdgeInsets . all ( 16.0 ),
135
- child : VisualizationTab ( ),
136
- ),
137
- // View Table Tab
138
- SingleChildScrollView (
139
- scrollDirection : Axis .vertical,
140
- child : SingleChildScrollView (
141
- scrollDirection : Axis .horizontal,
142
- child : FutureBuilder < List < Map < String , dynamic >>>(
143
- future : _getExercises (),
144
- builder : (context, snapshot) {
145
- if ( ! snapshot.hasData) {
146
- return const Center (child : CircularProgressIndicator ());
147
- }
148
- final exercises = snapshot.data ! ;
149
- return DataTable (
150
- columns : const [
151
- DataColumn (label: Text ('ID ' )),
152
- DataColumn (label: Text ('Exercise ' )),
153
- DataColumn (label: Text ('Weight ' )),
154
- DataColumn (label: Text ('Reps ' )),
155
- DataColumn (label: Text ('Sets ' )),
156
- DataColumn (label: Text ('Timestamp ' )),
157
- DataColumn (label : Text ( 'Actions' )) ,
158
- ],
159
- rows : exercises. map ((exercise) {
160
- return DataRow (cells : [
161
- DataCell (Text (exercise['id' ]. toString () )),
162
- DataCell (Text (exercise['exercise ' ])),
163
- DataCell (Text (exercise['weight' ] )),
164
- DataCell (Text (exercise['reps ' ].toString ())),
165
- DataCell (Text (exercise['sets' ]. toString () )),
166
- DataCell (Text (exercise[ 'timestamp' ])),
167
- DataCell (
168
- Row (
169
- children : [
170
- IconButton (
171
- icon : const Icon ( Icons .edit),
172
- onPressed : () {
173
- _showEditDialog (exercise);
174
- } ,
175
- ),
176
- IconButton (
177
- icon : const Icon ( Icons .delete),
178
- onPressed : () async {
179
- await _deleteExercise (exercise[ 'id' ]);
180
- } ,
181
- ) ,
182
- ] ,
130
+ // Summary Tab
131
+ SummaryTab (
132
+ selectedDay : _selectedDay,
133
+ onDateSelected : _onDateSelected ,
134
+ ) ,
135
+ // Visualize Data Tab
136
+ Padding (
137
+ padding : const EdgeInsets . all ( 16.0 ),
138
+ child : VisualizationTab (key : PageStorageKey ( 'visualizationTab' ) ),
139
+ ),
140
+ // View Table Tab
141
+ SingleChildScrollView (
142
+ scrollDirection : Axis .vertical,
143
+ child : SingleChildScrollView (
144
+ scrollDirection : Axis .horizontal,
145
+ child : FutureBuilder < List < Map < String , dynamic >>>(
146
+ future : _getExercises (),
147
+ builder : (context, snapshot) {
148
+ if ( ! snapshot.hasData ) {
149
+ return const Center (child : CircularProgressIndicator ());
150
+ }
151
+ final exercises = snapshot.data ! ;
152
+ return DataTable (
153
+ columns : const [
154
+ DataColumn (label : Text ( 'ID' )),
155
+ DataColumn (label: Text ('Exercise ' )),
156
+ DataColumn (label: Text ('Weight ' )),
157
+ DataColumn (label: Text ('Reps ' )),
158
+ DataColumn (label: Text ('Sets ' )),
159
+ DataColumn (label: Text ('Timestamp ' )),
160
+ DataColumn (label: Text ('Actions ' )),
161
+ ] ,
162
+ rows : exercises. map ((exercise) {
163
+ return DataRow (cells : [
164
+ DataCell ( Text (exercise[ 'id' ]. toString ())),
165
+ DataCell (Text (exercise['exercise' ] )),
166
+ DataCell (Text (exercise['weight ' ])),
167
+ DataCell (Text (exercise['reps' ]. toString () )),
168
+ DataCell (Text (exercise['sets ' ].toString ())),
169
+ DataCell (Text (exercise['timestamp' ] )),
170
+ DataCell (
171
+ Row (
172
+ children : [
173
+ IconButton (
174
+ icon : const Icon ( Icons .edit),
175
+ onPressed : () {
176
+ _showEditDialog (exercise);
177
+ },
178
+ ) ,
179
+ IconButton (
180
+ icon : const Icon ( Icons .delete),
181
+ onPressed : () async {
182
+ await _deleteExercise (exercise[ 'id' ]);
183
+ },
184
+ ) ,
185
+ ] ,
186
+ ) ,
183
187
),
184
- ),
185
- ]);
186
- }). toList (),
187
- );
188
- } ,
188
+ ]);
189
+ }). toList (),
190
+ );
191
+ },
192
+ ) ,
189
193
),
190
194
),
191
- ) ,
192
- ] ,
195
+ ] ,
196
+ ) ,
193
197
),
194
198
);
195
199
}
0 commit comments