@@ -41,98 +41,97 @@ class _CompassScreenContentState extends State<CompassScreenContent> {
41
41
@override
42
42
Widget build (BuildContext context) {
43
43
return Consumer <CompassProvider >(
44
- builder: (context, compassProvider, child) {
45
- return CommonScaffold (
46
- title: 'Compass' ,
47
- body: SafeArea (
48
- child: Container (
49
- padding: const EdgeInsets .all (16.0 ),
50
- child: Column (
51
- children: [
52
- Expanded (
53
- flex: 3 ,
54
- child: Center (
55
- child: Transform .rotate (
56
- angle: compassProvider.currentDegree,
57
- child: Container (
58
- width: 300 ,
59
- height: 300 ,
60
- decoration: const BoxDecoration (
61
- shape: BoxShape .circle,
62
- ),
63
- child: Image .asset (
64
- 'assets/icons/compass_icon.png' ,
65
- fit: BoxFit .contain,
66
- ),
44
+ builder: (context, compassProvider, child) {
45
+ return CommonScaffold (
46
+ title: 'Compass' ,
47
+ body: SafeArea (
48
+ child: Container (
49
+ padding: const EdgeInsets .all (16.0 ),
50
+ child: Column (
51
+ children: [
52
+ Expanded (
53
+ flex: 3 ,
54
+ child: Center (
55
+ child: Transform .rotate (
56
+ angle: compassProvider.currentDegree,
57
+ child: Container (
58
+ width: 300 ,
59
+ height: 300 ,
60
+ decoration: const BoxDecoration (
61
+ shape: BoxShape .circle,
62
+ ),
63
+ child: Image .asset (
64
+ 'assets/icons/compass_icon.png' ,
65
+ fit: BoxFit .contain,
67
66
),
68
67
),
69
68
),
70
69
),
71
- Container (
72
- padding : const EdgeInsets . symmetric (vertical : 16 ),
73
- child : Column (
74
- children : [
75
- Text (
76
- compassProvider
77
- . getDegreeForAxis ( compassProvider.selectedAxis)
78
- . round ( )
79
- . toStringAsFixed ( 1 ),
80
- style : const TextStyle (
81
- fontSize : 32 ,
82
- fontWeight : FontWeight .bold ,
83
- ) ,
70
+ ),
71
+ Container (
72
+ padding : const EdgeInsets . symmetric (vertical : 16 ),
73
+ child : Column (
74
+ children : [
75
+ Text (
76
+ compassProvider
77
+ . getDegreeForAxis (compassProvider.selectedAxis )
78
+ . round ()
79
+ . toStringAsFixed ( 1 ),
80
+ style : const TextStyle (
81
+ fontSize : 32 ,
82
+ fontWeight : FontWeight .bold ,
84
83
),
85
- ] ,
86
- ) ,
84
+ ) ,
85
+ ] ,
87
86
),
88
- const SizedBox (height: 24 ),
89
- Container (
90
- padding: const EdgeInsets .all (16 ),
91
- decoration: BoxDecoration (
92
- color: Colors .grey[100 ],
93
- borderRadius: BorderRadius .circular (12 ),
94
- ),
95
- child: Column (
96
- children: [
97
- Row (
98
- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
99
- children: [
100
- _buildAxisColumn (
101
- 'Bx' , compassProvider.magnetometerEvent.x),
102
- _buildAxisColumn (
103
- 'By' , compassProvider.magnetometerEvent.y),
104
- _buildAxisColumn (
105
- 'Bz' , compassProvider.magnetometerEvent.z),
106
- ],
107
- ),
108
- const SizedBox (height: 24 ),
109
- const Text (
110
- 'Select axes parallel to ground' ,
111
- style: TextStyle (
112
- fontSize: 16 ,
113
- fontWeight: FontWeight .w500,
114
- ),
115
- ),
116
- const SizedBox (height: 16 ),
117
- Row (
118
- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
119
- children: [
120
- _buildAxisSelector (context, 'X' , 'X axis' ),
121
- _buildAxisSelector (context, 'Y' , 'Y axis' ),
122
- _buildAxisSelector (context, 'Z' , 'Z axis' ),
123
- ],
87
+ ),
88
+ const SizedBox (height: 24 ),
89
+ Container (
90
+ padding: const EdgeInsets .all (16 ),
91
+ decoration: BoxDecoration (
92
+ color: Colors .grey[100 ],
93
+ borderRadius: BorderRadius .circular (12 ),
94
+ ),
95
+ child: Column (
96
+ children: [
97
+ Row (
98
+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
99
+ children: [
100
+ _buildAxisColumn (
101
+ 'Bx' , compassProvider.magnetometerEvent.x),
102
+ _buildAxisColumn (
103
+ 'By' , compassProvider.magnetometerEvent.y),
104
+ _buildAxisColumn (
105
+ 'Bz' , compassProvider.magnetometerEvent.z),
106
+ ],
107
+ ),
108
+ const SizedBox (height: 24 ),
109
+ const Text (
110
+ 'Select axes parallel to ground' ,
111
+ style: TextStyle (
112
+ fontSize: 16 ,
113
+ fontWeight: FontWeight .w500,
124
114
),
125
- ],
126
- ),
115
+ ),
116
+ const SizedBox (height: 16 ),
117
+ Row (
118
+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
119
+ children: [
120
+ _buildAxisSelector (context, 'X' , 'X axis' ),
121
+ _buildAxisSelector (context, 'Y' , 'Y axis' ),
122
+ _buildAxisSelector (context, 'Z' , 'Z axis' ),
123
+ ],
124
+ ),
125
+ ],
127
126
),
128
- const SizedBox (height : 16 ),
129
- ] ,
130
- ) ,
127
+ ),
128
+ const SizedBox (height : 16 ) ,
129
+ ] ,
131
130
),
132
131
),
133
- );
134
- },
135
- );
132
+ ),
133
+ );
134
+ } );
136
135
}
137
136
138
137
Widget _buildAxisColumn (String label, double value) {
@@ -168,46 +167,45 @@ class _CompassScreenContentState extends State<CompassScreenContent> {
168
167
169
168
Widget _buildAxisSelector (BuildContext context, String axis, String label) {
170
169
return Consumer <CompassProvider >(
171
- builder: (context, compassProvider, child) {
172
- bool isSelected = compassProvider.selectedAxis == axis;
170
+ builder: (context, compassProvider, child) {
171
+ bool isSelected = compassProvider.selectedAxis == axis;
173
172
174
- return GestureDetector (
175
- onTap: () => compassProvider.onAxisSelected (axis),
176
- child: Row (
177
- mainAxisSize: MainAxisSize .min,
178
- children: [
179
- Container (
180
- width: 20 ,
181
- height: 20 ,
182
- decoration: BoxDecoration (
183
- shape: BoxShape .circle,
184
- border: Border .all (
185
- color: isSelected ? Colors .red : Colors .grey,
186
- width: 2 ,
187
- ),
188
- color: isSelected ? Colors .red : Colors .transparent,
173
+ return GestureDetector (
174
+ onTap: () => compassProvider.onAxisSelected (axis),
175
+ child: Row (
176
+ mainAxisSize: MainAxisSize .min,
177
+ children: [
178
+ Container (
179
+ width: 20 ,
180
+ height: 20 ,
181
+ decoration: BoxDecoration (
182
+ shape: BoxShape .circle,
183
+ border: Border .all (
184
+ color: isSelected ? Colors .red : Colors .grey,
185
+ width: 2 ,
189
186
),
190
- child: isSelected
191
- ? const Icon (
192
- Icons .circle,
193
- size: 10 ,
194
- color: Colors .white,
195
- )
196
- : null ,
187
+ color: isSelected ? Colors .red : Colors .transparent,
197
188
),
198
- const SizedBox (width: 8 ),
199
- Text (
200
- label,
201
- style: TextStyle (
202
- fontSize: 14 ,
203
- color: isSelected ? Colors .red : Colors .grey[600 ],
204
- fontWeight: isSelected ? FontWeight .w500 : FontWeight .normal,
205
- ),
189
+ child: isSelected
190
+ ? const Icon (
191
+ Icons .circle,
192
+ size: 10 ,
193
+ color: Colors .white,
194
+ )
195
+ : null ,
196
+ ),
197
+ const SizedBox (width: 8 ),
198
+ Text (
199
+ label,
200
+ style: TextStyle (
201
+ fontSize: 14 ,
202
+ color: isSelected ? Colors .red : Colors .grey[600 ],
203
+ fontWeight: isSelected ? FontWeight .w500 : FontWeight .normal,
206
204
),
207
- ] ,
208
- ) ,
209
- );
210
- },
211
- );
205
+ ) ,
206
+ ] ,
207
+ ),
208
+ );
209
+ } );
212
210
}
213
- }
211
+ }
0 commit comments