Skip to content

Commit be08189

Browse files
Add ContactViewSection and enhance text fields with maxLines property for better input handling
1 parent 9ce182b commit be08189

File tree

7 files changed

+170
-9
lines changed

7 files changed

+170
-9
lines changed

lib/screens/auth/login_screen.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ class LogInScreen extends StatelessWidget {
7474
),
7575
const SizedBox(height: 30),
7676
const CustomTextField(
77+
maxLines: 1,
7778
hintText: 'Email',
7879
prefixIcon: Icons.mail_outline,
7980
),
8081
const SizedBox(height: 20),
8182
const CustomTextField(
83+
maxLines: 1,
8284
hintText: 'Password',
8385
prefixIcon: Icons.lock_outline,
8486
),
@@ -178,11 +180,13 @@ class LogInScreen extends StatelessWidget {
178180
),
179181
const SizedBox(height: 30),
180182
const CustomTextField(
183+
maxLines: 1,
181184
hintText: 'Email',
182185
prefixIcon: Icons.mail_outline,
183186
),
184187
const SizedBox(height: 20),
185188
const CustomTextField(
189+
maxLines: 1,
186190
hintText: 'Password',
187191
prefixIcon: Icons.lock_outline,
188192
),

lib/screens/auth/sign_up_screen.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,19 @@ class SignUpScreen extends StatelessWidget {
9393
),
9494
const SizedBox(height: 20),
9595
const CustomTextField(
96+
maxLines: 1,
9697
hintText: 'Email',
9798
prefixIcon: Icons.mail_outline,
9899
),
99100
const SizedBox(height: 20),
100101
const CustomTextField(
102+
maxLines: 1,
101103
hintText: 'Password',
102104
prefixIcon: Icons.lock_outline,
103105
),
104106
const SizedBox(height: 20),
105107
const CustomTextField(
108+
maxLines: 1,
106109
hintText: 'Confirm Password',
107110
prefixIcon: Icons.lock_outline,
108111
),
@@ -172,16 +175,19 @@ class SignUpScreen extends StatelessWidget {
172175
),
173176
const SizedBox(height: 20),
174177
const CustomTextField(
178+
maxLines: 1,
175179
hintText: 'Email',
176180
prefixIcon: Icons.mail_outline,
177181
),
178182
const SizedBox(height: 20),
179183
const CustomTextField(
184+
maxLines: 1,
180185
hintText: 'Password',
181186
prefixIcon: Icons.lock_outline,
182187
),
183188
const SizedBox(height: 20),
184189
const CustomTextField(
190+
maxLines: 1,
185191
hintText: 'Confirm Password',
186192
prefixIcon: Icons.lock_outline,
187193
),

