horecagelegenheidoverzicht_kaart_widget.dart 21 KB

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