Skip to content

Commit

Permalink
better error dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez committed Jul 22, 2021
1 parent 8a80e5f commit b500e4c
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions lib/views/ZoneChooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class LocationChooser {
static Future<LocationCoordinateData> _getAllLocationData() async {
String administrativeArea;
String locality;
String country;

Position _pos = await LocationData.getCurrentLocation();
DebugToast.show(_pos.toString());
Expand All @@ -54,6 +55,7 @@ class LocationChooser {
var first = placemarks.first;
administrativeArea = first.administrativeArea;
locality = first.locality;
country = first.country;
GetStorage().write(kStoredLocationLocality, locality);
} on PlatformException catch (e) {
GetStorage().write(kStoredLocationLocality, e.message.toString());
Expand All @@ -63,6 +65,10 @@ class LocationChooser {
rethrow;
}
}
DebugToast.show(country);
if (country.toLowerCase() != "malaysia") {
throw 'Outside Malaysia';
}

var zone = LocationCoordinate.getJakimCodeNearby(
_pos.latitude, _pos.longitude, administrativeArea);
Expand Down Expand Up @@ -282,48 +288,58 @@ class LocationChooser {
: Colors.white),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.fmd_bad_outlined,
size: 40,
color: Colors.red.shade300,
),
Icon(
Icons
.signal_cellular_connected_no_internet_0_bar_outlined,
size: 40,
color: Colors.red.shade300,
),
],
),
Text.rich(
TextSpan(
const TextSpan(
children: <TextSpan>[
TextSpan(
text: 'Please check your ',
text: 'Check your ',
),
TextSpan(
text: 'internet connection ',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
TextSpan(text: 'and make sure your '),
TextSpan(text: 'or '),
TextSpan(
text: 'GPS is turned on.',
text: 'location services.',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
textAlign: TextAlign.center,
style: TextStyle(color: Colors.red.shade300),
),
Text('\nYou can try the following:'),
Text.rich(
const Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(text: 'Try closing'),
TextSpan(text: '\nPlease'),
TextSpan(
text: ' this ',
text: ' retry ',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
TextSpan(text: 'dialog and open it back, or'),
],
),
),
Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(text: 'Set your location'),
TextSpan(text: 'or set your location'),
TextSpan(
text: ' manually.',
style: TextStyle(fontWeight: FontWeight.bold),
Expand Down

0 comments on commit b500e4c

Please sign in to comment.