mobile_skt/lib/screens/landing/landing_controller.dart

120 lines
3.3 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/models/app_bottom_nav_item.dart';
import 'package:sk_base_mobile/services/app_info.service.dart';
class LandingController extends GetxController {
RxMap userData = {}.obs;
RxString name = ''.obs;
RxInt currentIndex = 0.obs;
final PageController pageController = PageController();
final DateTime dateTime = DateTime.now();
List<IconData> iconList = [Icons.home_max, Icons.person_outline_rounded];
List<RxList> list = [
[].obs,
[].obs,
[].obs,
[].obs,
[].obs,
[].obs,
[].obs,
].obs;
RxList model = [].obs;
final ScrollController scrollController = ScrollController();
RxList bottomNavItems = RxList<BottomNavigationBarItem>([]);
List<Widget> pages = [];
@override
onInit() {
super.onInit();
List<AppBottomNavItem> roleWithBottomNavItems =
AppInfoService.to.bottomNavItems!;
bottomNavItems.assignAll(roleWithBottomNavItems
.map((e) => BottomNavigationBarItem(
icon: e.icon, activeIcon: e.activeIcon, label: e.label))
.toList());
pages = roleWithBottomNavItems.map((e) => e.page!).toList();
}
getUserData() async {
getName();
}
getName() {
// name.value = userData['NAME'];
}
getTasks() async {
// db.getData().then((value) {
// model.value = value;
// getSepretLists();
// });
}
setIndex(int value) {
pageController.animateToPage(value,
duration: const Duration(milliseconds: 300), curve: Curves.easeIn);
currentIndex.value = value;
}
// getDateAccordingTabs(int value) {
// return '${Utils.addPrefix(dateTime.add(Duration(days: value)).day.toString())}/${Utils.addPrefix(dateTime.add(Duration(days: value)).month.toString())}/${Utils.addPrefix(dateTime.add(Duration(days: value)).year.toString())}';
// }
getSepretLists() {
// List<RxList<dynamic>> tempList = [];
// for (int i = 0; i < 7; i++) {
// RxList tempList1 = [].obs;
// tempList1.clear();
// for (int j = 0; j < model.length; j++) {
// if (model[j].date == getDateAccordingTabs(i)) {
// tempList1.add(model[j]);
// }
// }
// tempList.add(tempList1);
// }
// list = tempList;
}
onMoveNextPage() {
if (currentIndex.value < 7) {
setIndex(currentIndex.value + 1);
}
}
onMoveBack() {
if (currentIndex.value > 0) {
setIndex(currentIndex.value - 1);
}
}
onTaskComplete(
int value, int index, int ind, String key, BuildContext context) {
// switch (value) {
// case 3:
// {
// Utils.showWarningDialog(context, 'Complete Task',
// 'This task will be marked as completed', 'Confirm', () {
// list[ind][index].status = 'complete';
// list[ind].add('');
// list[ind].remove('');
// db.update(key, 'status', 'complete');
// });
// }
// case 2:
// {
// Utils.showWarningDialog(context, 'Delete Task',
// 'Are you want to sure to remove', 'Confirm', () {
// list[ind].remove(list[ind][index]);
// db.delete(
// key,
// 'Tasks',
// );
// });
// }
// }
}
}