fotoboek_grid_component_widget.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. import '/backend/api_requests/api_calls.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 '/shared/lege_lijst_component/lege_lijst_component_widget.dart';
  6. import 'dart:ui';
  7. import 'package:easy_debounce/easy_debounce.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 'fotoboek_grid_component_model.dart';
  13. export 'fotoboek_grid_component_model.dart';
  14. class FotoboekGridComponentWidget extends StatefulWidget {
  15. const FotoboekGridComponentWidget({
  16. super.key,
  17. this.parameter1,
  18. this.parameter2,
  19. this.parameter3,
  20. this.parameter4,
  21. required this.bijKeuze,
  22. });
  23. final dynamic parameter1;
  24. final dynamic parameter2;
  25. final dynamic parameter3;
  26. final List<dynamic>? parameter4;
  27. final Future Function(String fid, String url)? bijKeuze;
  28. @override
  29. State<FotoboekGridComponentWidget> createState() =>
  30. _FotoboekGridComponentWidgetState();
  31. }
  32. class _FotoboekGridComponentWidgetState
  33. extends State<FotoboekGridComponentWidget> with RouteAware {
  34. late FotoboekGridComponentModel _model;
  35. @override
  36. void setState(VoidCallback callback) {
  37. super.setState(callback);
  38. _model.onUpdate();
  39. }
  40. @override
  41. void initState() {
  42. super.initState();
  43. _model = createModel(context, () => FotoboekGridComponentModel());
  44. _model.textController ??= TextEditingController()
  45. ..addListener(() {
  46. debugLogWidgetClass(_model);
  47. });
  48. _model.textFieldFocusNode ??= FocusNode();
  49. }
  50. @override
  51. void dispose() {
  52. routeObserver.unsubscribe(this);
  53. _model.maybeDispose();
  54. super.dispose();
  55. }
  56. @override
  57. void didUpdateWidget(FotoboekGridComponentWidget oldWidget) {
  58. super.didUpdateWidget(oldWidget);
  59. _model.widget = widget;
  60. }
  61. @override
  62. void didChangeDependencies() {
  63. super.didChangeDependencies();
  64. final route = DebugModalRoute.of(context);
  65. if (route != null) {
  66. routeObserver.subscribe(this, route);
  67. }
  68. debugLogGlobalProperty(context);
  69. }
  70. @override
  71. void didPopNext() {
  72. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  73. setState(() => _model.isRouteVisible = true);
  74. debugLogWidgetClass(_model);
  75. }
  76. }
  77. @override
  78. void didPush() {
  79. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  80. setState(() => _model.isRouteVisible = true);
  81. debugLogWidgetClass(_model);
  82. }
  83. }
  84. @override
  85. void didPop() {
  86. _model.isRouteVisible = false;
  87. }
  88. @override
  89. void didPushNext() {
  90. _model.isRouteVisible = false;
  91. }
  92. @override
  93. Widget build(BuildContext context) {
  94. DebugFlutterFlowModelContext.maybeOf(context)
  95. ?.parentModelCallback
  96. ?.call(_model);
  97. context.watch<FFAppState>();
  98. return Column(
  99. mainAxisSize: MainAxisSize.max,
  100. children: [
  101. Expanded(
  102. child: FutureBuilder<ApiCallResponse>(
  103. future: MijnFotosCall.call(
  104. sessionName: FFAppState().userSessionname,
  105. sessid: FFAppState().userSessionid,
  106. zoek: _model.zoekterm,
  107. ),
  108. builder: (context, snapshot) {
  109. // Customize what your widget looks like when it's loading.
  110. if (!snapshot.hasData) {
  111. return Center(
  112. child: SizedBox(
  113. width: 80.0,
  114. height: 80.0,
  115. child: SpinKitFadingCircle(
  116. color: FlutterFlowTheme.of(context).primary,
  117. size: 80.0,
  118. ),
  119. ),
  120. );
  121. }
  122. final gridViewMijnFotosResponse = snapshot.data!;
  123. _model.debugBackendQueries[
  124. 'MijnFotosCall_statusCode_GridView_inry4ta6'] =
  125. debugSerializeParam(
  126. gridViewMijnFotosResponse.statusCode,
  127. ParamType.int,
  128. link:
  129. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=FotoboekGridComponent',
  130. name: 'int',
  131. nullable: false,
  132. );
  133. _model.debugBackendQueries[
  134. 'MijnFotosCall_responseBody_GridView_inry4ta6'] =
  135. debugSerializeParam(
  136. gridViewMijnFotosResponse.bodyText,
  137. ParamType.String,
  138. link:
  139. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=FotoboekGridComponent',
  140. name: 'String',
  141. nullable: false,
  142. );
  143. debugLogWidgetClass(_model);
  144. return Builder(
  145. builder: (context) {
  146. final fotoboekItem = MijnFotosCall.items(
  147. gridViewMijnFotosResponse.jsonBody,
  148. )?.toList() ??
  149. [];
  150. if (fotoboekItem.isEmpty) {
  151. return Center(
  152. child: LegeLijstComponentWidget(
  153. tekst:
  154. 'Je hebt nog geen foto\'s. Upload er een met Logo kiezen.',
  155. ),
  156. );
  157. }
  158. _model.debugGeneratorVariables[
  159. 'fotoboekItem${fotoboekItem.length > 100 ? ' (first 100)' : ''}'] =
  160. debugSerializeParam(
  161. fotoboekItem.take(100),
  162. ParamType.JSON,
  163. isList: true,
  164. link:
  165. 'https://app.flutterflow.io/project/uitgaanskrant-1qhvtd?tab=uiBuilder&page=FotoboekGridComponent',
  166. name: 'dynamic',
  167. nullable: false,
  168. );
  169. debugLogWidgetClass(_model);
  170. return GridView.builder(
  171. padding: EdgeInsets.zero,
  172. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  173. crossAxisCount: 3,
  174. crossAxisSpacing: 10.0,
  175. mainAxisSpacing: 10.0,
  176. childAspectRatio: 1.0,
  177. ),
  178. scrollDirection: Axis.vertical,
  179. itemCount: fotoboekItem.length,
  180. itemBuilder: (context, fotoboekItemIndex) {
  181. final fotoboekItemItem = fotoboekItem[fotoboekItemIndex];
  182. return InkWell(
  183. splashColor: Colors.transparent,
  184. focusColor: Colors.transparent,
  185. hoverColor: Colors.transparent,
  186. highlightColor: Colors.transparent,
  187. onTap: () async {
  188. await widget.bijKeuze?.call(
  189. getJsonField(
  190. fotoboekItemItem,
  191. r'''$.fid''',
  192. ).toString(),
  193. getJsonField(
  194. fotoboekItemItem,
  195. r'''$.url''',
  196. ).toString(),
  197. );
  198. Navigator.pop(context);
  199. },
  200. child: ClipRRect(
  201. borderRadius: BorderRadius.circular(8.0),
  202. child: Image.network(
  203. getJsonField(
  204. fotoboekItemItem,
  205. r'''$.thumb''',
  206. ).toString(),
  207. width: double.infinity,
  208. height: double.infinity,
  209. fit: BoxFit.cover,
  210. ),
  211. ),
  212. );
  213. },
  214. );
  215. },
  216. );
  217. },
  218. ),
  219. ),
  220. Container(
  221. width: double.infinity,
  222. child: TextFormField(
  223. controller: _model.textController,
  224. focusNode: _model.textFieldFocusNode,
  225. onChanged: (_) => EasyDebounce.debounce(
  226. '_model.textController',
  227. Duration(milliseconds: 2000),
  228. () async {
  229. _model.zoekterm = _model.textController.text;
  230. safeSetState(() {});
  231. },
  232. ),
  233. autofocus: false,
  234. enabled: true,
  235. obscureText: false,
  236. decoration: InputDecoration(
  237. isDense: true,
  238. labelStyle: FlutterFlowTheme.of(context).labelMedium.override(
  239. font: GoogleFonts.roboto(
  240. fontWeight:
  241. FlutterFlowTheme.of(context).labelMedium.fontWeight,
  242. fontStyle:
  243. FlutterFlowTheme.of(context).labelMedium.fontStyle,
  244. ),
  245. letterSpacing: 0.0,
  246. fontWeight:
  247. FlutterFlowTheme.of(context).labelMedium.fontWeight,
  248. fontStyle:
  249. FlutterFlowTheme.of(context).labelMedium.fontStyle,
  250. ),
  251. hintText: FFLocalizations.of(context).getText(
  252. 'p5wf8u4i' /* TextField */,
  253. ),
  254. hintStyle: FlutterFlowTheme.of(context).labelMedium.override(
  255. font: GoogleFonts.roboto(
  256. fontWeight:
  257. FlutterFlowTheme.of(context).labelMedium.fontWeight,
  258. fontStyle:
  259. FlutterFlowTheme.of(context).labelMedium.fontStyle,
  260. ),
  261. letterSpacing: 0.0,
  262. fontWeight:
  263. FlutterFlowTheme.of(context).labelMedium.fontWeight,
  264. fontStyle:
  265. FlutterFlowTheme.of(context).labelMedium.fontStyle,
  266. ),
  267. enabledBorder: OutlineInputBorder(
  268. borderSide: BorderSide(
  269. color: Color(0x00000000),
  270. width: 1.0,
  271. ),
  272. borderRadius: BorderRadius.circular(8.0),
  273. ),
  274. focusedBorder: OutlineInputBorder(
  275. borderSide: BorderSide(
  276. color: Color(0x00000000),
  277. width: 1.0,
  278. ),
  279. borderRadius: BorderRadius.circular(8.0),
  280. ),
  281. errorBorder: OutlineInputBorder(
  282. borderSide: BorderSide(
  283. color: FlutterFlowTheme.of(context).error,
  284. width: 1.0,
  285. ),
  286. borderRadius: BorderRadius.circular(8.0),
  287. ),
  288. focusedErrorBorder: OutlineInputBorder(
  289. borderSide: BorderSide(
  290. color: FlutterFlowTheme.of(context).error,
  291. width: 1.0,
  292. ),
  293. borderRadius: BorderRadius.circular(8.0),
  294. ),
  295. filled: true,
  296. fillColor: FlutterFlowTheme.of(context).secondaryBackground,
  297. ),
  298. style: FlutterFlowTheme.of(context).bodyMedium.override(
  299. font: GoogleFonts.roboto(
  300. fontWeight:
  301. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  302. fontStyle:
  303. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  304. ),
  305. letterSpacing: 0.0,
  306. fontWeight:
  307. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  308. fontStyle: FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  309. ),
  310. cursorColor: FlutterFlowTheme.of(context).primaryText,
  311. enableInteractiveSelection: true,
  312. validator: _model.textControllerValidator.asValidator(context),
  313. ),
  314. ),
  315. ],
  316. );
  317. }
  318. }