44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:get/get.dart';
|
|
import 'package:SEFER/constant/links.dart';
|
|
import 'package:SEFER/constant/style.dart';
|
|
import 'package:SEFER/controller/functions/crud.dart';
|
|
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
|
|
|
class PromosController extends GetxController {
|
|
List<dynamic> promoList = [];
|
|
bool isLoading = true;
|
|
late String promos;
|
|
@override
|
|
void onInit() {
|
|
getPromoByToday();
|
|
super.onInit();
|
|
}
|
|
|
|
Future getPromoByToday() async {
|
|
var res = await CRUD().get(link: AppLink.getPromoBytody, payload: {});
|
|
if (res.toString() == 'failure') {
|
|
Get.defaultDialog(
|
|
title: 'No Promo for today .'.tr,
|
|
middleText: '',
|
|
titleStyle: AppStyle.title,
|
|
confirm: MyElevatedButton(
|
|
title: 'Back'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
Get.back();
|
|
}));
|
|
isLoading = false;
|
|
update();
|
|
} else {
|
|
var jsonDecoded = jsonDecode(res);
|
|
|
|
promoList = jsonDecoded['message'];
|
|
isLoading = false;
|
|
update();
|
|
print(promoList);
|
|
}
|
|
}
|
|
}
|