FIX: Tela de Seleção de Locais

This commit is contained in:
Ivan Antunes 2024-08-22 11:38:12 -03:00
parent fc06f41a25
commit ae12055d34
9 changed files with 248 additions and 319 deletions

View File

@ -379,4 +379,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 3bb356a4513d56583f2f2461d3d8eefb4cd4c3a4
COCOAPODS: 1.14.3
COCOAPODS: 1.15.2

View File

@ -510,8 +510,6 @@ class ApiManager {
result = ApiCallResponse(null, {}, -1, exception: e);
}
log('Params: $params');
log('JsonBody: ${result.jsonBody}');
return result;
}
}

View File

@ -1,14 +0,0 @@
import 'package:hub/components/organism_components/arrow_linked_locals_component/arrow_linked_locals_component_widget.dart';
import '../../../flutter_flow/flutter_flow_model.dart';
import 'package:flutter/material.dart';
class ArrowLinkedLocalsComponentModel
extends FlutterFlowModel<ArrowLinkedLocalsComponentWidget> {
@override
void initState(BuildContext context) {}
@override
void dispose() {}
}

View File

@ -1,41 +0,0 @@
import 'package:flutter/material.dart';
import 'package:hub/components/organism_components/arrow_linked_locals_component/arrow_linked_locals_component_model.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
class ArrowLinkedLocalsComponentWidget extends StatefulWidget {
const ArrowLinkedLocalsComponentWidget({super.key});
@override
State<ArrowLinkedLocalsComponentWidget> createState() =>
_ArrowLinkedLocalsComponentWidgetState();
}
class _ArrowLinkedLocalsComponentWidgetState
extends State<ArrowLinkedLocalsComponentWidget> {
late ArrowLinkedLocalsComponentModel _model;
@override
void setState(VoidCallback callback) {
super.setState(callback);
_model.onUpdate();
}
@override
void initState() {
super.initState();
_model = createModel(context, () => ArrowLinkedLocalsComponentModel());
}
@override
void dispose() {
_model.maybeDispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container();
}
}

View File

