Finish screen - attention message added

This commit is contained in:
2026-09-14 08:42:25 +03:00
parent 5f57af2ad2
commit 7460408784

View File

@@ -81,7 +81,6 @@ class _SendPhotoViewState extends State<SendPhotoView> {
); );
} }
// ✅ Метод для получения изображения из выбранного источника
Future<void> _getImage(ImageSource source) async { Future<void> _getImage(ImageSource source) async {
final XFile? pickedFile = await _imagePicker.pickImage( final XFile? pickedFile = await _imagePicker.pickImage(
source: source, source: source,
@@ -96,14 +95,12 @@ class _SendPhotoViewState extends State<SendPhotoView> {
} }
} }
// Метод для удаления конкретного фото
void _removeImage(String path) { void _removeImage(String path) {
final currentImages = context.read<SendPhotoBloc>().state.selectedImages; final currentImages = context.read<SendPhotoBloc>().state.selectedImages;
final updatedList = currentImages.where((p) => p != path).toList(); final updatedList = currentImages.where((p) => p != path).toList();
context.read<SendPhotoBloc>().add(PhotoSelected(updatedList)); context.read<SendPhotoBloc>().add(PhotoSelected(updatedList));
} }
// ✅ Динамический заголовок в зависимости от количества фото
String _getTopText(int photoCount) { String _getTopText(int photoCount) {
if (photoCount == 0) { if (photoCount == 0) {
return 'Для завершения аренды\nсфотографируйте самокат'; return 'Для завершения аренды\nсфотографируйте самокат';
@@ -129,94 +126,149 @@ class _SendPhotoViewState extends State<SendPhotoView> {
child: SafeArea( child: SafeArea(
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 16), const SizedBox(height: 16),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: CustomAppBar(title: "Отправить фото"), child: CustomAppBar(title: "Отправить фото"),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 100),
child: Text(
_getTopText(context.select((SendPhotoBloc bloc) => bloc.state.selectedImages.length)),
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
height: 1.4,
), ),
), Padding(
), padding: const EdgeInsets.symmetric(
horizontal: 20,
// Основной контент центрируем vertical: 60,
Expanded( ),
child: Center( child: Text(
child: SingleChildScrollView( _getTopText(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), context.select(
child: Column( (SendPhotoBloc bloc) =>
mainAxisAlignment: MainAxisAlignment.center, bloc.state.selectedImages.length,
children: [
BlocBuilder<SendPhotoBloc, SendPhotoState>(
builder: (context, state) {
final photoCount = state.selectedImages.length;
return Wrap(
spacing: 16,
runSpacing: 16,
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
// Список выбранных фото
...state.selectedImages.map((path) => _buildPhotoThumbnail(path)),
const SizedBox(height: 35),
// Кнопка "Добавить", если фото меньше лимита (например, 5)
if (photoCount < 2)
GestureDetector(
onTap: _pickImage,
child: _buildAddButton(),
),
],
);
},
), ),
const SizedBox(height: 200), ),
textAlign: TextAlign.center,
// Кнопка отправки style: const TextStyle(
BlocConsumer<SendPhotoBloc, SendPhotoState>( color: Colors.white,
listener: (context, state) { fontSize: 20,
if (state.status == SendPhotoStatus.success) { fontWeight: FontWeight.bold,
context.go('/home/checkout/${widget.orderId}', extra: state.recievedPhotoIds); height: 1.4,
} else if (state.status == SendPhotoStatus.failure) { ),
ScaffoldMessenger.of(context).showSnackBar( ),
SnackBar(content: Text(state.errorMessage ?? 'Ошибка')), ),
);
} // Основной контент центрируем
}, Expanded(
builder: (context, state) { child: Center(
final photoCount = state.selectedImages.length; child: SingleChildScrollView(
final isEnabled = photoCount >= 2 && padding: const EdgeInsets.symmetric(
state.status != SendPhotoStatus.loading; horizontal: 20,
vertical: 20,
return GradientButton( ),
text: 'Отправить', child: Column(
onTap: isEnabled mainAxisAlignment: MainAxisAlignment.center,
? () => context.read<SendPhotoBloc>().add(PhotoUploadSubmitted(widget.orderId)) children: [
: null, // ... inside SingleChildScrollView -> Column children:
enabled: isEnabled, BlocBuilder<SendPhotoBloc, SendPhotoState>(
showArrows: true, builder: (context, state) {
height: 56, final photoCount = state.selectedImages.length;
width: double.infinity,
fontSize: 16, return Wrap(
); spacing: 16,
}, runSpacing: 16,
), alignment: WrapAlignment.center,
], crossAxisAlignment: WrapCrossAlignment.center,
children: [
// Список выбранных фото
...state.selectedImages.map(
(path) => _buildPhotoThumbnail(path),
),
const SizedBox(height: 35),
// Кнопка "Добавить", если фото меньше лимита
if (photoCount < 2)
GestureDetector(
onTap: _pickImage,
child: _buildAddButton(),
),
],
);
},
),
const SizedBox(height: 100),
// Информационный блок под кнопкой добавления фото
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 14,
),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.25),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withOpacity(0.08),
width: 1,
),
),
child: const Text(
'Перед завершением поездки убедитесь, что Вы находитесь в зоне завершения поездки фиолетового цвета.',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 14,
height: 1.4,
),
),
),
const SizedBox(
height: 40,
), // Уменьшено со 200 для гармоничного отступа
// Кнопка отправки
BlocConsumer<SendPhotoBloc, SendPhotoState>(
listener: (context, state) {
if (state.status == SendPhotoStatus.success) {
context.go(
'/home/checkout/${widget.orderId}',
extra: state.recievedPhotoIds,
);
} else if (state.status ==
SendPhotoStatus.failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
state.errorMessage ?? 'Ошибка',
),
),
);
}
},
builder: (context, state) {
final photoCount = state.selectedImages.length;
final isEnabled =
photoCount >= 2 &&
state.status != SendPhotoStatus.loading;
return GradientButton(
text: 'Отправить',
onTap: isEnabled
? () => context.read<SendPhotoBloc>().add(
PhotoUploadSubmitted(widget.orderId),
)
: null,
enabled: isEnabled,
showArrows: true,
height: 56,
width: double.infinity,
fontSize: 16,
);
},
),
],
),
),
), ),
), ),
),
),
], ],
), ),
), ),
@@ -232,9 +284,7 @@ class _SendPhotoViewState extends State<SendPhotoView> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
CircularProgressIndicator( CircularProgressIndicator(color: Color(0xFF8BFFAA)),
color: Color(0xFF8BFFAA),
),
SizedBox(height: 16), SizedBox(height: 16),
Text( Text(
'Загружаем фото...', 'Загружаем фото...',
@@ -270,15 +320,12 @@ class _SendPhotoViewState extends State<SendPhotoView> {
color: Colors.black.withOpacity(0.1), color: Colors.black.withOpacity(0.1),
blurRadius: 8, blurRadius: 8,
offset: const Offset(0, 4), offset: const Offset(0, 4),
) ),
], ],
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
child: Image.file( child: Image.file(File(path), fit: BoxFit.cover),
File(path),
fit: BoxFit.cover,
),
), ),
), ),
// Кнопка удаления (крестик) // Кнопка удаления (крестик)
@@ -338,11 +385,7 @@ class _SendPhotoViewState extends State<SendPhotoView> {
], ],
), ),
child: const Center( child: const Center(
child: Icon( child: Icon(Icons.add, size: 32, color: Colors.white),
Icons.add,
size: 32,
color: Colors.white,
),
), ),
); );
} }