WIP
This commit is contained in:
parent
262b8dd63b
commit
2a5acf1016
|
@ -344,7 +344,6 @@ Future<bool> visitRequestComponentAction(
|
|||
|
||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||
log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID; status: ${respondeSolicitacaoCall.jsonBody['error']}');
|
||||
|
||||
return !respondeSolicitacaoCall.jsonBody['error'];
|
||||
} else {
|
||||
log('headers: ${respondeSolicitacaoCall.headers}');
|
||||
|
@ -485,8 +484,10 @@ Future changeStatusAction(
|
|||
if (!context.mounted) return;
|
||||
if (blockVisitRequest == true) {
|
||||
log('Bloqueado');
|
||||
return true;
|
||||
} else {
|
||||
log('Erro ao bloquear');
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1370,17 +1370,21 @@ class PostProvVisitSchedulingCall {
|
|||
}
|
||||
|
||||
class GetVisitsCall {
|
||||
Future<ApiCallResponse> call({
|
||||
Stream<ApiCallResponse> call({
|
||||
String? devUUID = '',
|
||||
String? userUUID = '',
|
||||
String? cliID = '',
|
||||
String? atividade = '',
|
||||
int? pageSize,
|
||||
int? pageNumber,
|
||||
}) async {
|
||||
}) {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final StreamController<ApiCallResponse> controller = StreamController();
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
Future.microtask(
|
||||
() async {
|
||||
try {
|
||||
final response = await ApiManager.instance.makeApiCall(
|
||||
callName: 'getVisits',
|
||||
apiUrl: '$baseUrl/processRequest.php',
|
||||
callType: ApiCallType.POST,
|
||||
|
@ -1403,6 +1407,16 @@ class GetVisitsCall {
|
|||
isStreamingApi: false,
|
||||
alwaysAllowBody: false,
|
||||
);
|
||||
controller.add(response);
|
||||
controller.close();
|
||||
} catch (e) {
|
||||
controller.addError(e);
|
||||
controller.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return controller.stream;
|
||||
}
|
||||
|
||||
bool? error(dynamic response) => castToType<bool>(getJsonField(
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:hub/app_state.dart';
|
|||
import 'package:hub/components/templates_components/details_component/details_component_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/flutter_flow/flutter_flow_widgets.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
@ -105,13 +106,47 @@ Widget buildDetails(
|
|||
ptText: 'Sim',
|
||||
),
|
||||
onPressed: () async {
|
||||
await changeStatusAction?.call(
|
||||
await changeStatusAction
|
||||
?.call(
|
||||
context,
|
||||
'B',
|
||||
visitaWrapItem['VAW_REF'] ?? '',
|
||||
'Mensagem',
|
||||
visitaWrapItem['VTE_ID'] ?? '',
|
||||
)
|
||||
.then((value) {
|
||||
Navigator.pop(context);
|
||||
if (value == false) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error blocking visit',
|
||||
ptText: 'Erro ao bloquear visita',
|
||||
),
|
||||
true,
|
||||
);
|
||||
} else if (value == true) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Success canceling visit',
|
||||
ptText: 'Succeso ao cancelar visita',
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}).catchError((err, stack) {
|
||||
debugPrint('Error: $err');
|
||||
debugPrint('Stack: $stack');
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error blocking visit',
|
||||
ptText: 'Erro ao bloquear visita',
|
||||
),
|
||||
true,
|
||||
);
|
||||
});
|
||||
},
|
||||
options: FFButtonOptions(
|
||||
width: 100,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:from_css_color/from_css_color.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'dart:math' show pow, pi, sin;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:json_path/json_path.dart';
|
||||
|
@ -505,7 +506,8 @@ void setDarkModeSetting(BuildContext context, ThemeMode themeMode) =>
|
|||
|
||||
void showSnackbar(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String message,
|
||||
bool error, {
|
||||
bool loading = false,
|
||||
int duration = 4,
|
||||
}) {
|
||||
|
@ -515,20 +517,32 @@ void showSnackbar(
|
|||
content: Row(
|
||||
children: [
|
||||
if (loading)
|
||||
const Padding(
|
||||
padding: EdgeInsetsDirectional.only(end: 10.0),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 10.0),
|
||||
child: SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(message),
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
duration: Duration(seconds: duration),
|
||||
backgroundColor: error
|
||||
? FlutterFlowTheme.of(context).error
|
||||
: FlutterFlowTheme.of(context).success,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -282,6 +282,8 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
tarefa: 'I',
|
||||
)
|
||||
.then((value) {
|
||||
log(value.jsonBody['error'].toString());
|
||||
if (value.jsonBody['error'] == false) {
|
||||
FFAppState().deleteCliUUID();
|
||||
FFAppState().deleteLocal();
|
||||
FFAppState().deleteOwnerUUID();
|
||||
|
@ -297,9 +299,8 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
'Dispositivo desvinculado com sucesso',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
color:
|
||||
FlutterFlowTheme.of(context).info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).success,
|
||||
duration: const Duration(seconds: 3),
|
||||
|
@ -309,7 +310,10 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
),
|
||||
),
|
||||
);
|
||||
}).catchError((err, stack) {
|
||||
}
|
||||
})
|
||||
// ignore: body_might_complete_normally_catch_error
|
||||
.catchError((err, stack) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
@ -319,31 +323,8 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
ptText: 'Erro ao desvincular dispositivo',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).error,
|
||||
duration: const Duration(seconds: 3),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).catchError((err, stack) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error unlinking device',
|
||||
ptText: 'Erro ao desvincular dispositivo',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
color:
|
||||
FlutterFlowTheme.of(context).info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).error,
|
||||
duration: const Duration(seconds: 3),
|
||||
|
@ -454,6 +435,7 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
userUUID: FFAppState().userUUID,
|
||||
)
|
||||
.then((value) {
|
||||
if (value.jsonBody['error'] == false) {
|
||||
FFAppState().deleteAll();
|
||||
FFAppState().isLogged = false;
|
||||
context.goNamed(
|
||||
|
@ -466,6 +448,7 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}).catchError((err) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
|
|
@ -12,11 +12,11 @@ import 'package:intl/intl.dart';
|
|||
|
||||
class ScheduleCompleteVisitPageModel
|
||||
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
Future<ApiCallResponse> visitHistory({
|
||||
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||
Stream<ApiCallResponse> visitHistory({
|
||||
String? uniqueQueryKey,
|
||||
bool? overrideCache,
|
||||
required Future<ApiCallResponse> Function() requestFn,
|
||||
required Stream<ApiCallResponse> Function() requestFn,
|
||||
}) =>
|
||||
_visitHistoryManager.performRequest(
|
||||
uniqueQueryKey: uniqueQueryKey,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1694,39 +1696,41 @@ Widget visitHistory(
|
|||
decoration: BoxDecoration(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: FutureBuilder<ApiCallResponse>(
|
||||
future: _model.visitHistory(
|
||||
child: StreamBuilder<ApiCallResponse>(
|
||||
stream: _model.visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
pageSize: 100,
|
||||
pageNumber: 1,
|
||||
),
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
// Customize what your widget looks like when it's loading.
|
||||
if (!snapshot.hasData) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
child: SpinKitCircle(
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
size: 50.0,
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
} else if (snapshot.hasError) {
|
||||
log('Error: ${snapshot.error}');
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.jsonBody == null) {
|
||||
log('No data or jsonBody is null');
|
||||
return const Center(child: Text('No visits found'));
|
||||
}
|
||||
|
||||
final wrapGetVisitsResponse = snapshot.data!;
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
log('Response: ${wrapGetVisitsResponse.jsonBody}');
|
||||
|
||||
final visitaWrap = PhpGroup.getVisitsCall
|
||||
.visitasList(
|
||||
wrapGetVisitsResponse.jsonBody,
|
||||
)
|
||||
.visitasList(wrapGetVisitsResponse.jsonBody)
|
||||
?.toList() ??
|
||||
[];
|
||||
log('visitaWrap: $visitaWrap');
|
||||
return ListView.builder(
|
||||
itemCount: visitaWrap.length,
|
||||
shrinkWrap: true,
|
||||
|
@ -1738,8 +1742,6 @@ Widget visitHistory(
|
|||
addSemanticIndexes: true,
|
||||
itemBuilder: (context, index) {
|
||||
final visitaWrapItem = visitaWrap[index];
|
||||
// visitaWrap.length, (visitaWrapIndex) {
|
||||
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: Map<String, String>.from({
|
||||
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
|
@ -1889,9 +1891,6 @@ Widget visitHistory(
|
|||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
|
@ -8,11 +6,11 @@ import 'package:hub/flutter_flow/request_manager.dart';
|
|||
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
|
||||
|
||||
class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
Future<ApiCallResponse> visitHistory({
|
||||
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||
Stream<ApiCallResponse> visitHistory({
|
||||
String? uniqueQueryKey,
|
||||
bool? overrideCache,
|
||||
required Future<ApiCallResponse> Function() requestFn,
|
||||
required Stream<ApiCallResponse> Function() requestFn,
|
||||
}) =>
|
||||
_visitHistoryManager.performRequest(
|
||||
uniqueQueryKey: uniqueQueryKey,
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:hub/flutter_flow/nav/nav.dart';
|
|||
import 'package:hub/pages/visit_history_page/visit_history_page_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
||||
class VisitHistoryPageWidget extends StatefulWidget {
|
||||
const VisitHistoryPageWidget({
|
||||
super.key,
|
||||
|
@ -233,8 +232,8 @@ Widget visitHistory(
|
|||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder<ApiCallResponse>(
|
||||
future: _model.visitHistory(
|
||||
StreamBuilder<ApiCallResponse>(
|
||||
stream: _model.visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
|
@ -586,8 +585,7 @@ Widget visitHistory(
|
|||
return FlutterFlowTheme
|
||||
.of(context)
|
||||
.success;
|
||||
} else if ((
|
||||
jsonToStr(
|
||||
} else if ((jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
|
@ -614,8 +612,7 @@ Widget visitHistory(
|
|||
return FlutterFlowTheme
|
||||
.of(context)
|
||||
.error;
|
||||
} else if (
|
||||
jsonToStr(
|
||||
} else if (jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
|
@ -655,8 +652,7 @@ Widget visitHistory(
|
|||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
);
|
||||
} else if ((
|
||||
jsonToStr(
|
||||
} else if ((jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
|
|
Loading…
Reference in New Issue