@ -1,8 +1,14 @@
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart';
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.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:provider/provider.dart';
import '/backend/api_requests/api_calls.dart';
@ -13,14 +19,20 @@ class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget {
const BottomArrowLinkedLocalsComponentWidget({super.key});
@override
State<BottomArrowLinkedLocalsComponentWidget> createState() =>
_BottomArrowLinkedLocalsComponentWidgetState();
State<BottomArrowLinkedLocalsComponentWidget> createState() => _BottomArrowLinkedLocalsComponentWidgetState();
}
class _BottomArrowLinkedLocalsComponentWidgetState
extends State<BottomArrowLinkedLocalsComponentWidget> {
class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLinkedLocalsComponentWidget> {
late BottomArrowLinkedLocalsComponentModel _model;
bool _loading = false;
bool _hasData = false;
late Future<void> _localsFuture;
List<dynamic> _localsWrap = [];
@override
void setState(VoidCallback callback) {
super.setState(callback);
@ -30,8 +42,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState
@override
void initState() {
super.initState();
_model =
createModel(context, () => BottomArrowLinkedLocalsComponentModel());
_model = createModel(context, () => BottomArrowLinkedLocalsComponentModel());
_localsFuture = _fetchLocals();
}
@override
@ -41,247 +53,224 @@ class _BottomArrowLinkedLocalsComponentWidgetState
super.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?> _fetchLocals() async {
try {
setState(() => _loading = true);
var response = await PhpGroup.getLocalsCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
);
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
if (locals != null && locals.isNotEmpty) {
setState(() {
_localsWrap.addAll(locals);
_hasData = true;
_loading = false;
});
return response;
}
_showNoMoreDataSnackBar(context);
setState(() {
_hasData = false;
_loading = false;
});
return null;
} catch (e, s) {
setState(() {
_hasData = false;
_loading = false;
});
}
}
Future<dynamic> _fetchResponseLink(String status, String cliID) async {
try {
var response = await PhpGroup.resopndeVinculo.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
cliID: cliID,
tarefa: status
);
if (response.jsonBody['error'] == false) {
return {'error': false, 'error_msg': FFLocalizations.of(context).getVariableText(ptText: "Vinculo Ativado com Sucesso", enText: "Link Activated Successfully") };
} else {
return response.jsonBody;
}
} catch (e, s) {
DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vinculo', e, s);
return {'error': true, 'error_msg': FFLocalizations.of(context).getVariableText(
ptText: "Falha ao efetuar operação, Tente Novamente mais tarde.",
enText: "Failed to perform operation, please try again later."
)};
}
}
String _imagePath(dynamic local) {
return 'https://freaccess.com.br/freaccess/Images/Clients/${local['CLI_ID']}.png';
}
Map<String, String> _labelsHashMap(dynamic local) {
return Map<String, String>.from({
'${local['CLI_PREFIXO']}:': local['CLI_NOME'],
'${FFLocalizations.of(context).getVariableText(ptText: 'Propriedade', enText: 'Property')}:': local['CLU_OWNER_DSC']
});
}
Map<String, Color> _statusHashMap(dynamic local) {
return Map<String, Color>.from({
if (local['CLU_STATUS'] == 'A')
FFLocalizations.of(context).getVariableText(ptText: 'Ativo', enText: 'Active'): FlutterFlowTheme.of(context).success
else if (local['CLU_STATUS'] == 'B')
FFLocalizations.of(context).getVariableText(ptText: 'Bloqueado', enText: 'Blocked'): FlutterFlowTheme.of(context).error
else
FFLocalizations.of(context).getVariableText(ptText: 'Pendente', enText: 'Pending'): FlutterFlowTheme.of(context).warning
});
}
Widget _item(BuildContext context, dynamic local) {
return CardItemTemplateComponentWidget(
imagePath: _imagePath(local),
labelsHashMap: _labelsHashMap(local),
statusHashMap: [_statusHashMap(local)],
onTapCardItemAction: () async {
if (local['CLU_STATUS'] == 'A') {
AppState().cliUUID = local['CLI_ID'];
AppState().local = local['CLI_NOME'];
AppState().ownerUUID = local['CLU_OWNER_ID'];
Navigator.pop(context);
} else if (local['CLU_STATUS'] == 'B') {
String message = FFLocalizations.of(context).getVariableText(
ptText: 'Local Bloqueado para Acesso, Entre em Contato com Administração',
enText: 'Location Blocked for Access, Contact Administration'
);
if (local['CLU_BLK_MESSAGE'] != null && local['CLU_BLK_MESSAGE'] != '') {
message = local['CLU_BLK_MESSAGE'];
}
DialogUtil.warning(context, message);
_localsWrap = [];
_localsFuture = _fetchLocals();
} else {
String localName = local['CLI_NOME'];
showAlertDialog(
context,
FFLocalizations.of(context).getVariableText(ptText: 'Ativar VInculo', enText: 'Activate Link'),
FFLocalizations.of(context).getVariableText(ptText: 'Deseja Aceitar o Vinculo a $localName?', enText: 'Do you wish to accept the link to $localName?'),
() async {
var response = await _fetchResponseLink('A', local['CLI_ID']);
Navigator.pop(context);
if (response['error'] == true) {
DialogUtil.error(context, response['error_msg']);
} else {
DialogUtil.success(context, response['error_msg']);
_localsWrap = [];
_localsFuture = _fetchLocals();
}
}
);
}
},
);
}
Widget _listItems(BuildContext context) {
return Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(),
padding: const EdgeInsets.only(top: 15),
child: FutureBuilder<void>(
future: _localsFuture,
builder: (context, snapshot) {
return ListView.builder(
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
itemCount: _localsWrap.length,
itemBuilder: (BuildContext context, int index) {
final item = _localsWrap[index];
return _item(context, item);
},
);
},
)
);
}
@override
Widget build(BuildContext context) {
context.watch<AppState>();
double height = MediaQuery.sizeOf(context).height;
return Align(
alignment: const AlignmentDirectional(0.0, 1.0),
alignment: const AlignmentDirectional(0, 1),
child: Container(
width: double.infinity,
height: 150.0,
height: height - (height * 0.5),
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primaryBackground,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(0.0),
topLeft: Radius.circular(25.0),
topRight: Radius.circular(25.0),
),
topLeft: Radius.circular(25),
topRight: Radius.circular(25)
)
),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 150.0,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(0.0),
topLeft: Radius.circular(0.0),
topRight: Radius.circular(0.0),
),
),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 100.0,
height: 100.0,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context)
.secondaryBackground,
),
child: FlutterFlowIconButton(
borderRadius: 20.0,
borderWidth: 1.0,
buttonSize: 40.0,
fillColor: FlutterFlowTheme.of(context).accent1,
icon: Icon(
Icons.add,
color: FlutterFlowTheme.of(context).primary,
size: 24.0,
),
onPressed: () {},
),
),
Expanded(
child: FutureBuilder<ApiCallResponse>(
future: PhpGroup.getLocalsCall.call(
devUUID: AppState().devUUID,
userUUID: AppState().userUUID,
),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return Center(
child: SizedBox(
width: 50.0,
height: 50.0,
child: SpinKitCircle(
color:
FlutterFlowTheme.of(context).primary,
size: 50.0,
),
),
);
}
final gridViewGetLocalsResponse = snapshot.data!;
return Builder(
builder: (context) {
final eachLocals = PhpGroup.getLocalsCall
.locais(
gridViewGetLocalsResponse.jsonBody,
)
?.map((e) => e)
.toList()
.toList() ??
[];
return GridView.builder(
padding: EdgeInsets.zero,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
crossAxisSpacing: 10.0,
mainAxisSpacing: 0.0,
childAspectRatio: 1.0,
),
scrollDirection: Axis.horizontal,
itemCount: eachLocals.length,
itemBuilder: (context, eachLocalsIndex) {
final eachLocalsItem =
eachLocals[eachLocalsIndex];
return InkWell(
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: () async {
AppState().cliUUID = getJsonField(
eachLocalsItem,
r'''$.CLI_ID''',
).toString();
setState(() {});
AppState().local = getJsonField(
eachLocalsItem,
r'''$.CLI_NOME''',
).toString();
setState(() {});
AppState().ownerUUID = getJsonField(
eachLocalsItem,
r'''$.CLU_OWNER_ID''',
).toString();
setState(() {});
Navigator.pop(context);
},
child: Container(
width: 50.0,
height: double.infinity,
decoration: const BoxDecoration(),
alignment: const AlignmentDirectional(
0.0, 0.0),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Container(
width: 100.0,
height: 100.0,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(
context)
.primaryText,
borderRadius:
const BorderRadius.only(
bottomLeft:
Radius.circular(25.0),
bottomRight:
Radius.circular(25.0),
topLeft:
Radius.circular(25.0),
topRight:
Radius.circular(25.0),
),
border: Border.all(
color: FlutterFlowTheme.of(
context)
.secondaryText,
width: 3.0,
),
),
child: ClipRRect(
borderRadius:
const BorderRadius.only(
bottomLeft:
Radius.circular(25.0),
bottomRight:
Radius.circular(25.0),
topLeft:
Radius.circular(25.0),
topRight:
Radius.circular(25.0),
),
child: Image.network(
'https://freaccess.com.br/freaccess/Images/Clients/${getJsonField(
eachLocalsItem,
r'''$.CLI_ID''',
).toString()}.png',
width: double.infinity,
height: double.infinity,
fit: BoxFit.fill,
alignment: const Alignment(
0.0, 0.0),
),
),
),
Padding(
padding:
const EdgeInsetsDirectional
.fromSTEB(
0.0, 10.0, 0.0, 0.0),
child: Text(
getJsonField(
eachLocalsItem,
r'''$.CLI_NOME''',
).toString(),
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily:
FlutterFlowTheme.of(
context)
.bodyMediumFamily,
color:
FlutterFlowTheme.of(
context)
.primaryText,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts
.asMap()
.containsKey(
FlutterFlowTheme.of(
context)
.bodyMediumFamily),
),
),
),
],
),
),
);
},
);
},
);
},
),
),
].addToStart(const SizedBox(width: 20.0)),
if (_hasData == false && _loading == false && _localsWrap.isEmpty)
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Center(
child: Text(FFLocalizations.of(context).getVariableText(
ptText: "Nenhum Local Encontrado.",
enText: "No local found")),
)
],
),
)
else if (_hasData == true && _loading == false && _localsWrap.isNotEmpty)
Expanded(child: _listItems(context)),
if (_loading == true)
Container(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
FlutterFlowTheme.of(context).primary,
),
),
],
),
),
),
)
],
),
),

