Skip to content

Commit a112b2a

Browse files
chore: ✨ Set default text selection to false in ChatBubble
1 parent 17a2d6b commit a112b2a

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## [3.0.0]
22

33
* **Feat**: [401](https://github.com/SimformSolutionsPvtLtd/chatview/pull/401)
4-
Add selection and copy options for text view.
4+
Added text selection and copy functionality to chat bubbles.
5+
Introduced the `onTextSelection` parameter in `FeatureActiveConfig` (default: false). When enabled, users can select and copy text with a long press.
56
* **Breaking**: [318](https://github.com/SimformSolutionsPvtLtd/chatview/issues/318)
67
Provide support for action item widgets on the chat text field with position options
78
`leadingActions` and `trailingActions` in `TextFieldConfiguration`. Also, provide a way to add

lib/src/models/chat_bubble.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import 'config_models/text_selection_config.dart';
2828

2929
class ChatBubble {
3030
const ChatBubble({
31-
this.enableTextSelection = true,
3231
this.color,
3332
this.borderRadius,
3433
this.textStyle,
@@ -74,11 +73,6 @@ class ChatBubble {
7473
/// Used for giving border of chat bubble.
7574
final Border? border;
7675

77-
/// Used to determine whether the text can be selected.
78-
///
79-
/// Defaults to `true`.
80-
final bool enableTextSelection;
81-
8276
/// Configuration for text selection behavior and appearance.
8377
final TextSelectionConfig? textSelectionConfig;
8478
}

lib/src/models/config_models/feature_active_config.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class FeatureActiveConfig {
3636
this.receiptsBuilderVisibility = true,
3737
this.enableOtherUserName = true,
3838
this.enableScrollToBottomButton = false,
39+
this.enableTextSelection = false,
3940
});
4041

4142
/// Used for enable/disable swipe to reply.
@@ -79,4 +80,9 @@ class FeatureActiveConfig {
7980

8081
/// Used for enable/disable Scroll To Bottom Button.
8182
final bool enableScrollToBottomButton;
83+
84+
/// Used to determine whether the text can be selected.
85+
///
86+
/// Defaults to `false`.
87+
final bool enableTextSelection;
8288
}

lib/src/widgets/message_view.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class _MessageViewState extends State<MessageView>
224224
messageReactionConfig: messageConfig?.messageReactionConfig,
225225
highlightColor: widget.highlightColor,
226226
highlightMessage: widget.shouldHighlight,
227+
featureActiveConfig: chatViewIW?.featureActiveConfig,
227228
);
228229
} else if (widget.message.messageType.isVoice) {
229230
return VoiceMessageView(

lib/src/widgets/text_message_view.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22+
import 'package:chatview/chatview.dart';
2223
import 'package:chatview/src/widgets/custom_selection_area.dart';
23-
import 'package:chatview_utils/chatview_utils.dart';
2424
import 'package:flutter/material.dart';
25-
2625
import '../extensions/extensions.dart';
27-
import '../models/chat_bubble.dart';
28-
import '../models/config_models/link_preview_configuration.dart';
29-
import '../models/config_models/message_reaction_configuration.dart';
3026
import '../utils/constants/constants.dart';
3127
import 'link_preview.dart';
3228
import 'reaction_widget.dart';
@@ -42,6 +38,7 @@ class TextMessageView extends StatelessWidget {
4238
this.messageReactionConfig,
4339
this.highlightMessage = false,
4440
this.highlightColor,
41+
this.featureActiveConfig,
4542
}) : super(key: key);
4643

4744
/// Represents current message is sent by current user.
@@ -68,16 +65,23 @@ class TextMessageView extends StatelessWidget {
6865
/// Allow user to set color of highlighted message.
6966
final Color? highlightColor;
7067

68+
final FeatureActiveConfig? featureActiveConfig;
69+
7170
@override
7271
Widget build(BuildContext context) {
7372
final textTheme = Theme.of(context).textTheme;
7473
final textMessage = message.message;
7574
final border = isMessageBySender
7675
? outgoingChatBubbleConfig?.border
7776
: inComingChatBubbleConfig?.border;
78-
final isSelectable = isMessageBySender
79-
? outgoingChatBubbleConfig?.enableTextSelection ?? false
80-
: inComingChatBubbleConfig?.enableTextSelection ?? false;
77+
// final isSelectable = isMessageBySender
78+
// ? outgoingChatBubbleConfig?.enableTextSelection ?? false
79+
// : inComingChatBubbleConfig?.enableTextSelection ?? false;
80+
final isSelectable = featureActiveConfig?.enableTextSelection ?? false;
81+
82+
// final isSelectable = isMessageBySender
83+
// ? outgoingChatBubbleConfig?.enableTextSelection ?? false
84+
// : inComingChatBubbleConfig?.enableTextSelection ?? false;
8185
final textSelectionConfig = isMessageBySender
8286
? outgoingChatBubbleConfig?.textSelectionConfig
8387
: inComingChatBubbleConfig?.textSelectionConfig;

0 commit comments

Comments
 (0)