import '/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart'; import '/flutter_flow/flutter_flow_animations.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import 'dart:async'; import '/flutter_flow/custom_functions.dart' as functions; import 'package:barcode_widget/barcode_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:percent_indicator/percent_indicator.dart'; import 'qr_code_page_model.dart'; export 'qr_code_page_model.dart'; class QrCodePageWidget extends StatefulWidget { const QrCodePageWidget({super.key}); @override State createState() => _QrCodePageWidgetState(); } class _QrCodePageWidgetState extends State with TickerProviderStateMixin { late QrCodePageModel _model; final scaffoldKey = GlobalKey(); final animationsMap = {}; @override void initState() { super.initState(); _model = createModel(context, () => QrCodePageModel()); // On page load action. SchedulerBinding.instance.addPostFrameCallback((_) async { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { animationsMap['barcodeOnActionTriggerAnimation']!.controller.repeat(); } }); animationsMap.addAll({ 'barcodeOnActionTriggerAnimation': AnimationInfo( trigger: AnimationTrigger.onActionTrigger, applyInitialState: true, effectsBuilder: () => [ VisibilityEffect(duration: 1.ms), BlurEffect( curve: Curves.linear, delay: 0.0.ms, duration: 600.0.ms, begin: const Offset(0.0, 0.0), end: const Offset(4.0, 4.0), ), ], ), }); setupAnimations( animationsMap.values.where((anim) => anim.trigger == AnimationTrigger.onActionTrigger || !anim.applyInitialState), this, ); } @override void dispose() { _model.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, appBar: AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, leading: FlutterFlowIconButton( borderColor: Colors.transparent, borderRadius: 30.0, borderWidth: 1.0, buttonSize: 60.0, icon: Icon( Icons.keyboard_arrow_left, color: FlutterFlowTheme.of(context).primaryText, size: 30.0, ), onPressed: () async { context.pop(); }, ), title: Text( FFLocalizations.of(context).getText( 'ku7jqe53' /* QR Code de Acesso */, ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, color: FlutterFlowTheme.of(context).primaryText, fontSize: 16.0, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( FlutterFlowTheme.of(context).headlineMediumFamily), ), ), actions: const [], centerTitle: true, elevation: 0.0, ), body: SafeArea( top: true, child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ if (_model.isAccess == true) Text( FFLocalizations.of(context).getText( 'vd84zgfe' /* Use esse QR Code para acesso */, ), style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontSize: 20.0, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap().containsKey( FlutterFlowTheme.of(context).bodyMediumFamily), ), ), Stack( children: [ Align( alignment: const AlignmentDirectional(0.0, 0.0), child: BarcodeWidget( data: 'Barcode', barcode: Barcode.qrCode(), width: 300.0, height: 200.0, color: FlutterFlowTheme.of(context).primaryText, backgroundColor: Colors.transparent, errorBuilder: (context, error) => const SizedBox( width: 300.0, height: 200.0, ), drawText: false, ).animateOnActionTrigger( animationsMap['barcodeOnActionTriggerAnimation']!, ), ), if (_model.isAccess == true) Align( alignment: const AlignmentDirectional(0.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onLongPress: () async { await _model.qrCodeEncoder( context, key: _model.key, ); setState(() {}); }, child: Container( width: 200.0, height: 200.0, decoration: const BoxDecoration(), child: Align( alignment: const AlignmentDirectional(0.0, 0.0), child: FFButtonWidget( onPressed: () async { await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, useSafeArea: true, 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: QrCodePassKeyTemplateComponentWidget( toggleActionStatus: (key) async { _model.key = key; setState(() {}); }, ), ), ); }, ).then((value) => safeSetState(() {})); unawaited( () async { await _model.qrCodeEncoder( context, key: _model.key, ); setState(() {}); }(), ); if (animationsMap[ 'barcodeOnActionTriggerAnimation'] != null) { animationsMap[ 'barcodeOnActionTriggerAnimation']! .controller .reverse(); } if (animationsMap[ 'barcodeOnActionTriggerAnimation'] != null) { animationsMap[ 'barcodeOnActionTriggerAnimation']! .controller .stop(); } _model.isAccess = !_model.isAccess; setState(() {}); }, text: FFLocalizations.of(context).getText( 'mxdrsbmy' /* Liberar QR Code */, ), options: FFButtonOptions( height: 40.0, padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), iconPadding: const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( fontFamily: FlutterFlowTheme.of(context) .titleSmallFamily, color: Colors.white, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .titleSmallFamily), ), elevation: 3.0, borderSide: const BorderSide( color: Colors.transparent, width: 1.0, ), borderRadius: BorderRadius.circular(8.0), ), ), ), ), ), ), ], ), if (_model.isAccess == true) Container( width: 300.0, decoration: const BoxDecoration(), child: Visibility( visible: _model.isAccess == true, child: Text( FFLocalizations.of(context).getText( '6z6kvmhl' /* Certifique-se de que o QRCode ... */, ), style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), ), if (_model.isAccess == true) Container( width: 250.0, height: 80.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100.0), border: Border.all( color: FlutterFlowTheme.of(context).primary, ), ), child: Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 10.0, 0.0, 0.0, 0.0), child: Text( FFLocalizations.of(context).getText( 'wkjkxd2e' /* Trocando QR code em */, ), textAlign: TextAlign.center, style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) .bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.w600, useGoogleFonts: GoogleFonts.asMap() .containsKey(FlutterFlowTheme.of(context) .bodyMediumFamily), ), ), ), ), Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( padding: const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 20.0, 0.0), child: CircularPercentIndicator( percent: functions.getProgressValue(1), radius: 30.0, lineWidth: 7.0, animation: true, animateFromLastPercent: true, progressColor: FlutterFlowTheme.of(context).primary, backgroundColor: FlutterFlowTheme.of(context).primaryText, center: Text( FFLocalizations.of(context).getText( '3bfr2tjr' /* 20 */, ), style: FlutterFlowTheme.of(context) .headlineSmall .override( fontFamily: FlutterFlowTheme.of(context) .headlineSmallFamily, fontSize: 14.0, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( FlutterFlowTheme.of(context) .headlineSmallFamily), ), ), startAngle: 20.0, ), ), ), ], ), ), ], ), ), ), ); } }