import 'package:comwell_key_app/contact/cubit/contact_cubit.dart';
import 'package:comwell_key_app/presentation/screens/profile_settings/components/intl_phone_field.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class GetAPhoneCallSection extends StatelessWidget {
const GetAPhoneCallSection({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final cubit = context.read<ContactCubit>();
final contactState = context.watch<ContactCubit>().state;
if (contactState == const ContactState.contactSend()) {
return _ReceivedCard(theme: theme);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.strings.get_a_call, style: theme.textTheme.headlineMedium),
const SizedBox(height: 8),
Text(context.strings.get_a_call_description, style: theme.textTheme.bodySmall),
const SizedBox(height: 8),
Text(context.strings.telephone_number, style: theme.textTheme.labelLarge),
IntlPhoneField(
readOnly: false,
title: context.strings.telephone_number,
phoneNumber: cubit.phoneNumber,
countryCode: cubit.countryCode,
controller: cubit.phoneNumberController,
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 0),
child: ElevatedButton(
onPressed: () async {
await cubit.sendContact(cubit.phoneNumber);
},
child: Text(
context.strings.get_a_call,
style:
theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
),
),
),
],
);
}
}
class _ReceivedCard extends StatelessWidget {
final ThemeData theme;
const _ReceivedCard({required this.theme});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.strings.get_a_call, style: theme.textTheme.headlineMedium),
const SizedBox(height: 8),
Text(context.strings.get_a_call_description, style: theme.textTheme.bodySmall),
const SizedBox(height: 8),
SizedBox(
height: 132,
width: double.infinity,
child: Card(
margin: EdgeInsets.zero,
elevation: 0,
color: theme.colorScheme.surfaceContainerLow,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 36.0, vertical: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(context.strings.call_received_title,
style: theme.textTheme.headlineSmall),
const SizedBox(height: 10),
Text(
context.strings.call_received_description,
textAlign: TextAlign.center,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.surfaceTint,
),
),
],
),
),
),
),
],
);
}
}