diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index d75f0893..f781e839 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -59,7 +59,7 @@ class PhpGroup { static GetResidentsByProperty getResidentsByProperty = GetResidentsByProperty(); static GetOpenedVisits getOpenedVisits = GetOpenedVisits(); static GetLicense getLicense = GetLicense(); - static FakeOpenedVisits getProvSchedules = FakeOpenedVisits(); + static GetProvSchedules getProvSchedules = GetProvSchedules(); } class GetProvSchedules { @@ -70,6 +70,7 @@ class GetProvSchedules { final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getAgendamentoProv'; const String pageSize = '10'; + final bool isFiltered = status != '' && status != '.*'; // const String baseUrl = 'http://localhost:3000'; return await ApiManager.instance.makeApiCall( callName: 'getProvSchedules', @@ -77,7 +78,7 @@ class GetProvSchedules { callType: ApiCallType.POST, headers: {'Content-Type': 'application/x-www-form-urlencoded'}, params: { - if (status != '') 'status': status, + if (isFiltered) 'status': status, 'devUUID': devUUID, 'userUUID': userUUID, 'cliID': cliID, @@ -128,40 +129,6 @@ class GetOpenedVisits { } } -class FakeOpenedVisits { - Future call(final String page, final String status) async { - final Map jsonBody = { - "error": false, - "agendamento": { - "total": 66, - "value": [ - {"AGP_ID": 32, "AGP_NOME": "assa", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-12-08T12:09:00.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 31, "AGP_NOME": "laksjsal", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-12-08T12:09:00.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 29, "AGP_NOME": "teste", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-12-08T12:01:00.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 30, "AGP_NOME": "jrjdj", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-12-08T12:01:00.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 28, "AGP_NOME": "Lucas test", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-12-08T11:57:00.000Z", "AGP_OBSERVACAO": "dds", "AGP_STATUS": "CO", "IS_DELETED": false}, - { - "AGP_ID": 27, - "AGP_NOME": "Lucas Teste", - "AGP_PRO_ID": 1, - "AGP_DT_VISITA": "2024-12-08T11:54:00.000Z", - "AGP_OBSERVACAO": "Testando ", - "AGP_STATUS": "CO", - "IS_DELETED": false - }, - {"AGP_ID": 84, "AGP_NOME": "dsfsaf", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-11-14T17:28:00.000Z", "AGP_OBSERVACAO": "sdfgds", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 107, "AGP_NOME": "twsre", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-11-12T19:20:00.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "AT", "IS_DELETED": false}, - {"AGP_ID": 86, "AGP_NOME": "AOBA", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-11-09T16:18:36.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false}, - {"AGP_ID": 85, "AGP_NOME": "alibaba", "AGP_PRO_ID": 1, "AGP_DT_VISITA": "2024-11-09T16:14:59.000Z", "AGP_OBSERVACAO": "", "AGP_STATUS": "CO", "IS_DELETED": false} - ] - } - }; - final Map headers = {'Content-Type': 'application/json'}; - final int statusCode = 200; - return ApiCallResponse(jsonBody, headers, statusCode); - } -} - class GetResidentsByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); diff --git a/lib/features/history/data/data_sources/index.dart b/lib/features/history/data/data_sources/index.dart index e69de29b..d3dfea4d 100644 --- a/lib/features/history/data/data_sources/index.dart +++ b/lib/features/history/data/data_sources/index.dart @@ -0,0 +1,2 @@ +export 'local_data_sources/index.dart'; +export 'remote_data_sources/index.dart'; diff --git a/lib/features/history/data/data_sources/local_data_sources/access_history_local_data_source.dart b/lib/features/history/data/data_sources/local_data_sources/access_history_local_data_source.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/data/data_sources/local_data_sources/index.dart b/lib/features/history/data/data_sources/local_data_sources/index.dart new file mode 100644 index 00000000..9c174b3c --- /dev/null +++ b/lib/features/history/data/data_sources/local_data_sources/index.dart @@ -0,0 +1,2 @@ +export 'access_history_local_data_source.dart'; +export 'provisional_history_local_data_source.dart'; diff --git a/lib/features/history/data/data_sources/local_data_sources/provisional_history_local_data_source.dart b/lib/features/history/data/data_sources/local_data_sources/provisional_history_local_data_source.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/data/data_sources/remote_data_sources/access_history_remote_data_source.dart b/lib/features/history/data/data_sources/remote_data_sources/access_history_remote_data_source.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/data/data_sources/remote_data_sources/index.dart b/lib/features/history/data/data_sources/remote_data_sources/index.dart new file mode 100644 index 00000000..a159cee8 --- /dev/null +++ b/lib/features/history/data/data_sources/remote_data_sources/index.dart @@ -0,0 +1,2 @@ +export 'access_history_remote_data_source.dart'; +export 'provisional_history_remote_data_source.dart'; diff --git a/lib/features/history/data/data_sources/remote_data_sources/provisional_history_remote_data_source.dart b/lib/features/history/data/data_sources/remote_data_sources/provisional_history_remote_data_source.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/data/repositories/access_history_repository_impl.dart b/lib/features/history/data/repositories/access_history_repository_impl.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/data/repositories/index.dart b/lib/features/history/data/repositories/index.dart index e69de29b..7d469d00 100644 --- a/lib/features/history/data/repositories/index.dart +++ b/lib/features/history/data/repositories/index.dart @@ -0,0 +1,2 @@ +export 'access_history_repository_impl.dart'; +export 'provisional_history_repository_impl.dart'; diff --git a/lib/features/history/data/repositories/provisional_history_repository_impl.dart b/lib/features/history/data/repositories/provisional_history_repository_impl.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/domain/respositories/history_repository.dart b/lib/features/history/domain/respositories/history_repository.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/history/domain/respositories/index.dart b/lib/features/history/domain/respositories/index.dart index e69de29b..00978e0a 100644 --- a/lib/features/history/domain/respositories/index.dart +++ b/lib/features/history/domain/respositories/index.dart @@ -0,0 +1 @@ +export 'history_repository.dart'; diff --git a/lib/features/history/presentation/pages/a/access_history_page.dart b/lib/features/history/presentation/pages/a/access_history_page.dart deleted file mode 100644 index 61dafaf6..00000000 --- a/lib/features/history/presentation/pages/a/access_history_page.dart +++ /dev/null @@ -1,106 +0,0 @@ -// import 'package:flutter/material.dart'; -// import 'package:flutter_bloc/flutter_bloc.dart'; -// import 'package:hub/backend/api_requests/api_calls.dart'; -// import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_widget.dart'; -// import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; -// import 'package:hub/features/history/index.dart'; -// import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -// import 'package:hub/flutter_flow/internationalization.dart'; -// import 'package:hub/shared/helpers/storage/base_storage.dart'; -// import 'package:hub/shared/helpers/storage/storage_helper.dart'; - -// class AcessCubit extends Cubit { -// AcessCubit() : super('Provisional'); - -// Future fetchCliUUID() async { -// final cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); -// emit(cliUUID); -// } - -// Future fetchHistoryService(int pageSize, int pageNumber, Map opt) async { -// return await PhpGroup.getAccessCall.call( -// pageSize: pageSize.toString(), -// pageNumber: pageNumber.toString(), -// pesTipo: opt['personType'] != 'E' && opt['personType'] != 'O' ? 'T' : opt['personType'], -// ); -// } - -// bool filterLogic(dynamic item, Map opt) { -// final personTypeMatches = opt['personType'] == '.*' || item["PES_TIPO"].toString() == opt['personType']; -// return personTypeMatches; -// } -// } - -// class AccessHistoryPage extends StatelessWidget { -// final Map opt = { -// 'personType': '.*', -// 'accessType': '.*', -// 'search': '.*', -// }; - -// final String appBarTitle = 'Histórico Provisório'; -// final String noHistoryMessage = 'Nenhum histórico encontrado!'; -// final String errorMessage = 'Falha ao realizar operação!'; - -// @override -// Widget build(BuildContext context) { -// return BlocProvider( -// create: (context) => AcessCubit()..fetchCliUUID(), -// child: HistoryPageTemplate( -// opt: opt, -// fetchHistoryService: (pageSize, pageNumber, opt) => context.read().fetchHistoryService(pageSize, pageNumber, opt), -// cardBuilder: cardBuilder, -// appBarTitle: appBarTitle, -// noHistoryMessage: noHistoryMessage, -// errorMessage: errorMessage, -// isLeading: true, -// isFilter: true, -// filterLogic: (item, opt) => context.read().filterLogic(item, opt), -// ), -// ); -// } - -// Widget cardBuilder(BuildContext context, dynamic historyItem) { -// final cliUUID = context.watch().state; -// final String imagePath = 'https://freaccess.com.br/freaccess/getImage.php?cliID=${cliUUID}&atividade=getFoto&Documento=${historyItem['PES_ID'] ?? ''}&tipo=${historyItem['PES_TIPO'] ?? ''}'; -// final Map labelsHashMap = { -// FFLocalizations.of(context).getVariableText(ptText: 'Nome:', enText: 'Name:'): historyItem['PES_NOME'] ?? '', -// FFLocalizations.of(context).getVariableText(ptText: 'Acesso:', enText: 'Access:'): historyItem['ACE_DATAHORA'] ?? '', -// FFLocalizations.of(context).getVariableText(ptText: 'Setor', enText: 'Sector'): historyItem['SET_DESCRICAO'] ?? '', -// }; - -// final statusHashMap = [ -// _getPersonTypeStatus(context, historyItem['PES_TIPO']), -// _getAccessTypeStatus(context, historyItem['ACE_TIPO']), -// ]; - -// return CardItemTemplateComponentWidget( -// imagePath: imagePath, -// labelsHashMap: labelsHashMap, -// statusHashMap: statusHashMap, -// onTapCardItemAction: () async {}, -// ); -// } - -// Map _getPersonTypeStatus(BuildContext context, String? personType) { -// switch (personType) { -// case 'O': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Morador', enText: 'Resident'): FlutterFlowTheme.of(context).alternate2}; -// case 'E': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Visitante', enText: 'Visitor'): FlutterFlowTheme.of(context).alternate2}; -// default: -// return {FFLocalizations.of(context).getVariableText(ptText: 'Desconhecido', enText: 'Unknown'): FlutterFlowTheme.of(context).alternate2}; -// } -// } - -// Map _getAccessTypeStatus(BuildContext context, String? accessType) { -// switch (accessType) { -// case '0': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Entrada', enText: 'Entrance'): FlutterFlowTheme.of(context).success}; -// case '1': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Saída', enText: 'Exit'): FlutterFlowTheme.of(context).error}; -// default: -// return {FFLocalizations.of(context).getVariableText(ptText: 'Desconhecido', enText: 'Unknown'): FlutterFlowTheme.of(context).warning}; -// } -// } -// } \ No newline at end of file diff --git a/lib/features/history/presentation/pages/a/history_bloc_template.dart b/lib/features/history/presentation/pages/a/history_bloc_template.dart deleted file mode 100644 index 84949a6d..00000000 --- a/lib/features/history/presentation/pages/a/history_bloc_template.dart +++ /dev/null @@ -1,117 +0,0 @@ -// import 'package:flutter/material.dart'; -// import 'package:flutter_bloc/flutter_bloc.dart'; -// import 'package:hub/backend/api_requests/api_manager.dart'; -// import 'package:hub/flutter_flow/nav/nav.dart'; -// import 'package:hub/shared/utils/dialog_util.dart'; -// import 'package:hub/shared/utils/log_util.dart'; - -// class HistoryBloc extends Bloc { -// final ScrollController scrollController = ScrollController(); -// final Future Function(int pageSize, int pageNumber, Map opt) fetchHistoryService; -// final bool Function(dynamic item, Map opt)? filterLogic; - -// HistoryBloc(Map opt, this.fetchHistoryService, {this.filterLogic}) : super(HistoryState(opt: opt)) { -// scrollController.addListener(_onScroll); -// on(_onUpdateHistory); -// on(_onFetchHistory); -// add(FetchHistoryEvent()); -// } - -// void _onScroll() { -// if (scrollController.position.atEdge && scrollController.position.pixels != 0) { -// add(FetchHistoryEvent()); -// } -// } - -// Future _onUpdateHistory(UpdateHistoryEvent event, Emitter emit) async { -// emit(state.copyWith(opt: event.newOpt, historyWrap: [], pageNumber: 1)); -// add(FetchHistoryEvent()); -// } - -// Future _onFetchHistory(FetchHistoryEvent event, Emitter emit) async { -// if (state.loading) return; -// emit(state.copyWith(loading: true)); -// try { -// var response = await fetchHistoryService(state.pageSize, state.pageNumber, state.opt); - -// final List history = response.jsonBody['acessos'] ?? []; -// List filteredHistory = history.where((item) { -// if (filterLogic != null) { -// return filterLogic!(item, state.opt); -// } else { -// return true; -// } -// }).toList(); - -// if (filteredHistory.isNotEmpty) { -// emit(state.copyWith( -// historyWrap: [...state.historyWrap, ...filteredHistory], -// hasData: true, -// loading: false, -// pageNumber: state.pageNumber + 1, -// )); -// } else { -// emit(state.copyWith(hasData: false, loading: false)); -// } -// } catch (e, s) { -// await DialogUtil.errorDefault(navigatorKey.currentContext!); -// LogUtil.requestAPIFailed('processRequest', "", "Fetch History", e, s); -// emit(state.copyWith(hasData: false, loading: false, error: e.toString())); -// } -// } - -// @override -// Future close() { -// scrollController.dispose(); -// return super.close(); -// } -// } - -// class HistoryState { -// final Map opt; -// final List historyWrap; -// final bool hasData; -// final bool loading; -// final int pageNumber; -// final int pageSize; -// final String? error; - -// HistoryState({ -// required this.opt, -// this.historyWrap = const [], -// this.hasData = false, -// this.loading = false, -// this.pageNumber = 1, -// this.pageSize = 10, -// this.error, -// }); - -// HistoryState copyWith({ -// Map? opt, -// List? historyWrap, -// bool? hasData, -// bool? loading, -// int? pageNumber, -// int? pageSize, -// String? error, -// }) { -// return HistoryState( -// opt: opt ?? this.opt, -// historyWrap: historyWrap ?? this.historyWrap, -// hasData: hasData ?? this.hasData, -// loading: loading ?? this.loading, -// pageNumber: pageNumber ?? this.pageNumber, -// pageSize: pageSize ?? this.pageSize, -// error: error ?? this.error, -// ); -// } -// } - -// abstract class HistoryEvent {} - -// class UpdateHistoryEvent extends HistoryEvent { -// final Map newOpt; -// UpdateHistoryEvent(this.newOpt); -// } - -// class FetchHistoryEvent extends HistoryEvent {} diff --git a/lib/features/history/presentation/pages/a/history_page_template.dart b/lib/features/history/presentation/pages/a/history_page_template.dart deleted file mode 100644 index 09fba0f6..00000000 --- a/lib/features/history/presentation/pages/a/history_page_template.dart +++ /dev/null @@ -1,218 +0,0 @@ -// import 'dart:developer'; - -// import 'package:flutter/material.dart'; -// import 'package:flutter_bloc/flutter_bloc.dart'; -// import 'package:google_fonts/google_fonts.dart'; -// import 'package:hub/features/history/index.dart'; -// import 'package:hub/flutter_flow/internationalization.dart'; -// import 'package:hub/flutter_flow/nav/nav.dart'; -// import 'package:hub/backend/api_requests/api_manager.dart'; -// import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -// import 'package:hub/shared/utils/dialog_util.dart'; -// import 'package:hub/shared/utils/log_util.dart'; -// import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; - -// class HistoryPageTemplate extends StatelessWidget { -// final Map opt; -// final Future Function(int pageSize, int pageNumber, Map opt) fetchHistoryService; -// final Widget Function(BuildContext context, dynamic historyItem) cardBuilder; -// final String appBarTitle; -// final String noHistoryMessage; -// final String errorMessage; -// final bool isLeading; -// final bool isFilter; -// final bool Function(dynamic item, Map opt)? filterLogic; - -// const HistoryPageTemplate({ -// Key? key, -// required this.opt, -// required this.fetchHistoryService, -// required this.cardBuilder, -// this.appBarTitle = 'History', -// this.noHistoryMessage = 'No history found!', -// this.errorMessage = 'Failed to perform operation!', -// this.isLeading = true, -// this.isFilter = false, -// this.filterLogic, -// }) : super(key: key); - -// @override -// Widget build(BuildContext context) { -// return BlocProvider( -// create: (context) => HistoryBloc(opt, fetchHistoryService, filterLogic: filterLogic), -// child: HistoryPageView( -// cardBuilder: cardBuilder, -// appBarTitle: appBarTitle, -// noHistoryMessage: noHistoryMessage, -// errorMessage: errorMessage, -// isLeading: isLeading, -// isFilter: isFilter, -// ), -// ); -// } -// } - -// class HistoryPageView extends StatelessWidget { -// final Widget Function(BuildContext context, dynamic historyItem) cardBuilder; -// final String appBarTitle; -// final String noHistoryMessage; -// final String errorMessage; -// final bool isLeading; -// final bool isFilter; - -// const HistoryPageView({ -// Key? key, -// required this.cardBuilder, -// required this.appBarTitle, -// required this.noHistoryMessage, -// required this.errorMessage, -// this.isLeading = false, -// this.isFilter = false, -// }) : super(key: key); - -// @override -// Widget build(BuildContext context) { -// final theme = FlutterFlowTheme.of(context); -// return Scaffold( -// key: GlobalKey(), -// backgroundColor: theme.primaryBackground, -// appBar: _buildAppBar(context, theme), -// body: _buildBody(context), -// ); -// } - -// PreferredSizeWidget _buildAppBar(BuildContext context, FlutterFlowTheme theme) { -// return AppBar( -// backgroundColor: theme.primaryBackground, -// automaticallyImplyLeading: false, -// leading: isLeading ? _buildBackButton(context, theme) : null, -// title: _buildTitle(context, theme), -// centerTitle: true, -// elevation: 0.0, -// actions: [ -// if (isFilter) _buildFilterButton(context), -// ], -// ); -// } - -// Widget _buildBackButton(BuildContext context, FlutterFlowTheme theme) { -// return FlutterFlowIconButton( -// borderColor: Colors.transparent, -// borderRadius: 30.0, -// borderWidth: 1.0, -// buttonSize: 60.0, -// icon: Icon( -// Icons.keyboard_arrow_left, -// color: theme.primaryText, -// size: 30.0, -// ), -// onPressed: () => Navigator.of(context).pop(), -// ); -// } - -// Widget _buildTitle(BuildContext context, FlutterFlowTheme theme) { -// return Text( -// appBarTitle, -// style: theme.headlineMedium.override( -// fontFamily: theme.headlineMediumFamily, -// color: theme.primaryText, -// fontSize: 16.0, -// letterSpacing: 0.0, -// useGoogleFonts: GoogleFonts.asMap().containsKey(theme.headlineMediumFamily), -// ), -// ); -// } - -// Widget _buildFilterButton(BuildContext context) { -// return Row( -// mainAxisAlignment: MainAxisAlignment.end, -// children: [ -// Padding( -// padding: const EdgeInsets.fromLTRB(0, 0, 10, 0), -// child: IconButton( -// icon: const Icon(Icons.filter_list), -// onPressed: () async { -// final Map? selectedFilter = await showModalBottomSheet>( -// isScrollControlled: true, -// backgroundColor: Colors.transparent, -// context: context, -// builder: (BuildContext bottomSheetContext) { -// return GestureDetector( -// onTap: () => Navigator.of(bottomSheetContext).pop(), -// child: Container( -// color: Colors.transparent, -// child: GestureDetector( -// onTap: () {}, -// child: FilterModalWidget( -// defaultSelections: { -// 'personType': context.read().state.opt['personType'] == '.*' ? ['E', 'O'] : [context.read().state.opt['personType']], -// 'search': '.*', -// }, -// filterOptions: { -// 'personType': [ -// { -// 'title': FFLocalizations.of(context).getVariableText(ptText: 'Visitante', enText: 'Visitor'), -// 'value': 'E', -// }, -// { -// 'title': FFLocalizations.of(context).getVariableText(ptText: 'Morador', enText: 'Resident'), -// 'value': 'O', -// }, -// ], -// }, -// filterTitles: { -// 'personType': 'Person Type', -// }, -// ), -// ), -// ), -// ); -// }, -// ); - -// if (selectedFilter != null) { -// context.read().add(UpdateHistoryEvent(selectedFilter)); -// } -// }, -// ), -// ), -// ], -// ); -// } - -// Widget _buildBody(BuildContext context) { -// return BlocBuilder( -// builder: (context, state) { -// log('state: ${state.historyWrap}'); -// if (state.loading && state.historyWrap.isEmpty) { -// return Center( -// child: CircularProgressIndicator( -// valueColor: AlwaysStoppedAnimation( -// FlutterFlowTheme.of(context).primary, -// ), -// ), -// ); -// } else if (state.error != null) { -// return Center( -// child: Text(errorMessage), -// ); -// } else if (state.historyWrap.isEmpty) { -// return Center( -// child: Text(noHistoryMessage), -// ); -// } else { -// return ListView.builder( -// shrinkWrap: true, -// physics: const BouncingScrollPhysics(), -// controller: context.read().scrollController, -// itemCount: state.historyWrap.length, -// itemBuilder: (context, index) { -// final historyItem = state.historyWrap[index]; -// return cardBuilder(context, historyItem); -// }, -// ); -// } -// }, -// ); -// } -// } diff --git a/lib/features/history/presentation/pages/a/index.dart b/lib/features/history/presentation/pages/a/index.dart deleted file mode 100644 index 41cbf609..00000000 --- a/lib/features/history/presentation/pages/a/index.dart +++ /dev/null @@ -1,3 +0,0 @@ -export 'access_history_page.dart'; -export 'history_page_template.dart'; -export 'provisional_history_page copy.dart'; diff --git a/lib/features/history/presentation/pages/a/provisional_history_page copy.dart b/lib/features/history/presentation/pages/a/provisional_history_page copy.dart deleted file mode 100644 index 81f60ba5..00000000 --- a/lib/features/history/presentation/pages/a/provisional_history_page copy.dart +++ /dev/null @@ -1,100 +0,0 @@ -// import 'dart:developer'; - -// import 'package:flutter/material.dart'; -// import 'package:flutter_bloc/flutter_bloc.dart'; -// import 'package:hub/backend/api_requests/api_calls.dart'; -// import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_widget.dart'; -// import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; -// import 'package:hub/features/history/index.dart'; -// import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -// import 'package:hub/flutter_flow/internationalization.dart'; -// import 'package:hub/shared/helpers/storage/base_storage.dart'; -// import 'package:hub/shared/helpers/storage/storage_helper.dart'; - -// class ProvisionalCubit extends Cubit { -// ProvisionalCubit() : super('Provisional'); - -// Future fetchCliUUID() async { -// final cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); -// emit(cliUUID); -// } - -// Future fetchHistoryService(int pageSize, int pageNumber, Map status) async { -// log('fetchHistoryService: $pageSize, $pageNumber, $status'); -// return await PhpGroup.getProvSchedules(pageNumber.toString(), ''); -// } - -// bool filterLogic(dynamic item, Map opt) { -// final personTypeMatches = opt['personType'] == '.*' || item["PES_TIPO"].toString() == opt['personType']; -// return personTypeMatches; -// } -// } - -// class ProvisionalHistoryPage extends StatelessWidget { -// ProvisionalHistoryPage({super.key}); - -// final Map opt = { -// 'personType': '.*', -// 'accessType': '.*', -// 'search': '.*', -// }; - -// final String appBarTitle = 'Histórico Provisório'; -// final String noHistoryMessage = 'Nenhum histórico encontrado!'; -// final String errorMessage = 'Falha ao realizar operação!'; - -// @override -// Widget build(BuildContext context) { -// return BlocProvider( -// create: (context) => HistoryBloc( -// opt, -// (pageSize, pageNumber, opt) => context.read().fetchHistoryService(pageSize, pageNumber, opt), -// filterLogic: (item, opt) => context.read().filterLogic(item, opt), -// ), -// child: HistoryPageTemplate( -// opt: opt, -// fetchHistoryService: (pageSize, pageNumber, opt) => context.read().fetchHistoryService(pageSize, pageNumber, opt), -// cardBuilder: cardBuilder, -// appBarTitle: appBarTitle, -// noHistoryMessage: noHistoryMessage, -// errorMessage: errorMessage, -// isLeading: true, -// isFilter: false, -// filterLogic: (item, opt) => context.read().filterLogic(item, opt), -// ), -// ); -// } - -// Widget cardBuilder(BuildContext context, dynamic historyItem) { -// log('historyItem: $historyItem'); -// final cliUUID = context.watch().state; -// final String imagePath = -// 'https://freaccess.com.br/freaccess/getImage.php?cliID=${cliUUID}&atividade=getFoto&Documento=${historyItem['PES_ID'] ?? ''}&tipo=${historyItem['PES_TIPO'] ?? ''}'; -// final Map labelsHashMap = { -// FFLocalizations.of(context).getVariableText(ptText: 'Nome:', enText: 'Name:'): historyItem['AGP_NOME'] ?? '', -// FFLocalizations.of(context).getVariableText(ptText: 'Acesso:', enText: 'Access:'): historyItem['AGP_DT_VISITA'] ?? '', -// }; - -// final statusHashMap = [ -// _getTypeStatus(context, historyItem['AGP_STATUS']), -// ]; - -// return CardItemTemplateComponentWidget( -// imagePath: imagePath, -// labelsHashMap: labelsHashMap, -// statusHashMap: statusHashMap, -// onTapCardItemAction: () async {}, -// ); -// } - -// Map _getTypeStatus(BuildContext context, String? accessType) { -// switch (accessType) { -// case '0': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Entrada', enText: 'Entrance'): FlutterFlowTheme.of(context).success}; -// case '1': -// return {FFLocalizations.of(context).getVariableText(ptText: 'Saída', enText: 'Exit'): FlutterFlowTheme.of(context).error}; -// default: -// return {FFLocalizations.of(context).getVariableText(ptText: 'Desconhecido', enText: 'Unknown'): FlutterFlowTheme.of(context).warning}; -// } -// } -// } diff --git a/lib/features/history/presentation/pages/provisional_history_page.dart b/lib/features/history/presentation/pages/provisional_history_page.dart index 3f6b23d2..257ab6c8 100644 --- a/lib/features/history/presentation/pages/provisional_history_page.dart +++ b/lib/features/history/presentation/pages/provisional_history_page.dart @@ -13,6 +13,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; +import 'package:hub/shared/utils/snackbar_util.dart'; import 'package:rxdart/rxdart.dart'; @immutable @@ -213,23 +214,15 @@ class ProvisionalHistoryState extends State { final List history = response.jsonBody['agendamento']['value'] ?? []; - List filtered = history.where((item) { - bool statusMatches = status == '.*'; - if (statusMatches) return statusMatches; - statusMatches = item["AGP_STATUS"].toString() == status; - return statusMatches; - }).toList(); - // List filtered = history; - - if (filtered.isNotEmpty) { + if (history.isNotEmpty) { setState(() { - wrap.addAll(filtered); + wrap.addAll(history); hasData = true; _loading = false; }); return response; } - _showNoMoreDataSnackbar(context); + SnackBarUtil.showNoMoreDataSnackbar(context); setState(() { hasData = false; _loading = false; @@ -246,22 +239,6 @@ class ProvisionalHistoryState extends State { return null; } - void _showNoMoreDataSnackbar(BuildContext context) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), - style: TextStyle( - color: Colors.white, - fontSize: LimitedFontSizeUtil.getBodyFontSize(context), - ), - ), - duration: const Duration(seconds: 3), - backgroundColor: FlutterFlowTheme.of(context).primary, - ), - ); - } - Widget _body(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -387,7 +364,6 @@ class ProvisionalHistoryState extends State { } Map _getStatusMap(BuildContext context, String status) { - log('status: $status'); switch (status) { case 'AT': return { @@ -400,8 +376,8 @@ class ProvisionalHistoryState extends State { return { FFLocalizations.of(context).getVariableText( ptText: 'Convidado', - enText: 'Guest', - ): FlutterFlowTheme.of(context).tertiary, + enText: 'Called', + ): FlutterFlowTheme.of(context).alternate2, }; case 'IN': return { diff --git a/lib/features/history/presentation/widgets/provisional_filter_modal.dart b/lib/features/history/presentation/widgets/provisional_filter_modal.dart index 5ef83145..2c5f8472 100644 --- a/lib/features/history/presentation/widgets/provisional_filter_modal.dart +++ b/lib/features/history/presentation/widgets/provisional_filter_modal.dart @@ -73,11 +73,8 @@ class _FilterWidgetState extends State { }; widget.filterOptions.forEach((key, options) { - log('key: $key' + ' selected: ${selected[key]}'); - log('options: $options'); filterResult[key] = selected[key]!.isEmpty || selected[key]!.length < 1 ? '.*' : selected[key]!; }); - log('filterResult: $filterResult'); setState(() { // Update the state with the new filter result selected = filterResult; @@ -130,10 +127,8 @@ class _FilterWidgetState extends State { value: selected[key]!.contains(option['value']), onChanged: (bool? value) { setState(() { - log('value: $value'); if (value == true) { if (!selected[key]!.contains(option['value'])) { - log('selected[key]: ${selected[key]}'); selected[key] = option['value']; } } else { @@ -166,7 +161,7 @@ class _FilterWidgetState extends State { return Center( child: Container( width: screenWidth - (screenWidth * 0.35), - height: 250, + height: screenWidth - (screenWidth * 0.25), decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, borderRadius: BorderRadius.circular(24.0), diff --git a/lib/features/home/presentation/pages/home_page.dart b/lib/features/home/presentation/pages/home_page.dart index 48742d97..64442d3d 100644 --- a/lib/features/home/presentation/pages/home_page.dart +++ b/lib/features/home/presentation/pages/home_page.dart @@ -1,11 +1,11 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/home/presentation/widgets/drawer_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/components/molecules/drawer/index.dart'; import 'package:hub/shared/components/molecules/locals/index.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; @@ -52,7 +52,7 @@ class _HomePageWidgetState extends State with WidgetsBindingObse backgroundColor: FlutterFlowTheme.of(context).primaryBackground, drawerEnableOpenDragGesture: true, drawerDragStartBehavior: DragStartBehavior.start, - drawer: CustomDrawer(), + drawer: DrawerWidget(), appBar: buildAppBar(context), body: buildPage(context), ); diff --git a/lib/shared/components/molecules/drawer/drawer_widget.dart b/lib/features/home/presentation/widgets/drawer_widget.dart similarity index 98% rename from lib/shared/components/molecules/drawer/drawer_widget.dart rename to lib/features/home/presentation/widgets/drawer_widget.dart index 0eac540d..f221d183 100644 --- a/lib/shared/components/molecules/drawer/drawer_widget.dart +++ b/lib/features/home/presentation/widgets/drawer_widget.dart @@ -9,8 +9,8 @@ import 'package:hub/shared/components/molecules/locals/index.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; import 'package:hub/shared/components/molecules/modules/index.dart'; -class CustomDrawer extends StatelessWidget { - const CustomDrawer({super.key}); +class DrawerWidget extends StatelessWidget { + const DrawerWidget({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/shared/components/molecules/drawer/index.dart b/lib/shared/components/molecules/drawer/index.dart deleted file mode 100644 index bbb9bc10..00000000 --- a/lib/shared/components/molecules/drawer/index.dart +++ /dev/null @@ -1 +0,0 @@ -export 'drawer_widget.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart index 8c4444ee..ac0bec64 100644 --- a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart +++ b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart @@ -65,7 +65,7 @@ class MenuEntry implements BaseModule { key: 'FRE-HUB-PROVISIONAL-HISTORY', icon: Icons.person_search_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Histórico Provisório', + ptText: 'Consultar Agendas', enText: 'Provisional History', ), route: '/provisionalHistoryPage', diff --git a/lib/shared/components/templates/history/history_page_template.dart b/lib/shared/components/templates/history/history_page_template.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/templates/home/home_page_template.dart b/lib/shared/components/templates/home/home_page_template.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/templates/schedule/schedule_page_template.dart b/lib/shared/components/templates/schedule/schedule_page_template.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/utils/snackbar_util.dart b/lib/shared/utils/snackbar_util.dart index 21c43566..1b8ae0d0 100644 --- a/lib/shared/utils/snackbar_util.dart +++ b/lib/shared/utils/snackbar_util.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import '../../flutter_flow/flutter_flow_theme.dart'; @@ -22,4 +23,20 @@ class SnackBarUtil { ), ); } + + static void showNoMoreDataSnackbar(BuildContext context) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), + style: TextStyle( + color: Colors.white, + fontSize: LimitedFontSizeUtil.getBodyFontSize(context), + ), + ), + duration: const Duration(seconds: 3), + backgroundColor: FlutterFlowTheme.of(context).primary, + ), + ); + } }