Skip to content

Commit 16ee7cb

Browse files
made suggested changes
1 parent 0c29ce8 commit 16ee7cb

File tree

2 files changed

+119
-121
lines changed

2 files changed

+119
-121
lines changed

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ void _preCacheImages(BuildContext context) {
6161
}
6262
precacheImage(
6363
const AssetImage('assets/icons/ic_nav_header_logo.png'), context);
64-
}
64+
}

lib/view/compass_screen.dart

Lines changed: 118 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -41,98 +41,97 @@ class _CompassScreenContentState extends State<CompassScreenContent> {
4141
@override
4242
Widget build(BuildContext context) {
4343
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,
6766
),
6867
),
6968
),
7069
),
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,
8483
),
85-
],
86-
),
84+
),
85+
],
8786
),
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,
124114
),
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+
],
127126
),
128-
const SizedBox(height: 16),
129-
],
130-
),
127+
),
128+
const SizedBox(height: 16),
129+
],
131130
),
132131
),
133-
);
134-
},
135-
);
132+
),
133+
);
134+
});
136135
}
137136

138137
Widget _buildAxisColumn(String label, double value) {
@@ -168,46 +167,45 @@ class _CompassScreenContentState extends State<CompassScreenContent> {
168167

169168
Widget _buildAxisSelector(BuildContext context, String axis, String label) {
170169
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;
173172

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,
189186
),
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,
197188
),
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,
206204
),
207-
],
208-
),
209-
);
210-
},
211-
);
205+
),
206+
],
207+
),
208+
);
209+
});
212210
}
213-
}
211+
}

0 commit comments

Comments
 (0)