fist commit ftc staff app clone
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ftc_mobile_app/models/training/TrainingResponseData.dart';
|
||||
import 'package:ftc_mobile_app/utilities/extensions/custom_extensions.dart';
|
||||
import 'package:ftc_mobile_app/utilities/frequent_functions.dart';
|
||||
import 'package:ftc_mobile_app/web_services/api_services.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class TrainingsScreenController extends GetxController {
|
||||
final GlobalKey<ScaffoldState> screenKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
final trainings = <TrainingUsers>[].obs;
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
|
||||
getAllTrainings();
|
||||
}
|
||||
|
||||
void removeFocus() {
|
||||
FocusScope.of(screenKey.currentContext!).unfocus();
|
||||
}
|
||||
|
||||
getAllTrainings() async {
|
||||
final resp = await ApiService().allTrainingsList().showLoader();
|
||||
|
||||
if (resp is TrainingResponseData) {
|
||||
//Todo: change this static user id here
|
||||
trainings.value = resp.proposedTrainings ?? [];
|
||||
} else {
|
||||
if (resp.isNotNullOrEmpty()) {
|
||||
FrequentFunctions.showToast(message: resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Get.delete<TrainingsScreenController>();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user