Skip to content

Commit

Permalink
TW-1351: add draft chat catch phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian KOUNE authored and hoangdat committed Jan 18, 2024
1 parent bbc0bce commit 8ea59cb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
12 changes: 11 additions & 1 deletion assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2994,5 +2994,15 @@
"placeholders": {
"count": {}
}
}
},
"draftChatHookPhrase": "Hi {user}! I would like to chat with you.",
"@draftChatHookPhrase": {
"placeholders": {
"user": {
"type": "String",
"example": "John"
}
}
},
"twakeChatUser": "Twake Chat User"
}
4 changes: 2 additions & 2 deletions lib/pages/chat/chat_event_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:fluffychat/pages/chat/group_chat_empty_view.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat_empty_view.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat_empty_widget.dart';
import 'package:fluffychat/presentation/model/search/presentation_search.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -165,7 +165,7 @@ class ChatEventList extends StatelessWidget {

Widget _chatEmptyBuilder(Timeline timeline) {
if (controller.room?.isDirectChat ?? true) {
return DirectDraftChatView(
return DraftChatEmpty(
onTap: () => controller.inputFocus.requestFocus(),
);
} else {
Expand Down
10 changes: 10 additions & 0 deletions lib/pages/chat_draft/draft_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ class DraftChatController extends State<DraftChat>
widget.onChangeRightColumnType?.call(RightColumnType.profileInfo);
}

void handleDraftAction(BuildContext context) {
inputFocus.requestFocus();

sendController.value = TextEditingValue(
text: L10n.of(context)!.draftChatHookPhrase(
presentationContact!.displayName ?? L10n.of(context)!.twakeChatUser,
),
);
}

@override
Widget build(BuildContext context) {
return DraftChatView(controller: this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

class DirectDraftChatView extends StatelessWidget {
class DraftChatEmpty extends StatelessWidget {
final void Function()? onTap;

const DirectDraftChatView({
const DraftChatEmpty({
Key? key,
this.onTap,
}) : super(key: key);
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/chat_draft/draft_chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:fluffychat/pages/chat/chat_app_bar_title_style.dart';
import 'package:fluffychat/pages/chat/chat_input_row_style.dart';
import 'package:fluffychat/pages/chat/input_bar/input_bar.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat_empty_view.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat_empty_widget.dart';
import 'package:fluffychat/pages/chat_draft/draft_chat_view_style.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/utils/platform_infos.dart';
Expand Down Expand Up @@ -100,8 +100,8 @@ class DraftChatView extends StatelessWidget {
controller.handleDragDone(details),
onDragEntered: controller.onDragEntered,
onDragExited: controller.onDragExited,
child: DirectDraftChatView(
onTap: controller.inputFocus.requestFocus,
child: DraftChatEmpty(
onTap: () => controller.handleDraftAction(context),
),
),
),
Expand Down

0 comments on commit 8ea59cb

Please sign in to comment.