Обновлен проект. Добавлена БД
This commit is contained in:
190
lib/screens/collections/widgets/collection_card.dart
Normal file
190
lib/screens/collections/widgets/collection_card.dart
Normal file
@@ -0,0 +1,190 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:remever/common/functions.dart';
|
||||
import 'package:remever/common/resources.dart';
|
||||
import 'package:remever/common/widgets/typography.dart';
|
||||
import 'package:remever/common/widgets/wspace.dart';
|
||||
import 'package:remever/components/extensions/context.dart';
|
||||
import 'package:remever/gen/assets.gen.dart';
|
||||
import 'package:remever/router.gr.dart';
|
||||
import 'package:remever/screens/collections/widgets/collection_progress_bar.dart';
|
||||
import 'package:remever/screens/dialogs/action_dialog.dart';
|
||||
|
||||
class CollectionCard extends StatelessWidget {
|
||||
const CollectionCard({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Slidable(
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.62,
|
||||
motion: const StretchMotion(),
|
||||
children: <Widget>[
|
||||
const WSpace(8),
|
||||
_buildSlidableAction(
|
||||
context: context,
|
||||
backgroundColor: const Color(0xFFD7E6F4),
|
||||
foregroundColor: const Color(0xFF0058AB),
|
||||
icon: Icons.info_outline,
|
||||
onPressed: () {},
|
||||
),
|
||||
const WSpace(8),
|
||||
_buildSlidableAction(
|
||||
context: context,
|
||||
backgroundColor: const Color(0xFFFFE4E6),
|
||||
foregroundColor: const Color(0xFFFF5C69),
|
||||
icon: Icons.favorite_border,
|
||||
onPressed: () {},
|
||||
),
|
||||
const WSpace(8),
|
||||
_buildSlidableAction(
|
||||
context: context,
|
||||
backgroundColor: AppColors.secondary,
|
||||
foregroundColor: AppColors.primary,
|
||||
icon: Icons.visibility_off_outlined,
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () => context.pushRoute(CollectionDetailRoute()),
|
||||
child: Container(
|
||||
constraints: BoxConstraints(minHeight: 66.h, maxHeight: 84.h),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12).r,
|
||||
color: AppColors.white,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8).r,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
_buildAvatar(),
|
||||
const WSpace(5),
|
||||
_buildInfo(),
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showCuperModalBottomSheet(
|
||||
context: context,
|
||||
height: 477.h,
|
||||
builder: (BuildContext context) => const ActionDialog(),
|
||||
);
|
||||
},
|
||||
child: Assets.icons.typeMenuVertical.image(
|
||||
height: 24.h,
|
||||
width: 24.w,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Построение основной информации
|
||||
///
|
||||
Widget _buildInfo() {
|
||||
return SizedBox(
|
||||
width: 230.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
_buildTitle(),
|
||||
const HSpace(4),
|
||||
_buildLikeAndCardsLength(),
|
||||
const HSpace(6),
|
||||
const CollectionProgressBar(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Построение кол-ва карточек и лайков
|
||||
///
|
||||
Widget _buildLikeAndCardsLength() {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
_buildIconWithText(
|
||||
icon: Assets.icons.typeCards,
|
||||
color: AppColors.disabled,
|
||||
text: Random().nextInt(654).toString(),
|
||||
),
|
||||
const WSpace(8),
|
||||
_buildIconWithText(
|
||||
icon: Assets.icons.typeLike1818,
|
||||
color: AppColors.danger,
|
||||
text: Random().nextInt(7689).toString(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Название коллекции
|
||||
///
|
||||
Widget _buildTitle() {
|
||||
return AppTypography(
|
||||
'Астрономия',
|
||||
type: Medium16px(),
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Обложка коллекции
|
||||
///
|
||||
Widget _buildAvatar() {
|
||||
return SizedBox.square(
|
||||
dimension: 50.r,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(image: Assets.images.img.provider()),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Кнопка в меню свайпа
|
||||
///
|
||||
Widget _buildSlidableAction({
|
||||
required BuildContext context,
|
||||
required Color backgroundColor,
|
||||
required Color foregroundColor,
|
||||
required IconData icon,
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
return SlidableAction(
|
||||
borderRadius: BorderRadius.circular(12).r,
|
||||
onPressed: (_) => onPressed(),
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
icon: icon,
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
/// Построение инфо
|
||||
///
|
||||
Widget _buildIconWithText({
|
||||
required AssetGenImage icon,
|
||||
required Color color,
|
||||
required String text,
|
||||
}) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
icon.image(height: 18.h, width: 18.w, color: color),
|
||||
const WSpace(2),
|
||||
AppTypography(text, type: Regular14px(), color: color),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user