sapaly_store/lib/features/screens/drawer/contacts.dart

316 lines
12 KiB
Dart
Raw Normal View History

2023-03-11 00:07:28 +00:00
// ignore_for_file: use_build_context_synchronously
import 'package:adaptix/adaptix.dart';
2023-03-02 03:04:51 +00:00
import 'package:flutter/material.dart';
2023-03-11 00:07:28 +00:00
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
2023-03-11 00:07:28 +00:00
import 'package:sapaly_shop/common/custom_button.dart';
import 'package:sapaly_shop/common/widgets/custom_text_field.dart';
import 'package:sapaly_shop/constants/global_variables.dart';
2023-03-13 13:06:30 +00:00
import 'package:sapaly_shop/constants/utils.dart';
2023-03-12 12:11:41 +00:00
import 'package:sapaly_shop/features/screens/drawer/sapaly_drawer.dart';
import 'package:sapaly_shop/features/screens/home/home_screen.dart';
import 'package:sapaly_shop/features/services/auth_service.dart';
2023-03-11 00:07:28 +00:00
import 'package:sapaly_shop/features/widgets/sapaly_app_bar.dart';
import 'package:sapaly_shop/features/widgets/unauthenticatedWidget.dart';
2023-03-11 00:07:28 +00:00
import 'package:sapaly_shop/models/settings_model.dart';
import 'package:sapaly_shop/providers/user_provider.dart';
2023-03-11 00:07:28 +00:00
import 'package:url_launcher/url_launcher_string.dart';
import '../../../models/auth/login/login_request_model.dart';
2023-03-11 00:07:28 +00:00
import '../../../themes/app_theme.dart';
2023-03-02 03:04:51 +00:00
2023-03-11 00:07:28 +00:00
class ContactsScreen extends StatefulWidget {
2023-03-02 03:04:51 +00:00
const ContactsScreen({super.key});
2023-03-11 00:07:28 +00:00
@override
State<ContactsScreen> createState() => _ContactsScreenState();
}
class _ContactsScreenState extends State<ContactsScreen> {
TextEditingController firstNameController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController subjectController = TextEditingController();
TextEditingController messageController = TextEditingController();
final GlobalKey<ScaffoldState> _key = GlobalKey();
final AuthService authService = AuthService();
2023-03-11 00:07:28 +00:00
String number1 = '+993 63721584';
String number2 = '25-53-19';
String mail1 = 'enquery@gmail.com';
String mail2 = 'help@yourdomain.com';
void sendMessage() {
debugPrint('EMAIL ${emailController.text}');
authService.sendMessage(
loginRequestModel: LoginRequestModel(
email: emailController.text,
password: messageController.text,
),
context: context,
);
}
2023-03-02 03:04:51 +00:00
@override
Widget build(BuildContext context) {
var me = Provider.of<UserProvider>(context, listen: false);
2023-03-02 03:04:51 +00:00
return Scaffold(
2023-03-12 12:11:41 +00:00
drawer: SapalyDrawer(),
2023-03-11 00:07:28 +00:00
backgroundColor: AppTheme.lightBackgroundColor,
appBar: SapalyAppBar(
hasActionButton: true,
title: 'contacts'.translation,
badge: '2',
2023-03-12 20:03:30 +00:00
leadingButton: const Icon(
Icons.arrow_back,
color: AppTheme.blackColor,
),
2023-03-11 00:07:28 +00:00
actionButton: SvgPicture.asset('assets/icons/cart.svg'),
leadingOnTap: () {
2023-03-12 20:03:30 +00:00
Navigator.of(context).pop();
2023-03-11 00:07:28 +00:00
},
actionOnTap: () {},
),
body: Container(
margin: EdgeInsets.symmetric(
vertical: GlobalVariables.verticalPadding(context),
horizontal: GlobalVariables.horizontalPadding(context),
),
2023-03-13 13:06:30 +00:00
child: ScrollConfiguration(
behavior: CustomScrollBehavior(),
child: ListView(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomTextField(
labelText: 'first_name'.translation,
hintText: 'first_name'.translation,
controller: firstNameController,
2023-03-11 00:07:28 +00:00
obscureText: false,
inputType: TextInputType.text,
isPassword: false,
2023-03-13 13:06:30 +00:00
contentPadding: 0,
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
Padding(
padding: EdgeInsets.symmetric(
vertical: GlobalVariables.verticalPadding(context),
),
child: CustomTextField(
labelText: 'email'.translation,
hintText: 'email'.translation,
controller: emailController,
obscureText: false,
inputType: TextInputType.emailAddress,
isPassword: false,
contentPadding: 0,
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
CustomTextField(
labelText: 'subject'.translation,
hintText: 'subject'.translation,
controller: subjectController,
obscureText: false,
inputType: TextInputType.text,
isPassword: false,
contentPadding: 0,
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
Padding(
padding: EdgeInsets.symmetric(
vertical: GlobalVariables.verticalPadding(context),
),
child: SizedBox(
height: GlobalVariables.deviceHeight(context) / 6,
child: CustomTextField(
labelText: 'message'.translation,
hintText: 'message'.translation,
controller: messageController,
obscureText: false,
inputType: TextInputType.text,
isPassword: false,
contentPadding: 100.adaptedPx(),
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
CustomButton(
name: 'send_message'.translation,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => me.user.token.isEmpty
? const UnAuthenticated()
: const HomeScreen(),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
);
},
backgroundColor: AppTheme.lightPrimaryColor,
isMain: true,
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
ListTile(
leading: const Icon(
Icons.location_on_outlined,
color: AppTheme.lightPrimaryColor,
),
title: Text(
'our_location'.translation,
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
subtitle: Text(
'Turkmenistan, Ashgabat city, Galkynysh, street 66(old printing house)',
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.blackColor,
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
ListTile(
leading: const Icon(
Icons.email_outlined,
color: AppTheme.lightPrimaryColor,
),
title: Text(
'email'.translation,
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
subtitle: Text(
'enquery@gmail.com help@yourdomain.com',
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.blackColor,
),
),
onTap: () {
showModalBottomSheet(
context: context,
builder: (context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 10.adaptedPx()),
TextButton(
onPressed: () async {
if (await canLaunchUrlString("mailto:$mail1")) {
await launchUrlString("mailto:$mail1");
}
Navigator.of(context).pop();
},
child: Text(
mail1,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium!
.copyWith(
fontSize: 20.adaptedPx(),
color: AppTheme.blackColor,
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
SizedBox(height: 10.adaptedPx()),
TextButton(
onPressed: () async {
if (await canLaunchUrlString("mailto:$mail2")) {
await launchUrlString("mailto:$mail2");
}
Navigator.of(context).pop();
},
child: Text(
mail2,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium!
.copyWith(
fontSize: 20.adaptedPx(),
color: AppTheme.blackColor,
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
SizedBox(height: 10.adaptedPx()),
],
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
);
},
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
ListTile(
leading: const Icon(
Icons.phone_outlined,
color: AppTheme.lightPrimaryColor,
),
title: Text(
'contacts'.translation,
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 15.adaptedPx(),
fontWeight: FontWeight.w600,
color: AppTheme.blackColor,
),
),
subtitle: Text(
'$number1 $number2',
style:
Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
fontSize: 13.adaptedPx(),
color: AppTheme.blackColor,
),
),
onTap: () {
showModalBottomSheet(
context: context,
builder: (context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () {
launchUrlString('tel://$number1');
Navigator.of(context).pop();
},
child: Text(
number1,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium!
.copyWith(
fontSize: 20.adaptedPx(),
color: AppTheme.blackColor,
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
SizedBox(height: 10.adaptedPx()),
TextButton(
onPressed: () {
launchUrlString('tel://$number2');
Navigator.of(context).pop();
},
child: Text(
number2,
style: Theme.of(context)
.primaryTextTheme
.bodyMedium!
.copyWith(
fontSize: 20.adaptedPx(),
color: AppTheme.blackColor,
),
),
2023-03-11 00:07:28 +00:00
),
2023-03-13 13:06:30 +00:00
SizedBox(height: 10.adaptedPx()),
],
),
);
},
),
],
),
2023-03-11 00:07:28 +00:00
),
),
2023-03-02 03:04:51 +00:00
);
}
}