You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tangheem/lib/ui/screens/contact_us_screen.dart

155 lines
6.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:tangheem/api/tangheem_user_api_client.dart';
import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/utils.dart';
import 'package:tangheem/extensions/string_extensions.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart';
class ContactUsScreen extends StatefulWidget {
static const String routeName = "/contact_us";
ContactUsScreen({Key key}) : super(key: key);
@override
_ContactUsScreenState createState() {
return _ContactUsScreenState();
}
}
class _ContactUsScreenState extends State<ContactUsScreen> {
TextEditingController _firstNameController = TextEditingController();
TextEditingController _lastNameController = TextEditingController();
TextEditingController _emailController = TextEditingController();
TextEditingController _mobileNumberController = TextEditingController();
TextEditingController _descriptionController = TextEditingController();
@override
void initState() {
super.initState();
}
void sendFeedback(String _firstName, String _lastName, String _email, String _phone, String _description) async {
Utils.showLoading(context);
try {
await TangheemUserApiClient().contactUs(_firstName, _lastName, _email, _phone, _description);
Utils.showToast("شكرا لك على مراسلتنا ، نحن نقدر كلماتك.");
Utils.hideLoading(context);
Navigator.pop(context);
} catch (ex, tr) {
Utils.handleException(ex, null);
Utils.hideLoading(context);
}
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ColorConsts.secondaryWhite,
body: SingleChildScrollView(
padding: EdgeInsets.all(32.0),
physics: BouncingScrollPhysics(),
child: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8.0), color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.only(top: 24, bottom: 24),
child: SvgPicture.asset("assets/logos/tangheem_logo.svg", width: 100, height: 100),
),
Text(
"اتصل بنا",
style: TextStyle(fontSize: 22, color: ColorConsts.primaryBlue),
),
Padding(
padding: EdgeInsets.all(8),
child: Text(
"لا تتردد في الاتصال بنا ، يسعدنا أن نسمع منك",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue, height: 1),
),
),
Container(
margin: EdgeInsets.only(top: 16),
width: double.infinity,
padding: EdgeInsets.all(32.0),
decoration: BoxDecoration(
color: ColorConsts.primaryBlue,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
bottomRight: Radius.circular(8),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CommonTextFieldWidget(hint: "الاسم الاول", controller: _firstNameController),
SizedBox(height: 8),
CommonTextFieldWidget(hint: "اسم النهاية", controller: _lastNameController),
SizedBox(height: 8),
CommonTextFieldWidget(hint: "الايميل", controller: _emailController),
SizedBox(height: 8),
CommonTextFieldWidget(hint: " رقم الجوال${" (" + ("9xx") + " xxxxxxxxx)"}", controller: _mobileNumberController),
SizedBox(height: 8),
CommonTextFieldWidget(hint: "اكتب لنا", controller: _descriptionController, maxLines: 4),
SizedBox(height: 12),
SizedBox(
width: double.infinity,
height: 50,
child: TextButton(
onPressed: () {
if (_firstNameController.text.length < 1) {
Utils.showToast("الاسم الأول فارغ");
return;
}
if (_lastNameController.text.length < 1) {
Utils.showToast("الاسم الأخير فارغ");
return;
}
if (_emailController.text.length < 1) {
Utils.showToast("البريد الإلكتروني فارغ");
return;
}
if (_mobileNumberController.text.length < 1) {
Utils.showToast("رقم الهاتف فارغ");
return;
}
if (_descriptionController.text.length < 1) {
Utils.showToast("يجب أن تكتب لنا كلمات قليلة");
return;
}
if (!_emailController.text.isValidEmail()) {
Utils.showToast("بريد إلكتروني خاطئ");
return;
}
sendFeedback(_firstNameController.text, _lastNameController.text, _emailController.text, _mobileNumberController.text, _descriptionController.text);
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: ColorConsts.secondaryPink,
textStyle: TextStyle(fontSize: 16, fontFamily: "DroidKufi"),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6.0),
),
),
child: Text("ارسل رأيك"),
),
),
],
),
),
],
),
),
),
);
}
}