wachtwoord_vergeten_widget.dart 14 KB

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