iq/lib/app/modules/notificationsScreen/controllers/notifications_screen_contro...

70 lines
2.0 KiB
Dart
Raw Normal View History

2023-09-11 12:11:35 +00:00
// ignore_for_file: unnecessary_overrides
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:IQ/app/global/static_informs.dart';
import 'package:IQ/app/modules/home/models/notifications_model.dart';
import 'package:IQ/app/modules/home/providers/language_currency.dart';
import 'package:IQ/app/modules/home/providers/notifications.dart';
import 'package:IQ/app/modules/home/providers/service.dart';
class NotificationsScreenController extends GetxController
with WidgetsBindingObserver {
bool fetchNotifsData = false;
// ignore: prefer_typing_uninitialized_variables
var fetchLoadingNotifsDataVar;
Future<void> onRefresh() async {
fetchNotifsData = false;
notifications = null;
fetchLoadingNotifsDataVar = fetchLoadingNotifsData();
update();
}
fetchLoadingNotifsData() async {
await getUserNotificationsInforms("");
if (getUserNotificationsInformsLoads) {
fetchNotifsData = true;
listOfNotifs = notifications?.data ?? [];
update();
}
}
String activiationType = '${service?.data?.profileName}';
String subscriptionCurrency = languagesCurrencyModel?.data?.currency ?? '';
String profileName = service?.data?.profileName ?? '';
List<Data>? listOfNotifs = notifications?.data ?? [];
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.inactive ||
state == AppLifecycleState.detached ||
state == AppLifecycleState.paused) return;
if (state == AppLifecycleState.resumed) {
defaultLocale = Platform.localeName.split('_')[0];
snackBarText = 'back_twice'.tr;
}
}
@override
void onInit() {
fetchLoadingNotifsDataVar = fetchLoadingNotifsData();
WidgetsBinding.instance.addObserver(this);
super.onInit();
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
WidgetsBinding.instance.removeObserver(this);
}
}