126 lines
4.3 KiB
Dart
126 lines
4.3 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:remever/common/functions.dart';
|
|
import 'package:remever/common/resources.dart';
|
|
import 'package:remever/common/widgets/bottom_safe_space.dart';
|
|
import 'package:remever/components/extensions/context.dart';
|
|
import 'package:remever/database/database.dart';
|
|
import 'package:remever/gen/assets.gen.dart';
|
|
import 'package:remever/inject.dart';
|
|
import 'package:remever/router.gr.dart';
|
|
import 'package:remever/screens/crud_collection/crud_collection.dart';
|
|
import 'package:remever/screens/dialogs/alert_dialog.dart';
|
|
import 'package:remever/screens/dialogs/dialog_header.dart';
|
|
import 'package:remever/screens/dialogs/dialog_item.dart';
|
|
import 'package:remever/services/collection/collections_interface.dart';
|
|
|
|
class ActionDialog extends StatelessWidget {
|
|
const ActionDialog({super.key, required this.collection});
|
|
|
|
final Collection collection;
|
|
|
|
void _makePublic(BuildContext context, bool public) {
|
|
if (public) {
|
|
showCuperModalBottomSheet(
|
|
context: context,
|
|
height: 282.h,
|
|
builder:
|
|
(BuildContext context) => const AlertInfoDialog(
|
|
title:
|
|
'Коллекция станет видна всем пользователям сервиса.\nЕё будет проще найти по тэгам ;)',
|
|
acceptTitle: 'Позже добавлю',
|
|
declineTitle: 'Добавить тэги',
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: <Widget>[
|
|
const DialogHeader(title: 'Действия'),
|
|
DialogItem(
|
|
title: 'Публичная коллекция',
|
|
dimension: 36,
|
|
child: FittedBox(
|
|
fit: BoxFit.contain,
|
|
child: CupertinoSwitch(
|
|
activeTrackColor: AppColors.primary,
|
|
value: collection.isPublic,
|
|
onChanged: (bool value) => _makePublic(context, value),
|
|
),
|
|
),
|
|
onTap: () => _makePublic(context, collection.isPublic),
|
|
),
|
|
DialogItem(
|
|
title: 'Исключена из тренировки',
|
|
child: Assets.icons.typeHide.image(color: AppColors.primary),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
DialogItem(
|
|
title: 'Редактировать',
|
|
child: Assets.icons.typeEdit.image(color: AppColors.primary),
|
|
onTap: () {
|
|
// context.back();
|
|
context.pushRoute(
|
|
CrudCollectionRoute(editedCollection: collection),
|
|
);
|
|
},
|
|
),
|
|
DialogItem(
|
|
title: 'Статистика',
|
|
child: Assets.icons.typeStat.image(color: AppColors.primary),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
DialogItem(
|
|
title: 'Скачать',
|
|
child: Assets.icons.typeDownload.image(color: AppColors.primary),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
DialogItem(
|
|
title: 'Поделиться',
|
|
child: Assets.icons.typeShare.image(color: AppColors.primary),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
DialogItem(
|
|
title: 'Удалить',
|
|
color: AppColors.danger,
|
|
onTap: () async {
|
|
final bool? res = await showCuperModalBottomSheet(
|
|
context: context,
|
|
height: 262.h,
|
|
builder:
|
|
(BuildContext context) => const AlertInfoDialog(
|
|
title:
|
|
'Вы хотите удалить коллекцию?\nЭто действие необратимо',
|
|
acceptTitle: 'Да, удалить',
|
|
declineTitle: 'Нет, оставить',
|
|
),
|
|
);
|
|
|
|
if (true) {
|
|
await getIt<CollectionsInterface>().deleteCollection(
|
|
collection.id,
|
|
);
|
|
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
child: Assets.icons.typeTrash.image(color: AppColors.danger),
|
|
),
|
|
const BottomSafeSpace(),
|
|
],
|
|
);
|
|
}
|
|
}
|