list traction and add leaderboard panel
This commit is contained in:
@@ -13,6 +13,9 @@ class DataService extends ChangeNotifier {
|
||||
List<Leg> _legs = [];
|
||||
List<Leg> get legs => _legs;
|
||||
|
||||
List<LocoSummary> _traction = [];
|
||||
List<LocoSummary> get traction => _traction;
|
||||
|
||||
bool _isHomepageLoading = false;
|
||||
bool get isHomepageLoading => _isHomepageLoading;
|
||||
|
||||
@@ -31,23 +34,36 @@ class DataService extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchLegs({
|
||||
int offset = 0,
|
||||
int limit = 100,
|
||||
String sortBy = 'date',
|
||||
int sortDirection = 0,
|
||||
}) async {
|
||||
final query = '?sort_direction=$sortDirection&sort_by=$sortBy&offset=$offset&limit=$limit';
|
||||
final json = await api.get('/user/legs$query');
|
||||
|
||||
if (json is List) {
|
||||
_legs = json.map((e) => Leg.fromJson(e)).toList();
|
||||
notifyListeners();
|
||||
} else {
|
||||
throw Exception('Unexpected legs response: $json');
|
||||
Future<void> fetchLegs({
|
||||
int offset = 0,
|
||||
int limit = 100,
|
||||
String sortBy = 'date',
|
||||
int sortDirection = 0,
|
||||
}) async {
|
||||
final query =
|
||||
'?sort_direction=$sortDirection&sort_by=$sortBy&offset=$offset&limit=$limit';
|
||||
final json = await api.get('/user/legs$query');
|
||||
|
||||
if (json is List) {
|
||||
_legs = json.map((e) => Leg.fromJson(e)).toList();
|
||||
notifyListeners();
|
||||
} else {
|
||||
throw Exception('Unexpected legs response: $json');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchHadTraction({int offset = 0, int limit = 100}) async {
|
||||
final query = '?offset=$offset&limit=$limit';
|
||||
final json = await api.get('/loco/mileage$query');
|
||||
|
||||
if (json is List) {
|
||||
_traction = json.map((e) => LocoSummary.fromJson(e)).toList();
|
||||
notifyListeners();
|
||||
} else {
|
||||
throw Exception('Unexpected traction response: $json');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_homepageStats = null;
|
||||
|
||||
Reference in New Issue
Block a user