lib/screens/main/home_screen.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_responsive_web/screens/view_sections/about_view_section.dart';
3+
import 'package:flutter_responsive_web/screens/view_sections/contact_view_section.dart';
34
import 'package:flutter_responsive_web/screens/view_sections/home_view_section.dart';
45
import 'package:flutter_responsive_web/widgets/custom_app_bar.dart';
56
import 'package:flutter_responsive_web/widgets/custom_drawer.dart';
@@ -51,12 +52,7 @@ class _HomeScreenState extends State<HomeScreen> {
5152
AboutViewSection(divKey: sectionKeys[1]),
5253

5354
/// Contact Section
54-
Container(
55-
key: sectionKeys[2],
56-
height: 600,
57-
color: Colors.purple,
58-
child: Center(child: Text('Contact Section')),
59-
),
55+
ContactViewSection(divKey: sectionKeys[2]),
6056

6157
/// Privacy Section
6258
Container(
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_responsive_web/widgets/custom_button.dart';
3+
import 'package:flutter_responsive_web/widgets/custom_text_field.dart';
4+
import 'package:responsive_framework/responsive_framework.dart';
5+
6+
class ContactViewSection extends StatelessWidget {
7+
final Key? divKey;
8+
9+
const ContactViewSection({
10+
super.key,
11+
required this.divKey,
12+
});
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
final isResponsive = ResponsiveBreakpoints.of(context).largerThan(TABLET);
17+
18+
return Container(
19+
key: divKey,
20+
padding: EdgeInsets.symmetric(
21+
vertical: 50, horizontal: isResponsive ? 40 : 20),
22+
decoration: BoxDecoration(
23+
gradient: LinearGradient(
24+
colors: [
25+
Colors.blue.shade300,
26+
Colors.blue.shade600,
27+
Colors.blue.shade800,
28+
],
29+
begin: Alignment.topCenter,
30+
end: Alignment.bottomCenter,
31+
),
32+
),
33+
child: Column(
34+
crossAxisAlignment: CrossAxisAlignment.center,
35+
children: [
36+
Text(
37+
'Get In Touch',
38+
style: TextStyle(
39+
fontSize: isResponsive ? 40 : 36,
40+
fontWeight: FontWeight.bold,
41+
color: Colors.white,
42+
),
43+
textAlign: TextAlign.center,
44+
),
45+
const SizedBox(height: 20),
46+
Text(
47+
'We would love to hear from you! Feel free to reach out using the form below.',
48+
style: TextStyle(
49+
fontSize: isResponsive ? 20 : 18, color: Colors.white70),
50+
textAlign: TextAlign.center,
51+
),
52+
const SizedBox(height: 40),
53+
isResponsive
54+
? Row(
55+
mainAxisAlignment: MainAxisAlignment.center,
56+
children: [
57+
Expanded(child: _buildContactForm(isResponsive)),
58+
const SizedBox(width: 40),
59+
Expanded(child: _buildContactInfo(isResponsive)),
60+
],
61+
)
62+
: Column(
63+
children: [
64+
_buildContactForm(isResponsive),
65+
const SizedBox(height: 30),
66+
_buildContactInfo(isResponsive),
67+
],
68+
),
69+
],
70+
),
71+
);
72+
}
73+
74+
Widget _buildContactForm(bool isResponsive) {
75+
return Container(
76+
width: isResponsive ? 500 : double.infinity,
77+
padding: const EdgeInsets.all(20),
78+
decoration: BoxDecoration(
79+
color: Colors.white,
80+
borderRadius: BorderRadius.circular(12),
81+
boxShadow: [
82+
BoxShadow(
83+
color: Colors.black.withOpacity(0.1),
84+
blurRadius: 10,
85+
offset: const Offset(0, 4),
86+
),
87+
],
88+
),
89+
child: Column(
90+
crossAxisAlignment: CrossAxisAlignment.start,
91+
children: [
92+
CustomTextField(
93+
hintText: 'Your Name',
94+
prefixIcon: Icons.person_outline,
95+
),
96+
const SizedBox(height: 20),
97+
CustomTextField(
98+
hintText: 'Your Email',
99+
prefixIcon: Icons.email_outlined,
100+
),
101+
const SizedBox(height: 20),
102+
CustomTextField(
103+
hintText: 'Your Message',
104+
prefixIcon: Icons.message_outlined,
105+
),
106+
const SizedBox(height: 20),
107+
SizedBox(
108+
width: double.infinity,
109+
child: CustomButton(title: 'Send Message', onPressed: () {})),
110+
],
111+
),
112+
);
113+
}
114+
115+
Widget _buildContactInfo(bool isResponsive) {
116+
return Container(
117+
width: isResponsive ? 300 : double.infinity,
118+
padding: const EdgeInsets.all(20),
119+
decoration: BoxDecoration(
120+
color: Colors.white,
121+
borderRadius: BorderRadius.circular(12),
122+
boxShadow: [
123+
BoxShadow(
124+
color: Colors.black.withOpacity(0.1),
125+
blurRadius: 10,
126+
offset: const Offset(0, 4),
127+
),
128+
],
129+
),
130+
child: Column(
131+
crossAxisAlignment: CrossAxisAlignment.start,
132+
children: [
133+
Text(
134+
'You can also reach us at:',
135+
style:
136+
TextStyle(fontSize: isResponsive ? 20 : 18, color: Colors.teal),
137+
),
138+
const SizedBox(height: 10),
139+
Text(
140+
'Email: contact@example.com | Phone: +123 456 7890',
141+
style: TextStyle(
142+
fontSize: isResponsive ? 16 : 14, color: Colors.black),
143+
),
144+
],
145+
),
146+
);
147+
}
148+
}

lib/screens/view_sections/home_view_section.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class _HomeViewSectionState extends State<HomeViewSection> {
5151
child: CustomTextField(
5252
hintText: 'Search',
5353
prefixIcon: Icons.search_outlined,
54+
maxLines: 1,
5455
),
5556
),
5657
const SizedBox(width: 10.0),
@@ -69,6 +70,7 @@ class _HomeViewSectionState extends State<HomeViewSection> {
6970
CustomTextField(
7071
hintText: 'Search',
7172
prefixIcon: Icons.search_outlined,
73+
maxLines: 1,
7274
),
7375
],
7476
const SizedBox(height: 20.0),

lib/widgets/custom_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class CustomButton extends StatelessWidget {
77
const CustomButton({
88
super.key,
99
required this.title,
10-
this.onPressed,
10+
required this.onPressed,
1111
});
1212

1313
@override

lib/widgets/custom_text_field.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ import 'package:flutter/material.dart';
33
class CustomTextField extends StatelessWidget {
44
final String hintText;
55
final IconData prefixIcon;
6+
final int? maxLines;
67

78
const CustomTextField({
89
super.key,
910
required this.hintText,
1011
required this.prefixIcon,
12+
this.maxLines,
1113
});
1214

1315
@override
1416
Widget build(BuildContext context) {
15-
return TextFormField(
17+
return TextField(
18+
maxLines: maxLines ?? 1,
1619
decoration: InputDecoration(
17-
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
1820
hintText: hintText,
1921
prefixIcon: Icon(prefixIcon),
22+
border: OutlineInputBorder(
23+
borderRadius: BorderRadius.circular(10.0),
24+
),
2025
),
2126
);
2227
}

0 commit comments

Comments
 (0)