132 lines
4.4 KiB
Dart
132 lines
4.4 KiB
Dart
import 'package:didvan/config/theme_data.dart';
|
|
import 'package:didvan/constants/app_icons.dart';
|
|
import 'package:didvan/models/radar_overview.dart';
|
|
import 'package:didvan/models/requests/radar.dart';
|
|
import 'package:didvan/routes/routes.dart';
|
|
import 'package:didvan/utils/date_time.dart';
|
|
import 'package:didvan/widgets/bookmark_button.dart';
|
|
import 'package:didvan/widgets/didvan/card.dart';
|
|
import 'package:didvan/widgets/didvan/divider.dart';
|
|
import 'package:didvan/widgets/didvan/icon_button.dart';
|
|
import 'package:didvan/widgets/didvan/text.dart';
|
|
import 'package:didvan/widgets/skeleton_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class RadarOverview extends StatelessWidget {
|
|
final RadarOverviewData radar;
|
|
final void Function(int count) onCommentsChanged;
|
|
final void Function(bool value) onMarkChanged;
|
|
final RadarRequestArgs? radarRequestArgs;
|
|
const RadarOverview({
|
|
Key? key,
|
|
required this.radar,
|
|
required this.onCommentsChanged,
|
|
required this.onMarkChanged,
|
|
this.radarRequestArgs,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return DidvanCard(
|
|
onTap: () => Navigator.of(context).pushNamed(
|
|
Routes.radarDetails,
|
|
arguments: {
|
|
'onMarkChanged': onMarkChanged,
|
|
'onCommentsChanged': onCommentsChanged,
|
|
'id': radar.id,
|
|
'args': radarRequestArgs,
|
|
},
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SizedBox(height: 8),
|
|
DidvanText(
|
|
radar.title,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Stack(
|
|
children: [
|
|
SkeletonImage(
|
|
imageUrl: radar.image,
|
|
aspectRatio: 16 / 9,
|
|
),
|
|
if (radar.forManagers)
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(4),
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(8),
|
|
topRight: Radius.circular(8),
|
|
),
|
|
),
|
|
child: DidvanText(
|
|
'برای مدیران',
|
|
style: Theme.of(context).textTheme.overline,
|
|
color: Theme.of(context).colorScheme.white,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
children: [
|
|
DidvanText(
|
|
radar.categories.first.label,
|
|
style: Theme.of(context).textTheme.overline,
|
|
color: Theme.of(context).colorScheme.caption,
|
|
),
|
|
const Spacer(),
|
|
DidvanText(
|
|
'${DateTimeUtils.momentGenerator(radar.createdAt)} | خواندن ${radar.timeToRead} دقیقه',
|
|
style: Theme.of(context).textTheme.overline,
|
|
color: Theme.of(context).colorScheme.caption,
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
DidvanText(
|
|
radar.description,
|
|
maxLines: 3,
|
|
),
|
|
const DidvanDivider(),
|
|
Row(
|
|
children: [
|
|
BookmarkButton(
|
|
value: radar.marked,
|
|
onMarkChanged: onMarkChanged,
|
|
),
|
|
const Spacer(),
|
|
if (radar.comments != 0) DidvanText(radar.comments.toString()),
|
|
const SizedBox(width: 4),
|
|
DidvanIconButton(
|
|
icon: DidvanIcons.chats_regular,
|
|
gestureSize: 24,
|
|
onPressed: () => Navigator.of(context).pushNamed(
|
|
Routes.comments,
|
|
arguments: {
|
|
'isRadar': true,
|
|
'title': radar.title,
|
|
'id': radar.id,
|
|
'onCommentsChanged': onCommentsChanged
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
// const DidvanText('10'),
|
|
// const SizedBox(width: 4),
|
|
// const Icon(DidvanIcons.evaluation_regular),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|