horecagelegenheidoverzicht_kaart_widget.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. import '/flutter_flow/flutter_flow_icon_button.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 'dart:ui';
  6. import '/custom_code/actions/index.dart' as actions;
  7. import '/flutter_flow/custom_functions.dart' as functions;
  8. import 'package:aligned_tooltip/aligned_tooltip.dart';
  9. import 'package:cached_network_image/cached_network_image.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter_blurhash/flutter_blurhash.dart';
  12. import 'package:flutter_spinkit/flutter_spinkit.dart';
  13. import 'package:google_fonts/google_fonts.dart';
  14. import 'package:octo_image/octo_image.dart';
  15. import 'package:provider/provider.dart';
  16. import 'horecagelegenheidoverzicht_kaart_model.dart';
  17. export 'horecagelegenheidoverzicht_kaart_model.dart';
  18. /// Create a component with a card overview of cards with the following data;
  19. /// {
  20. /// "nid": "75618",
  21. /// "titel": "Hof van Cartesius",
  22. /// "adres": "Vlampijpstraat 84-94\n",
  23. /// "plaats": "Utrecht (stad)",
  24. /// "logo":
  25. /// "https://uitgaanskrant.com/sites/uitgaanskrant.com/files/car.jpg",
  26. /// "categorie": [
  27. /// "Ondernemen",
  28. /// "Zaalverhuur"
  29. /// ]
  30. /// },
  31. /// i retrieve it with an api call named; Establishments
  32. ///
  33. /// The cards have a logo on the left and the details on the rigth of the
  34. /// card.
  35. ///
  36. /// Only show max 3 categorie items. Put points behind the last to expand all
  37. /// the categories.
  38. /// The categories are shown as buttons (containers) on the logo picture.
  39. class HorecagelegenheidoverzichtKaartWidget extends StatefulWidget {
  40. const HorecagelegenheidoverzichtKaartWidget({
  41. super.key,
  42. this.titel,
  43. this.logo,
  44. this.nid,
  45. this.adres,
  46. this.plaats,
  47. this.categorie,
  48. });
  49. final String? titel;
  50. final String? logo;
  51. final String? nid;
  52. final String? adres;
  53. final String? plaats;
  54. final List<String>? categorie;
  55. @override
  56. State<HorecagelegenheidoverzichtKaartWidget> createState() =>
  57. _HorecagelegenheidoverzichtKaartWidgetState();
  58. }
  59. class _HorecagelegenheidoverzichtKaartWidgetState
  60. extends State<HorecagelegenheidoverzichtKaartWidget> with RouteAware {
  61. late HorecagelegenheidoverzichtKaartModel _model;
  62. @override
  63. void setState(VoidCallback callback) {
  64. super.setState(callback);
  65. _model.onUpdate();
  66. }
  67. @override
  68. void initState() {
  69. super.initState();
  70. _model = createModel(context, () => HorecagelegenheidoverzichtKaartModel());
  71. }
  72. @override
  73. void dispose() {
  74. routeObserver.unsubscribe(this);
  75. _model.maybeDispose();
  76. super.dispose();
  77. }
  78. @override
  79. void didUpdateWidget(HorecagelegenheidoverzichtKaartWidget oldWidget) {
  80. super.didUpdateWidget(oldWidget);
  81. _model.widget = widget;
  82. }
  83. @override
  84. void didChangeDependencies() {
  85. super.didChangeDependencies();
  86. final route = DebugModalRoute.of(context);
  87. if (route != null) {
  88. routeObserver.subscribe(this, route);
  89. }
  90. debugLogGlobalProperty(context);
  91. }
  92. @override
  93. void didPopNext() {
  94. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  95. setState(() => _model.isRouteVisible = true);
  96. debugLogWidgetClass(_model);
  97. }
  98. }
  99. @override
  100. void didPush() {
  101. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  102. setState(() => _model.isRouteVisible = true);
  103. debugLogWidgetClass(_model);
  104. }
  105. }
  106. @override
  107. void didPop() {
  108. _model.isRouteVisible = false;
  109. }
  110. @override
  111. void didPushNext() {
  112. _model.isRouteVisible = false;
  113. }
  114. @override
  115. Widget build(BuildContext context) {
  116. DebugFlutterFlowModelContext.maybeOf(context)
  117. ?.parentModelCallback
  118. ?.call(_model);
  119. context.watch<FFAppState>();
  120. return Padding(
  121. padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 16.0),
  122. child: Container(
  123. decoration: BoxDecoration(
  124. color: FlutterFlowTheme.of(context).secondaryBackground,
  125. boxShadow: [
  126. BoxShadow(
  127. blurRadius: 4.0,
  128. color: Color(0x33000000),
  129. offset: Offset(
  130. 0.0,
  131. 2.0,
  132. ),
  133. spreadRadius: 0.0,
  134. )
  135. ],
  136. borderRadius: BorderRadius.circular(12.0),
  137. ),
  138. child: Padding(
  139. padding: EdgeInsets.all(12.0),
  140. child: Row(
  141. mainAxisSize: MainAxisSize.max,
  142. children: [
  143. Flexible(
  144. child: Align(
  145. alignment: AlignmentDirectional(-1.0, 1.0),
  146. child: Stack(
  147. alignment: AlignmentDirectional(-1.0, 1.0),
  148. children: [
  149. Builder(
  150. builder: (context) {
  151. if ((widget!.logo != '') &&
  152. (widget!.logo != null && widget!.logo != '')) {
  153. return ClipRRect(
  154. borderRadius: BorderRadius.circular(8.0),
  155. child: OctoImage(
  156. placeholderBuilder: (_) {
  157. final blurHash =
  158. 'L6PZfSi_.AyE_3t7t7R**0o#DgR4';
  159. if (!validateBlurhash(blurHash)) {
  160. return const SizedBox.shrink();
  161. }
  162. return SizedBox.expand(
  163. child: Image(
  164. image: BlurHashImage(blurHash),
  165. fit: BoxFit.cover,
  166. ),
  167. );
  168. },
  169. image: CachedNetworkImageProvider(
  170. widget!.logo!,
  171. ),
  172. width: 100.0,
  173. height: 100.0,
  174. fit: BoxFit.cover,
  175. ),
  176. );
  177. } else {
  178. return Icon(
  179. Icons.image_not_supported,
  180. color: FlutterFlowTheme.of(context).primaryText,
  181. size: 24.0,
  182. );
  183. }
  184. },
  185. ),
  186. Align(
  187. alignment: AlignmentDirectional(1.0, -1.0),
  188. child: AlignedTooltip(
  189. content: Padding(
  190. padding: EdgeInsets.all(4.0),
  191. child: Text(
  192. FFLocalizations.of(context).getText(
  193. 'y7slo4b4' /* MessageFavoriet... */,
  194. ),
  195. style: FlutterFlowTheme.of(context)
  196. .bodyLarge
  197. .override(
  198. font: GoogleFonts.roboto(
  199. fontWeight: FlutterFlowTheme.of(context)
  200. .bodyLarge
  201. .fontWeight,
  202. fontStyle: FlutterFlowTheme.of(context)
  203. .bodyLarge
  204. .fontStyle,
  205. ),
  206. letterSpacing: 0.0,
  207. fontWeight: FlutterFlowTheme.of(context)
  208. .bodyLarge
  209. .fontWeight,
  210. fontStyle: FlutterFlowTheme.of(context)
  211. .bodyLarge
  212. .fontStyle,
  213. ),
  214. ),
  215. ),
  216. offset: 4.0,
  217. preferredDirection: AxisDirection.down,
  218. borderRadius: BorderRadius.circular(8.0),
  219. backgroundColor:
  220. FlutterFlowTheme.of(context).secondaryBackground,
  221. elevation: 4.0,
  222. tailBaseWidth: 24.0,
  223. tailLength: 12.0,
  224. waitDuration: Duration(milliseconds: 100),
  225. showDuration: Duration(milliseconds: 1500),
  226. triggerMode: TooltipTriggerMode.tap,
  227. child: Builder(
  228. builder: (context) {
  229. if (FFAppState()
  230. .favorieteHorecaNids
  231. .contains(widget!.nid)) {
  232. return FlutterFlowIconButton(
  233. borderRadius: 8.0,
  234. buttonSize: 32.0,
  235. fillColor: Colors.white,
  236. icon: Icon(
  237. Icons.favorite,
  238. color: FlutterFlowTheme.of(context).primary,
  239. size: 24.0,
  240. ),
  241. onPressed: () async {
  242. FFAppState().removeFromFavorieteHorecaNids(
  243. widget!.nid!);
  244. safeSetState(() {});
  245. await actions.drupalRequest(
  246. 'POST',
  247. 'https://uitgaanskrant.com/nl/flutterdrup/favorieten/unflag.json',
  248. FFAppState().userSessionname,
  249. FFAppState().userSessionid,
  250. FFAppState().userToken,
  251. functions
  252. .favorietenBodyNode(widget!.nid!)!,
  253. );
  254. },
  255. );
  256. } else {
  257. return FlutterFlowIconButton(
  258. borderRadius: 8.0,
  259. buttonSize: 32.0,
  260. fillColor: Colors.white,
  261. icon: Icon(
  262. Icons.favorite_border,
  263. color: FlutterFlowTheme.of(context).primary,
  264. size: 24.0,
  265. ),
  266. onPressed: () async {
  267. FFAppState()
  268. .addToFavorieteHorecaNids(widget!.nid!);
  269. safeSetState(() {});
  270. await actions.drupalRequest(
  271. 'POST',
  272. 'https://uitgaanskrant.com/nl/flutterdrup/favorieten/flag.json',
  273. FFAppState().userSessionname,
  274. FFAppState().userSessionid,
  275. FFAppState().userToken,
  276. functions
  277. .favorietenBodyNode(widget!.nid!)!,
  278. );
  279. },
  280. );
  281. }
  282. },
  283. ),
  284. ),
  285. ),
  286. ],
  287. ),
  288. ),
  289. ),
  290. Expanded(
  291. child: Container(
  292. width: () {
  293. if (MediaQuery.sizeOf(context).width < kBreakpointSmall) {
  294. return 200.0;
  295. } else if (MediaQuery.sizeOf(context).width <
  296. kBreakpointMedium) {
  297. return 250.0;
  298. } else if (MediaQuery.sizeOf(context).width <
  299. kBreakpointLarge) {
  300. return 300.0;
  301. } else {
  302. return 350.0;
  303. }
  304. }(),
  305. decoration: BoxDecoration(),
  306. child: Column(
  307. mainAxisSize: MainAxisSize.min,
  308. mainAxisAlignment: MainAxisAlignment.start,
  309. crossAxisAlignment: CrossAxisAlignment.start,
  310. children: [
  311. Text(
  312. valueOrDefault<String>(
  313. widget!.titel,
  314. 'Titel onbekend',
  315. ),
  316. maxLines: 2,
  317. style:
  318. FlutterFlowTheme.of(context).titleMedium.override(
  319. font: GoogleFonts.roboto(
  320. fontWeight: FontWeight.w600,
  321. fontStyle: FlutterFlowTheme.of(context)
  322. .titleMedium
  323. .fontStyle,
  324. ),
  325. letterSpacing: 0.0,
  326. fontWeight: FontWeight.w600,
  327. fontStyle: FlutterFlowTheme.of(context)
  328. .titleMedium
  329. .fontStyle,
  330. ),
  331. ),
  332. Column(
  333. mainAxisSize: MainAxisSize.min,
  334. crossAxisAlignment: CrossAxisAlignment.start,
  335. children: [
  336. Text(
  337. valueOrDefault<String>(
  338. widget!.adres,
  339. 'Adres onbekend',
  340. ),
  341. style: FlutterFlowTheme.of(context)
  342. .bodyMedium
  343. .override(
  344. font: GoogleFonts.roboto(
  345. fontWeight: FlutterFlowTheme.of(context)
  346. .bodyMedium
  347. .fontWeight,
  348. fontStyle: FlutterFlowTheme.of(context)
  349. .bodyMedium
  350. .fontStyle,
  351. ),
  352. color: FlutterFlowTheme.of(context)
  353. .secondaryText,
  354. letterSpacing: 0.0,
  355. fontWeight: FlutterFlowTheme.of(context)
  356. .bodyMedium
  357. .fontWeight,
  358. fontStyle: FlutterFlowTheme.of(context)
  359. .bodyMedium
  360. .fontStyle,
  361. ),
  362. ),
  363. Text(
  364. valueOrDefault<String>(
  365. widget!.plaats,
  366. 'Plaats onbekend',
  367. ),
  368. style: FlutterFlowTheme.of(context)
  369. .bodyMedium
  370. .override(
  371. font: GoogleFonts.roboto(
  372. fontWeight: FlutterFlowTheme.of(context)
  373. .bodyMedium
  374. .fontWeight,
  375. fontStyle: FlutterFlowTheme.of(context)
  376. .bodyMedium
  377. .fontStyle,
  378. ),
  379. color: FlutterFlowTheme.of(context)
  380. .secondaryText,
  381. letterSpacing: 0.0,
  382. fontWeight: FlutterFlowTheme.of(context)
  383. .bodyMedium
  384. .fontWeight,
  385. fontStyle: FlutterFlowTheme.of(context)
  386. .bodyMedium
  387. .fontStyle,
  388. ),
  389. ),
  390. ].divide(SizedBox(height: 4.0)),
  391. ),
  392. Padding(
  393. padding:
  394. EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
  395. child: Builder(
  396. builder: (context) {
  397. final categorie =
  398. (widget!.categorie?.toList() ?? [])
  399. .take(3)
  400. .toList();
  401. _model.debugGeneratorVariables[
  402. 'categorie${categorie.length > 100 ? ' (first 100)' : ''}'] =
  403. debugSerializeParam(
  404. categorie.take(100),
  405. ParamType.String,
  406. isList: true,
  407. link:
  408. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=HorecagelegenheidoverzichtKaart',
  409. name: 'String',
  410. nullable: false,
  411. );
  412. debugLogWidgetClass(_model);
  413. return Wrap(
  414. spacing: 0.0,
  415. runSpacing: 4.0,
  416. alignment: WrapAlignment.start,
  417. crossAxisAlignment: WrapCrossAlignment.start,
  418. direction: Axis.horizontal,
  419. runAlignment: WrapAlignment.start,
  420. verticalDirection: VerticalDirection.down,
  421. clipBehavior: Clip.none,
  422. children: List.generate(categorie.length,
  423. (categorieIndex) {
  424. final categorieItem = categorie[categorieIndex];
  425. return Align(
  426. alignment: AlignmentDirectional(-1.0, 1.0),
  427. child: Container(
  428. decoration: BoxDecoration(),
  429. alignment: AlignmentDirectional(-1.0, 1.0),
  430. child: Padding(
  431. padding: EdgeInsetsDirectional.fromSTEB(
  432. 6.0, 0.0, 6.0, 0.0),
  433. child: Container(
  434. decoration: BoxDecoration(
  435. color: Color(0xFF09B34A),
  436. borderRadius:
  437. BorderRadius.circular(0.0),
  438. ),
  439. child: Padding(
  440. padding: EdgeInsets.all(8.0),
  441. child: Text(
  442. categorieItem,
  443. style: FlutterFlowTheme.of(context)
  444. .labelSmall
  445. .override(
  446. font: GoogleFonts.roboto(
  447. fontWeight:
  448. FlutterFlowTheme.of(
  449. context)
  450. .labelSmall
  451. .fontWeight,
  452. fontStyle:
  453. FlutterFlowTheme.of(
  454. context)
  455. .labelSmall
  456. .fontStyle,
  457. ),
  458. color: Colors.white,
  459. fontSize: 10.0,
  460. letterSpacing: 0.0,
  461. fontWeight:
  462. FlutterFlowTheme.of(
  463. context)
  464. .labelSmall
  465. .fontWeight,
  466. fontStyle:
  467. FlutterFlowTheme.of(
  468. context)
  469. .labelSmall
  470. .fontStyle,
  471. ),
  472. ),
  473. ),
  474. ),
  475. ),
  476. ),
  477. );
  478. }),
  479. );
  480. },
  481. ),
  482. ),
  483. ].divide(SizedBox(height: 8.0)),
  484. ),
  485. ),
  486. ),
  487. ].divide(SizedBox(width: 16.0)),
  488. ),
  489. ),
  490. ),
  491. );
  492. }
  493. }