Доработка действий с билетом
This commit is contained in:
@@ -10,7 +10,6 @@ import 'package:remever/components/extensions/context.dart';
|
|||||||
import 'package:remever/components/extensions/state.dart';
|
import 'package:remever/components/extensions/state.dart';
|
||||||
import 'package:remever/database/database.dart';
|
import 'package:remever/database/database.dart';
|
||||||
import 'package:remever/gen/assets.gen.dart';
|
import 'package:remever/gen/assets.gen.dart';
|
||||||
import 'package:remever/i18n/strings.g.dart';
|
|
||||||
import 'package:remever/inject.dart';
|
import 'package:remever/inject.dart';
|
||||||
import 'package:remever/router.gr.dart';
|
import 'package:remever/router.gr.dart';
|
||||||
import 'package:remever/screens/collections/widgets/collection_progress_bar.dart';
|
import 'package:remever/screens/collections/widgets/collection_progress_bar.dart';
|
||||||
@@ -18,6 +17,7 @@ import 'package:remever/screens/dialogs/dialog_header.dart';
|
|||||||
import 'package:remever/services/tickets/tickets_interface.dart';
|
import 'package:remever/services/tickets/tickets_interface.dart';
|
||||||
import 'package:remever/widgets/primary_button.dart';
|
import 'package:remever/widgets/primary_button.dart';
|
||||||
|
|
||||||
|
/// Диалог для переноса карточки в другую коллекцию
|
||||||
class ReplaceDialog extends StatefulWidget {
|
class ReplaceDialog extends StatefulWidget {
|
||||||
const ReplaceDialog({
|
const ReplaceDialog({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -33,8 +33,10 @@ class ReplaceDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ReplaceDialogState extends State<ReplaceDialog> {
|
class _ReplaceDialogState extends State<ReplaceDialog> {
|
||||||
|
/// Коллекция, в которую будет перенесена карточка
|
||||||
Collection? _collectionToTransfer;
|
Collection? _collectionToTransfer;
|
||||||
|
|
||||||
|
/// Обработчик выбора коллекции
|
||||||
void _onCollectionTap() {
|
void _onCollectionTap() {
|
||||||
context.pushRoute(
|
context.pushRoute(
|
||||||
CollectionSearchRoute(
|
CollectionSearchRoute(
|
||||||
@@ -45,23 +47,29 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTransferTap() async {
|
/// Обработчик кнопки "Перенести"
|
||||||
|
Future<void> _onTransferTap() async {
|
||||||
|
// Проверяем, что выбрана коллекция для переноса
|
||||||
if (_collectionToTransfer == null) {
|
if (_collectionToTransfer == null) {
|
||||||
showErrorToast('Необходимо выбрать место для переноса');
|
showErrorToast('Необходимо выбрать место для переноса');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Проверяем, что выбранная коллекция не совпадает с текущей
|
||||||
if (_collectionToTransfer!.id == widget.currentCollection.id) {
|
if (_collectionToTransfer!.id == widget.currentCollection.id) {
|
||||||
showErrorToast('Карточка итак в этой коллекции, выберете другую');
|
showErrorToast(
|
||||||
|
'Карточка уже находится в этой коллекции, выберите другую',
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Переносим карточку через сервис
|
||||||
await getIt<TicketsInterface>().transferTicket(
|
await getIt<TicketsInterface>().transferTicket(
|
||||||
widget.ticket.id,
|
widget.ticket.id,
|
||||||
_collectionToTransfer!.id,
|
_collectionToTransfer!.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Закрываем диалог
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,19 +78,48 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
return Material(
|
return Material(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: [
|
||||||
const DialogHeader(title: 'Переместить карточку'),
|
const DialogHeader(title: 'Переместить карточку'),
|
||||||
const HSpace(16),
|
const HSpace(16),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 28).r,
|
padding: const EdgeInsets.symmetric(horizontal: 28).r,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: [
|
||||||
AppTypography('из коллекции', type: Medium16px()),
|
AppTypography('из коллекции', type: Medium16px()),
|
||||||
const HSpace(8),
|
const HSpace(8),
|
||||||
_buildCollection(widget.currentCollection),
|
_buildCollection(widget.currentCollection),
|
||||||
const HSpace(16),
|
const HSpace(16),
|
||||||
Center(
|
_buildArrowIcon(),
|
||||||
|
const HSpace(16),
|
||||||
|
AppTypography('в коллекцию', type: Medium16px()),
|
||||||
|
const HSpace(8),
|
||||||
|
_buildCollection(_collectionToTransfer, isSelectable: true),
|
||||||
|
const HSpace(16),
|
||||||
|
_buildTransferButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Кнопка "Перенести"
|
||||||
|
Widget _buildTransferButton() {
|
||||||
|
return PrimaryButton(
|
||||||
|
onTap: _onTransferTap,
|
||||||
|
child: AppTypography(
|
||||||
|
'Перенести',
|
||||||
|
type: Regular14px(),
|
||||||
|
color: AppColors.white,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Иконка стрелки между коллекциями
|
||||||
|
Widget _buildArrowIcon() {
|
||||||
|
return Center(
|
||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
dimension: 34.r,
|
dimension: 34.r,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
@@ -91,42 +128,17 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
color: AppColors.gray,
|
color: AppColors.gray,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Assets.icons.typeArrowDown.image(
|
child: Assets.icons.typeArrowDown.image(height: 18.h, width: 18.w),
|
||||||
height: 18.h,
|
|
||||||
width: 18.w,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
const HSpace(16),
|
|
||||||
AppTypography('в коллекцию', type: Medium16px()),
|
|
||||||
const HSpace(8),
|
|
||||||
_buildCollection(_collectionToTransfer, isSelectable: true),
|
|
||||||
const HSpace(16),
|
|
||||||
_buildTransferButton(context),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildTransferButton(BuildContext context) {
|
|
||||||
return PrimaryButton(
|
|
||||||
child: AppTypography(
|
|
||||||
'Перенести',
|
|
||||||
type: Regular14px(),
|
|
||||||
color: AppColors.white,
|
|
||||||
),
|
|
||||||
onTap: () => _onTransferTap(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Виджет отображения коллекции
|
||||||
Widget _buildCollection(Collection? collection, {bool isSelectable = false}) {
|
Widget _buildCollection(Collection? collection, {bool isSelectable = false}) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: isSelectable ? () => _onCollectionTap() : null,
|
onTap: isSelectable ? _onCollectionTap : null,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: BoxConstraints(minHeight: 66.h, maxHeight: 84.h),
|
constraints: BoxConstraints(minHeight: 66.h, maxHeight: 84.h),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -143,7 +155,7 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
children: <Widget>[
|
children: [
|
||||||
_buildAvatar(collection),
|
_buildAvatar(collection),
|
||||||
const WSpace(5),
|
const WSpace(5),
|
||||||
_buildInfo(collection),
|
_buildInfo(collection),
|
||||||
@@ -153,16 +165,14 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
/// Информация о коллекции
|
||||||
/// Построение основной информации
|
|
||||||
///
|
|
||||||
Widget _buildInfo(Collection collection) {
|
Widget _buildInfo(Collection collection) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 230.w,
|
width: 230.w,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: [
|
||||||
_buildTitle(collection),
|
_buildTitle(collection),
|
||||||
const HSpace(4),
|
const HSpace(4),
|
||||||
Row(
|
Row(
|
||||||
@@ -174,7 +184,7 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
),
|
),
|
||||||
const WSpace(2),
|
const WSpace(2),
|
||||||
AppTypography(
|
AppTypography(
|
||||||
'${collection.likesCount.toString()} ${Utils.declOfNum(collection.likesCount, ['карточек', 'карточки', 'карточек'])}',
|
'${collection.likesCount} ${Utils.declOfNum(collection.likesCount, ['карточек', 'карточки', 'карточек'])}',
|
||||||
type: Regular14px(),
|
type: Regular14px(),
|
||||||
color: AppColors.disabled,
|
color: AppColors.disabled,
|
||||||
),
|
),
|
||||||
@@ -187,9 +197,7 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Название коллекции
|
/// Название коллекции
|
||||||
///
|
|
||||||
Widget _buildTitle(Collection collection) {
|
Widget _buildTitle(Collection collection) {
|
||||||
return AppTypography(
|
return AppTypography(
|
||||||
collection.title,
|
collection.title,
|
||||||
@@ -199,9 +207,7 @@ class _ReplaceDialogState extends State<ReplaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
|
||||||
/// Обложка коллекции
|
/// Обложка коллекции
|
||||||
///
|
|
||||||
Widget _buildAvatar(Collection collection) {
|
Widget _buildAvatar(Collection collection) {
|
||||||
return SizedBox.square(
|
return SizedBox.square(
|
||||||
dimension: 50.r,
|
dimension: 50.r,
|
||||||
|
|||||||
Reference in New Issue
Block a user