mijn_aanmeldingen_widget.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. import '/backend/api_requests/api_calls.dart';
  2. import '/components/header_buttons_component_widget.dart';
  3. import '/flutter_flow/flutter_flow_theme.dart';
  4. import '/flutter_flow/flutter_flow_util.dart';
  5. import '/flutter_flow/flutter_flow_widgets.dart';
  6. import '/shared/drawer_component/drawer_component_widget.dart';
  7. import 'dart:ui';
  8. import '/flutter_flow/custom_functions.dart' as functions;
  9. import '/index.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter_spinkit/flutter_spinkit.dart';
  12. import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
  13. import 'package:google_fonts/google_fonts.dart';
  14. import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
  15. import 'package:provider/provider.dart';
  16. import 'mijn_aanmeldingen_model.dart';
  17. export 'mijn_aanmeldingen_model.dart';
  18. class MijnAanmeldingenWidget extends StatefulWidget {
  19. const MijnAanmeldingenWidget({
  20. super.key,
  21. this.type,
  22. });
  23. final String? type;
  24. static String routeName = 'MijnAanmeldingen';
  25. static String routePath = '/mijnAanmeldingen';
  26. @override
  27. State<MijnAanmeldingenWidget> createState() => _MijnAanmeldingenWidgetState();
  28. }
  29. class _MijnAanmeldingenWidgetState extends State<MijnAanmeldingenWidget>
  30. with RouteAware {
  31. late MijnAanmeldingenModel _model;
  32. final scaffoldKey = GlobalKey<ScaffoldState>();
  33. @override
  34. void initState() {
  35. super.initState();
  36. _model = createModel(context, () => MijnAanmeldingenModel());
  37. }
  38. @override
  39. void dispose() {
  40. routeObserver.unsubscribe(this);
  41. _model.dispose();
  42. super.dispose();
  43. }
  44. @override
  45. void didUpdateWidget(MijnAanmeldingenWidget oldWidget) {
  46. super.didUpdateWidget(oldWidget);
  47. _model.widget = widget;
  48. }
  49. @override
  50. void didChangeDependencies() {
  51. super.didChangeDependencies();
  52. final route = DebugModalRoute.of(context);
  53. if (route != null) {
  54. routeObserver.subscribe(this, route);
  55. }
  56. debugLogGlobalProperty(context);
  57. }
  58. @override
  59. void didPopNext() {
  60. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  61. setState(() => _model.isRouteVisible = true);
  62. debugLogWidgetClass(_model);
  63. }
  64. }
  65. @override
  66. void didPush() {
  67. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  68. setState(() => _model.isRouteVisible = true);
  69. debugLogWidgetClass(_model);
  70. }
  71. }
  72. @override
  73. void didPop() {
  74. _model.isRouteVisible = false;
  75. }
  76. @override
  77. void didPushNext() {
  78. _model.isRouteVisible = false;
  79. }
  80. @override
  81. Widget build(BuildContext context) {
  82. DebugFlutterFlowModelContext.maybeOf(context)
  83. ?.parentModelCallback
  84. ?.call(_model);
  85. context.watch<FFAppState>();
  86. return GestureDetector(
  87. onTap: () {
  88. FocusScope.of(context).unfocus();
  89. FocusManager.instance.primaryFocus?.unfocus();
  90. },
  91. child: Scaffold(
  92. key: scaffoldKey,
  93. backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
  94. drawer: Drawer(
  95. elevation: 16.0,
  96. child: wrapWithModel(
  97. model: _model.drawerComponentModel,
  98. updateCallback: () => safeSetState(() {}),
  99. child: Builder(builder: (_) {
  100. return DebugFlutterFlowModelContext(
  101. rootModel: _model.rootModel,
  102. child: DrawerComponentWidget(),
  103. );
  104. }),
  105. ),
  106. ),
  107. appBar: PreferredSize(
  108. preferredSize: Size.fromHeight(80.0),
  109. child: AppBar(
  110. backgroundColor: FlutterFlowTheme.of(context).primaryText,
  111. automaticallyImplyLeading: false,
  112. actions: [],
  113. flexibleSpace: FlexibleSpaceBar(
  114. background: wrapWithModel(
  115. model: _model.headerButtonsComponentModel,
  116. updateCallback: () => safeSetState(() {}),
  117. child: Builder(builder: (_) {
  118. return DebugFlutterFlowModelContext(
  119. rootModel: _model.rootModel,
  120. child: HeaderButtonsComponentWidget(
  121. showBackButton: true,
  122. landelijk: false,
  123. ),
  124. );
  125. }),
  126. ),
  127. centerTitle: true,
  128. expandedTitleScale: 1.0,
  129. ),
  130. bottom: PreferredSize(
  131. preferredSize: Size.fromHeight(70.0),
  132. child: Container(),
  133. ),
  134. toolbarHeight: MediaQuery.sizeOf(context).height * 0.25,
  135. elevation: 2.0,
  136. ),
  137. ),
  138. body: SafeArea(
  139. top: true,
  140. child: Column(
  141. mainAxisSize: MainAxisSize.max,
  142. children: [
  143. Expanded(
  144. child: PagedMasonryGridView<ApiPagingParams, dynamic>.count(
  145. pagingController: _model.setStaggeredViewController(
  146. (nextPageMarker) => MijnAanmeldingenCall.call(
  147. sessionName: FFAppState().userSessionname,
  148. sessid: FFAppState().userSessionid,
  149. page: nextPageMarker.nextPageNumber,
  150. type: widget!.type,
  151. ),
  152. ),
  153. crossAxisCount: () {
  154. if (MediaQuery.sizeOf(context).width < kBreakpointSmall) {
  155. return 1;
  156. } else if (MediaQuery.sizeOf(context).width <
  157. kBreakpointMedium) {
  158. return 1;
  159. } else if (MediaQuery.sizeOf(context).width <
  160. kBreakpointLarge) {
  161. return 2;
  162. } else {
  163. return 3;
  164. }
  165. }(),
  166. crossAxisSpacing: 10.0,
  167. mainAxisSpacing: 10.0,
  168. builderDelegate: PagedChildBuilderDelegate<dynamic>(
  169. // Customize what your widget looks like when it's loading the first page.
  170. firstPageProgressIndicatorBuilder: (_) => Center(
  171. child: SizedBox(
  172. width: 80.0,
  173. height: 80.0,
  174. child: SpinKitFadingCircle(
  175. color: FlutterFlowTheme.of(context).primary,
  176. size: 80.0,
  177. ),
  178. ),
  179. ),
  180. // Customize what your widget looks like when it's loading another page.
  181. newPageProgressIndicatorBuilder: (_) => Center(
  182. child: SizedBox(
  183. width: 80.0,
  184. height: 80.0,
  185. child: SpinKitFadingCircle(
  186. color: FlutterFlowTheme.of(context).primary,
  187. size: 80.0,
  188. ),
  189. ),
  190. ),
  191. noItemsFoundIndicatorBuilder: (_) => Center(
  192. child: Image.asset(
  193. 'assets/images/uitgaanskrant.com-applogo.jpg',
  194. ),
  195. ),
  196. itemBuilder: (context, _, aanmeldingItemIndex) {
  197. final aanmeldingItemItem = _model
  198. .staggeredViewPagingController!
  199. .itemList![aanmeldingItemIndex];
  200. return Padding(
  201. padding: EdgeInsets.all(12.0),
  202. child: Container(
  203. decoration: BoxDecoration(
  204. color: FlutterFlowTheme.of(context)
  205. .secondaryBackground,
  206. borderRadius: BorderRadius.circular(8.0),
  207. ),
  208. child: Column(
  209. mainAxisSize: MainAxisSize.max,
  210. children: [
  211. Padding(
  212. padding: EdgeInsets.all(12.0),
  213. child: InkWell(
  214. splashColor: Colors.transparent,
  215. focusColor: Colors.transparent,
  216. hoverColor: Colors.transparent,
  217. highlightColor: Colors.transparent,
  218. onTap: () async {
  219. if (functions
  220. .isOngepubliceerd(aanmeldingItemItem)) {
  221. ScaffoldMessenger.of(context)
  222. .showSnackBar(
  223. SnackBar(
  224. content: Text(
  225. 'Dit item staat nog in beoordeling en is nog niet online.',
  226. style: TextStyle(
  227. color:
  228. FlutterFlowTheme.of(context)
  229. .primaryText,
  230. ),
  231. ),
  232. duration:
  233. Duration(milliseconds: 4000),
  234. backgroundColor:
  235. FlutterFlowTheme.of(context)
  236. .secondary,
  237. ),
  238. );
  239. } else {
  240. context.pushNamed(
  241. EventCurrentWidget.routeName,
  242. queryParameters: {
  243. 'nid': serializeParam(
  244. getJsonField(
  245. aanmeldingItemItem,
  246. r'''$.nid''',
  247. ).toString(),
  248. ParamType.String,
  249. ),
  250. 'horecaid': serializeParam(
  251. getJsonField(
  252. aanmeldingItemItem,
  253. r'''$.horecagelegenheidnid''',
  254. ).toString(),
  255. ParamType.String,
  256. ),
  257. }.withoutNulls,
  258. );
  259. }
  260. },
  261. child: Column(
  262. mainAxisSize: MainAxisSize.max,
  263. children: [
  264. if (getJsonField(
  265. aanmeldingItemItem,
  266. r'''$.logo''',
  267. ) !=
  268. null)
  269. ClipRRect(
  270. borderRadius:
  271. BorderRadius.circular(8.0),
  272. child: Image.network(
  273. getJsonField(
  274. aanmeldingItemItem,
  275. r'''$.logo''',
  276. ).toString(),
  277. width: double.infinity,
  278. height: 120.0,
  279. fit: BoxFit.cover,
  280. ),
  281. ),
  282. Text(
  283. getJsonField(
  284. aanmeldingItemItem,
  285. r'''$.title''',
  286. ).toString(),
  287. style: FlutterFlowTheme.of(context)
  288. .bodyMedium
  289. .override(
  290. font: GoogleFonts.roboto(
  291. fontWeight:
  292. FlutterFlowTheme.of(context)
  293. .bodyMedium
  294. .fontWeight,
  295. fontStyle:
  296. FlutterFlowTheme.of(context)
  297. .bodyMedium
  298. .fontStyle,
  299. ),
  300. letterSpacing: 0.0,
  301. fontWeight:
  302. FlutterFlowTheme.of(context)
  303. .bodyMedium
  304. .fontWeight,
  305. fontStyle:
  306. FlutterFlowTheme.of(context)
  307. .bodyMedium
  308. .fontStyle,
  309. ),
  310. ),
  311. Text(
  312. getJsonField(
  313. aanmeldingItemItem,
  314. r'''$.datum_start''',
  315. ).toString(),
  316. style: FlutterFlowTheme.of(context)
  317. .bodyMedium
  318. .override(
  319. font: GoogleFonts.roboto(
  320. fontWeight:
  321. FlutterFlowTheme.of(context)
  322. .bodyMedium
  323. .fontWeight,
  324. fontStyle:
  325. FlutterFlowTheme.of(context)
  326. .bodyMedium
  327. .fontStyle,
  328. ),
  329. letterSpacing: 0.0,
  330. fontWeight:
  331. FlutterFlowTheme.of(context)
  332. .bodyMedium
  333. .fontWeight,
  334. fontStyle:
  335. FlutterFlowTheme.of(context)
  336. .bodyMedium
  337. .fontStyle,
  338. ),
  339. ),
  340. Text(
  341. getJsonField(
  342. aanmeldingItemItem,
  343. r'''$.status_label''',
  344. ).toString(),
  345. style: FlutterFlowTheme.of(context)
  346. .bodyMedium
  347. .override(
  348. font: GoogleFonts.roboto(
  349. fontWeight:
  350. FlutterFlowTheme.of(context)
  351. .bodyMedium
  352. .fontWeight,
  353. fontStyle:
  354. FlutterFlowTheme.of(context)
  355. .bodyMedium
  356. .fontStyle,
  357. ),
  358. letterSpacing: 0.0,
  359. fontWeight:
  360. FlutterFlowTheme.of(context)
  361. .bodyMedium
  362. .fontWeight,
  363. fontStyle:
  364. FlutterFlowTheme.of(context)
  365. .bodyMedium
  366. .fontStyle,
  367. ),
  368. ),
  369. ],
  370. ),
  371. ),
  372. ),
  373. FFButtonWidget(
  374. onPressed: () async {
  375. _model.apiResulttzz =
  376. await AanmeldingKloonbronCall.call(
  377. sessionName: FFAppState().userSessionname,
  378. sessid: FFAppState().userSessionid,
  379. nid: getJsonField(
  380. aanmeldingItemItem,
  381. r'''$.nid''',
  382. ).toString(),
  383. );
  384. if ((_model.apiResulttzz?.succeeded ??
  385. true)) {
  386. FFAppState().kloonBron =
  387. (_model.apiResulttzz?.jsonBody ?? '');
  388. safeSetState(() {});
  389. if (widget!.type == 'go_out_event') {
  390. context.pushNamed(
  391. UitgaansevenementAanmakenWidget
  392. .routeName,
  393. queryParameters: {
  394. 'horecagelegenheidNid':
  395. serializeParam(
  396. getJsonField(
  397. aanmeldingItemItem,
  398. r'''$.horecagelegenheidnid''',
  399. ).toString(),
  400. ParamType.String,
  401. ),
  402. }.withoutNulls,
  403. );
  404. } else {
  405. context.pushNamed(
  406. StadsactiviteitAanmakenWidget.routeName,
  407. queryParameters: {
  408. 'gemeenteTid': serializeParam(
  409. getJsonField(
  410. (_model.apiResulttzz?.jsonBody ??
  411. ''),
  412. r'''$.gemeente_tid''',
  413. ).toString(),
  414. ParamType.String,
  415. ),
  416. }.withoutNulls,
  417. );
  418. }
  419. }
  420. safeSetState(() {});
  421. },
  422. text: FFLocalizations.of(context).getText(
  423. 'g4pbs1et' /* Kopie */,
  424. ),
  425. options: FFButtonOptions(
  426. height: 40.0,
  427. padding: EdgeInsetsDirectional.fromSTEB(
  428. 16.0, 0.0, 16.0, 0.0),
  429. iconPadding: EdgeInsetsDirectional.fromSTEB(
  430. 0.0, 0.0, 0.0, 0.0),
  431. color: FlutterFlowTheme.of(context)
  432. .secondaryBackground,
  433. textStyle: FlutterFlowTheme.of(context)
  434. .titleSmall
  435. .override(
  436. font: GoogleFonts.roboto(
  437. fontWeight:
  438. FlutterFlowTheme.of(context)
  439. .titleSmall
  440. .fontWeight,
  441. fontStyle:
  442. FlutterFlowTheme.of(context)
  443. .titleSmall
  444. .fontStyle,
  445. ),
  446. color: FlutterFlowTheme.of(context)
  447. .primaryText,
  448. letterSpacing: 0.0,
  449. fontWeight: FlutterFlowTheme.of(context)
  450. .titleSmall
  451. .fontWeight,
  452. fontStyle: FlutterFlowTheme.of(context)
  453. .titleSmall
  454. .fontStyle,
  455. ),
  456. elevation: 0.0,
  457. borderRadius: BorderRadius.circular(8.0),
  458. ),
  459. ),
  460. ],
  461. ),
  462. ),
  463. );
  464. },
  465. ),
  466. ),
  467. ),
  468. ],
  469. ),
  470. ),
  471. ),
  472. );
  473. }
  474. }