horecagelegenheidoverzicht_kaart_widget.dart 16 KB

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