favorieten_widget.dart 33 KB

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