diff --git a/lib/presentation/screens/send_photo_screen.dart b/lib/presentation/screens/send_photo_screen.dart index d91158b..c57c8f5 100644 --- a/lib/presentation/screens/send_photo_screen.dart +++ b/lib/presentation/screens/send_photo_screen.dart @@ -81,7 +81,6 @@ class _SendPhotoViewState extends State { ); } - // ✅ Метод для получения изображения из выбранного источника Future _getImage(ImageSource source) async { final XFile? pickedFile = await _imagePicker.pickImage( source: source, @@ -96,14 +95,12 @@ class _SendPhotoViewState extends State { } } - // Метод для удаления конкретного фото void _removeImage(String path) { final currentImages = context.read().state.selectedImages; final updatedList = currentImages.where((p) => p != path).toList(); context.read().add(PhotoSelected(updatedList)); } - // ✅ Динамический заголовок в зависимости от количества фото String _getTopText(int photoCount) { if (photoCount == 0) { return 'Для завершения аренды\nсфотографируйте самокат'; @@ -129,94 +126,149 @@ class _SendPhotoViewState extends State { child: SafeArea( child: Column( children: [ - const SizedBox(height: 16), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - 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, + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: CustomAppBar(title: "Отправить фото"), ), - ), - ), - - // Основной контент центрируем - Expanded( - child: Center( - child: SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - BlocBuilder( - 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(), - ), - ], - ); - }, + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 60, + ), + child: Text( + _getTopText( + context.select( + (SendPhotoBloc bloc) => + bloc.state.selectedImages.length, ), - const SizedBox(height: 200), - - // Кнопка отправки - BlocConsumer( - 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().add(PhotoUploadSubmitted(widget.orderId)) - : null, - enabled: isEnabled, - showArrows: true, - height: 56, - width: double.infinity, - fontSize: 16, - ); - }, - ), - ], + ), + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.bold, + height: 1.4, + ), + ), + ), + + // Основной контент центрируем + Expanded( + child: Center( + child: SingleChildScrollView( + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 20, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // ... inside SingleChildScrollView -> Column children: + BlocBuilder( + 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), + + // Кнопка "Добавить", если фото меньше лимита + 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( + 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().add( + PhotoUploadSubmitted(widget.orderId), + ) + : null, + enabled: isEnabled, + showArrows: true, + height: 56, + width: double.infinity, + fontSize: 16, + ); + }, + ), + ], + ), + ), ), ), - ), - ), ], ), ), @@ -232,9 +284,7 @@ class _SendPhotoViewState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - CircularProgressIndicator( - color: Color(0xFF8BFFAA), - ), + CircularProgressIndicator(color: Color(0xFF8BFFAA)), SizedBox(height: 16), Text( 'Загружаем фото...', @@ -270,15 +320,12 @@ class _SendPhotoViewState extends State { color: Colors.black.withOpacity(0.1), blurRadius: 8, offset: const Offset(0, 4), - ) + ), ], ), child: ClipRRect( borderRadius: BorderRadius.circular(16), - child: Image.file( - File(path), - fit: BoxFit.cover, - ), + child: Image.file(File(path), fit: BoxFit.cover), ), ), // Кнопка удаления (крестик) @@ -338,11 +385,7 @@ class _SendPhotoViewState extends State { ], ), child: const Center( - child: Icon( - Icons.add, - size: 32, - color: Colors.white, - ), + child: Icon(Icons.add, size: 32, color: Colors.white), ), ); }