wachtwoord_vergeten_widget.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. import '/backend/api_requests/api_calls.dart';
  2. import '/backend/api_requests/api_streaming.dart';
  3. import '/components/header_buttons_component_widget.dart';
  4. import '/flutter_flow/flutter_flow_theme.dart';
  5. import '/flutter_flow/flutter_flow_util.dart';
  6. import '/flutter_flow/flutter_flow_widgets.dart';
  7. import '/shared/drawer_component/drawer_component_widget.dart';
  8. import 'dart:convert';
  9. import 'dart:ui';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter_spinkit/flutter_spinkit.dart';
  12. import 'package:google_fonts/google_fonts.dart';
  13. import 'package:provider/provider.dart';
  14. import 'wachtwoord_vergeten_model.dart';
  15. export 'wachtwoord_vergeten_model.dart';
  16. class WachtwoordVergetenWidget extends StatefulWidget {
  17. const WachtwoordVergetenWidget({super.key});
  18. static String routeName = 'wachtwoordVergeten';
  19. static String routePath = '/wachtwoordVergeten';
  20. @override
  21. State<WachtwoordVergetenWidget> createState() =>
  22. _WachtwoordVergetenWidgetState();
  23. }
  24. class _WachtwoordVergetenWidgetState extends State<WachtwoordVergetenWidget>
  25. with RouteAware {
  26. late WachtwoordVergetenModel _model;
  27. final scaffoldKey = GlobalKey<ScaffoldState>();
  28. @override
  29. void initState() {
  30. super.initState();
  31. _model = createModel(context, () => WachtwoordVergetenModel());
  32. _model.naamOfEmailFieldTextController ??= TextEditingController()
  33. ..addListener(() {
  34. debugLogWidgetClass(_model);
  35. });
  36. _model.naamOfEmailFieldFocusNode ??= FocusNode();
  37. }
  38. @override
  39. void dispose() {
  40. routeObserver.unsubscribe(this);
  41. _model.dispose();
  42. super.dispose();
  43. }
  44. @override
  45. void didUpdateWidget(WachtwoordVergetenWidget oldWidget) {
  46. super.didUpdateWidget(oldWidget);
  47. _model.widget = widget;
  48. }
  49. @override
  50. void didChangeDependencies() {
  51. super.didChangeDependencies();
  52. final route = DebugModalRoute.of(context);
  53. if (route != null) {
  54. routeObserver.subscribe(this, route);
  55. }
  56. debugLogGlobalProperty(context);
  57. }
  58. @override
  59. void didPopNext() {
  60. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  61. setState(() => _model.isRouteVisible = true);
  62. debugLogWidgetClass(_model);
  63. }
  64. }
  65. @override
  66. void didPush() {
  67. if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
  68. setState(() => _model.isRouteVisible = true);
  69. debugLogWidgetClass(_model);
  70. }
  71. }
  72. @override
  73. void didPop() {
  74. _model.isRouteVisible = false;
  75. }
  76. @override
  77. void didPushNext() {
  78. _model.isRouteVisible = false;
  79. }
  80. @override
  81. Widget build(BuildContext context) {
  82. DebugFlutterFlowModelContext.maybeOf(context)
  83. ?.parentModelCallback
  84. ?.call(_model);
  85. return GestureDetector(
  86. onTap: () {
  87. FocusScope.of(context).unfocus();
  88. FocusManager.instance.primaryFocus?.unfocus();
  89. },
  90. child: Scaffold(
  91. key: scaffoldKey,
  92. backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
  93. drawer: Drawer(
  94. elevation: 16.0,
  95. child: wrapWithModel(
  96. model: _model.drawerComponentModel,
  97. updateCallback: () => safeSetState(() {}),
  98. child: Builder(builder: (_) {
  99. return DebugFlutterFlowModelContext(
  100. rootModel: _model.rootModel,
  101. child: DrawerComponentWidget(),
  102. );
  103. }),
  104. ),
  105. ),
  106. appBar: PreferredSize(
  107. preferredSize: Size.fromHeight(80.0),
  108. child: AppBar(
  109. backgroundColor: FlutterFlowTheme.of(context).info,
  110. automaticallyImplyLeading: false,
  111. actions: [],
  112. flexibleSpace: FlexibleSpaceBar(
  113. background: wrapWithModel(
  114. model: _model.headerButtonsComponentModel,
  115. updateCallback: () => safeSetState(() {}),
  116. child: Builder(builder: (_) {
  117. return DebugFlutterFlowModelContext(
  118. rootModel: _model.rootModel,
  119. child: HeaderButtonsComponentWidget(
  120. showBackButton: true,
  121. ),
  122. );
  123. }),
  124. ),
  125. centerTitle: true,
  126. expandedTitleScale: 1.0,
  127. ),
  128. bottom: PreferredSize(
  129. preferredSize: Size.fromHeight(70.0),
  130. child: Container(),
  131. ),
  132. toolbarHeight: MediaQuery.sizeOf(context).height * 0.25,
  133. elevation: 2.0,
  134. ),
  135. ),
  136. body: SafeArea(
  137. top: true,
  138. child: Column(
  139. mainAxisSize: MainAxisSize.max,
  140. children: [
  141. Text(
  142. FFLocalizations.of(context).getText(
  143. 'vrbz9a3l' /* Wachtwoord vergeten */,
  144. ),
  145. style: FlutterFlowTheme.of(context).bodyMedium.override(
  146. font: GoogleFonts.roboto(
  147. fontWeight:
  148. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  149. fontStyle:
  150. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  151. ),
  152. letterSpacing: 0.0,
  153. fontWeight:
  154. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  155. fontStyle:
  156. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  157. ),
  158. ),
  159. Text(
  160. FFLocalizations.of(context).getText(
  161. '503u6v73' /* Vul je gebruikersnaam of e-mai... */,
  162. ),
  163. style: FlutterFlowTheme.of(context).bodyMedium.override(
  164. font: GoogleFonts.roboto(
  165. fontWeight:
  166. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  167. fontStyle:
  168. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  169. ),
  170. letterSpacing: 0.0,
  171. fontWeight:
  172. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  173. fontStyle:
  174. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  175. ),
  176. ),
  177. Container(
  178. width: 200.0,
  179. child: TextFormField(
  180. controller: _model.naamOfEmailFieldTextController,
  181. focusNode: _model.naamOfEmailFieldFocusNode,
  182. autofocus: false,
  183. enabled: true,
  184. obscureText: false,
  185. decoration: InputDecoration(
  186. isDense: true,
  187. labelStyle:
  188. FlutterFlowTheme.of(context).labelMedium.override(
  189. font: GoogleFonts.roboto(
  190. fontWeight: FlutterFlowTheme.of(context)
  191. .labelMedium
  192. .fontWeight,
  193. fontStyle: FlutterFlowTheme.of(context)
  194. .labelMedium
  195. .fontStyle,
  196. ),
  197. letterSpacing: 0.0,
  198. fontWeight: FlutterFlowTheme.of(context)
  199. .labelMedium
  200. .fontWeight,
  201. fontStyle: FlutterFlowTheme.of(context)
  202. .labelMedium
  203. .fontStyle,
  204. ),
  205. hintText: FFLocalizations.of(context).getText(
  206. 'ush5uxz1' /* Gebruikersnaam of e-mailadres */,
  207. ),
  208. hintStyle:
  209. FlutterFlowTheme.of(context).labelMedium.override(
  210. font: GoogleFonts.roboto(
  211. fontWeight: FlutterFlowTheme.of(context)
  212. .labelMedium
  213. .fontWeight,
  214. fontStyle: FlutterFlowTheme.of(context)
  215. .labelMedium
  216. .fontStyle,
  217. ),
  218. letterSpacing: 0.0,
  219. fontWeight: FlutterFlowTheme.of(context)
  220. .labelMedium
  221. .fontWeight,
  222. fontStyle: FlutterFlowTheme.of(context)
  223. .labelMedium
  224. .fontStyle,
  225. ),
  226. enabledBorder: OutlineInputBorder(
  227. borderSide: BorderSide(
  228. color: Color(0x00000000),
  229. width: 1.0,
  230. ),
  231. borderRadius: BorderRadius.circular(8.0),
  232. ),
  233. focusedBorder: OutlineInputBorder(
  234. borderSide: BorderSide(
  235. color: Color(0x00000000),
  236. width: 1.0,
  237. ),
  238. borderRadius: BorderRadius.circular(8.0),
  239. ),
  240. errorBorder: OutlineInputBorder(
  241. borderSide: BorderSide(
  242. color: FlutterFlowTheme.of(context).error,
  243. width: 1.0,
  244. ),
  245. borderRadius: BorderRadius.circular(8.0),
  246. ),
  247. focusedErrorBorder: OutlineInputBorder(
  248. borderSide: BorderSide(
  249. color: FlutterFlowTheme.of(context).error,
  250. width: 1.0,
  251. ),
  252. borderRadius: BorderRadius.circular(8.0),
  253. ),
  254. filled: true,
  255. fillColor: FlutterFlowTheme.of(context).secondaryBackground,
  256. ),
  257. style: FlutterFlowTheme.of(context).bodyMedium.override(
  258. font: GoogleFonts.roboto(
  259. fontWeight: FlutterFlowTheme.of(context)
  260. .bodyMedium
  261. .fontWeight,
  262. fontStyle:
  263. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  264. ),
  265. letterSpacing: 0.0,
  266. fontWeight:
  267. FlutterFlowTheme.of(context).bodyMedium.fontWeight,
  268. fontStyle:
  269. FlutterFlowTheme.of(context).bodyMedium.fontStyle,
  270. ),
  271. cursorColor: FlutterFlowTheme.of(context).primaryText,
  272. enableInteractiveSelection: true,
  273. validator: _model.naamOfEmailFieldTextControllerValidator
  274. .asValidator(context),
  275. ),
  276. ),
  277. FFButtonWidget(
  278. onPressed: () async {
  279. _model.apiResultuoz = await RequestNewPasswordCall.call(
  280. name: _model.naamOfEmailFieldTextController.text,
  281. );
  282. if ((_model.apiResultuoz?.succeeded ?? true)) {
  283. ScaffoldMessenger.of(context).showSnackBar(
  284. SnackBar(
  285. content: Text(
  286. 'Als dit account bestaat, ontvang je een e-mail om je wachtwoord opnieuw in te stellen.',
  287. style: TextStyle(
  288. color: FlutterFlowTheme.of(context).primaryText,
  289. ),
  290. ),
  291. duration: Duration(milliseconds: 4000),
  292. backgroundColor: FlutterFlowTheme.of(context).secondary,
  293. ),
  294. );
  295. } else {
  296. ScaffoldMessenger.of(context).showSnackBar(
  297. SnackBar(
  298. content: Text(
  299. RequestNewPasswordCall.errorMessage(
  300. (_model.apiResultuoz?.jsonBody ?? ''),
  301. )!,
  302. style: TextStyle(
  303. color: FlutterFlowTheme.of(context).primaryText,
  304. ),
  305. ),
  306. duration: Duration(milliseconds: 4000),
  307. backgroundColor: FlutterFlowTheme.of(context).secondary,
  308. ),
  309. );
  310. }
  311. safeSetState(() {});
  312. },
  313. text: FFLocalizations.of(context).getText(
  314. '0gfuq6i7' /* Verstuur */,
  315. ),
  316. options: FFButtonOptions(
  317. height: 40.0,
  318. padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0),
  319. iconPadding:
  320. EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
  321. color: FlutterFlowTheme.of(context).secondary,
  322. textStyle: FlutterFlowTheme.of(context).titleSmall.override(
  323. font: GoogleFonts.roboto(
  324. fontWeight: FlutterFlowTheme.of(context)
  325. .titleSmall
  326. .fontWeight,
  327. fontStyle:
  328. FlutterFlowTheme.of(context).titleSmall.fontStyle,
  329. ),
  330. color: Colors.white,
  331. letterSpacing: 0.0,
  332. fontWeight:
  333. FlutterFlowTheme.of(context).titleSmall.fontWeight,
  334. fontStyle:
  335. FlutterFlowTheme.of(context).titleSmall.fontStyle,
  336. ),
  337. elevation: 0.0,
  338. borderRadius: BorderRadius.circular(8.0),
  339. ),
  340. ),
  341. ],
  342. ),
  343. ),
  344. ),
  345. );
  346. }
  347. }