Skip to content

Commit

Permalink
fix: Contact Form issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wizlif committed Oct 24, 2022
1 parent 4fc62df commit e8790c4
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 134 deletions.
19 changes: 10 additions & 9 deletions lib/presentation/contact_form/contact_form_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ class ContactFormPageState extends State<ContactFormPage> {
extendBodyBehindAppBar: true,
appBar: const CustomAppBar(),
backgroundColor: kSecondaryColor,
body: ScrollConfiguration(
behavior: NoRippleBehavior(),
child: SingleChildScrollView(
controller: _pageScrollController,
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 100.0,
horizontal: 20.0,
body: SafeArea(
child: ScrollConfiguration(
behavior: NoRippleBehavior(),
child: SingleChildScrollView(
controller: _pageScrollController,
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.0,
),
child: ContactForm(),
),
child: ContactForm(),
),
),
),
Expand Down
244 changes: 121 additions & 123 deletions lib/presentation/contact_form/widgets/contact_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,145 +35,143 @@ class _ContactFormState extends State<ContactForm> {

@override
Widget build(BuildContext context) {
return Scaffold(
body: BlocConsumer<ContactFormBloc, ContactFormState>(
listener: _contactFormBlocListener,
bloc: _contactFormBloc,
builder: (context, state) {
final isEnabled = state.maybeMap(
initial: (_) => true,
failed: (_) => true,
orElse: () => false,
);
return Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: centerTitle
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
children: [
Text(
"Get in touch",
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 32.0,
),
maxLines: 2,
textAlign: centerTitle ? TextAlign.center : TextAlign.left,
return BlocConsumer<ContactFormBloc, ContactFormState>(
listener: _contactFormBlocListener,
bloc: _contactFormBloc,
builder: (context, state) {
final isEnabled = state.maybeMap(
initial: (_) => true,
failed: (_) => true,
orElse: () => false,
);
return Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: centerTitle
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
children: [
Text(
"Get in touch",
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 32.0,
),
const SizedBox(height: 35.0),
TextFormField(
key: _emailKey,
onChanged: (value) => _emailKey.currentState!.validate(),
enabled: isEnabled,
keyboardType: TextInputType.emailAddress,
style: const TextStyle(fontSize: 20.0),
decoration: InputDecoration(
hintText: 'Your email address',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
maxLines: 2,
textAlign: centerTitle ? TextAlign.center : TextAlign.left,
),
const SizedBox(height: 35.0),
TextFormField(
key: _emailKey,
onChanged: (value) => _emailKey.currentState!.validate(),
enabled: isEnabled,
keyboardType: TextInputType.emailAddress,
style: const TextStyle(fontSize: 20.0),
decoration: InputDecoration(
hintText: 'Your email address',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
validator: (value) => _validateEmail(value),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 0, 0),
child: Row(
children: [
Text(
"We’ll get back to you by email",
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: kPrimaryColor300),
maxLines: 2,
textAlign: TextAlign.left,
),
],
),
validator: (value) => _validateEmail(value),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 0, 0),
child: Row(
children: [
Text(
"We’ll get back to you by email",
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: kPrimaryColor300),
maxLines: 2,
textAlign: TextAlign.left,
),
],
),
const SizedBox(height: 25.0),
TextFormField(
enabled: isEnabled,
keyboardType: TextInputType.multiline,
maxLines: null,
minLines: 5,
decoration: InputDecoration(
hintText: 'Your message to us',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
),
const SizedBox(height: 25.0),
TextFormField(
enabled: isEnabled,
keyboardType: TextInputType.multiline,
maxLines: null,
minLines: 5,
decoration: InputDecoration(
hintText: 'Your message to us',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.transparent,
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
borderSide: const BorderSide(
color: Colors.red,
),
),
validator: _validateMessage,
onChanged: _validateMessage,
),
const SizedBox(height: 35.0),
PillButton(
text: 'Send',
isLoading: state is Submitting,
isEnabled: isEnabled,
onTap: isEnabled ? _submitForm : null,
),
],
),
);
},
),
validator: _validateMessage,
onChanged: _validateMessage,
),
const SizedBox(height: 35.0),
PillButton(
text: 'Send',
isLoading: state is Submitting,
isEnabled: isEnabled,
onTap: isEnabled ? _submitForm : null,
),
],
),
);
},
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/core/routes/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:go_router/go_router.dart';
import '../../../domain/crowdaction/crowdaction.dart';
import '../../auth/auth_screen.dart';
import '../../auth/widgets/verified.dart';
import '../../contact_form/widgets/contact_form.dart';
import '../../contact_form/contact_form_screen.dart';
import '../../crowdaction/crowdaction_browse/crowdaction_browse_screen.dart';
import '../../crowdaction/crowdaction_details/crowdaction_details_screen.dart';
import '../../crowdaction/crowdaction_home/crowdaction_home_screen.dart';
Expand Down Expand Up @@ -123,7 +123,7 @@ class AppRouter {
GoRoute(
path: AppPage.contactForm.toPath,
parentNavigatorKey: _rootNavigatorKey,
builder: (_, __) => const ContactForm(),
builder: (_, __) => const ContactFormPage(),
),
GoRoute(
path: AppPage.webView.toPath,
Expand Down

0 comments on commit e8790c4

Please sign in to comment.