| @@ -190,9 +190,12 @@ class GlobalState extends ChangeNotifier { | |||||
| Status allFiltersStatus = Status.empty; | Status allFiltersStatus = Status.empty; | ||||
| Future<Status> getAllFiltersItems({bool refresh = false}) async { | Future<Status> getAllFiltersItems({bool refresh = false}) async { | ||||
| final int role = setting.userLocalDb.getUser().role ?? -1; | |||||
| allFiltersStatus = Status.loading; | allFiltersStatus = Status.loading; | ||||
| notifyListeners(); | notifyListeners(); | ||||
| if (_isDataAlreadyLoaded() && !refresh) { | |||||
| if (_isDataAlreadyLoaded(role) && !refresh) { | |||||
| allFiltersStatus = Status.ready; | allFiltersStatus = Status.ready; | ||||
| } else { | } else { | ||||
| allFiltersStatus = Status.loading; | allFiltersStatus = Status.loading; | ||||
| @@ -200,39 +203,48 @@ class GlobalState extends ChangeNotifier { | |||||
| notifyListeners(); | notifyListeners(); | ||||
| await _fetchAllData(refresh: refresh); | |||||
| await _fetchAllData(role: role, refresh: refresh); | |||||
| _updateAllFiltersStatus(); | |||||
| _updateAllFiltersStatus(role); | |||||
| notifyListeners(); | notifyListeners(); | ||||
| return allFiltersStatus; | return allFiltersStatus; | ||||
| } | } | ||||
| bool _isDataAlreadyLoaded() { | |||||
| bool _isDataAlreadyLoaded(int role) { | |||||
| return locationsModel != null && | return locationsModel != null && | ||||
| locationsModel!.isNotEmpty && | locationsModel!.isNotEmpty && | ||||
| usersModel != null && | |||||
| usersModel!.isNotEmpty && | |||||
| meetingsManagerModel != null && | |||||
| meetingsManagerModel!.isNotEmpty && | |||||
| subjectsModel != null && | subjectsModel != null && | ||||
| subjectsModel!.isNotEmpty; | |||||
| subjectsModel!.isNotEmpty && | |||||
| (role == 1 || (usersModel != null && usersModel!.isNotEmpty)) && | |||||
| (role == 1 || | |||||
| (meetingsManagerModel != null && meetingsManagerModel!.isNotEmpty)); | |||||
| } | } | ||||
| Future<void> _fetchAllData({required bool refresh}) async { | |||||
| await Future.wait([ | |||||
| Future<void> _fetchAllData({required int role, required bool refresh}) async { | |||||
| final List<Future<void>> tasks = [ | |||||
| getLocations(refresh: refresh), | getLocations(refresh: refresh), | ||||
| getMeetingsManager(refresh: refresh), | |||||
| getSubjects(refresh: refresh), | getSubjects(refresh: refresh), | ||||
| getUsers(refresh: refresh), | |||||
| ]); | |||||
| ]; | |||||
| // Only add getUsers if role is not 1 | |||||
| if (role != 1) { | |||||
| tasks.add(getUsers(refresh: refresh)); | |||||
| } | |||||
| // Only add getMeetingsManager if role is not 1 | |||||
| if (role != 1) { | |||||
| tasks.add(getMeetingsManager(refresh: refresh)); | |||||
| } | |||||
| await Future.wait(tasks); | |||||
| } | } | ||||
| void _updateAllFiltersStatus() { | |||||
| void _updateAllFiltersStatus(int role) { | |||||
| if (locationsStatus == Status.ready && | if (locationsStatus == Status.ready && | ||||
| subjectsStatus == Status.ready && | subjectsStatus == Status.ready && | ||||
| usersStatus == Status.ready && | |||||
| meetingsManagerStatus == Status.ready) { | |||||
| (role == 1 || usersStatus == Status.ready) && | |||||
| (role == 1 || meetingsManagerStatus == Status.ready)) { | |||||
| allFiltersStatus = Status.ready; | allFiltersStatus = Status.ready; | ||||
| } else { | } else { | ||||
| allFiltersStatus = Status.error; | allFiltersStatus = Status.error; | ||||
| @@ -2,6 +2,7 @@ | |||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
| import 'package:qadirneyriz/global/global_state/global_state.dart'; | import 'package:qadirneyriz/global/global_state/global_state.dart'; | ||||
| import 'package:qadirneyriz/setting/setting.dart'; | |||||
| import 'package:qadirneyriz/widgets/ExpansionTileCustom.dart'; | import 'package:qadirneyriz/widgets/ExpansionTileCustom.dart'; | ||||
| import 'package:qadirneyriz/widgets/error_widget.dart'; | import 'package:qadirneyriz/widgets/error_widget.dart'; | ||||
| import 'package:qadirneyriz/config/config.dart'; | import 'package:qadirneyriz/config/config.dart'; | ||||
| @@ -237,43 +238,46 @@ class _DiologMeetingsFiltersState extends State<DiologMeetingsFilters> { | |||||
| ), | ), | ||||
| ], | ], | ||||
| ), | ), | ||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)! | |||||
| .meetingmanager, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| physics: NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| itemCount: globalState | |||||
| .meetingsManagerModel!.length, | |||||
| itemBuilder: | |||||
| (BuildContext context, int index) { | |||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: meetingsState | |||||
| .selectedManagersId, | |||||
| value: items.id ?? -1, | |||||
| title: Text( | |||||
| items.name ?? '', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| meetingsState.selectManager( | |||||
| newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| if (setting.userLocalDb.getUser().role != 1) | |||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)! | |||||
| .meetingmanager, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| physics: | |||||
| NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| itemCount: globalState | |||||
| .meetingsManagerModel!.length, | |||||
| itemBuilder: (BuildContext context, | |||||
| int index) { | |||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: meetingsState | |||||
| .selectedManagersId, | |||||
| value: items.id ?? -1, | |||||
| title: Text( | |||||
| items.name ?? '', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: | |||||
| config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| meetingsState.selectManager( | |||||
| newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| ExpansionTileCustom( | ExpansionTileCustom( | ||||
| title: | title: | ||||
| AppLocalizations.of(context)!.subject, | AppLocalizations.of(context)!.subject, | ||||
| @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; | |||||
| import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
| import 'package:qadirneyriz/global/global_state/global_state.dart'; | import 'package:qadirneyriz/global/global_state/global_state.dart'; | ||||
| import 'package:qadirneyriz/screens/private_meeting/state.dart'; | import 'package:qadirneyriz/screens/private_meeting/state.dart'; | ||||
| import 'package:qadirneyriz/setting/setting.dart'; | |||||
| import 'package:qadirneyriz/widgets/ExpansionTileCustom.dart'; | import 'package:qadirneyriz/widgets/ExpansionTileCustom.dart'; | ||||
| import 'package:qadirneyriz/widgets/error_widget.dart'; | import 'package:qadirneyriz/widgets/error_widget.dart'; | ||||
| import 'package:qadirneyriz/config/config.dart'; | import 'package:qadirneyriz/config/config.dart'; | ||||
| @@ -243,44 +244,47 @@ class _DiologPrivateMeetingsFiltersState | |||||
| ), | ), | ||||
| ], | ], | ||||
| ), | ), | ||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)! | |||||
| .meetingmanager, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| physics: NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| itemCount: globalState | |||||
| .meetingsManagerModel!.length, | |||||
| itemBuilder: | |||||
| (BuildContext context, int index) { | |||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: privateMeetingsState | |||||
| .selectedManagersId, | |||||
| value: items.id ?? -1, | |||||
| title: Text( | |||||
| items.name ?? '', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| privateMeetingsState | |||||
| .selectManager( | |||||
| newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| if (setting.userLocalDb.getUser().role != 1) | |||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)! | |||||
| .meetingmanager, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| physics: | |||||
| NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| itemCount: globalState | |||||
| .meetingsManagerModel!.length, | |||||
| itemBuilder: (BuildContext context, | |||||
| int index) { | |||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: privateMeetingsState | |||||
| .selectedManagersId, | |||||
| value: items.id ?? -1, | |||||
| title: Text( | |||||
| items.name ?? '', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: | |||||
| config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| privateMeetingsState | |||||
| .selectManager( | |||||
| newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| ExpansionTileCustom( | ExpansionTileCustom( | ||||
| title: | title: | ||||
| AppLocalizations.of(context)!.subject, | AppLocalizations.of(context)!.subject, | ||||
| @@ -196,108 +196,111 @@ class _FiltersItemInReportState extends State<FiltersItemInReport> { | |||||
| ), | ), | ||||
| ], | ], | ||||
| ), | ), | ||||
| if (setting.userLocalDb.getUser().role != 1) | |||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)! | |||||
| .meetingmanager, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| physics: NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| itemCount: globalState | |||||
| .meetingsManagerModel!.length, | |||||
| itemBuilder: | |||||
| (BuildContext context, int index) { | |||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: | |||||
| reportState.selectedManagersId, | |||||
| value: items.id ?? -1, | |||||
| title: Text( | |||||
| items.name ?? '', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| reportState | |||||
| .selectManager(newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | |||||
| ], | |||||
| ), | |||||
| ExpansionTileCustom( | ExpansionTileCustom( | ||||
| title: | |||||
| AppLocalizations.of(context)!.meetingmanager, | |||||
| title: AppLocalizations.of(context)!.subject, | |||||
| widgets: <Widget>[ | widgets: <Widget>[ | ||||
| ListView.builder( | ListView.builder( | ||||
| primary: false, | primary: false, | ||||
| physics: NeverScrollableScrollPhysics(), | physics: NeverScrollableScrollPhysics(), | ||||
| shrinkWrap: true, | shrinkWrap: true, | ||||
| itemCount: | |||||
| globalState.meetingsManagerModel!.length, | |||||
| itemCount: globalState.subjectsModel!.length, | |||||
| itemBuilder: | itemBuilder: | ||||
| (BuildContext context, int index) { | (BuildContext context, int index) { | ||||
| final items = globalState | |||||
| .meetingsManagerModel![index]; | |||||
| final items = | |||||
| globalState.subjectsModel![index]; | |||||
| return RadioListTile<int>( | return RadioListTile<int>( | ||||
| toggleable: true, | toggleable: true, | ||||
| groupValue: | |||||
| reportState.selectedManagersId, | |||||
| groupValue: reportState.selectedSubjectId, | |||||
| value: items.id ?? -1, | value: items.id ?? -1, | ||||
| title: Text( | title: Text( | ||||
| items.name ?? '', | |||||
| items.subject ?? '', | |||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| style: TextStyle( | style: TextStyle( | ||||
| fontWeight: FontWeight.w100, | fontWeight: FontWeight.w100, | ||||
| fontSize: 14), | fontSize: 14), | ||||
| maxLines: 1, | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | ), | ||||
| activeColor: config.ui.secendGreen, | activeColor: config.ui.secendGreen, | ||||
| onChanged: (int? newValue) { | onChanged: (int? newValue) { | ||||
| reportState | reportState | ||||
| .selectManager(newValue ?? null); | |||||
| .selectSubject(newValue ?? null); | |||||
| }, | }, | ||||
| ); | ); | ||||
| }, | }, | ||||
| ), | ), | ||||
| ], | ], | ||||
| ), | ), | ||||
| ExpansionTileCustom( | |||||
| title: AppLocalizations.of(context)!.subject, | |||||
| widgets: <Widget>[ | |||||
| ListView.builder( | |||||
| primary: false, | |||||
| Divider(), | |||||
| if (setting.userLocalDb.getUser().role != 1) | |||||
| SizedBox( | |||||
| height: 250, | |||||
| child: ListView.builder( | |||||
| physics: NeverScrollableScrollPhysics(), | physics: NeverScrollableScrollPhysics(), | ||||
| shrinkWrap: true, | shrinkWrap: true, | ||||
| itemCount: globalState.subjectsModel!.length, | |||||
| primary: false, | |||||
| itemCount: meetingStatuses.length, | |||||
| itemBuilder: | itemBuilder: | ||||
| (BuildContext context, int index) { | (BuildContext context, int index) { | ||||
| final items = | |||||
| globalState.subjectsModel![index]; | |||||
| final items = meetingStatuses[index]; | |||||
| return RadioListTile<int>( | return RadioListTile<int>( | ||||
| toggleable: true, | toggleable: true, | ||||
| groupValue: reportState.selectedSubjectId, | |||||
| value: items.id ?? -1, | |||||
| groupValue: reportState.selectedStatusId, | |||||
| value: items.id, | |||||
| title: Text( | title: Text( | ||||
| items.subject ?? '', | |||||
| items.title, | |||||
| maxLines: 1, | maxLines: 1, | ||||
| overflow: TextOverflow.ellipsis, | |||||
| style: TextStyle( | style: TextStyle( | ||||
| fontWeight: FontWeight.w100, | fontWeight: FontWeight.w100, | ||||
| fontSize: 14), | fontSize: 14), | ||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | ), | ||||
| activeColor: config.ui.secendGreen, | activeColor: config.ui.secendGreen, | ||||
| onChanged: (int? newValue) { | onChanged: (int? newValue) { | ||||
| reportState | |||||
| .selectSubject(newValue ?? null); | |||||
| reportState.selectStatusMeeting( | |||||
| newValue ?? null); | |||||
| }, | }, | ||||
| ); | ); | ||||
| }, | }, | ||||
| ), | ), | ||||
| ], | |||||
| ), | |||||
| Divider(), | |||||
| SizedBox( | |||||
| height: 250, | |||||
| child: ListView.builder( | |||||
| physics: NeverScrollableScrollPhysics(), | |||||
| shrinkWrap: true, | |||||
| primary: false, | |||||
| itemCount: meetingStatuses.length, | |||||
| itemBuilder: (BuildContext context, int index) { | |||||
| final items = meetingStatuses[index]; | |||||
| return RadioListTile<int>( | |||||
| toggleable: true, | |||||
| groupValue: reportState.selectedStatusId, | |||||
| value: items.id, | |||||
| title: Text( | |||||
| items.title, | |||||
| maxLines: 1, | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w100, | |||||
| fontSize: 14), | |||||
| overflow: TextOverflow.ellipsis, | |||||
| ), | |||||
| activeColor: config.ui.secendGreen, | |||||
| onChanged: (int? newValue) { | |||||
| reportState.selectStatusMeeting( | |||||
| newValue ?? null); | |||||
| }, | |||||
| ); | |||||
| }, | |||||
| ), | ), | ||||
| ), | |||||
| Padding( | Padding( | ||||
| padding: const EdgeInsets.symmetric( | padding: const EdgeInsets.symmetric( | ||||
| horizontal: 20, vertical: 50), | horizontal: 20, vertical: 50), | ||||