horecagelegenheidoverzicht_kaart_widget.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. import '/flutter_flow/flutter_flow_theme.dart';
  2. import '/flutter_flow/flutter_flow_util.dart';
  3. import '/flutter_flow/flutter_flow_widgets.dart';
  4. import 'dart:ui';
  5. import 'package:cached_network_image/cached_network_image.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_blurhash/flutter_blurhash.dart';
  8. import 'package:flutter_spinkit/flutter_spinkit.dart';
  9. import 'package:google_fonts/google_fonts.dart';
  10. import 'package:octo_image/octo_image.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. return Padding(
  116. padding: EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 16.0, 16.0),
  117. child: Container(
  118. decoration: BoxDecoration(
  119. color: FlutterFlowTheme.of(context).secondaryBackground,
  120. boxShadow: [
  121. BoxShadow(
  122. blurRadius: 4.0,
  123. color: Color(0x33000000),
  124. offset: Offset(
  125. 0.0,
  126. 2.0,
  127. ),
  128. spreadRadius: 0.0,
  129. )
  130. ],
  131. borderRadius: BorderRadius.circular(12.0),
  132. ),
  133. child: Padding(
  134. padding: EdgeInsets.all(12.0),
  135. child: Row(
  136. mainAxisSize: MainAxisSize.max,
  137. children: [
  138. Flexible(
  139. child: Align(
  140. alignment: AlignmentDirectional(-1.0, 1.0),
  141. child: Stack(
  142. alignment: AlignmentDirectional(-1.0, 1.0),
  143. children: [
  144. Builder(
  145. builder: (context) {
  146. if ((widget!.logo != '') &&
  147. (widget!.logo != null && widget!.logo != '')) {
  148. return ClipRRect(
  149. borderRadius: BorderRadius.circular(8.0),
  150. child: OctoImage(
  151. placeholderBuilder: (_) {
  152. final blurHash =
  153. 'L6PZfSi_.AyE_3t7t7R**0o#DgR4';
  154. if (!validateBlurhash(blurHash)) {
  155. return const SizedBox.shrink();
  156. }
  157. return SizedBox.expand(
  158. child: Image(
  159. image: BlurHashImage(blurHash),
  160. fit: BoxFit.cover,
  161. ),
  162. );
  163. },
  164. image: CachedNetworkImageProvider(
  165. widget!.logo!,
  166. ),
  167. width: 100.0,
  168. height: 100.0,
  169. fit: BoxFit.cover,
  170. ),
  171. );
  172. } else {
  173. return Icon(
  174. Icons.image_not_supported,
  175. color: FlutterFlowTheme.of(context).primaryText,
  176. size: 24.0,
  177. );
  178. }
  179. },
  180. ),
  181. ],
  182. ),
  183. ),
  184. ),
  185. Expanded(
  186. child: Container(
  187. width: () {
  188. if (MediaQuery.sizeOf(context).width < kBreakpointSmall) {
  189. return 200.0;
  190. } else if (MediaQuery.sizeOf(context).width <
  191. kBreakpointMedium) {
  192. return 250.0;
  193. } else if (MediaQuery.sizeOf(context).width <
  194. kBreakpointLarge) {
  195. return 300.0;
  196. } else {
  197. return 350.0;
  198. }
  199. }(),
  200. decoration: BoxDecoration(),
  201. child: Column(
  202. mainAxisSize: MainAxisSize.min,
  203. mainAxisAlignment: MainAxisAlignment.start,
  204. crossAxisAlignment: CrossAxisAlignment.start,
  205. children: [
  206. Text(
  207. valueOrDefault<String>(
  208. widget!.titel,
  209. 'Titel onbekend',
  210. ),
  211. maxLines: 2,
  212. style:
  213. FlutterFlowTheme.of(context).titleMedium.override(
  214. font: GoogleFonts.roboto(
  215. fontWeight: FontWeight.w600,
  216. fontStyle: FlutterFlowTheme.of(context)
  217. .titleMedium
  218. .fontStyle,
  219. ),
  220. letterSpacing: 0.0,
  221. fontWeight: FontWeight.w600,
  222. fontStyle: FlutterFlowTheme.of(context)
  223. .titleMedium
  224. .fontStyle,
  225. ),
  226. ),
  227. Column(
  228. mainAxisSize: MainAxisSize.min,
  229. crossAxisAlignment: CrossAxisAlignment.start,
  230. children: [
  231. Text(
  232. valueOrDefault<String>(
  233. widget!.adres,
  234. 'Adres onbekend',
  235. ),
  236. style: FlutterFlowTheme.of(context)
  237. .bodyMedium
  238. .override(
  239. font: GoogleFonts.roboto(
  240. fontWeight: FlutterFlowTheme.of(context)
  241. .bodyMedium
  242. .fontWeight,
  243. fontStyle: FlutterFlowTheme.of(context)
  244. .bodyMedium
  245. .fontStyle,
  246. ),
  247. color: FlutterFlowTheme.of(context)
  248. .secondaryText,
  249. letterSpacing: 0.0,
  250. fontWeight: FlutterFlowTheme.of(context)
  251. .bodyMedium
  252. .fontWeight,
  253. fontStyle: FlutterFlowTheme.of(context)
  254. .bodyMedium
  255. .fontStyle,
  256. ),
  257. ),
  258. Text(
  259. valueOrDefault<String>(
  260. widget!.plaats,
  261. 'Plaats onbekend',
  262. ),
  263. style: FlutterFlowTheme.of(context)
  264. .bodyMedium
  265. .override(
  266. font: GoogleFonts.roboto(
  267. fontWeight: FlutterFlowTheme.of(context)
  268. .bodyMedium
  269. .fontWeight,
  270. fontStyle: FlutterFlowTheme.of(context)
  271. .bodyMedium
  272. .fontStyle,
  273. ),
  274. color: FlutterFlowTheme.of(context)
  275. .secondaryText,
  276. letterSpacing: 0.0,
  277. fontWeight: FlutterFlowTheme.of(context)
  278. .bodyMedium
  279. .fontWeight,
  280. fontStyle: FlutterFlowTheme.of(context)
  281. .bodyMedium
  282. .fontStyle,
  283. ),
  284. ),
  285. ].divide(SizedBox(height: 4.0)),
  286. ),
  287. Padding(
  288. padding:
  289. EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
  290. child: Builder(
  291. builder: (context) {
  292. final categorie =
  293. (widget!.categorie?.toList() ?? [])
  294. .take(3)
  295. .toList();
  296. _model.debugGeneratorVariables[
  297. 'categorie${categorie.length > 100 ? ' (first 100)' : ''}'] =
  298. debugSerializeParam(
  299. categorie.take(100),
  300. ParamType.String,
  301. isList: true,
  302. link:
  303. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=HorecagelegenheidoverzichtKaart',
  304. name: 'String',
  305. nullable: false,
  306. );
  307. debugLogWidgetClass(_model);
  308. return Wrap(
  309. spacing: 0.0,
  310. runSpacing: 4.0,
  311. alignment: WrapAlignment.start,
  312. crossAxisAlignment: WrapCrossAlignment.start,
  313. direction: Axis.horizontal,
  314. runAlignment: WrapAlignment.start,
  315. verticalDirection: VerticalDirection.down,
  316. clipBehavior: Clip.none,
  317. children: List.generate(categorie.length,
  318. (categorieIndex) {
  319. final categorieItem = categorie[categorieIndex];
  320. return Align(
  321. alignment: AlignmentDirectional(-1.0, 1.0),
  322. child: Container(
  323. decoration: BoxDecoration(),
  324. alignment: AlignmentDirectional(-1.0, 1.0),
  325. child: Padding(
  326. padding: EdgeInsetsDirectional.fromSTEB(
  327. 6.0, 0.0, 6.0, 0.0),
  328. child: Container(
  329. decoration: BoxDecoration(
  330. color: Color(0xFF09B34A),
  331. borderRadius:
  332. BorderRadius.circular(0.0),
  333. ),
  334. child: Padding(
  335. padding: EdgeInsets.all(8.0),
  336. child: Text(
  337. categorieItem,
  338. style: FlutterFlowTheme.of(context)
  339. .labelSmall
  340. .override(
  341. font: GoogleFonts.roboto(
  342. fontWeight:
  343. FlutterFlowTheme.of(
  344. context)
  345. .labelSmall
  346. .fontWeight,
  347. fontStyle:
  348. FlutterFlowTheme.of(
  349. context)
  350. .labelSmall
  351. .fontStyle,
  352. ),
  353. color: Colors.white,
  354. fontSize: 10.0,
  355. letterSpacing: 0.0,
  356. fontWeight:
  357. FlutterFlowTheme.of(
  358. context)
  359. .labelSmall
  360. .fontWeight,
  361. fontStyle:
  362. FlutterFlowTheme.of(
  363. context)
  364. .labelSmall
  365. .fontStyle,
  366. ),
  367. ),
  368. ),
  369. ),
  370. ),
  371. ),
  372. );
  373. }),
  374. );
  375. },
  376. ),
  377. ),
  378. ].divide(SizedBox(height: 8.0)),
  379. ),
  380. ),
  381. ),
  382. ].divide(SizedBox(width: 16.0)),
  383. ),
  384. ),
  385. ),
  386. );
  387. }
  388. }