import '/backend/api_requests/api_calls.dart'; import '/components/header_buttons_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; import '/shared/drawer_component/drawer_component_widget.dart'; import 'dart:ui'; import '/flutter_flow/custom_functions.dart' as functions; import '/index.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:provider/provider.dart'; import 'mijn_aanmeldingen_model.dart'; export 'mijn_aanmeldingen_model.dart'; class MijnAanmeldingenWidget extends StatefulWidget { const MijnAanmeldingenWidget({ super.key, this.type, }); final String? type; static String routeName = 'MijnAanmeldingen'; static String routePath = '/mijnAanmeldingen'; @override State createState() => _MijnAanmeldingenWidgetState(); } class _MijnAanmeldingenWidgetState extends State with RouteAware { late MijnAanmeldingenModel _model; final scaffoldKey = GlobalKey(); @override void initState() { super.initState(); _model = createModel(context, () => MijnAanmeldingenModel()); } @override void dispose() { routeObserver.unsubscribe(this); _model.dispose(); super.dispose(); } @override void didUpdateWidget(MijnAanmeldingenWidget oldWidget) { super.didUpdateWidget(oldWidget); _model.widget = widget; } @override void didChangeDependencies() { super.didChangeDependencies(); final route = DebugModalRoute.of(context); if (route != null) { routeObserver.subscribe(this, route); } debugLogGlobalProperty(context); } @override void didPopNext() { if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) { setState(() => _model.isRouteVisible = true); debugLogWidgetClass(_model); } } @override void didPush() { if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) { setState(() => _model.isRouteVisible = true); debugLogWidgetClass(_model); } } @override void didPop() { _model.isRouteVisible = false; } @override void didPushNext() { _model.isRouteVisible = false; } @override Widget build(BuildContext context) { DebugFlutterFlowModelContext.maybeOf(context) ?.parentModelCallback ?.call(_model); context.watch(); return GestureDetector( onTap: () { FocusScope.of(context).unfocus(); FocusManager.instance.primaryFocus?.unfocus(); }, child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, drawer: Drawer( elevation: 16.0, child: wrapWithModel( model: _model.drawerComponentModel, updateCallback: () => safeSetState(() {}), child: Builder(builder: (_) { return DebugFlutterFlowModelContext( rootModel: _model.rootModel, child: DrawerComponentWidget(), ); }), ), ), appBar: PreferredSize( preferredSize: Size.fromHeight(80.0), child: AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryText, automaticallyImplyLeading: false, actions: [], flexibleSpace: FlexibleSpaceBar( background: wrapWithModel( model: _model.headerButtonsComponentModel, updateCallback: () => safeSetState(() {}), child: Builder(builder: (_) { return DebugFlutterFlowModelContext( rootModel: _model.rootModel, child: HeaderButtonsComponentWidget( showBackButton: true, landelijk: false, ), ); }), ), centerTitle: true, expandedTitleScale: 1.0, ), bottom: PreferredSize( preferredSize: Size.fromHeight(70.0), child: Container(), ), toolbarHeight: MediaQuery.sizeOf(context).height * 0.25, elevation: 2.0, ), ), body: SafeArea( top: true, child: Column( mainAxisSize: MainAxisSize.max, children: [ Expanded( child: PagedMasonryGridView.count( pagingController: _model.setStaggeredViewController( (nextPageMarker) => MijnAanmeldingenCall.call( sessionName: FFAppState().userSessionname, sessid: FFAppState().userSessionid, page: nextPageMarker.nextPageNumber, type: widget!.type, ), ), crossAxisCount: () { if (MediaQuery.sizeOf(context).width < kBreakpointSmall) { return 1; } else if (MediaQuery.sizeOf(context).width < kBreakpointMedium) { return 1; } else if (MediaQuery.sizeOf(context).width < kBreakpointLarge) { return 2; } else { return 3; } }(), crossAxisSpacing: 10.0, mainAxisSpacing: 10.0, builderDelegate: PagedChildBuilderDelegate( // Customize what your widget looks like when it's loading the first page. firstPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 80.0, height: 80.0, child: SpinKitFadingCircle( color: FlutterFlowTheme.of(context).primary, size: 80.0, ), ), ), // Customize what your widget looks like when it's loading another page. newPageProgressIndicatorBuilder: (_) => Center( child: SizedBox( width: 80.0, height: 80.0, child: SpinKitFadingCircle( color: FlutterFlowTheme.of(context).primary, size: 80.0, ), ), ), noItemsFoundIndicatorBuilder: (_) => Center( child: Image.asset( 'assets/images/uitgaanskrant.com-applogo.jpg', ), ), itemBuilder: (context, _, aanmeldingItemIndex) { final aanmeldingItemItem = _model .staggeredViewPagingController! .itemList![aanmeldingItemIndex]; return Padding( padding: EdgeInsets.all(12.0), child: Container( decoration: BoxDecoration( color: FlutterFlowTheme.of(context) .secondaryBackground, borderRadius: BorderRadius.circular(8.0), ), child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsets.all(12.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { if (functions .isOngepubliceerd(aanmeldingItemItem)) { ScaffoldMessenger.of(context) .showSnackBar( SnackBar( content: Text( 'Dit item staat nog in beoordeling en is nog niet online.', style: TextStyle( color: FlutterFlowTheme.of(context) .primaryText, ), ), duration: Duration(milliseconds: 4000), backgroundColor: FlutterFlowTheme.of(context) .secondary, ), ); } else { context.pushNamed( EventCurrentWidget.routeName, queryParameters: { 'nid': serializeParam( getJsonField( aanmeldingItemItem, r'''$.nid''', ).toString(), ParamType.String, ), 'horecaid': serializeParam( getJsonField( aanmeldingItemItem, r'''$.horecagelegenheidnid''', ).toString(), ParamType.String, ), }.withoutNulls, ); } }, child: Column( mainAxisSize: MainAxisSize.max, children: [ if (getJsonField( aanmeldingItemItem, r'''$.logo''', ) != null) ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.network( getJsonField( aanmeldingItemItem, r'''$.logo''', ).toString(), width: double.infinity, height: 120.0, fit: BoxFit.cover, ), ), Text( getJsonField( aanmeldingItemItem, r'''$.title''', ).toString(), style: FlutterFlowTheme.of(context) .bodyMedium .override( font: GoogleFonts.roboto( fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), letterSpacing: 0.0, fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), ), Text( getJsonField( aanmeldingItemItem, r'''$.datum_start''', ).toString(), style: FlutterFlowTheme.of(context) .bodyMedium .override( font: GoogleFonts.roboto( fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), letterSpacing: 0.0, fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), ), Text( getJsonField( aanmeldingItemItem, r'''$.status_label''', ).toString(), style: FlutterFlowTheme.of(context) .bodyMedium .override( font: GoogleFonts.roboto( fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), letterSpacing: 0.0, fontWeight: FlutterFlowTheme.of(context) .bodyMedium .fontWeight, fontStyle: FlutterFlowTheme.of(context) .bodyMedium .fontStyle, ), ), ], ), ), ), FFButtonWidget( onPressed: () async { _model.apiResulttzz = await AanmeldingKloonbronCall.call( sessionName: FFAppState().userSessionname, sessid: FFAppState().userSessionid, nid: getJsonField( aanmeldingItemItem, r'''$.nid''', ).toString(), ); if ((_model.apiResulttzz?.succeeded ?? true)) { FFAppState().kloonBron = (_model.apiResulttzz?.jsonBody ?? ''); safeSetState(() {}); if (widget!.type == 'go_out_event') { context.pushNamed( UitgaansevenementAanmakenWidget .routeName, queryParameters: { 'horecagelegenheidNid': serializeParam( getJsonField( aanmeldingItemItem, r'''$.horecagelegenheidnid''', ).toString(), ParamType.String, ), }.withoutNulls, ); } else { context.pushNamed( StadsactiviteitAanmakenWidget .routeName); } } safeSetState(() {}); }, text: FFLocalizations.of(context).getText( 'g4pbs1et' /* Kopie */, ), options: FFButtonOptions( height: 40.0, padding: EdgeInsetsDirectional.fromSTEB( 16.0, 0.0, 16.0, 0.0), iconPadding: EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context) .titleSmall .override( font: GoogleFonts.roboto( fontWeight: FlutterFlowTheme.of(context) .titleSmall .fontWeight, fontStyle: FlutterFlowTheme.of(context) .titleSmall .fontStyle, ), color: Colors.white, letterSpacing: 0.0, fontWeight: FlutterFlowTheme.of(context) .titleSmall .fontWeight, fontStyle: FlutterFlowTheme.of(context) .titleSmall .fontStyle, ), elevation: 0.0, borderRadius: BorderRadius.circular(8.0), ), ), ], ), ), ); }, ), ), ), ], ), ), ), ); } }