// Flutter imports: import 'package:flutter/material.dart'; // Package imports: import 'package:provider/provider.dart'; // Project imports: import 'package:aku_community_manager/mock_models/fix/fix_model.dart'; import 'package:aku_community_manager/mock_models/fix/fixer_model.dart'; import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; class FixProvider extends ChangeNotifier { List _fixModels = FixModel.initList(); List get fixModels => _fixModels; addFixModel(FixModel model) { _fixModels.insert(0, model); notifyListeners(); } List getFixModel(int index, BuildContext context) { final userProvider = Provider.of(context, listen: false); USER_ROLE role = userProvider.userInfoModel.role; List _doneModels = _fixModels.where((element) => element.type == FIX_ENUM.DONE).toList(); List _processingModels = _fixModels .where((element) => element.type == FIX_ENUM.PROCESSING) .toList(); List _handOutModels = _fixModels .where((element) => element.type == FIX_ENUM.HAND_OUT) .toList(); List _waitPickUpModels = _fixModels .where((element) => element.type == FIX_ENUM.WAIT_PICKUP) .toList(); List _fixerModels = _fixModels .where((element) => element.type != FIX_ENUM.HAND_OUT) .toList(); switch (role) { case USER_ROLE.MANAGER: return [ _handOutModels, _waitPickUpModels, _processingModels, _doneModels, _fixModels, ][index]; break; default: return [ _waitPickUpModels, _processingModels, _doneModels, _fixerModels, ][index]; break; } } List _fixerModels = FixerTypedModel.models; List _propertyModels = FixerTypedModel.propertyModels; List get fixerModels => _fixerModels; List get propertyModels => _propertyModels; }