Skip to content

Commit b500e4c

Browse files
committed
better error dialog
1 parent 8a80e5f commit b500e4c

1 file changed

Lines changed: 33 additions & 17 deletions

File tree

lib/views/ZoneChooser.dart

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LocationChooser {
4545
static Future<LocationCoordinateData> _getAllLocationData() async {
4646
String administrativeArea;
4747
String locality;
48+
String country;
4849

4950
Position _pos = await LocationData.getCurrentLocation();
5051
DebugToast.show(_pos.toString());
@@ -54,6 +55,7 @@ class LocationChooser {
5455
var first = placemarks.first;
5556
administrativeArea = first.administrativeArea;
5657
locality = first.locality;
58+
country = first.country;
5759
GetStorage().write(kStoredLocationLocality, locality);
5860
} on PlatformException catch (e) {
5961
GetStorage().write(kStoredLocationLocality, e.message.toString());
@@ -63,6 +65,10 @@ class LocationChooser {
6365
rethrow;
6466
}
6567
}
68+
DebugToast.show(country);
69+
if (country.toLowerCase() != "malaysia") {
70+
throw 'Outside Malaysia';
71+
}
6672

6773
var zone = LocationCoordinate.getJakimCodeNearby(
6874
_pos.latitude, _pos.longitude, administrativeArea);
@@ -282,48 +288,58 @@ class LocationChooser {
282288
: Colors.white),
283289
child: Column(
284290
mainAxisAlignment: MainAxisAlignment.center,
285-
children: const [
291+
children: [
292+
Row(
293+
mainAxisAlignment: MainAxisAlignment.center,
294+
children: <Widget>[
295+
Icon(
296+
Icons.fmd_bad_outlined,
297+
size: 40,
298+
color: Colors.red.shade300,
299+
),
300+
Icon(
301+
Icons
302+
.signal_cellular_connected_no_internet_0_bar_outlined,
303+
size: 40,
304+
color: Colors.red.shade300,
305+
),
306+
],
307+
),
286308
Text.rich(
287-
TextSpan(
309+
const TextSpan(
288310
children: <TextSpan>[
289311
TextSpan(
290-
text: 'Please check your ',
312+
text: 'Check your ',
291313
),
292314
TextSpan(
293315
text: 'internet connection ',
294316
style: TextStyle(
295317
fontWeight: FontWeight.bold,
296318
),
297319
),
298-
TextSpan(text: 'and make sure your '),
320+
TextSpan(text: 'or '),
299321
TextSpan(
300-
text: 'GPS is turned on.',
322+
text: 'location services.',
301323
style: TextStyle(
302324
fontWeight: FontWeight.bold,
303325
),
304326
),
305327
],
306328
),
329+
textAlign: TextAlign.center,
330+
style: TextStyle(color: Colors.red.shade300),
307331
),
308-
Text('\nYou can try the following:'),
309-
Text.rich(
332+
const Text.rich(
310333
TextSpan(
311334
children: <TextSpan>[
312-
TextSpan(text: 'Try closing'),
335+
TextSpan(text: '\nPlease'),
313336
TextSpan(
314-
text: ' this ',
337+
text: ' retry ',
315338
style: TextStyle(
316339
fontWeight: FontWeight.bold,
317340
),
318341
),
319-
TextSpan(text: 'dialog and open it back, or'),
320-
],
321-
),
322-
),
323-
Text.rich(
324-
TextSpan(
325-
children: <TextSpan>[
326-
TextSpan(text: 'Set your location'),
342+
TextSpan(text: 'or set your location'),
327343
TextSpan(
328344
text: ' manually.',
329345
style: TextStyle(fontWeight: FontWeight.bold),

0 commit comments

Comments
 (0)