horecagelegenheidoverzicht_kaart_widget.dart 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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. return ClipRRect(
  151. borderRadius: BorderRadius.circular(8.0),
  152. child: OctoImage(
  153. placeholderBuilder: (_) => SizedBox.expand(
  154. child: Image(
  155. image: BlurHashImage(
  156. 'L6PZfSi_.AyE_3t7t7R**0o#DgR4'),
  157. fit: BoxFit.cover,
  158. ),
  159. ),
  160. image: CachedNetworkImageProvider(
  161. widget!.logo!,
  162. ),
  163. fit: BoxFit.cover,
  164. ),
  165. );
  166. } else {
  167. return Icon(
  168. Icons.image_not_supported,
  169. color: FlutterFlowTheme.of(context).primaryText,
  170. size: 24.0,
  171. );
  172. }
  173. },
  174. ),
  175. Align(
  176. alignment: AlignmentDirectional(-1.0, 1.0),
  177. child: Container(
  178. decoration: BoxDecoration(
  179. color: Color(0x40000000),
  180. ),
  181. child: Padding(
  182. padding: EdgeInsetsDirectional.fromSTEB(
  183. 8.0, 0.0, 8.0, 0.0),
  184. child: Builder(
  185. builder: (context) {
  186. final categorie =
  187. (widget!.categorie?.toList() ?? [])
  188. .take(3)
  189. .toList();
  190. _model.debugGeneratorVariables[
  191. 'categorie${categorie.length > 100 ? ' (first 100)' : ''}'] =
  192. debugSerializeParam(
  193. categorie.take(100),
  194. ParamType.String,
  195. isList: true,
  196. link:
  197. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=HorecagelegenheidoverzichtKaart',
  198. name: 'String',
  199. nullable: false,
  200. );
  201. debugLogWidgetClass(_model);
  202. return Column(
  203. mainAxisSize: MainAxisSize.min,
  204. mainAxisAlignment: MainAxisAlignment.end,
  205. crossAxisAlignment: CrossAxisAlignment.start,
  206. children: List.generate(categorie.length,
  207. (categorieIndex) {
  208. final categorieItem =
  209. categorie[categorieIndex];
  210. return Align(
  211. alignment:
  212. AlignmentDirectional(-1.0, 1.0),
  213. child: Container(
  214. decoration: BoxDecoration(),
  215. alignment:
  216. AlignmentDirectional(-1.0, 1.0),
  217. child: Padding(
  218. padding:
  219. EdgeInsetsDirectional.fromSTEB(
  220. 6.0, 0.0, 6.0, 0.0),
  221. child: Container(
  222. decoration: BoxDecoration(
  223. color: Color(0xFF09B34A),
  224. borderRadius:
  225. BorderRadius.circular(12.0),
  226. ),
  227. child: Padding(
  228. padding: EdgeInsets.all(8.0),
  229. child: Text(
  230. categorieItem,
  231. style:
  232. FlutterFlowTheme.of(context)
  233. .labelSmall
  234. .override(
  235. font:
  236. GoogleFonts.inter(
  237. fontWeight:
  238. FlutterFlowTheme.of(
  239. context)
  240. .labelSmall
  241. .fontWeight,
  242. fontStyle:
  243. FlutterFlowTheme.of(
  244. context)
  245. .labelSmall
  246. .fontStyle,
  247. ),
  248. color: Colors.white,
  249. fontSize: 10.0,
  250. letterSpacing: 0.0,
  251. fontWeight:
  252. FlutterFlowTheme.of(
  253. context)
  254. .labelSmall
  255. .fontWeight,
  256. fontStyle:
  257. FlutterFlowTheme.of(
  258. context)
  259. .labelSmall
  260. .fontStyle,
  261. ),
  262. ),
  263. ),
  264. ),
  265. ),
  266. ),
  267. );
  268. }).divide(SizedBox(height: 4.0)),
  269. );
  270. },
  271. ),
  272. ),
  273. ),
  274. ),
  275. Align(
  276. alignment: AlignmentDirectional(1.0, -1.0),
  277. child: AlignedTooltip(
  278. content: Padding(
  279. padding: EdgeInsets.all(4.0),
  280. child: Text(
  281. FFLocalizations.of(context).getText(
  282. 'ujd0p09x' /* MessageFavoriet... */,
  283. ),
  284. style: FlutterFlowTheme.of(context)
  285. .bodyLarge
  286. .override(
  287. font: GoogleFonts.inter(
  288. fontWeight: FlutterFlowTheme.of(context)
  289. .bodyLarge
  290. .fontWeight,
  291. fontStyle: FlutterFlowTheme.of(context)
  292. .bodyLarge
  293. .fontStyle,
  294. ),
  295. letterSpacing: 0.0,
  296. fontWeight: FlutterFlowTheme.of(context)
  297. .bodyLarge
  298. .fontWeight,
  299. fontStyle: FlutterFlowTheme.of(context)
  300. .bodyLarge
  301. .fontStyle,
  302. ),
  303. ),
  304. ),
  305. offset: 4.0,
  306. preferredDirection: AxisDirection.down,
  307. borderRadius: BorderRadius.circular(8.0),
  308. backgroundColor:
  309. FlutterFlowTheme.of(context).secondaryBackground,
  310. elevation: 4.0,
  311. tailBaseWidth: 24.0,
  312. tailLength: 12.0,
  313. waitDuration: Duration(milliseconds: 100),
  314. showDuration: Duration(milliseconds: 1500),
  315. triggerMode: TooltipTriggerMode.tap,
  316. child: Builder(
  317. builder: (context) {
  318. if (FFAppState()
  319. .favorieteHorecaNids
  320. .contains(widget!.nid)) {
  321. return FlutterFlowIconButton(
  322. borderRadius: 8.0,
  323. buttonSize: 32.0,
  324. fillColor: Colors.white,
  325. icon: Icon(
  326. Icons.favorite,
  327. color: Color(0xFFB50808),
  328. size: 24.0,
  329. ),
  330. onPressed: () async {
  331. FFAppState().removeFromFavorieteHorecaNids(
  332. widget!.nid!);
  333. safeSetState(() {});
  334. },
  335. );
  336. } else {
  337. return FlutterFlowIconButton(
  338. borderRadius: 8.0,
  339. buttonSize: 32.0,
  340. fillColor: Colors.white,
  341. icon: Icon(
  342. Icons.favorite_border,
  343. color: Color(0xFFB50808),
  344. size: 24.0,
  345. ),
  346. onPressed: () async {
  347. FFAppState()
  348. .addToFavorieteHorecaNids(widget!.nid!);
  349. safeSetState(() {});
  350. },
  351. );
  352. }
  353. },
  354. ),
  355. ),
  356. ),
  357. ],
  358. ),
  359. ),
  360. ),
  361. Expanded(
  362. child: Container(
  363. width: () {
  364. if (MediaQuery.sizeOf(context).width < kBreakpointSmall) {
  365. return 200.0;
  366. } else if (MediaQuery.sizeOf(context).width <
  367. kBreakpointMedium) {
  368. return 250.0;
  369. } else if (MediaQuery.sizeOf(context).width <
  370. kBreakpointLarge) {
  371. return 300.0;
  372. } else {
  373. return 350.0;
  374. }
  375. }(),
  376. decoration: BoxDecoration(),
  377. child: Column(
  378. mainAxisSize: MainAxisSize.min,
  379. mainAxisAlignment: MainAxisAlignment.start,
  380. crossAxisAlignment: CrossAxisAlignment.start,
  381. children: [
  382. Text(
  383. valueOrDefault<String>(
  384. widget!.titel,
  385. 'Titel onbekend',
  386. ),
  387. maxLines: 2,
  388. style:
  389. FlutterFlowTheme.of(context).titleMedium.override(
  390. font: GoogleFonts.interTight(
  391. fontWeight: FontWeight.w600,
  392. fontStyle: FlutterFlowTheme.of(context)
  393. .titleMedium
  394. .fontStyle,
  395. ),
  396. letterSpacing: 0.0,
  397. fontWeight: FontWeight.w600,
  398. fontStyle: FlutterFlowTheme.of(context)
  399. .titleMedium
  400. .fontStyle,
  401. ),
  402. ),
  403. Column(
  404. mainAxisSize: MainAxisSize.min,
  405. crossAxisAlignment: CrossAxisAlignment.start,
  406. children: [
  407. Text(
  408. valueOrDefault<String>(
  409. widget!.adres,
  410. 'Adres onbekend',
  411. ),
  412. style: FlutterFlowTheme.of(context)
  413. .bodyMedium
  414. .override(
  415. font: GoogleFonts.inter(
  416. fontWeight: FlutterFlowTheme.of(context)
  417. .bodyMedium
  418. .fontWeight,
  419. fontStyle: FlutterFlowTheme.of(context)
  420. .bodyMedium
  421. .fontStyle,
  422. ),
  423. color: FlutterFlowTheme.of(context)
  424. .secondaryText,
  425. letterSpacing: 0.0,
  426. fontWeight: FlutterFlowTheme.of(context)
  427. .bodyMedium
  428. .fontWeight,
  429. fontStyle: FlutterFlowTheme.of(context)
  430. .bodyMedium
  431. .fontStyle,
  432. ),
  433. ),
  434. Text(
  435. valueOrDefault<String>(
  436. widget!.plaats,
  437. 'Plaats onbekend',
  438. ),
  439. style: FlutterFlowTheme.of(context)
  440. .bodyMedium
  441. .override(
  442. font: GoogleFonts.inter(
  443. fontWeight: FlutterFlowTheme.of(context)
  444. .bodyMedium
  445. .fontWeight,
  446. fontStyle: FlutterFlowTheme.of(context)
  447. .bodyMedium
  448. .fontStyle,
  449. ),
  450. color: FlutterFlowTheme.of(context)
  451. .secondaryText,
  452. letterSpacing: 0.0,
  453. fontWeight: FlutterFlowTheme.of(context)
  454. .bodyMedium
  455. .fontWeight,
  456. fontStyle: FlutterFlowTheme.of(context)
  457. .bodyMedium
  458. .fontStyle,
  459. ),
  460. ),
  461. ].divide(SizedBox(height: 4.0)),
  462. ),
  463. ].divide(SizedBox(height: 8.0)),
  464. ),
  465. ),
  466. ),
  467. ].divide(SizedBox(width: 16.0)),
  468. ),
  469. ),
  470. ),
  471. );
  472. }
  473. }