View File

@ -78,6 +78,8 @@ class _LocalProfileComponentWidgetState
isScrollControlled: true,
backgroundColor: const Color(0x00FFFFFF),
context: context,
enableDrag: false,
isDismissible: false,
builder: (context) {
return Padding(
padding: MediaQuery.viewInsetsOf(context),

View File

@ -59,20 +59,15 @@ class _HomePageWidgetState extends State<HomePageWidget> {
// Rest of your code...
if (AppState().cliUUID == null || AppState().cliUUID.isEmpty) {
showModalBottomSheet(
isScrollControlled: false,
isScrollControlled: true,
backgroundColor: Colors.transparent,
enableDrag: false,
isDismissible: false,
context: context,
builder: (context) {
return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode)
: FocusScope.of(context).unfocus(),
child: Padding(
padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(),
),
return Padding(
padding: MediaQuery.viewInsetsOf(context),
child: const BottomArrowLinkedLocalsComponentWidget(),
);
},
).then((value) => safeSetState(() {}));

View File

@ -148,7 +148,7 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
Center(
child: Text(FFLocalizations.of(context).getVariableText(
ptText: "Nenhuma solicitação encontrada!",
enText: "No visit found")),
enText: "No requests found")),
)
],
),

View File

@ -817,18 +817,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
@ -905,10 +905,10 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.8.0"
maybe_just_nothing:
dependency: transitive
description:
@ -921,10 +921,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.12.0"
mime:
dependency: transitive
description:
@ -1286,10 +1286,10 @@ packages:
dependency: transitive
description:
name: sqflite_common
sha256: "7b41b6c3507854a159e24ae90a8e3e9cc01eb26a477c118d6dca065b5f55453e"
sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4"
url: "https://pub.dev"
source: hosted
version: "2.5.4+2"
version: "2.5.4"
stack_trace:
dependency: transitive
description:
@ -1342,10 +1342,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.0"
timeago:
dependency: "direct main"
description:
@ -1510,10 +1510,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.1"
web:
dependency: transitive
description:
@ -1526,10 +1526,10 @@ packages:
dependency: "direct main"
description:
name: webview_flutter
sha256: ec81f57aa1611f8ebecf1d2259da4ef052281cb5ad624131c93546c79ccc7736
sha256: "6869c8786d179f929144b4a1f86e09ac0eddfe475984951ea6c634774c16b522"
url: "https://pub.dev"
source: hosted
version: "4.9.0"
version: "4.8.0"
webview_flutter_android:
dependency: transitive
description:
@ -1550,10 +1550,10 @@ packages:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: "1942a12224ab31e9508cf00c0c6347b931b023b8a4f0811e5dec3b06f94f117d"
sha256: "9c62cc46fa4f2d41e10ab81014c1de470a6c6f26051a2de32111b2ee55287feb"
url: "https://pub.dev"
source: hosted
version: "3.15.0"
version: "3.14.0"
win32:
dependency: "direct overridden"
description:
@ -1595,5 +1595,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.0"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"