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.
139 lines
6.2 KiB
Dart
139 lines
6.2 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/int_extensions.dart';
|
|
import 'package:tangheem/extensions/string_extensions.dart';
|
|
import 'package:tangheem/extensions/widget_extensions.dart';
|
|
import 'package:tangheem/widgets/common_textfield_widget.dart';
|
|
import 'package:tangheem/widgets/new/CommonHeader.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) {
|
|
if (mounted) Utils.handleException(ex, null);
|
|
Utils.hideLoading(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
bool isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
|
|
|
|
return Scaffold(
|
|
backgroundColor: ColorConsts.greyF4Color,
|
|
body: SingleChildScrollView(
|
|
physics: BouncingScrollPhysics(),
|
|
child: Column(
|
|
children: [
|
|
CommonHeader("اتصل بنا", "assets/icons/new/contact_bg.jpg", Color(0xff416A6C)),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
"نسعد بتواصلكم بالمساهمة في تطوير المشروع وطرح المقترحات التي حقق جودته. الرجاء تعبئة البيانات لكي تصل إلينا بشكل مناسب، وسيتم التواصل معكم في أقرب وقت ممكن."
|
|
.toText(13, color: ColorConsts.darkText, textAlign: TextAlign.center),
|
|
32.height,
|
|
CommonTextFieldWidget(hint: "الاسم الأول", controller: _firstNameController, fillColor: Colors.white, isBorder: true),
|
|
8.height,
|
|
CommonTextFieldWidget(hint: "الاسم الأخير", controller: _lastNameController, fillColor: Colors.white, isBorder: true),
|
|
8.height,
|
|
CommonTextFieldWidget(hint: "البريد الإلكتروني", controller: _emailController, fillColor: Colors.white, isBorder: true, isEmail: true),
|
|
8.height,
|
|
CommonTextFieldWidget(hint: " رقم الاتصال${" (" + ("9xx") + " xxxxxxxxx)"}", controller: _mobileNumberController, fillColor: Colors.white, isBorder: true),
|
|
8.height,
|
|
CommonTextFieldWidget(hint: "التفاصيل", controller: _descriptionController, maxLines: 5, fillColor: Colors.white, isBorder: true),
|
|
22.height,
|
|
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 (_mobileNumberController.text.length != 12) {
|
|
Utils.showToast("صيغة الرقم غير صحيحة");
|
|
return;
|
|
}
|
|
if (_descriptionController.text.length < 1) {
|
|
Utils.showToast("يرجى إدخال التفاصيل");
|
|
return;
|
|
}
|
|
if (_descriptionController.text.trim().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(
|
|
backgroundColor: ColorConsts.darkText,
|
|
foregroundColor: Colors.white,
|
|
textStyle: TextStyle(fontSize: 18),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(25.0),
|
|
),
|
|
),
|
|
child: Text("إرسال"),
|
|
),
|
|
),
|
|
],
|
|
).paddingAll(35),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|