// ignore_for_file: use_build_context_synchronously import 'package:adaptix/adaptix.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; 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'; import 'package:sapaly_shop/constants/utils.dart'; 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'; import 'package:sapaly_shop/features/widgets/sapaly_app_bar.dart'; import 'package:sapaly_shop/features/widgets/unauthenticatedWidget.dart'; import 'package:sapaly_shop/models/settings_model.dart'; import 'package:sapaly_shop/providers/user_provider.dart'; import 'package:url_launcher/url_launcher_string.dart'; import '../../../models/auth/login/login_request_model.dart'; import '../../../themes/app_theme.dart'; class ContactsScreen extends StatefulWidget { const ContactsScreen({super.key}); @override State createState() => _ContactsScreenState(); } class _ContactsScreenState extends State { TextEditingController firstNameController = TextEditingController(); TextEditingController emailController = TextEditingController(); TextEditingController subjectController = TextEditingController(); TextEditingController messageController = TextEditingController(); final GlobalKey _key = GlobalKey(); final AuthService authService = AuthService(); 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, ); } @override Widget build(BuildContext context) { var me = Provider.of(context, listen: false); return Scaffold( drawer: SapalyDrawer(), backgroundColor: AppTheme.lightBackgroundColor, appBar: SapalyAppBar( hasActionButton: true, title: 'contacts'.translation, badge: '2', leadingButton: const Icon( Icons.arrow_back, color: AppTheme.blackColor, ), actionButton: SvgPicture.asset('assets/icons/cart.svg'), leadingOnTap: () { Navigator.of(context).pop(); }, actionOnTap: () {}, ), body: Container( margin: EdgeInsets.symmetric( vertical: GlobalVariables.verticalPadding(context), horizontal: GlobalVariables.horizontalPadding(context), ), child: ScrollConfiguration( behavior: CustomScrollBehavior(), child: ListView( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ CustomTextField( labelText: 'first_name'.translation, hintText: 'first_name'.translation, controller: firstNameController, obscureText: false, inputType: TextInputType.text, isPassword: false, contentPadding: 0, ), 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, ), ), CustomTextField( labelText: 'subject'.translation, hintText: 'subject'.translation, controller: subjectController, obscureText: false, inputType: TextInputType.text, isPassword: false, contentPadding: 0, ), 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(), ), ), ), CustomButton( name: 'send_message'.translation, onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => me.user.token.isEmpty ? const UnAuthenticated() : const HomeScreen(), ), ); }, backgroundColor: AppTheme.lightPrimaryColor, isMain: true, ), 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, ), ), ), 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, ), ), ), 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, ), ), ), SizedBox(height: 10.adaptedPx()), ], ), ); }, ), 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, ), ), ), 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, ), ), ), SizedBox(height: 10.adaptedPx()), ], ), ); }, ), ], ), ), ), ); } }