favorieten_widget.dart 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. import '/backend/api_requests/api_calls.dart';
  2. import '/flutter_flow/flutter_flow_theme.dart';
  3. import '/flutter_flow/flutter_flow_util.dart';
  4. import '/flutter_flow/flutter_flow_widgets.dart';
  5. import '/uitgaanspaginas/uitgaantabel_kaart/uitgaantabel_kaart_widget.dart';
  6. import 'dart:ui';
  7. import '/custom_code/actions/index.dart' as actions;
  8. import '/index.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/scheduler.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:provider/provider.dart';
  15. import 'favorieten_model.dart';
  16. export 'favorieten_model.dart';
  17. class FavorietenWidget extends StatefulWidget {
  18. const FavorietenWidget({super.key});
  19. static String routeName = 'favorieten';
  20. static String routePath = '/favorieten';
  21. @override
  22. State<FavorietenWidget> createState() => _FavorietenWidgetState();
  23. }
  24. class _FavorietenWidgetState extends State<FavorietenWidget>
  25. with TickerProviderStateMixin, RouteAware {
  26. late FavorietenModel _model;
  27. final scaffoldKey = GlobalKey<ScaffoldState>();
  28. @override
  29. void initState() {
  30. super.initState();
  31. _model = createModel(context, () => FavorietenModel());
  32. // On page load action.
  33. SchedulerBinding.instance.addPostFrameCallback((_) async {
  34. _model.responseActionDrupalRequestPageLoad = await actions.drupalRequest(
  35. 'POST',
  36. 'https://uitgaanskrant.com/nl/flutterdrup/favorieten_agenda.json',
  37. FFAppState().userSessionname,
  38. FFAppState().userSessionid,
  39. FFAppState().userToken,
  40. '',
  41. );
  42. _model.favorietenAgenda =
  43. _model.responseActionDrupalRequestPageLoad!.toList().cast<dynamic>();
  44. safeSetState(() {});
  45. });
  46. _model.tabBarController = TabController(
  47. vsync: this,
  48. length: 4,
  49. initialIndex: 0,
  50. )
  51. ..addListener(() => safeSetState(() {}))
  52. ..addListener(() {
  53. debugLogWidgetClass(_model);
  54. });
  55. }
  56. @override
  57. void dispose() {
  58. routeObserver.unsubscribe(this);
  59. _model.dispose();
  60. super.dispose();
  61. }
  62. @override
  63. void didUpdateWidget(FavorietenWidget oldWidget) {
  64. super.didUpdateWidget(oldWidget);
  65. _model.widget = widget;
  66. }
  67. @override
  68. void didChangeDependencies() {
  69. super.didChangeDependencies();
  70. final route = DebugModalRoute.of(context);
  71. if (route != null) {
  72. routeObserver.subscribe(this, route);
  73. }
  74. debugLogGlobalProperty(context);
  75. }
  76. @override
  77. void didPopNext() {
  78. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  79. setState(() => _model.isRouteVisible = true);
  80. debugLogWidgetClass(_model);
  81. }
  82. }
  83. @override
  84. void didPush() {
  85. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  86. setState(() => _model.isRouteVisible = true);
  87. debugLogWidgetClass(_model);
  88. }
  89. }
  90. @override
  91. void didPop() {
  92. _model.isRouteVisible = false;
  93. }
  94. @override
  95. void didPushNext() {
  96. _model.isRouteVisible = false;
  97. }
  98. @override
  99. Widget build(BuildContext context) {
  100. DebugFlutterFlowModelContext.maybeOf(context)
  101. ?.parentModelCallback
  102. ?.call(_model);
  103. context.watch<FFAppState>();
  104. _model.uitgaantabelKaartModels.clear();
  105. return GestureDetector(
  106. onTap: () {
  107. FocusScope.of(context).unfocus();
  108. FocusManager.instance.primaryFocus?.unfocus();
  109. },
  110. child: Scaffold(
  111. key: scaffoldKey,
  112. backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
  113. body: SafeArea(
  114. top: true,
  115. child: Column(
  116. mainAxisSize: MainAxisSize.max,
  117. children: [
  118. Expanded(
  119. child: Column(
  120. children: [
  121. Align(
  122. alignment: Alignment(0.0, 0),
  123. child: TabBar(
  124. labelColor: FlutterFlowTheme.of(context).primaryText,
  125. unselectedLabelColor:
  126. FlutterFlowTheme.of(context).secondaryText,
  127. labelStyle:
  128. FlutterFlowTheme.of(context).titleMedium.override(
  129. font: GoogleFonts.interTight(
  130. fontWeight: FlutterFlowTheme.of(context)
  131. .titleMedium
  132. .fontWeight,
  133. fontStyle: FlutterFlowTheme.of(context)
  134. .titleMedium
  135. .fontStyle,
  136. ),
  137. letterSpacing: 0.0,
  138. fontWeight: FlutterFlowTheme.of(context)
  139. .titleMedium
  140. .fontWeight,
  141. fontStyle: FlutterFlowTheme.of(context)
  142. .titleMedium
  143. .fontStyle,
  144. ),
  145. unselectedLabelStyle:
  146. FlutterFlowTheme.of(context).titleMedium.override(
  147. font: GoogleFonts.interTight(
  148. fontWeight: FlutterFlowTheme.of(context)
  149. .titleMedium
  150. .fontWeight,
  151. fontStyle: FlutterFlowTheme.of(context)
  152. .titleMedium
  153. .fontStyle,
  154. ),
  155. letterSpacing: 0.0,
  156. fontWeight: FlutterFlowTheme.of(context)
  157. .titleMedium
  158. .fontWeight,
  159. fontStyle: FlutterFlowTheme.of(context)
  160. .titleMedium
  161. .fontStyle,
  162. ),
  163. indicatorColor: FlutterFlowTheme.of(context).primary,
  164. tabs: [
  165. Tab(
  166. text: FFLocalizations.of(context).getText(
  167. 'txq7zl0f' /* Persoonlijke agenda */,
  168. ),
  169. ),
  170. Tab(
  171. text: FFLocalizations.of(context).getText(
  172. '9wq117bv' /* Favoriete gemeenten */,
  173. ),
  174. ),
  175. Tab(
  176. text: FFLocalizations.of(context).getText(
  177. 'ygk8aifq' /* Favoriete Gelegenheden */,
  178. ),
  179. ),
  180. Tab(
  181. text: FFLocalizations.of(context).getText(
  182. 'jwojezxv' /* Gebruiker */,
  183. ),
  184. ),
  185. ],
  186. controller: _model.tabBarController,
  187. onTap: (i) async {
  188. [
  189. () async {
  190. _model.responsActionDrupalRequest =
  191. await actions.drupalRequest(
  192. 'POST',
  193. 'https://uitgaanskrant.com/nl/flutterdrup/favorieten_agenda.json',
  194. FFAppState().userSessionname,
  195. FFAppState().userSessionid,
  196. FFAppState().userToken,
  197. '',
  198. );
  199. _model.favorietenAgenda = _model
  200. .responsActionDrupalRequest!
  201. .toList()
  202. .cast<dynamic>();
  203. safeSetState(() {});
  204. safeSetState(() {});
  205. },
  206. () async {},
  207. () async {},
  208. () async {}
  209. ][i]();
  210. },
  211. ),
  212. ),
  213. Expanded(
  214. child: TabBarView(
  215. controller: _model.tabBarController,
  216. children: [
  217. Column(
  218. mainAxisSize: MainAxisSize.max,
  219. children: [
  220. Expanded(
  221. child: Builder(
  222. builder: (context) {
  223. final favorietenAgendaItems =
  224. _model.favorietenAgenda.toList();
  225. _model.debugGeneratorVariables[
  226. 'favorietenAgendaItems${favorietenAgendaItems.length > 100 ? ' (first 100)' : ''}'] =
  227. debugSerializeParam(
  228. favorietenAgendaItems.take(100),
  229. ParamType.JSON,
  230. isList: true,
  231. link:
  232. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorieten',
  233. name: 'dynamic',
  234. nullable: false,
  235. );
  236. debugLogWidgetClass(_model);
  237. return MasonryGridView.builder(
  238. gridDelegate:
  239. SliverSimpleGridDelegateWithFixedCrossAxisCount(
  240. crossAxisCount: 2,
  241. ),
  242. crossAxisSpacing: 10.0,
  243. mainAxisSpacing: 10.0,
  244. itemCount: favorietenAgendaItems.length,
  245. itemBuilder: (context,
  246. favorietenAgendaItemsIndex) {
  247. final favorietenAgendaItemsItem =
  248. favorietenAgendaItems[
  249. favorietenAgendaItemsIndex];
  250. return Builder(builder: (_) {
  251. return DebugFlutterFlowModelContext(
  252. rootModel: _model.rootModel,
  253. parentModelCallback: (m) {
  254. _model.uitgaantabelKaartModels[
  255. 'Keyiv6_${favorietenAgendaItemsIndex}_of_${favorietenAgendaItems.length}'] = m;
  256. },
  257. child: UitgaantabelKaartWidget(
  258. key: Key(
  259. 'Keyiv6_${favorietenAgendaItemsIndex}_of_${favorietenAgendaItems.length}'),
  260. logo: getJsonField(
  261. favorietenAgendaItemsItem,
  262. r'''$[:].logo''',
  263. ),
  264. categorie: getJsonField(
  265. favorietenAgendaItemsItem,
  266. r'''$[:].categorie''',
  267. ),
  268. titel: getJsonField(
  269. favorietenAgendaItemsItem,
  270. r'''$[:].titel''',
  271. ),
  272. horecagelegenheid: getJsonField(
  273. favorietenAgendaItemsItem,
  274. r'''$[:].horecagelegenheid''',
  275. ),
  276. adres: getJsonField(
  277. favorietenAgendaItemsItem,
  278. r'''$[:].adres''',
  279. ),
  280. plaats: getJsonField(
  281. favorietenAgendaItemsItem,
  282. r'''$[:].plaats''',
  283. ),
  284. datum: getJsonField(
  285. favorietenAgendaItemsItem,
  286. r'''$[:].datum''',
  287. ),
  288. inhoud: null,
  289. nid: getJsonField(
  290. favorietenAgendaItemsItem,
  291. r'''$[:].nid''',
  292. ),
  293. horecagelegenheidNid:
  294. getJsonField(
  295. favorietenAgendaItemsItem,
  296. r'''$[:].horecagelegenheidNid''',
  297. ),
  298. ),
  299. );
  300. });
  301. },
  302. );
  303. },
  304. ),
  305. ),
  306. ],
  307. ),
  308. Column(
  309. mainAxisSize: MainAxisSize.max,
  310. children: [
  311. Text(
  312. FFLocalizations.of(context).getText(
  313. 'o7pt2vls' /* De gemeentes die je hebt gemar... */,
  314. ),
  315. style: FlutterFlowTheme.of(context)
  316. .bodyMedium
  317. .override(
  318. font: GoogleFonts.inter(
  319. fontWeight: FlutterFlowTheme.of(context)
  320. .bodyMedium
  321. .fontWeight,
  322. fontStyle: FlutterFlowTheme.of(context)
  323. .bodyMedium
  324. .fontStyle,
  325. ),
  326. letterSpacing: 0.0,
  327. fontWeight: FlutterFlowTheme.of(context)
  328. .bodyMedium
  329. .fontWeight,
  330. fontStyle: FlutterFlowTheme.of(context)
  331. .bodyMedium
  332. .fontStyle,
  333. ),
  334. ),
  335. ],
  336. ),
  337. Column(
  338. mainAxisSize: MainAxisSize.max,
  339. children: [
  340. FutureBuilder<ApiCallResponse>(
  341. future: FavorietenAgendaCall.call(),
  342. builder: (context, snapshot) {
  343. // Customize what your widget looks like when it's loading.
  344. if (!snapshot.hasData) {
  345. return Center(
  346. child: SizedBox(
  347. width: 80.0,
  348. height: 80.0,
  349. child: SpinKitFadingCircle(
  350. color: Color(0xFFB1061E),
  351. size: 80.0,
  352. ),
  353. ),
  354. );
  355. }
  356. final listViewFavorietenAgendaResponse =
  357. snapshot.data!;
  358. _model.debugBackendQueries[
  359. 'FavorietenAgendaCall_statusCode_ListView_5fedvgkl'] =
  360. debugSerializeParam(
  361. listViewFavorietenAgendaResponse.statusCode,
  362. ParamType.int,
  363. link:
  364. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorieten',
  365. name: 'int',
  366. nullable: false,
  367. );
  368. _model.debugBackendQueries[
  369. 'FavorietenAgendaCall_responseBody_ListView_5fedvgkl'] =
  370. debugSerializeParam(
  371. listViewFavorietenAgendaResponse.bodyText,
  372. ParamType.String,
  373. link:
  374. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorieten',
  375. name: 'String',
  376. nullable: false,
  377. );
  378. debugLogWidgetClass(_model);
  379. return Builder(
  380. builder: (context) {
  381. final favorieteGelegenheidItem =
  382. listViewFavorietenAgendaResponse
  383. .jsonBody
  384. .toList();
  385. if (favorieteGelegenheidItem.isEmpty) {
  386. return Image.asset(
  387. 'assets/images/logo800px.png',
  388. );
  389. }
  390. _model.debugGeneratorVariables[
  391. 'favorieteGelegenheidItem${favorieteGelegenheidItem.length > 100 ? ' (first 100)' : ''}'] =
  392. debugSerializeParam(
  393. favorieteGelegenheidItem.take(100),
  394. ParamType.JSON,
  395. isList: true,
  396. link:
  397. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=favorieten',
  398. name: 'dynamic',
  399. nullable: false,
  400. );
  401. debugLogWidgetClass(_model);
  402. return ListView.builder(
  403. padding: EdgeInsets.zero,
  404. shrinkWrap: true,
  405. scrollDirection: Axis.vertical,
  406. itemCount:
  407. favorieteGelegenheidItem.length,
  408. itemBuilder: (context,
  409. favorieteGelegenheidItemIndex) {
  410. final favorieteGelegenheidItemItem =
  411. favorieteGelegenheidItem[
  412. favorieteGelegenheidItemIndex];
  413. return InkWell(
  414. splashColor: Colors.transparent,
  415. focusColor: Colors.transparent,
  416. hoverColor: Colors.transparent,
  417. highlightColor: Colors.transparent,
  418. onTap: () async {
  419. context.pushNamed(
  420. HorecagelegenheidCurrentWidget
  421. .routeName,
  422. queryParameters: {
  423. 'nid': serializeParam(
  424. getJsonField(
  425. favorieteGelegenheidItemItem,
  426. r'''$.nid''',
  427. ).toString(),
  428. ParamType.String,
  429. ),
  430. }.withoutNulls,
  431. );
  432. },
  433. child: Material(
  434. color: Colors.transparent,
  435. child: ListTile(
  436. title: Text(
  437. getJsonField(
  438. favorieteGelegenheidItemItem,
  439. r'''$.node_title''',
  440. ).toString(),
  441. style: FlutterFlowTheme.of(
  442. context)
  443. .titleLarge
  444. .override(
  445. font: GoogleFonts
  446. .interTight(
  447. fontWeight:
  448. FlutterFlowTheme.of(
  449. context)
  450. .titleLarge
  451. .fontWeight,
  452. fontStyle:
  453. FlutterFlowTheme.of(
  454. context)
  455. .titleLarge
  456. .fontStyle,
  457. ),
  458. letterSpacing: 0.0,
  459. fontWeight:
  460. FlutterFlowTheme.of(
  461. context)
  462. .titleLarge
  463. .fontWeight,
  464. fontStyle:
  465. FlutterFlowTheme.of(
  466. context)
  467. .titleLarge
  468. .fontStyle,
  469. ),
  470. ),
  471. trailing: Icon(
  472. Icons
  473. .arrow_forward_ios_rounded,
  474. color: FlutterFlowTheme.of(
  475. context)
  476. .secondaryText,
  477. size: 24.0,
  478. ),
  479. tileColor:
  480. FlutterFlowTheme.of(context)
  481. .secondaryBackground,
  482. dense: false,
  483. contentPadding:
  484. EdgeInsetsDirectional
  485. .fromSTEB(12.0, 0.0,
  486. 12.0, 0.0),
  487. shape: RoundedRectangleBorder(
  488. borderRadius:
  489. BorderRadius.circular(
  490. 8.0),
  491. ),
  492. ),
  493. ),
  494. );
  495. },
  496. );
  497. },
  498. );
  499. },
  500. ),
  501. ],
  502. ),
  503. Column(
  504. mainAxisSize: MainAxisSize.max,
  505. children: [
  506. InkWell(
  507. splashColor: Colors.transparent,
  508. focusColor: Colors.transparent,
  509. hoverColor: Colors.transparent,
  510. highlightColor: Colors.transparent,
  511. onTap: () async {
  512. FFAppState().deleteUserToken();
  513. FFAppState().userToken = '';
  514. FFAppState().deleteUserSessionid();
  515. FFAppState().userSessionid = '';
  516. FFAppState().deleteUserSessionname();
  517. FFAppState().userSessionname = '';
  518. FFAppState().deleteUserName();
  519. FFAppState().userName = '';
  520. FFAppState().deleteUserUid();
  521. FFAppState().userUid = 0;
  522. FFAppState().deleteUserMail();
  523. FFAppState().userMail = '';
  524. safeSetState(() {});
  525. context.goNamed(LoginWidget.routeName);
  526. },
  527. child: Material(
  528. color: Colors.transparent,
  529. child: ListTile(
  530. title: Text(
  531. FFLocalizations.of(context).getText(
  532. '275gmehq' /* Uitloggen */,
  533. ),
  534. style: FlutterFlowTheme.of(context)
  535. .titleLarge
  536. .override(
  537. font: GoogleFonts.interTight(
  538. fontWeight:
  539. FlutterFlowTheme.of(context)
  540. .titleLarge
  541. .fontWeight,
  542. fontStyle:
  543. FlutterFlowTheme.of(context)
  544. .titleLarge
  545. .fontStyle,
  546. ),
  547. letterSpacing: 0.0,
  548. fontWeight:
  549. FlutterFlowTheme.of(context)
  550. .titleLarge
  551. .fontWeight,
  552. fontStyle:
  553. FlutterFlowTheme.of(context)
  554. .titleLarge
  555. .fontStyle,
  556. ),
  557. ),
  558. trailing: Icon(
  559. Icons.arrow_forward_ios_rounded,
  560. color: FlutterFlowTheme.of(context)
  561. .secondaryText,
  562. size: 24.0,
  563. ),
  564. tileColor: FlutterFlowTheme.of(context)
  565. .secondaryBackground,
  566. dense: false,
  567. contentPadding:
  568. EdgeInsetsDirectional.fromSTEB(
  569. 12.0, 0.0, 12.0, 0.0),
  570. shape: RoundedRectangleBorder(
  571. borderRadius: BorderRadius.circular(8.0),
  572. ),
  573. ),
  574. ),
  575. ),
  576. ],
  577. ),
  578. ],
  579. ),
  580. ),
  581. ],
  582. ),
  583. ),
  584. ],
  585. ),
  586. ),
  587. ),
  588. );
  589. }
  590. }