Skip to content

Commit

Permalink
Achievements UI no backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cgu2020 committed Apr 24, 2024
1 parent 9745e53 commit 9903fbb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
16 changes: 1 addition & 15 deletions game/lib/achievements/achievements_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,8 @@ class _AchievementsPageState extends State<AchievementsPage> {
}
return ListView.separated(
padding: const EdgeInsets.symmetric(horizontal: 3),
itemCount: eventCells.length + 1,
itemCount: eventCells.length,
itemBuilder: (context, index) {
if (index == eventCells.length) {
// Footer widget
return Padding(
padding:
const EdgeInsets.only(bottom: 50.0),
child: Center(
child: Image(
image: AssetImage(
'assets/images/go-logo.png'),
width: 200,
height: 200,
),
));
}
return eventCells[index];
},
physics: BouncingScrollPhysics(),
Expand Down
18 changes: 7 additions & 11 deletions game/lib/api/geopoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class GeoPoint {
double get long => _long;
double get heading => _heading;

static bool _isRequestingLocationPermissions = false;
static bool _isRequestingLocation = false;

GeoPoint(
double lat,
double long,
Expand All @@ -25,38 +22,37 @@ class GeoPoint {
_heading = heading;
}

static Future<GeoPoint?> current() async {
static Future<GeoPoint> current() async {
var serviceEnabled = await Geolocator.isLocationServiceEnabled();
print("current");
if (!serviceEnabled) {
print("Failed to enable location!!!!!!!!");
// Location services are not enabled don't continue
// accessing the position and request users of the
// App to enable the location services.
return Future.error('Location services are disabled.');
}

if (_isRequestingLocationPermissions || _isRequestingLocation) {
//To handle the case where a request is already occuring.

return null;
}

try {
_isRequestingLocationPermissions = true;
var permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
print("permissions denied");
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
print("permissions denied again");
return Future.error('Location services are disabled.');
}
}
if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
print("permissions denied");
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
final pos = await Geolocator.getCurrentPosition();
return GeoPoint(pos.latitude, pos.longitude, pos.heading);
} catch (e) {
print(e);
return Future.error(e.toString());
}
}
Expand Down
4 changes: 4 additions & 0 deletions game/lib/gameplay/gameplay_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class _GameplayMapState extends State<GameplayMap> {

GeoPoint.current().then(
(location) {
print("Getting loco");
print(location);
currentLocation = location;
},
);
Expand Down Expand Up @@ -163,6 +165,7 @@ class _GameplayMapState extends State<GameplayMap> {
);
setState(() {});
});
print("position stream true");
return true;
}

Expand Down Expand Up @@ -515,6 +518,7 @@ class _GameplayMapState extends State<GameplayMap> {

/** Returns whether the user is at the challenge location */
bool checkArrived() {
print(currentLocation);
return currentLocation!.distanceTo(widget.targetLocation) <=
widget.awardingRadius;
}
Expand Down
4 changes: 3 additions & 1 deletion game/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class MyApp extends StatelessWidget {
],
supportedLocales: const [Locale('en', '')],
theme: ThemeData(
fontFamily: 'Poppins', primarySwatch: ColorPalette.BigRed),
useMaterial3: false,
fontFamily: 'Poppins',
primarySwatch: ColorPalette.BigRed),
home: StreamBuilder<bool>(
stream: Stream.fromFuture(client.tryRelog()),
builder: (stream, snapshot) => (snapshot.data == null)
Expand Down

0 comments on commit 9903fbb

Please sign in to comment.