You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
4.1 KiB
Dart
125 lines
4.1 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart';
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart';
|
|
import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart';
|
|
import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart';
|
|
import 'package:mohem_flutter_app/models/vacation_rule/vr_item_types_list_model.dart';
|
|
import 'package:mohem_flutter_app/models/vacation_rule/wf_look_up_list_model.dart';
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
class AddVacationRuleScreen extends StatefulWidget {
|
|
AddVacationRuleScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_AddVacationRuleScreenState createState() {
|
|
return _AddVacationRuleScreenState();
|
|
}
|
|
}
|
|
|
|
class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
List<VrItemTypesList>? vrItemTypesList;
|
|
List<GetItemTypeNotificationsList>? itemTypeNotificationsList;
|
|
|
|
List<GetNotificationReassignModeList>? notificationReassignModeList;
|
|
List<RespondAttributesList>? respondAttributesList;
|
|
List<WFLookUpList>? wfLookupList;
|
|
|
|
int currentStage = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getVacationRulesList();
|
|
}
|
|
|
|
void getVacationRulesList() async {
|
|
try {
|
|
Utils.showLoading(context);
|
|
vrItemTypesList = await VacationRuleApiClient().getVrItemTypes();
|
|
Utils.hideLoading(context);
|
|
currentStage = 1;
|
|
setState(() {});
|
|
} catch (ex) {
|
|
Utils.hideLoading(context);
|
|
Utils.handleException(ex, context, null);
|
|
}
|
|
}
|
|
|
|
void getItemTypeNotificationsList() async {
|
|
try {
|
|
Utils.showLoading(context);
|
|
//itemTypeNotificationsList = await VacationRuleApiClient().getItemTypeNotifications();
|
|
Utils.hideLoading(context);
|
|
currentStage = 2;
|
|
setState(() {});
|
|
} catch (ex) {
|
|
Utils.hideLoading(context);
|
|
Utils.handleException(ex, context, null);
|
|
}
|
|
}
|
|
|
|
void callCombineApis() async {
|
|
try {
|
|
Utils.showLoading(context);
|
|
List results = await Future.wait([
|
|
// VacationRuleApiClient().getNotificationReassignMode(),
|
|
// VacationRuleApiClient().getRespondAttributes("", ""),
|
|
// VacationRuleApiClient().getWfLookup(P_LOOKUP_TYPE),
|
|
]);
|
|
notificationReassignModeList = results[0];
|
|
respondAttributesList = results[1];
|
|
wfLookupList = results[2];
|
|
Utils.hideLoading(context);
|
|
currentStage = 3;
|
|
setState(() {});
|
|
} catch (ex) {
|
|
Utils.hideLoading(context);
|
|
Utils.handleException(ex, context, null);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBarWidget(
|
|
context,
|
|
title: LocaleKeys.vacationRule.tr(),
|
|
),
|
|
body: vrItemTypesList == null
|
|
? const SizedBox()
|
|
: (vrItemTypesList!.isEmpty
|
|
? Utils.getNoDataWidget(context)
|
|
: Column(
|
|
children: [
|
|
ListView(
|
|
padding: const EdgeInsets.all(21),
|
|
physics: const BouncingScrollPhysics(),
|
|
children: [],
|
|
).expanded,
|
|
DefaultButton(
|
|
currentStage == 3 ? LocaleKeys.apply.tr() : LocaleKeys.next.tr(),
|
|
() {
|
|
if (currentStage == 1) {
|
|
getItemTypeNotificationsList();
|
|
} else if (currentStage == 2) {
|
|
callCombineApis();
|
|
}
|
|
},
|
|
).insideContainer,
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
}
|