From 43cae32cf133670ce85bf463da232f55853c325c Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Sun, 31 Mar 2019 23:43:26 -0600 Subject: [PATCH] Added methods to allow the new task screen to update the blocs properties, revised --- lib/src/blocs/new_task_bloc.dart | 8 ++++++++ lib/src/screens/new_task_screen.dart | 7 ++++--- lib/src/widgets/big_text_input.dart | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/src/blocs/new_task_bloc.dart b/lib/src/blocs/new_task_bloc.dart index da3dee8..e575ebb 100644 --- a/lib/src/blocs/new_task_bloc.dart +++ b/lib/src/blocs/new_task_bloc.dart @@ -18,6 +18,14 @@ class NewTaskBloc { setCurrentUser(); } + void setText(String newText) { + text = newText; + } + + void setPriority(TaskPriority newPriority) { + priority = newPriority; + } + Future setCurrentUser() async { final user = await _auth.currentUser; currentUser = user; diff --git a/lib/src/screens/new_task_screen.dart b/lib/src/screens/new_task_screen.dart index aebb74c..406489a 100644 --- a/lib/src/screens/new_task_screen.dart +++ b/lib/src/screens/new_task_screen.dart @@ -37,6 +37,7 @@ class _NewTaskScreenState extends State { children: [ BigTextInput( height: 95, + onChanged: bloc.setText, ), SizedBox( height: 15, @@ -45,7 +46,7 @@ class _NewTaskScreenState extends State { SizedBox( height: 15, ), - buildPrioritySelectorSection(), + buildPrioritySelectorSection(bloc), SizedBox( height: 20, ), @@ -90,7 +91,7 @@ class _NewTaskScreenState extends State { ); } - Widget buildPrioritySelectorSection() { + Widget buildPrioritySelectorSection(NewTaskBloc bloc) { return Row( children: [ Text( @@ -99,7 +100,7 @@ class _NewTaskScreenState extends State { ), Spacer(), PrioritySelector( - onChage: (priority) {}, + onChage: bloc.setPriority, width: 230, ), ], diff --git a/lib/src/widgets/big_text_input.dart b/lib/src/widgets/big_text_input.dart index cf6d14d..cd6bef1 100644 --- a/lib/src/widgets/big_text_input.dart +++ b/lib/src/widgets/big_text_input.dart @@ -4,8 +4,10 @@ class BigTextInput extends StatelessWidget { final double height; final double width; final bool elevated; + final Function(String) onChanged; BigTextInput({ + @required this.onChanged, this.height, this.width, this.elevated = true, @@ -27,6 +29,7 @@ class BigTextInput extends StatelessWidget { borderRadius: BorderRadius.circular(8.0), ), child: TextField( + onChanged: onChanged, maxLines: 3, maxLength: 220, maxLengthEnforced: true,