23-02-1403 / Rhmn / changes: Mentions & Comments state Complete.
This commit is contained in:
parent
2d00d239be
commit
08d5564422
|
|
@ -6,7 +6,7 @@ class NotificationController {
|
|||
@pragma("vm:entry-point")
|
||||
static Future <void> onNotificationCreatedMethod(ReceivedNotification receivedNotification) async {
|
||||
// Your code goes here
|
||||
print("onNotificationCreatedMethod--------------------------------------------------------------");
|
||||
// print("onNotificationCreatedMethod--------------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ class NotificationController {
|
|||
@pragma("vm:entry-point")
|
||||
static Future <void> onNotificationDisplayedMethod(ReceivedNotification receivedNotification) async {
|
||||
// Your code goes here
|
||||
print("onNotificationDisplayedMethod--------------------------------------------------------------");
|
||||
// print("onNotificationDisplayedMethod--------------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ class NotificationController {
|
|||
@pragma("vm:entry-point")
|
||||
static Future <void> onDismissActionReceivedMethod(ReceivedAction receivedAction) async {
|
||||
// Your code goes here
|
||||
print("onDismissActionReceivedMethod--------------------------------------------------------------");
|
||||
// print("onDismissActionReceivedMethod--------------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +36,6 @@ class NotificationController {
|
|||
// MyApp.navigatorKey.currentState?.pushNamedAndRemoveUntil('/notification-page',
|
||||
// (route) => (route.settings.name != '/notification-page') || route.isFirst,
|
||||
// arguments: receivedAction);
|
||||
print("onActionReceivedMethod--------------------------------------------------------------");
|
||||
// print("onActionReceivedMethod--------------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:awesome_notifications/awesome_notifications.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../models/notification_message.dart';
|
||||
import 'awsome_notification_controller.dart';
|
||||
|
|
@ -87,7 +85,6 @@ class AwsomeNotificationHandler {
|
|||
|
||||
break;
|
||||
}
|
||||
try {} catch (ex) {}
|
||||
}
|
||||
|
||||
showNotificationTypeNews(NotificationMessage message) async {
|
||||
|
|
@ -97,7 +94,7 @@ class AwsomeNotificationHandler {
|
|||
channelKey: 'alerts',
|
||||
actionType: ActionType.Default,
|
||||
title: "\u200f ${message.title} \u200f",
|
||||
body: "${message.body.toString()}",
|
||||
body: message.body.toString(),
|
||||
notificationLayout: NotificationLayout.BigText,
|
||||
largeIcon: message.image.toString(),
|
||||
color: const Color(0xFF007EA7)),
|
||||
|
|
@ -135,10 +132,8 @@ class AwsomeNotificationHandler {
|
|||
content: NotificationContent(
|
||||
id: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
channelKey: 'alerts',
|
||||
title: 'Emojis are awesome too! ' +
|
||||
Emojis.animals_lady_beetle +
|
||||
Emojis.activites_balloon +
|
||||
Emojis.emotion_red_heart,
|
||||
title: 'Emojis are awes'
|
||||
'ome too! ${Emojis.animals_lady_beetle}${Emojis.activites_balloon}${Emojis.emotion_red_heart}',
|
||||
body:
|
||||
'Simple body with a bunch of Emojis! ${Emojis.transport_police_car} ${Emojis.animals_dog} ${Emojis.flag_UnitedStates} ${Emojis.person_baby}',
|
||||
largeIcon:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import 'package:firebase_messaging/firebase_messaging.dart';
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../lc/local_notification_service.dart';
|
||||
import '../../app_initalizer.dart';
|
||||
|
||||
class FirebaseNotificationHandler {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:didvan/constants/app_icons.dart';
|
|||
import 'package:didvan/constants/assets.dart';
|
||||
import 'package:didvan/models/users_mention.dart';
|
||||
import 'package:didvan/models/view/app_bar_data.dart';
|
||||
import 'package:didvan/services/network/request_helper.dart';
|
||||
import 'package:didvan/views/comments/comments_state.dart';
|
||||
import 'package:didvan/views/comments/widgets/comment.dart';
|
||||
import 'package:didvan/views/widgets/animated_visibility.dart';
|
||||
|
|
@ -17,12 +16,10 @@ import 'package:didvan/views/widgets/didvan/text.dart';
|
|||
import 'package:didvan/views/widgets/shimmer_placeholder.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/empty_state.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/sliver_state_handler.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../widgets/skeleton_image.dart';
|
||||
import '../widgets/didvan/didvan_title_divider.dart';
|
||||
import '../widgets/user_mention.dart';
|
||||
|
||||
class Comments extends StatefulWidget {
|
||||
|
|
@ -83,6 +80,7 @@ class _CommentsState extends State<Comments> {
|
|||
)
|
||||
: null,
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 92),
|
||||
showSliversFirst: false,
|
||||
slivers: [
|
||||
Consumer<CommentsState>(
|
||||
builder: (context, state, child) =>
|
||||
|
|
@ -93,7 +91,8 @@ class _CommentsState extends State<Comments> {
|
|||
childCount: state.comments.length,
|
||||
placeholder: const _CommentPlaceholder(),
|
||||
centerEmptyState: _isPage,
|
||||
enableEmptyState: state.comments.isEmpty,
|
||||
enableEmptyState:
|
||||
state.comments.isEmpty && state.privateComments.isEmpty,
|
||||
emptyState: EmptyState(
|
||||
asset: Assets.emptyChat,
|
||||
title: 'اولین نظر را بنویسید...',
|
||||
|
|
@ -109,6 +108,35 @@ class _CommentsState extends State<Comments> {
|
|||
),
|
||||
),
|
||||
],
|
||||
children: commentsState.privateComments.isNotEmpty
|
||||
? [
|
||||
const SizedBox(
|
||||
height: 6,
|
||||
),
|
||||
DidvanTitleDivider(
|
||||
title: "نظرات پنهان شده",
|
||||
onClick: () {
|
||||
commentsState.showPrivates =
|
||||
!commentsState.showPrivates;
|
||||
commentsState.update();
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
AnimatedVisibility(
|
||||
duration: DesignConfig.lowAnimationDuration,
|
||||
isVisible: commentsState.showPrivates,
|
||||
child: _buildPrivateComments(commentsState),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
const DidvanTitleDivider(
|
||||
title: "سایر نظرات",
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
AnimatedVisibility(
|
||||
duration: DesignConfig.lowAnimationDuration,
|
||||
|
|
@ -162,6 +190,23 @@ class _CommentsState extends State<Comments> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
ListView _buildPrivateComments(CommentsState commentsState) {
|
||||
return ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: commentsState.privateComments.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
return Comment(
|
||||
key: ValueKey(
|
||||
commentsState.privateComments[index].id.toString() +
|
||||
commentsState.privateComments[index].text,
|
||||
),
|
||||
focusNode: _focusNode,
|
||||
comment: commentsState.privateComments[index],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _MessageBox extends StatefulWidget {
|
||||
|
|
@ -178,7 +223,7 @@ class _MessageBoxState extends State<_MessageBox> {
|
|||
Widget build(BuildContext context) {
|
||||
final state = context.watch<CommentsState>();
|
||||
|
||||
void _onCheckBoxChange(bool b) {
|
||||
void onCheckBoxChange(bool b) {
|
||||
state.hideMentionedUser = b;
|
||||
state.update();
|
||||
}
|
||||
|
|
@ -263,16 +308,10 @@ class _MessageBoxState extends State<_MessageBox> {
|
|||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondCTA,
|
||||
borderRadius: !state.showReplyBox
|
||||
? BorderRadius.only(
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16))
|
||||
: null
|
||||
// border: Border(
|
||||
// top: BorderSide(
|
||||
// color: Theme.of(context).colorScheme.border,
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
: null),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
|
@ -285,7 +324,7 @@ class _MessageBoxState extends State<_MessageBox> {
|
|||
width: 2,
|
||||
height: 40,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Column(
|
||||
|
|
@ -322,10 +361,10 @@ class _MessageBoxState extends State<_MessageBox> {
|
|||
title: "پنهان کردن فراخوانی",
|
||||
value: state.hideMentionedUser,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onChanged: _onCheckBoxChange,
|
||||
onChanged: onCheckBoxChange,
|
||||
size: 12,
|
||||
)
|
||||
: SizedBox(),
|
||||
: const SizedBox(),
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
@ -353,11 +392,6 @@ class _MessageBoxState extends State<_MessageBox> {
|
|||
color: state.showReplyBox && state.usersMentioned.name == null
|
||||
? Theme.of(context).colorScheme.secondCTA
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
// border: Border(
|
||||
// top: BorderSide(
|
||||
// color: Theme.of(context).colorScheme.border,
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import 'package:didvan/providers/user.dart';
|
|||
import 'package:didvan/services/network/request.dart';
|
||||
import 'package:didvan/services/network/request_helper.dart';
|
||||
import 'package:didvan/utils/action_sheet.dart';
|
||||
import 'package:didvan/views/widgets/user_mention.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
|
@ -23,12 +22,14 @@ class CommentsState extends CoreProvier {
|
|||
UserOverview? replyingTo;
|
||||
bool showReplyBox = false;
|
||||
bool showUsersForMentionsLayout = false;
|
||||
bool showPrivates = false;
|
||||
bool hideMentionedUser = false;
|
||||
late void Function(int count) onCommentsChanged;
|
||||
int _count = 0;
|
||||
late String type;
|
||||
|
||||
final List<CommentData> comments = [];
|
||||
final List<CommentData> privateComments = [];
|
||||
final List<UsersMention> usersMention = [];
|
||||
final Map<int, MapEntry<bool, bool>> _feedbackQueue = {};
|
||||
|
||||
|
|
@ -41,11 +42,20 @@ class CommentsState extends CoreProvier {
|
|||
await service.httpGet();
|
||||
if (service.isSuccess) {
|
||||
comments.clear();
|
||||
final messages = service.result['comments']['public'];
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
comments.add(CommentData.fromJson(messages[i], false));
|
||||
final messagesPublic = service.result['comments']['public'];
|
||||
for (var i = 0; i < messagesPublic.length; i++) {
|
||||
comments.add(CommentData.fromJson(messagesPublic[i], false));
|
||||
_count++;
|
||||
for (var j = 0; j < messages[i]['replies'].length; j++) {
|
||||
for (var j = 0; j < messagesPublic[i]['replies'].length; j++) {
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
|
||||
final messagesPrivate = service.result['comments']['private'];
|
||||
for (var i = 0; i < messagesPrivate.length; i++) {
|
||||
privateComments.add(CommentData.fromJson(messagesPrivate[i], true));
|
||||
_count++;
|
||||
for (var j = 0; j < messagesPrivate[i]['replies'].length; j++) {
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
|
|
@ -112,6 +122,8 @@ class CommentsState extends CoreProvier {
|
|||
}
|
||||
|
||||
Future<void> addComment() async {
|
||||
late List<CommentData> cList =
|
||||
hideMentionedUser ? privateComments : comments;
|
||||
final user = DesignConfig.context!.read<UserProvider>().user;
|
||||
if (replyingTo != null) {
|
||||
comments.firstWhere((comment) => comment.id == commentId).replies.add(
|
||||
|
|
@ -133,7 +145,7 @@ class CommentsState extends CoreProvier {
|
|||
),
|
||||
);
|
||||
} else {
|
||||
comments.insert(
|
||||
cList.insert(
|
||||
0,
|
||||
CommentData(
|
||||
id: 0,
|
||||
|
|
@ -180,13 +192,13 @@ class CommentsState extends CoreProvier {
|
|||
await service.post();
|
||||
if (service.isSuccess) {
|
||||
if (replyingTo != null) {
|
||||
comments
|
||||
cList
|
||||
.firstWhere((comment) => comment.id == commentId)
|
||||
.replies
|
||||
.firstWhere((reply) => reply.id == 0)
|
||||
.id = service.result['comment']['id'];
|
||||
} else {
|
||||
comments.firstWhere((comment) => comment.id == 0).id =
|
||||
cList.firstWhere((comment) => comment.id == 0).id =
|
||||
service.result['comment']['id'];
|
||||
}
|
||||
commentId = null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
import 'package:didvan/config/theme_data.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'text.dart';
|
||||
import '../ink_wrapper.dart';
|
||||
|
||||
class DidvanTitleDivider extends StatelessWidget{
|
||||
|
||||
final String title;
|
||||
final Function()? onClick;
|
||||
|
||||
const DidvanTitleDivider({super.key, required this.title, this.onClick});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWrapper(
|
||||
onPressed: onClick,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.border,
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8, right: 8),
|
||||
child: DidvanText(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
color: Theme.of(context).colorScheme.inputText,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).colorScheme.border,
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ class _DidvanScaffoldState extends State<DidvanScaffold> {
|
|||
),
|
||||
if (widget.children != null && !widget.showSliversFirst)
|
||||
SliverPadding(
|
||||
padding: widget.padding,
|
||||
padding: widget.padding.copyWith(bottom: 16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => widget.children![index],
|
||||
|
|
|
|||
Loading…
Reference in New Issue