Добавлено удаление коллекций

This commit is contained in:
2025-03-25 21:36:00 +03:00
parent 94193658f1
commit 5892830499
380 changed files with 142 additions and 4057 deletions

View File

@@ -12,6 +12,7 @@ import 'package:remever/common/widgets/typography.dart';
import 'package:remever/common/widgets/w_if.dart';
import 'package:remever/common/widgets/wspace.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/models/collection_dto.dart';
@@ -24,13 +25,11 @@ import 'package:remever/widgets/primary_button.dart';
import '../../../components/extensions/state.dart';
enum CrudType { CREATE, EDIT }
@RoutePage()
class CrudCollectionScreen extends StatefulWidget {
const CrudCollectionScreen({super.key, this.crudType = CrudType.CREATE});
const CrudCollectionScreen({super.key, this.editedCollection});
final CrudType crudType;
final Collection? editedCollection;
@override
State<CrudCollectionScreen> createState() => _CrudCollectionScreenState();
@@ -50,7 +49,12 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
@override
void initState() {
_collection = CollectionDto(desc: '', title: '', isPublic: false);
_collection = CollectionDto(
desc: widget.editedCollection?.desc ?? '',
title: widget.editedCollection?.title ?? '',
isPublic: widget.editedCollection?.isPublic ?? false,
avatar: widget.editedCollection?.image,
);
super.initState();
}
@@ -79,8 +83,6 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
_collection = _collection?.copyWith(avatar: base64String);
safeSetState(() {});
print('Base64 строка: $base64String');
}
@override
@@ -108,7 +110,8 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
_buildPublickSwitch(),
const HSpace(16),
AnimatedOpacity(
opacity: _isPublic ? 1 : 0,
// opacity: _isPublic ? 1 : 0,
opacity: 0,
duration: const Duration(seconds: 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -141,13 +144,20 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
return;
}
getIt<CollectionsInterface>().createCollection(_collection!);
widget.editedCollection != null
? await getIt<CollectionsInterface>().updateCollection(
_collection!,
widget.editedCollection!.id,
)
: await getIt<CollectionsInterface>().createCollection(
_collection!,
);
context.back();
},
color: AppColors.primary,
child: AppTypography(
widget.crudType == CrudType.CREATE
widget.editedCollection == null
? 'Создать коллекцию'
: 'Сохранить изменения',
type: Regular14px(),
@@ -390,7 +400,7 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
shadowColor: Colors.transparent,
leading: IconButton(
onPressed: () async {
if (widget.crudType == CrudType.EDIT) {
if (widget.editedCollection != null) {
final bool? res = await showCuperModalBottomSheet(
context: context,
height: 262.h,
@@ -413,7 +423,7 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
title: GestureDetector(
onLongPress: () => context.pushRoute(const SandboxRoute()),
child: AppTypography(
widget.crudType == CrudType.CREATE
widget.editedCollection == null
? 'Создать коллекцию'
: 'Редактировать',
type: SemiBold20px(),
@@ -422,7 +432,7 @@ class _CrudCollectionScreenState extends State<CrudCollectionScreen> {
),
actions: <Widget>[
Wif(
condition: widget.crudType == CrudType.EDIT,
condition: widget.editedCollection != null,
builder: (BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 16).r,