add bug report section to news
This commit is contained in:
parent
5bd556e691
commit
bb7f683389
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'news_attachment.dart';
|
||||
import 'radar_attachment.dart';
|
||||
|
||||
class MessageData {
|
||||
|
|
@ -10,6 +11,7 @@ class MessageData {
|
|||
final bool writedByAdmin;
|
||||
final bool readed;
|
||||
final String createdAt;
|
||||
final NewsAttachment? news;
|
||||
final RadarAttachment? radar;
|
||||
final File? audioFile;
|
||||
final int? audioDuration;
|
||||
|
|
@ -21,6 +23,7 @@ class MessageData {
|
|||
required this.createdAt,
|
||||
this.text,
|
||||
this.audio,
|
||||
this.news,
|
||||
this.radar,
|
||||
this.audioFile,
|
||||
this.audioDuration,
|
||||
|
|
@ -39,6 +42,8 @@ class MessageData {
|
|||
radar: json['radar'] == null
|
||||
? null
|
||||
: RadarAttachment.fromJson(json['radar']),
|
||||
news:
|
||||
json['news'] == null ? null : NewsAttachment.fromJson(json['news']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
|
@ -48,6 +53,7 @@ class MessageData {
|
|||
'writedByAdmin': writedByAdmin,
|
||||
'readed': readed,
|
||||
'createdAt': createdAt,
|
||||
'news': news?.toJson(),
|
||||
'radar': radar?.toJson(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
class NewsAttachment {
|
||||
final int id;
|
||||
final String title;
|
||||
final String description;
|
||||
final String image;
|
||||
final String createdAt;
|
||||
|
||||
const NewsAttachment({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.image,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory NewsAttachment.fromJson(Map<String, dynamic> json) => NewsAttachment(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
description: json['description'],
|
||||
image: json['image'],
|
||||
createdAt: json['createdAt'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'image': image,
|
||||
};
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ class _DirectState extends State<Direct> {
|
|||
@override
|
||||
void initState() {
|
||||
final state = context.read<DirectState>();
|
||||
state.replyNews = widget.pageData['newsAttachment'];
|
||||
state.replyRadar = widget.pageData['radarAttachment'];
|
||||
final typeId = ServerDataProvider.labelToTypeId(widget.pageData['type']);
|
||||
state.typeId = typeId;
|
||||
|
|
@ -68,9 +69,10 @@ class _DirectState extends State<Direct> {
|
|||
slivers: [
|
||||
if (state.appState != AppState.busy)
|
||||
SliverPadding(
|
||||
padding: state.replyRadar == null
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.only(bottom: 68),
|
||||
padding:
|
||||
state.replyRadar == null && state.replyNews == null
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.only(bottom: 68),
|
||||
sliver: SliverStateHandler<DirectState>(
|
||||
itemPadding: const EdgeInsets.only(bottom: 12),
|
||||
state: state,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/models/message_data/message_data.dart';
|
||||
import 'package:didvan/models/message_data/news_attachment.dart';
|
||||
import 'package:didvan/models/message_data/radar_attachment.dart';
|
||||
import 'package:didvan/providers/core.dart';
|
||||
import 'package:didvan/services/media/media.dart';
|
||||
|
|
@ -19,6 +20,7 @@ class DirectState extends CoreProvier {
|
|||
final List<int> deletionQueue = [];
|
||||
|
||||
String? text;
|
||||
NewsAttachment? replyNews;
|
||||
RadarAttachment? replyRadar;
|
||||
File? recordedFile;
|
||||
int? audioDuration;
|
||||
|
|
@ -116,21 +118,30 @@ class DirectState extends CoreProvier {
|
|||
audio: null,
|
||||
audioFile: recordedFile,
|
||||
radar: replyRadar,
|
||||
news: replyNews,
|
||||
audioDuration: audioDuration,
|
||||
),
|
||||
);
|
||||
_addToDailyGrouped(messages.first);
|
||||
final body = {};
|
||||
|
||||
if (text != null) {
|
||||
body.addAll({'text': text});
|
||||
}
|
||||
|
||||
if (replyRadar != null) {
|
||||
body.addAll({'radarId': replyRadar!.id});
|
||||
}
|
||||
|
||||
if (replyNews != null) {
|
||||
body.addAll({'newsId': replyNews!.id});
|
||||
}
|
||||
|
||||
final uploadFile = recordedFile;
|
||||
text = null;
|
||||
recordedFile = null;
|
||||
replyRadar = null;
|
||||
replyNews = null;
|
||||
notifyListeners();
|
||||
final service =
|
||||
RequestService(RequestHelper.sendDirectMessage(typeId), body: body);
|
||||
|
|
|
|||
|
|
@ -89,11 +89,16 @@ class Message extends StatelessWidget {
|
|||
audioUrl: message.audio,
|
||||
id: message.id,
|
||||
),
|
||||
if (message.radar != null) const DidvanDivider(),
|
||||
if (message.radar != null) const SizedBox(height: 4),
|
||||
if (message.radar != null || message.news != null)
|
||||
const DidvanDivider(),
|
||||
if (message.radar != null || message.news != null)
|
||||
const SizedBox(height: 4),
|
||||
if (message.radar != null)
|
||||
_ReplyRadarOverview(message: message),
|
||||
if (message.radar != null) const SizedBox(height: 4),
|
||||
if (message.news != null)
|
||||
_ReplyNewsOverview(message: message),
|
||||
if (message.radar != null || message.news != null)
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -168,7 +173,59 @@ class _ReplyRadarOverview extends StatelessWidget {
|
|||
color: Theme.of(context).colorScheme.focusedBorder,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
// DidvanText('text'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ReplyNewsOverview extends StatelessWidget {
|
||||
final MessageData message;
|
||||
const _ReplyNewsOverview({Key? key, required this.message}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SkeletonImage(
|
||||
imageUrl: message.news!.image,
|
||||
height: 52,
|
||||
width: 52,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 52,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
DidvanText(
|
||||
message.news!.title,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
color: Theme.of(context).colorScheme.focusedBorder,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
DidvanText(
|
||||
'خبر',
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
color: Theme.of(context).colorScheme.focusedBorder,
|
||||
),
|
||||
const Spacer(),
|
||||
DidvanText(
|
||||
DateTimeUtils.momentGenerator(message.news!.createdAt),
|
||||
color: Theme.of(context).colorScheme.focusedBorder,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class MessageBox extends StatelessWidget {
|
|||
return Column(
|
||||
children: [
|
||||
Consumer<DirectState>(
|
||||
builder: (context, state, child) => state.replyRadar != null
|
||||
builder: (context, state, child) => state.replyRadar != null ||
|
||||
state.replyNews != null
|
||||
? _MessageBoxContainer(
|
||||
isMessage: false,
|
||||
child: Padding(
|
||||
|
|
@ -32,7 +33,9 @@ class MessageBox extends StatelessWidget {
|
|||
'لینک به مطلب:',
|
||||
),
|
||||
DidvanText(
|
||||
state.replyRadar!.title,
|
||||
state.replyRadar != null
|
||||
? state.replyRadar!.title
|
||||
: state.replyNews!.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
|
|
@ -45,6 +48,7 @@ class MessageBox extends StatelessWidget {
|
|||
gestureSize: 24,
|
||||
onPressed: () {
|
||||
state.replyRadar = null;
|
||||
state.replyNews = null;
|
||||
state.update();
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:didvan/config/design_config.dart';
|
||||
import 'package:didvan/config/theme_data.dart';
|
||||
import 'package:didvan/constants/app_icons.dart';
|
||||
import 'package:didvan/models/message_data/news_attachment.dart';
|
||||
import 'package:didvan/models/message_data/radar_attachment.dart';
|
||||
import 'package:didvan/models/view/action_sheet_data.dart';
|
||||
import 'package:didvan/routes/routes.dart';
|
||||
|
|
@ -102,23 +103,22 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
|||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (widget.isRadar)
|
||||
BookmarkButton(
|
||||
itemId: widget.item.id,
|
||||
type: 'radar',
|
||||
color: DesignConfig.isDark
|
||||
? Theme.of(context).colorScheme.focusedBorder
|
||||
: Theme.of(context).colorScheme.focused,
|
||||
askForConfirmation: widget.hasUnmarkConfirmation,
|
||||
value: widget.item.marked,
|
||||
onMarkChanged: (value) {
|
||||
widget.onMarkChanged(value);
|
||||
if (widget.hasUnmarkConfirmation && !value) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
gestureSize: 32,
|
||||
),
|
||||
BookmarkButton(
|
||||
itemId: widget.item.id,
|
||||
type: widget.isRadar ? 'radar' : 'news',
|
||||
color: DesignConfig.isDark
|
||||
? Theme.of(context).colorScheme.focusedBorder
|
||||
: Theme.of(context).colorScheme.focused,
|
||||
askForConfirmation: widget.hasUnmarkConfirmation,
|
||||
value: widget.item.marked,
|
||||
onMarkChanged: (value) {
|
||||
widget.onMarkChanged(value);
|
||||
if (widget.hasUnmarkConfirmation && !value) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
gestureSize: 32,
|
||||
),
|
||||
SizedBox(
|
||||
width: 60,
|
||||
child: Row(
|
||||
|
|
@ -145,30 +145,12 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (!widget.isRadar) const SizedBox(width: 12),
|
||||
if (!widget.isRadar)
|
||||
BookmarkButton(
|
||||
itemId: widget.item.id,
|
||||
type: 'news',
|
||||
color: DesignConfig.isDark
|
||||
? Theme.of(context).colorScheme.focusedBorder
|
||||
: Theme.of(context).colorScheme.focused,
|
||||
askForConfirmation: widget.hasUnmarkConfirmation,
|
||||
value: widget.item.marked,
|
||||
onMarkChanged: (value) {
|
||||
widget.onMarkChanged(value);
|
||||
if (widget.hasUnmarkConfirmation && !value) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
gestureSize: 32,
|
||||
),
|
||||
if (widget.isRadar)
|
||||
DidvanIconButton(
|
||||
gestureSize: 32,
|
||||
onPressed: _showMoreOptions,
|
||||
icon: DidvanIcons.menu_regular,
|
||||
),
|
||||
DidvanIconButton(
|
||||
gestureSize: 32,
|
||||
onPressed:
|
||||
widget.isRadar ? _showRadarMoreOptions : _showNewsMoreOptions,
|
||||
icon: DidvanIcons.menu_regular,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -192,7 +174,7 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
|||
});
|
||||
}
|
||||
|
||||
void _showMoreOptions() {
|
||||
void _showRadarMoreOptions() {
|
||||
final categories = widget.item.categories!;
|
||||
ActionSheetUtils.showBottomSheet(
|
||||
data: ActionSheetData(
|
||||
|
|
@ -293,4 +275,38 @@ class _FloatingNavigationBarState extends State<FloatingNavigationBar> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showNewsMoreOptions() {
|
||||
ActionSheetUtils.showBottomSheet(
|
||||
data: ActionSheetData(
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
MenuOption(
|
||||
title: 'گزارش اشکال',
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed(
|
||||
Routes.direct,
|
||||
arguments: {
|
||||
'newsAttachment': NewsAttachment(
|
||||
id: widget.item.id,
|
||||
title: widget.item.title,
|
||||
description: widget.item.contents.first.text,
|
||||
image: widget.item.image,
|
||||
createdAt: widget.item.createdAt,
|
||||
),
|
||||
'type': 'پشتیبانی'
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: DidvanIcons.description_regular,
|
||||
),
|
||||
],
|
||||
),
|
||||
title: 'موارد بیشتر',
|
||||
withoutButtonMode: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue