horecagelegenheidoverzicht_kaart_widget.dart 21 KB

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