diff --git a/lib/core/constants/api_constants.dart b/lib/core/constants/api_constants.dart index 17ed2a2..580bf60 100644 --- a/lib/core/constants/api_constants.dart +++ b/lib/core/constants/api_constants.dart @@ -27,6 +27,7 @@ class ApiConstants { // CMS static const String cmsPageLanding = '/cms/page/landing'; + static const String cmsPageContact = '/cms/page/contact'; // Messages static const String conversations = '/messages/conversations'; diff --git a/lib/features/contact/presentation/screens/contact_screen.dart b/lib/features/contact/presentation/screens/contact_screen.dart index b5dd69d..440cfe8 100644 --- a/lib/features/contact/presentation/screens/contact_screen.dart +++ b/lib/features/contact/presentation/screens/contact_screen.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:go_router/go_router.dart'; +import 'package:real_estate_mobile/core/constants/api_constants.dart'; import 'package:real_estate_mobile/core/constants/app_colors.dart'; +import 'package:real_estate_mobile/core/network/api_client.dart'; class ContactScreen extends StatefulWidget { const ContactScreen({super.key}); @@ -17,6 +19,48 @@ class _ContactScreenState extends State { final _messageController = TextEditingController(); bool _isSending = false; + // CMS data with defaults + String _contactEmail = '123support@gmail.com'; + String _contactPhone = '1234567890'; + String _contactPhoneHours = 'Mon-Fri 9am-6pm'; + String _contactOfficeAddress = '123 Market Street'; + String _contactOfficeCity = 'New York CA 234737'; + String _pageTitle = 'Get In Touch'; + String _pageDescription = 'Have a question about a property or need assistance? Fill out the form below and our team will get back to you shortly.'; + + @override + void initState() { + super.initState(); + _loadContactCms(); + } + + Future _loadContactCms() async { + try { + final dio = ApiClient.instance.dio; + final response = await dio.get(ApiConstants.cmsPageContact); + final data = response.data['data'] as List?; + if (data == null) return; + + for (final section in data) { + final sectionKey = section['sectionKey'] as String?; + final content = section['content'] as Map?; + if (sectionKey == 'contactDetails' && content != null) { + setState(() { + _contactEmail = content['email'] as String? ?? _contactEmail; + _contactPhone = content['phone'] as String? ?? _contactPhone; + _contactPhoneHours = content['phoneHours'] as String? ?? _contactPhoneHours; + _contactOfficeAddress = content['officeAddress'] as String? ?? _contactOfficeAddress; + _contactOfficeCity = content['officeCity'] as String? ?? _contactOfficeCity; + _pageTitle = content['title'] as String? ?? _pageTitle; + _pageDescription = content['description'] as String? ?? _pageDescription; + }); + } + } + } catch (_) { + // Use defaults on error + } + } + @override void dispose() { _nameController.dispose(); @@ -77,10 +121,10 @@ class _ContactScreenState extends State { // -- Title -- Widget _buildTitle() { - return const Center( + return Center( child: Text( - 'Get In Touch', - style: TextStyle( + _pageTitle, + style: const TextStyle( fontFamily: 'Fractul', fontSize: 25, fontWeight: FontWeight.w700, @@ -92,12 +136,12 @@ class _ContactScreenState extends State { // -- Description -- Widget _buildDescription() { - return const Padding( - padding: EdgeInsets.symmetric(horizontal: 20), + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), child: Text( - 'Have a question about a property or need assistance? Fill out the form below and our team will get back to you shortly.', + _pageDescription, textAlign: TextAlign.center, - style: TextStyle( + style: const TextStyle( fontFamily: 'SourceSerif4', fontSize: 14, fontWeight: FontWeight.w400, @@ -365,22 +409,22 @@ class _ContactScreenState extends State { _buildContactDetailRow( svgIcon: 'assets/icons/email_orange_icon.svg', label: 'Email Support', - value: '123support@gmail.com', + value: _contactEmail, ), _buildDetailDivider(), // Phone _buildContactDetailRow( svgIcon: 'assets/icons/phone_orange_icon.svg', label: 'Phone', - value: '1234567890', - subtitle: 'Mon-Fri 9am-6pm', + value: _contactPhone, + subtitle: _contactPhoneHours, ), _buildDetailDivider(), // Office _buildContactDetailRow( svgIcon: 'assets/icons/location_orange_icon.svg', label: 'Office', - value: '123 Market Street\nNew York CA 234737', + value: '$_contactOfficeAddress\n$_contactOfficeCity', ), const SizedBox(height: 16), // Map image