Merge pull request #28 from FRE-Informatica/front/fd-467
FET: Encomendas / Reservas
This commit is contained in:
commit
7fc7f50aa5
|
@ -14,7 +14,8 @@
|
||||||
android:label="FREHub"
|
android:label="FREHub"
|
||||||
tools:replace="android:label"
|
tools:replace="android:label"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:requestLegacyExternalStorage="true">
|
android:requestLegacyExternalStorage="true"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="io.flutter.embedding.android.FlutterFragmentActivity"
|
android:name="io.flutter.embedding.android.FlutterFragmentActivity"
|
||||||
|
|
|
@ -16,7 +16,6 @@ const _kPrivateApiFunctionName = 'ffPrivateApiCall';
|
||||||
|
|
||||||
class PhpGroup {
|
class PhpGroup {
|
||||||
static String getBaseUrl() => 'https://freaccess.com.br/freaccess';
|
static String getBaseUrl() => 'https://freaccess.com.br/freaccess';
|
||||||
// static String getBaseUrl() => 'http://192.168.2.250:8080';
|
|
||||||
static Map<String, String> headers = {};
|
static Map<String, String> headers = {};
|
||||||
static LoginCall loginCall = LoginCall();
|
static LoginCall loginCall = LoginCall();
|
||||||
static UpdToken updToken = UpdToken();
|
static UpdToken updToken = UpdToken();
|
||||||
|
@ -49,6 +48,55 @@ class PhpGroup {
|
||||||
static ChangePanic changePanic = ChangePanic();
|
static ChangePanic changePanic = ChangePanic();
|
||||||
static DeleteAccount deleteAccount = DeleteAccount();
|
static DeleteAccount deleteAccount = DeleteAccount();
|
||||||
static CancelaVisita cancelaVisita = CancelaVisita();
|
static CancelaVisita cancelaVisita = CancelaVisita();
|
||||||
|
static BuscaEnconcomendas buscaEnconcomendas = BuscaEnconcomendas();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BuscaEnconcomendas {
|
||||||
|
Future<ApiCallResponse> call({
|
||||||
|
String? devUUID = '',
|
||||||
|
String? userUUID = '',
|
||||||
|
String? cliID = '',
|
||||||
|
String? atividade = '',
|
||||||
|
|
||||||
|
String? page = '',
|
||||||
|
String? pageSize = '',
|
||||||
|
String? adresseeType = '',
|
||||||
|
String? status = '',
|
||||||
|
}) async {
|
||||||
|
final baseUrl = PhpGroup.getBaseUrl();
|
||||||
|
|
||||||
|
return ApiManager.instance.makeApiCall(
|
||||||
|
callName: 'getEncomendas',
|
||||||
|
apiUrl: '$baseUrl/processRequest.php',
|
||||||
|
callType: ApiCallType.POST,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
'devUUID': devUUID,
|
||||||
|
'userUUID': userUUID,
|
||||||
|
'atividade': atividade,
|
||||||
|
'cliID': cliID,
|
||||||
|
|
||||||
|
'page': page,
|
||||||
|
'pageSize': pageSize,
|
||||||
|
'adresseeType': adresseeType,
|
||||||
|
'status': status,
|
||||||
|
},
|
||||||
|
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||||
|
returnBody: true,
|
||||||
|
encodeBodyUtf8: false,
|
||||||
|
decodeUtf8: false,
|
||||||
|
cache: false,
|
||||||
|
alwaysAllowBody: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool? error(dynamic response) => castToType<bool>(getJsonField(
|
||||||
|
response,
|
||||||
|
r'''$.error''',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
class CancelaVisita {
|
class CancelaVisita {
|
||||||
|
|
|
@ -85,8 +85,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
||||||
Navigator.pop(context, filterResult);
|
Navigator.pop(context, filterResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCheckboxListTile(
|
Widget _buildCheckboxListTile(String key, List<Map<String, String>> options, double fontsize) {
|
||||||
String key, List<Map<String, String>> options, double fontsize) {
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
|
@ -152,8 +151,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
||||||
width: 5,
|
width: 5,
|
||||||
color: FlutterFlowTheme.of(context).secondaryText,
|
color: FlutterFlowTheme.of(context).secondaryText,
|
||||||
),
|
),
|
||||||
controlAffinity:
|
controlAffinity: ListTileControlAffinity.leading, // Adiciona esta linha
|
||||||
ListTileControlAffinity.leading, // Adiciona esta linha
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -182,8 +180,8 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: screenWidth * 0.75,
|
width: screenWidth - (screenWidth * 0.35),
|
||||||
height: screenHeight * 0.35,
|
height: 250,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
borderRadius: BorderRadius.circular(24.0),
|
borderRadius: BorderRadius.circular(24.0),
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
import '/flutter_flow/form_field_controller.dart';
|
||||||
|
import 'order_filter_modal_widget.dart' show OrderFilterModalWidget;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class OrderFilterModalModel extends FlutterFlowModel<OrderFilterModalWidget> {
|
||||||
|
|
||||||
|
// State field(s) for TextField widget.
|
||||||
|
FocusNode? textFieldFocusNode;
|
||||||
|
TextEditingController? textController;
|
||||||
|
String? Function(BuildContext, String?)? textControllerValidator;
|
||||||
|
// State field(s) for Checkbox widget.
|
||||||
|
bool? checkboxValue1;
|
||||||
|
// State field(s) for Checkbox widget.
|
||||||
|
bool? checkboxValue2;
|
||||||
|
// State field(s) for CheckboxGroup widget.
|
||||||
|
FormFieldController<List<String>>? checkboxGroupValueController;
|
||||||
|
List<String>? get checkboxGroupValues => checkboxGroupValueController?.value;
|
||||||
|
set checkboxGroupValues(List<String>? v) =>
|
||||||
|
checkboxGroupValueController?.value = v;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState(BuildContext context) {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
textFieldFocusNode?.dispose();
|
||||||
|
textController?.dispose();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hub/components/molecular_components/order_filter_modal/order_filter_modal_model.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||||
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
|
|
||||||
|
class OrderFilterModalWidget extends StatefulWidget {
|
||||||
|
final String defaultAdresseeType;
|
||||||
|
final String defaultStatus;
|
||||||
|
|
||||||
|
const OrderFilterModalWidget({
|
||||||
|
Key? key,
|
||||||
|
this.defaultAdresseeType = '.*',
|
||||||
|
this.defaultStatus = '.*',
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_OrderFilterModalWidgetState createState() => _OrderFilterModalWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
|
||||||
|
late OrderFilterModalModel _model;
|
||||||
|
|
||||||
|
late Map<String, dynamic> selected;
|
||||||
|
final List<Map<String, String>> adresseeTypeOptions = [
|
||||||
|
{'title': 'Morador', 'value': 'MOR'},
|
||||||
|
{'title': 'Propriedade', 'value': 'PRO'},
|
||||||
|
];
|
||||||
|
final List<Map<String, String>> statusOptions = [
|
||||||
|
{'title': 'Aguardando Retirada', 'value': 'notPickedUp'},
|
||||||
|
{'title': 'Retirado', 'value': 'pickedUp'},
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void setState(VoidCallback callback) {
|
||||||
|
super.setState(callback);
|
||||||
|
_model.onUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
_model = createModel(context, () => OrderFilterModalModel());
|
||||||
|
|
||||||
|
selected = {
|
||||||
|
'adresseeType': widget.defaultAdresseeType == '.*' ? ['MOR', 'PRO'] : [widget.defaultAdresseeType],
|
||||||
|
'status': widget.defaultStatus == '.*' ? ['notPickedUp', 'pickedUp'] : [widget.defaultStatus],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void _applyFilter() {
|
||||||
|
Map<String, String> filterResult = {
|
||||||
|
'adresseeType': '',
|
||||||
|
'status': '',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (selected['adresseeType']!.isEmpty) {
|
||||||
|
filterResult['adresseeType'] = '.*';
|
||||||
|
} else if (selected['adresseeType']!.length > 1) {
|
||||||
|
filterResult['adresseeType'] = '.*';
|
||||||
|
} else {
|
||||||
|
filterResult['adresseeType'] = selected['adresseeType']!.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected['status']!.isEmpty) {
|
||||||
|
filterResult['status'] = '.*';
|
||||||
|
} else if (selected['status']!.length > 1) {
|
||||||
|
filterResult['status'] = '.*';
|
||||||
|
} else {
|
||||||
|
filterResult['status'] = selected['status']!.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
Navigator.pop(context, filterResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCheckboxListTile(String key, List<Map<String, String>> options, double fontsize) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 3.0, 0.0, 0.0),
|
||||||
|
child: Text(
|
||||||
|
key == 'status' ? 'Status' : 'Destinátario',
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
fontSize: fontsize,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ListView.builder(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: options.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final option = options[index];
|
||||||
|
return CheckboxListTile(
|
||||||
|
title: Text(
|
||||||
|
option['title']!,
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontSize: fontsize,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dense: true,
|
||||||
|
value: selected[key]!.contains(option['value']),
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
setState(() {
|
||||||
|
if (value == true) {
|
||||||
|
if (!selected[key]!.contains(option['value'])) {
|
||||||
|
selected[key]!.add(option['value']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selected[key]!.remove(option['value']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
activeColor: FlutterFlowTheme.of(context).primary,
|
||||||
|
checkColor: FlutterFlowTheme.of(context).info,
|
||||||
|
checkboxShape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
),
|
||||||
|
|
||||||
|
enableFeedback: true,
|
||||||
|
side: BorderSide(
|
||||||
|
width: 5,
|
||||||
|
color: FlutterFlowTheme.of(context).secondaryText,
|
||||||
|
),
|
||||||
|
controlAffinity: ListTileControlAffinity.leading, // Adiciona esta linha
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
double screenHeight = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
width: screenWidth - (screenWidth * 0.35),
|
||||||
|
height: 420,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
borderRadius: BorderRadius.circular(24.0),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
10.0, 10.0, 0.0, 10.0),
|
||||||
|
child: Text(
|
||||||
|
FFLocalizations.of(context)
|
||||||
|
.getText('yfj9pd6k'), // Filtros
|
||||||
|
style:
|
||||||
|
FlutterFlowTheme.of(context).headlineMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.headlineMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
fontSize: 18.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.headlineMediumFamily),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
_buildCheckboxListTile('adresseeType', adresseeTypeOptions, 14),
|
||||||
|
_buildCheckboxListTile('status', statusOptions, 14),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _applyFilter,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
foregroundColor: FlutterFlowTheme.of(context).info,
|
||||||
|
backgroundColor: FlutterFlowTheme.of(context).primary,
|
||||||
|
),
|
||||||
|
child: Text(FFLocalizations.of(context).getText('88kshkph')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import 'dart:developer';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart';
|
import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
|
import 'package:hub/pages/reservation_page/reservation_page_widget.dart';
|
||||||
|
|
||||||
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
||||||
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
|
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
|
||||||
|
@ -150,6 +151,23 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
||||||
).then((value) => true);
|
).then((value) => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future packageOrder(BuildContext context) async {
|
||||||
|
context.pushNamed(
|
||||||
|
'packageOrder',
|
||||||
|
extra: <String, dynamic>{
|
||||||
|
kTransitionInfoKey: const TransitionInfo(
|
||||||
|
hasTransition: true,
|
||||||
|
transitionType: PageTransitionType.scale,
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
).then((value) => true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future reservation(BuildContext context) async {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => ReservationPageWidget()));
|
||||||
|
}
|
||||||
|
|
||||||
Future liberationHistoryOptAction(BuildContext context) async {
|
Future liberationHistoryOptAction(BuildContext context) async {
|
||||||
await showAdaptiveDialog(
|
await showAdaptiveDialog(
|
||||||
// isScrollControlled: true,
|
// isScrollControlled: true,
|
||||||
|
|
|
@ -111,6 +111,28 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
||||||
ptText: 'Consultar\nHistóricos',
|
ptText: 'Consultar\nHistóricos',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MenuButtonWidget(
|
||||||
|
icon: Icons.inventory_2_rounded,
|
||||||
|
action: () async {
|
||||||
|
await _model.packageOrder(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Orders',
|
||||||
|
ptText: 'Encomendas',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MenuButtonWidget(
|
||||||
|
icon: Icons.event_available,
|
||||||
|
action: () async {
|
||||||
|
await _model.reservation(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Reservations',
|
||||||
|
ptText: 'Reservas',
|
||||||
|
),
|
||||||
|
),
|
||||||
MenuButtonWidget(
|
MenuButtonWidget(
|
||||||
icon: Icons.settings,
|
icon: Icons.settings,
|
||||||
action: () async {
|
action: () async {
|
||||||
|
@ -122,6 +144,7 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
||||||
ptText: 'Preferências \nde Configurações',
|
ptText: 'Preferências \nde Configurações',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (widget.item == MenuItem.card) {
|
if (widget.item == MenuItem.card) {
|
||||||
|
@ -181,6 +204,28 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
||||||
ptText: 'Consultar\nHistoricos',
|
ptText: 'Consultar\nHistoricos',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MenuCardItem(
|
||||||
|
icon: Icons.inventory_2_rounded,
|
||||||
|
action: () async {
|
||||||
|
await _model.packageOrder(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Orders',
|
||||||
|
ptText: 'Encomendas',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MenuCardItem(
|
||||||
|
icon: Icons.event_available,
|
||||||
|
action: () async {
|
||||||
|
await _model.reservation(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Reservations',
|
||||||
|
ptText: 'Reservas',
|
||||||
|
),
|
||||||
|
),
|
||||||
MenuCardItem(
|
MenuCardItem(
|
||||||
icon: Icons.settings,
|
icon: Icons.settings,
|
||||||
action: () async {
|
action: () async {
|
||||||
|
@ -262,6 +307,28 @@ class _MenuComponentWidgetState extends State<MenuComponentWidget> {
|
||||||
ptText: 'Sair da Conta',
|
ptText: 'Sair da Conta',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MenuCardItem(
|
||||||
|
icon: Icons.inventory_2_rounded,
|
||||||
|
action: () async {
|
||||||
|
await _model.packageOrder(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Orders',
|
||||||
|
ptText: 'Encomendas',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MenuCardItem(
|
||||||
|
icon: Icons.event_available,
|
||||||
|
action: () async {
|
||||||
|
await _model.reservation(context);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Reservations',
|
||||||
|
ptText: 'Reservas',
|
||||||
|
),
|
||||||
|
),
|
||||||
MenuCardItem(
|
MenuCardItem(
|
||||||
icon: Icons.settings,
|
icon: Icons.settings,
|
||||||
action: () async {
|
action: () async {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:collection';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import '/flutter_flow/flutter_flow_theme.dart';
|
import '/flutter_flow/flutter_flow_theme.dart';
|
||||||
import '/flutter_flow/flutter_flow_util.dart';
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
@ -29,20 +30,13 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
|
||||||
final Future Function()? onTapCardItemAction;
|
final Future Function()? onTapCardItemAction;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CardItemTemplateComponentWidget> createState() =>
|
State<CardItemTemplateComponentWidget> createState() => _CardItemTemplateComponentWidgetState();
|
||||||
_CardItemTemplateComponentWidgetState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CardItemTemplateComponentWidgetState
|
class _CardItemTemplateComponentWidgetState extends State<CardItemTemplateComponentWidget> {
|
||||||
extends State<CardItemTemplateComponentWidget> {
|
|
||||||
late CardItemTemplateComponentModel _model;
|
late CardItemTemplateComponentModel _model;
|
||||||
LinkedHashMap<String, String> get labelsLinkedHashMap =>
|
LinkedHashMap<String, String> get labelsLinkedHashMap => LinkedHashMap.from(widget.labelsHashMap ?? {});
|
||||||
LinkedHashMap.from(widget.labelsHashMap ?? {});
|
List<LinkedHashMap<String, Color>> get statusLinkedHashMap => widget.statusHashMap.map((map) => LinkedHashMap<String, Color>.from(map ?? {})).toList();
|
||||||
|
|
||||||
List<LinkedHashMap<String, Color>> get statusLinkedHashMap =>
|
|
||||||
widget.statusHashMap
|
|
||||||
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void setState(VoidCallback callback) {
|
void setState(VoidCallback callback) {
|
||||||
|
@ -58,42 +52,167 @@ class _CardItemTemplateComponentWidgetState
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_model.maybeDispose();
|
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
_model.maybeDispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getColorForStatus(String status) {
|
String truncate(int cutoff, String text) {
|
||||||
if (status.length % 3 == 0) {
|
return (text.length <= cutoff) ? text : '${text.substring(0, cutoff)}...';
|
||||||
return FlutterFlowTheme.of(context).success;
|
|
||||||
} else if (status.length % 3 == 1) {
|
|
||||||
return FlutterFlowTheme.of(context).error;
|
|
||||||
} else {
|
|
||||||
return FlutterFlowTheme.of(context).primary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String truncate(int cutoff, String mytext) {
|
List<Widget> _generateLabels() {
|
||||||
return (mytext.length <= cutoff)
|
List<Widget> labels = [];
|
||||||
? mytext
|
|
||||||
: '${mytext.substring(0, cutoff)}...';
|
for (var key in labelsLinkedHashMap.keys) {
|
||||||
|
String text = labelsLinkedHashMap[key].toString();
|
||||||
|
|
||||||
|
Widget widget = Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
key,
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 2.5),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||||
|
fontSize: 12.5,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
labels.add(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _generateImage() {
|
||||||
|
return Container(
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
fadeInDuration: const Duration(milliseconds: 500),
|
||||||
|
fadeOutDuration: const Duration(milliseconds: 500),
|
||||||
|
imageUrl: widget.imagePath ?? '',
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _generateStatus() {
|
||||||
|
List<Widget> status = [];
|
||||||
|
|
||||||
|
statusLinkedHashMap.expand((statusLinked) {
|
||||||
|
statusLinked.forEach((text, color) {
|
||||||
|
Widget widget = Container(
|
||||||
|
padding: const EdgeInsets.all(5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color,
|
||||||
|
borderRadius: BorderRadius.circular(5)
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: FlutterFlowTheme.of(context).info,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
status.add(widget);
|
||||||
|
});
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _smallScreen() {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
_generateImage(),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
..._generateLabels(),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: _generateStatus(),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _largeScreen() {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
..._generateLabels(),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: _generateStatus(),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
_generateImage()
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double screenWidth = MediaQuery.of(context).size.width;
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
double screenHeight = MediaQuery.of(context).size.height;
|
double screenHeight = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
context.watch<AppState>();
|
context.watch<AppState>();
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
splashColor: Colors.transparent,
|
splashColor: Colors.transparent,
|
||||||
focusColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
highlightColor: Colors.transparent,
|
||||||
onTap: () async {
|
onTap: () async => await widget.onTapCardItemAction?.call(),
|
||||||
await widget.onTapCardItemAction?.call();
|
|
||||||
},
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Card(
|
child: Card(
|
||||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
@ -102,158 +221,16 @@ class _CardItemTemplateComponentWidgetState
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 350,
|
width: double.infinity,
|
||||||
height: 125,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
),
|
),
|
||||||
child: Row(
|
padding: const EdgeInsets.all(8),
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
decoration: const BoxDecoration(),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
screenWidth > 360 ? _largeScreen() : _smallScreen(),
|
||||||
child: ListView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: labelsLinkedHashMap.length,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
String key =
|
|
||||||
labelsLinkedHashMap.keys.elementAt(index);
|
|
||||||
String value = labelsLinkedHashMap[key]!;
|
|
||||||
return Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.fromLTRB(20, 0, 0, 5),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
key,
|
|
||||||
style: FlutterFlowTheme.of(context)
|
|
||||||
.bodyMedium
|
|
||||||
.override(
|
|
||||||
fontFamily:
|
|
||||||
FlutterFlowTheme.of(context)
|
|
||||||
.bodyMediumFamily,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
useGoogleFonts: GoogleFonts
|
|
||||||
.asMap()
|
|
||||||
.containsKey(
|
|
||||||
FlutterFlowTheme.of(
|
|
||||||
context)
|
|
||||||
.bodyMediumFamily),
|
|
||||||
color:
|
|
||||||
FlutterFlowTheme.of(context)
|
|
||||||
.primaryText,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 3.0), // Espaçamento entre o label e o valor
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
value,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: FlutterFlowTheme.of(context)
|
|
||||||
.bodyMedium
|
|
||||||
.override(
|
|
||||||
fontFamily:
|
|
||||||
FlutterFlowTheme.of(
|
|
||||||
context)
|
|
||||||
.bodyMediumFamily,
|
|
||||||
fontSize: 12.5,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
useGoogleFonts: GoogleFonts
|
|
||||||
.asMap()
|
|
||||||
.containsKey(
|
|
||||||
FlutterFlowTheme.of(
|
|
||||||
context)
|
|
||||||
.bodyMediumFamily),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children:
|
|
||||||
statusLinkedHashMap.expand((linkedHashMap) {
|
|
||||||
return linkedHashMap.entries
|
|
||||||
.map((MapEntry<String, Color> item) {
|
|
||||||
return Container(
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 1.0, vertical: 3.0),
|
|
||||||
child: Container(
|
|
||||||
width: 100.0,
|
|
||||||
height: 27.0,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: item
|
|
||||||
.value, // Usa a cor do item atual
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(5.0),
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
|
||||||
item.key, // Usa a chave do item atual como texto
|
|
||||||
style: TextStyle(
|
|
||||||
color: FlutterFlowTheme.of(
|
|
||||||
context)
|
|
||||||
.info, // Ajuste conforme necessário
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
10.0, 10.0, 10.0, 10.0),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(22.0),
|
|
||||||
child: AspectRatio(
|
|
||||||
aspectRatio:
|
|
||||||
1.0, // Define a proporção desejada (1:1 neste caso)
|
|
||||||
child: CachedNetworkImage(
|
|
||||||
fadeInDuration: const Duration(milliseconds: 500),
|
|
||||||
fadeOutDuration: const Duration(milliseconds: 500),
|
|
||||||
imageUrl: widget.imagePath ?? '',
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -4,6 +4,9 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
import 'package:hub/pages/fast_pass_page/fast_pass_page_widget.dart';
|
||||||
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
|
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
|
||||||
|
import 'package:hub/pages/no_connection_page/no_connection_page.dart';
|
||||||
|
import 'package:hub/pages/package_order_page/package_order_page.dart';
|
||||||
|
import 'package:hub/pages/reservation_page/reservation_page_widget.dart';
|
||||||
import 'package:hub/pages/preferences_settings_page/preferences_settings_widget.dart';
|
import 'package:hub/pages/preferences_settings_page/preferences_settings_widget.dart';
|
||||||
import 'package:hub/pages/reception_page/reception_page_widget.dart';
|
import 'package:hub/pages/reception_page/reception_page_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -168,6 +171,16 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
|
||||||
path: '/preferencesPage',
|
path: '/preferencesPage',
|
||||||
builder: (context, params) => const PreferencesPageWidget(),
|
builder: (context, params) => const PreferencesPageWidget(),
|
||||||
),
|
),
|
||||||
|
FFRoute(
|
||||||
|
name: 'packageOrder',
|
||||||
|
path: '/packageOrder',
|
||||||
|
builder: (context, params) => const PackageOrderPage(),
|
||||||
|
),
|
||||||
|
FFRoute(
|
||||||
|
name: 'reservation',
|
||||||
|
path: '/reservation',
|
||||||
|
builder: (context, params) => ReservationPageWidget(),
|
||||||
|
),
|
||||||
// FFRoute(
|
// FFRoute(
|
||||||
// name: 'settingsPage',
|
// name: 'settingsPage',
|
||||||
// path: '/settingsPage',
|
// path: '/settingsPage',
|
||||||
|
|
|
@ -30,23 +30,7 @@ class AcessHistoryPageWidget extends StatefulWidget {
|
||||||
};
|
};
|
||||||
AcessHistoryPageWidget({super.key, required this.opt});
|
AcessHistoryPageWidget({super.key, required this.opt});
|
||||||
@override
|
@override
|
||||||
State<AcessHistoryPageWidget> createState() =>
|
State<AcessHistoryPageWidget> createState() => _AcessHistoryPageWidgetState(opt);
|
||||||
_AcessHistoryPageWidgetState(opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccessHistoryItemWidget extends StatelessWidget {
|
|
||||||
final dynamic accessHistoryItem;
|
|
||||||
|
|
||||||
const AccessHistoryItemWidget({Key? key, required this.accessHistoryItem})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Column(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
|
@ -66,8 +50,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
late Future<void> _accessFuture;
|
late Future<void> _accessFuture;
|
||||||
List<dynamic> _accessWrap = [];
|
List<dynamic> _accessWrap = [];
|
||||||
|
|
||||||
_AcessHistoryPageWidgetState(Map<String, String> opt)
|
_AcessHistoryPageWidgetState(Map<String, String> opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
||||||
: selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
|
||||||
selectedTypeSubject.listen((value) {});
|
selectedTypeSubject.listen((value) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:hub/app_state.dart';
|
import 'package:hub/app_state.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
@ -57,12 +54,9 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
_controllerIOS = controller;
|
_controllerIOS = controller;
|
||||||
},
|
},
|
||||||
onLoadStop: (controller, url) async {
|
onLoadStop: (controller, url) async {
|
||||||
await controller.evaluateJavascript(
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
|
||||||
source:
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
|
||||||
"window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('enableBackButton', 'true')");
|
||||||
await controller.evaluateJavascript(
|
|
||||||
source:
|
|
||||||
"window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: WebViewWidget(
|
: WebViewWidget(
|
||||||
|
@ -75,13 +69,13 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||||
NavigationDelegate(
|
NavigationDelegate(
|
||||||
onProgress: (int progress) {},
|
onProgress: (int progress) {},
|
||||||
onPageStarted: (String url) {
|
onPageStarted: (String url) {
|
||||||
final String token =
|
final String token = "localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
||||||
"localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
final String data = "localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
||||||
final String data =
|
const String backNavigation = "localStorage.setItem('enableBackButton', 'true');";
|
||||||
"localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
|
||||||
|
|
||||||
_controllerAll.runJavaScript(token);
|
_controllerAll.runJavaScript(token);
|
||||||
_controllerAll.runJavaScript(data);
|
_controllerAll.runJavaScript(data);
|
||||||
|
_controllerAll.runJavaScript(backNavigation);
|
||||||
},
|
},
|
||||||
onNavigationRequest: (NavigationRequest request) {
|
onNavigationRequest: (NavigationRequest request) {
|
||||||
if (request.url.startsWith('http') ||
|
if (request.url.startsWith('http') ||
|
||||||
|
|
|
@ -0,0 +1,410 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
|
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||||
|
import 'package:hub/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart';
|
||||||
|
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.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/shared/utils/dialog_util.dart';
|
||||||
|
import 'package:hub/shared/utils/log_util.dart';
|
||||||
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
|
||||||
|
class PackageOrderPage extends StatefulWidget {
|
||||||
|
const PackageOrderPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PackageOrderPage> createState() => _PackageOrderPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PackageOrderPage extends State<PackageOrderPage> {
|
||||||
|
|
||||||
|
late ScrollController _scrollController;
|
||||||
|
int _pageNumber = 1;
|
||||||
|
final int _pageSize = 10;
|
||||||
|
bool _hasData = false;
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
late Future<void> _orderFuture;
|
||||||
|
List<dynamic> _orderList = [];
|
||||||
|
|
||||||
|
final Map<String, String> filter = {
|
||||||
|
'adresseeType': '.*',
|
||||||
|
'status': 'notPickedUp',
|
||||||
|
};
|
||||||
|
|
||||||
|
String _adresseeType = '.*';
|
||||||
|
String _status = 'notPickedUp';
|
||||||
|
|
||||||
|
late BehaviorSubject<Map<String, String>> _selectedTypeSubject;
|
||||||
|
bool _isSubjectClosed = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_selectedTypeSubject = BehaviorSubject.seeded(filter);
|
||||||
|
_selectedTypeSubject.listen((value) {});
|
||||||
|
|
||||||
|
_orderFuture = _fetchOrders();
|
||||||
|
|
||||||
|
_scrollController = ScrollController()..addListener(() {
|
||||||
|
if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) {
|
||||||
|
_loadMoreOrders();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_selectedTypeSubject.close();
|
||||||
|
_isSubjectClosed = true;
|
||||||
|
_scrollController.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
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."),
|
||||||
|
),
|
||||||
|
duration: const Duration(seconds: 3),
|
||||||
|
backgroundColor: FlutterFlowTheme.of(context).primary,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ApiCallResponse?> _fetchOrders() async {
|
||||||
|
try {
|
||||||
|
setState(() => _loading = true);
|
||||||
|
|
||||||
|
var response = await PhpGroup.buscaEnconcomendas.call(
|
||||||
|
devUUID: AppState().devUUID,
|
||||||
|
userUUID: AppState().userUUID,
|
||||||
|
cliID: AppState().cliUUID,
|
||||||
|
atividade: 'getEncomendas',
|
||||||
|
pageSize: _pageSize.toString(),
|
||||||
|
page: _pageNumber.toString(),
|
||||||
|
adresseeType: _adresseeType == '.*' ? 'TOD' : _adresseeType,
|
||||||
|
status: _status == '.*' ? 'all' : _status
|
||||||
|
);
|
||||||
|
|
||||||
|
final List<dynamic> orders = response.jsonBody['value']['list'] ?? [];
|
||||||
|
|
||||||
|
if (orders != null && orders.isNotEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_orderList.addAll(orders);
|
||||||
|
_hasData = true;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
_showNoMoreDataSnackbar(context);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_hasData = false;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (e, s) {
|
||||||
|
DialogUtil.errorDefault(context);
|
||||||
|
LogUtil.requestAPIFailed('processRequest', "", "Busca Encomendas", e, s);
|
||||||
|
setState(() {
|
||||||
|
_hasData = false;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadMoreOrders() {
|
||||||
|
if (_hasData == true) {
|
||||||
|
_pageNumber++;
|
||||||
|
_orderFuture = _fetchOrders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _backButton(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 _filterButton(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<String, String>? selectedFilter =
|
||||||
|
await showModalBottomSheet<Map<String, String>>(
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => Navigator.of(context).pop(),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: OrderFilterModalWidget(
|
||||||
|
defaultAdresseeType: _selectedTypeSubject.value['adresseeType'] ?? '.*',
|
||||||
|
defaultStatus: _selectedTypeSubject.value['status'] ?? '.*',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (selectedFilter != null) {
|
||||||
|
_updateFilterAction(selectedFilter);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateFilterAction(Map<String, String> newType) {
|
||||||
|
if (!_isSubjectClosed) {
|
||||||
|
final currentType = _selectedTypeSubject.value;
|
||||||
|
final updatedType = Map<String, String>.from(currentType);
|
||||||
|
bool needsUpdate = false;
|
||||||
|
newType.forEach((key, newValue) {
|
||||||
|
if (currentType[key] != newValue) {
|
||||||
|
updatedType[key] = newValue;
|
||||||
|
needsUpdate = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (needsUpdate) {
|
||||||
|
_selectedTypeSubject.add(updatedType);
|
||||||
|
_fetchFilterOrder(updatedType);
|
||||||
|
safeSetState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _fetchFilterOrder(Map<String, String> select) {
|
||||||
|
_adresseeType = select['adresseeType']!;
|
||||||
|
_status = select['status']!;
|
||||||
|
_orderList = [];
|
||||||
|
_pageNumber = 1;
|
||||||
|
_orderFuture = _fetchOrders();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferredSizeWidget _appBar(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
double screenHeight = MediaQuery.of(context).size.height;
|
||||||
|
|
||||||
|
return AppBar(
|
||||||
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
title: Text(
|
||||||
|
FFLocalizations.of(context).getVariableText(enText: 'Orders', ptText: 'Encomendas'),
|
||||||
|
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||||
|
fontFamily: 'Nunito',
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
fontSize: 15.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
leading: _backButton(context, FlutterFlowTheme.of(context)),
|
||||||
|
centerTitle: true,
|
||||||
|
elevation: 0.0,
|
||||||
|
actions: [_filterButton(context)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _appBody(BuildContext context) {
|
||||||
|
return SafeArea(
|
||||||
|
top: true,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (_hasData == false && _pageNumber <= 1 && _loading == false)
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: "Nenhuma encomenda encontrada!",
|
||||||
|
enText: "No orders found!"),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else if (_hasData || _pageNumber >= 1)
|
||||||
|
Expanded(child: _itemList()),
|
||||||
|
if (_hasData == true && _loading == true)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
FlutterFlowTheme.of(context).primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _itemList() {
|
||||||
|
return FutureBuilder<void>(
|
||||||
|
future: _orderFuture,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
controller: _scrollController,
|
||||||
|
itemCount: _orderList.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final order = _orderList[index];
|
||||||
|
return _item(context, order);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _imagePath(dynamic order) {
|
||||||
|
return '${PhpGroup.getBaseUrl()}/getImage.php?cliID=${AppState().cliUUID}&atividade=getFotoEncomenda&orderId=${order['id'] ?? ''}';
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> _labelsHashMap(dynamic order) {
|
||||||
|
return Map<String, String>.from({
|
||||||
|
if (order['isPending'] == true)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': order['id'].toString(),
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Categoria', enText: 'Category')}:': order['customCategory'],
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Recebido em', enText: 'Received on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtReceive']),
|
||||||
|
if (order['isPending'] == false)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> _labelsHashMapDialog(dynamic order) {
|
||||||
|
return Map<String, String>.from({
|
||||||
|
if (order['isPending'] == true)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': order['id'].toString(),
|
||||||
|
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Categoria', enText: 'Category')}:': order['customCategory'],
|
||||||
|
|
||||||
|
if (order['code'] != null)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Objeto', enText: 'Object Code')}:': order['code'],
|
||||||
|
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Entregue por', enText: 'Delivered by')}:': order['sendedBy'],
|
||||||
|
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Recebido por', enText: 'Received by')}:': order['receivedBy'],
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Recebido em', enText: 'Received on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtReceive']),
|
||||||
|
|
||||||
|
if (order['isPending'] == false)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Retirado por', enText: 'Picked up by')}:': order['pickedUpBy'],
|
||||||
|
if (order['isPending'] == false)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']),
|
||||||
|
|
||||||
|
if (order['message'] != null)
|
||||||
|
'${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': order['message']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Color>> _statusHashMap(dynamic order) {
|
||||||
|
return [
|
||||||
|
if (order['isPending'] == true)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting Pick up'): FlutterFlowTheme.of(context).warning,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(ptText: 'Retirado', enText: 'Picked up'): FlutterFlowTheme.of(context).primary,
|
||||||
|
}),
|
||||||
|
|
||||||
|
if (order['adresseeType'] == 'PRO')
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Propriedade',
|
||||||
|
enText: 'Property',
|
||||||
|
): FlutterFlowTheme.of(context).alternate2,
|
||||||
|
})
|
||||||
|
else if (order['adresseeType'] == 'MOR')
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Morador',
|
||||||
|
enText: 'Resident',
|
||||||
|
): FlutterFlowTheme.of(context).alternate2,
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _item(BuildContext context, dynamic order) {
|
||||||
|
return CardItemTemplateComponentWidget(
|
||||||
|
imagePath: _imagePath(order),
|
||||||
|
labelsHashMap: _labelsHashMap(order),
|
||||||
|
statusHashMap: _statusHashMap(order),
|
||||||
|
onTapCardItemAction: () async {
|
||||||
|
showDialog(
|
||||||
|
useSafeArea: true,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Dialog(
|
||||||
|
child: DetailsComponentWidget(
|
||||||
|
imagePath: _imagePath(order),
|
||||||
|
labelsHashMap: _labelsHashMapDialog(order),
|
||||||
|
statusHashMap: [
|
||||||
|
if (order['isPending'] == true)
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting Pick up'): FlutterFlowTheme.of(context).warning,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
Map<String, Color>.from({
|
||||||
|
FFLocalizations.of(context).getVariableText(ptText: 'Retirado', enText: 'Picked up'): FlutterFlowTheme.of(context).primary,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
buttons: [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: _appBar(context),
|
||||||
|
body: _appBody(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:hub/app_state.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
|
class ReservationPageWidget extends StatefulWidget {
|
||||||
|
final String freToken = AppState().userUUID;
|
||||||
|
final String freUserData = "{\"name\": \"${AppState().name}\", " +
|
||||||
|
"\"email\": \"${AppState().email}\"," +
|
||||||
|
"\"dev_id\": \"${AppState().devUUID}\"," +
|
||||||
|
"\"created_at\": \"${AppState().createdAt}\"," +
|
||||||
|
"\"updated_at\": \"0000-00-00 00:00:00\"," +
|
||||||
|
"\"status\": \"A\" }";
|
||||||
|
|
||||||
|
final String clientId = AppState().cliUUID;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ReservationPageWidgetState createState() => _ReservationPageWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReservationPageWidgetState extends State<ReservationPageWidget> {
|
||||||
|
late InAppWebViewController _controllerIOS;
|
||||||
|
late WebViewController _controllerAll;
|
||||||
|
late String url;
|
||||||
|
late String name;
|
||||||
|
late String email;
|
||||||
|
late String userUUID;
|
||||||
|
late String created_at;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
name = AppState().name;
|
||||||
|
email = AppState().email;
|
||||||
|
userUUID = AppState().userUUID;
|
||||||
|
created_at = AppState().createdAt;
|
||||||
|
url = 'https://hub.freaccess.com.br/hub/reservation/${widget.clientId}';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SafeArea(
|
||||||
|
child: Scaffold(
|
||||||
|
body: Platform.isIOS
|
||||||
|
? InAppWebView(
|
||||||
|
initialUrlRequest: URLRequest(url: WebUri(url)),
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
allowsBackForwardNavigationGestures: true,
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
),
|
||||||
|
onWebViewCreated: (controller) async {
|
||||||
|
_controllerIOS = controller;
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-token', '\"${widget.freToken}\"')");
|
||||||
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-user-data', '${widget.freUserData}')");
|
||||||
|
await controller.evaluateJavascript(source: "window.localStorage.setItem('enableBackButton', 'true')");
|
||||||
|
},
|
||||||
|
onUpdateVisitedHistory: (controller, uri, isVisited) {
|
||||||
|
if (uri.toString().contains('/hub/home')) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: WebViewWidget(
|
||||||
|
controller: _controllerAll = WebViewController()
|
||||||
|
..clearCache()
|
||||||
|
..clearLocalStorage()
|
||||||
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..setBackgroundColor(const Color(0x00000000))
|
||||||
|
..setNavigationDelegate(
|
||||||
|
NavigationDelegate(
|
||||||
|
onProgress: (int progress) {},
|
||||||
|
onPageStarted: (String url) {
|
||||||
|
final String token = "localStorage.setItem('fre-token', '\"${widget.freToken}\"');";
|
||||||
|
final String data = "localStorage.setItem('fre-user-data', '${widget.freUserData}');";
|
||||||
|
const String backNavigation = "localStorage.setItem('enableBackButton', 'true');";
|
||||||
|
|
||||||
|
_controllerAll.runJavaScript(token);
|
||||||
|
_controllerAll.runJavaScript(data);
|
||||||
|
_controllerAll.runJavaScript(backNavigation);
|
||||||
|
},
|
||||||
|
onNavigationRequest: (NavigationRequest request) {
|
||||||
|
if (request.url.startsWith('http') ||
|
||||||
|
request.url
|
||||||
|
.startsWith('https://api.whatsapp.com/send') ||
|
||||||
|
request.url.startsWith('https://wa.me')) {
|
||||||
|
launchUrlString(request.url);
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
}
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
},
|
||||||
|
onUrlChange: (url) {
|
||||||
|
if (url.url.toString().contains('/hub/home')) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..loadRequest(Uri.parse(url)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue