fotoboek_grid_component_widget.dart 12 KB

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