259 lines
12 KiB
Dart
259 lines
12 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:hub/commons/actions/api_calls.dart';
|
|
import 'package:hub/commons/actions/api_manager.dart';
|
|
|
|
import '/commons/widgets/flutter_flow_theme.dart';
|
|
import '/commons/widgets/flutter_flow_util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'model.dart';
|
|
export 'model.dart';
|
|
|
|
class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget {
|
|
const BottomArrowLinkedLocalsComponentWidget({super.key});
|
|
|
|
@override
|
|
State<BottomArrowLinkedLocalsComponentWidget> createState() =>
|
|
_BottomArrowLinkedLocalsComponentWidgetState();
|
|
}
|
|
|
|
class _BottomArrowLinkedLocalsComponentWidgetState
|
|
extends State<BottomArrowLinkedLocalsComponentWidget> {
|
|
late BottomArrowLinkedLocalsComponentModel _model;
|
|
|
|
@override
|
|
void setState(VoidCallback callback) {
|
|
super.setState(callback);
|
|
_model.onUpdate();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model =
|
|
createModel(context, () => BottomArrowLinkedLocalsComponentModel());
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.maybeDispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
context.watch<FFAppState>();
|
|
|
|
return Align(
|
|
alignment: const AlignmentDirectional(0.0, 1.0),
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 150.0,
|
|
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),
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
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: FutureBuilder<ApiCallResponse>(
|
|
future: PhpGroup.getLocalsCall.call(
|
|
devUUID: FFAppState().devUUID,
|
|
userUUID: FFAppState().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 localsResponse = snapshot.data!;
|
|
return Builder(
|
|
builder: (context) {
|
|
final linkedLocals = PhpGroup.getLocalsCall
|
|
.locais(
|
|
localsResponse.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: linkedLocals.length,
|
|
itemBuilder: (context, index) {
|
|
final localItem =
|
|
linkedLocals[index];
|
|
return InkWell(
|
|
splashColor: Colors.transparent,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
onTap: () async {
|
|
if (localItem['CLU_STATUS'] == 'A') {
|
|
|
|
FFAppState().cliUUID = localItem['CLI_ID'];
|
|
setState(() {});
|
|
FFAppState().local = localItem['CLI_NOME'];
|
|
setState(() {});
|
|
FFAppState().ownerUUID = localItem['CLU_OWNER_ID'];
|
|
setState(() {});
|
|
log('Local: ${FFAppState().local}');
|
|
Navigator.pop(context);
|
|
} else {
|
|
log('Local não disponível');
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text(
|
|
'Local não disponível',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
},
|
|
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(
|
|
localItem,
|
|
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(
|
|
localItem,
|
|
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),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|