Skip to content

Commit

Permalink
feat: ✨Added configuration for emoji picker sheet
Browse files Browse the repository at this point in the history
- Added emojiPickerSheetConfig for configuration of emoji picker modal sheet.
  • Loading branch information
apurva010 committed May 20, 2024
1 parent aeb843f commit a2dee7e
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [1.3.2] (Unreleased)

* **Fix**: [160](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/160) Added
configuration for emoji picker sheet.
* **Fix**: [130](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/130) Added
report button for receiver message and update onMoreTap, onReportTap callback.
* **Fix**: [126](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/126) Added
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,24 @@ ChatView(
)
```

22. Added `emojiPickerSheetConfig` for configuration of emoji picker sheet.

```dart
ChatView(
...
emojiPickerSheetConfig: const Config(
columns: 7,
emojiSizeMax: 32
initCategory: Category.RECENT,
bgColor: Colors.white,
recentTabBehavior: RecentTabBehavior.NONE,
recentsLimit: 28,
),
...
)
```


## How to use
Expand Down
1 change: 1 addition & 0 deletions lib/chatview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export 'package:audio_waveforms/audio_waveforms.dart'
show WaveStyle, PlayerWaveStyle;
export 'src/models/receipts_widget_config.dart';
export 'src/extensions/extensions.dart' show MessageTypes;
export'package:emoji_picker_flutter/emoji_picker_flutter.dart';
5 changes: 5 additions & 0 deletions lib/src/widgets/chat_list_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ChatListWidget extends StatefulWidget {
this.isLastPage,
this.onChatListTap,
this.chatTextFieldTopPadding = 0,
this.emojiPickerSheetConfig,
}) : super(key: key);

/// Provides controller for accessing few function for running chat.
Expand Down Expand Up @@ -112,6 +113,9 @@ class ChatListWidget extends StatefulWidget {
/// Provides top padding of chat text field
final double chatTextFieldTopPadding;

/// Configuration for emoji picker sheet
final Config? emojiPickerSheetConfig;

@override
State<ChatListWidget> createState() => _ChatListWidgetState();
}
Expand Down Expand Up @@ -233,6 +237,7 @@ class _ChatListWidgetState extends State<ChatListWidget>
reactionPopupConfig: widget.reactionPopupConfig,
onTap: _onChatListTap,
showPopUp: showPopupValue,
emojiPickerSheetConfig: widget.emojiPickerSheetConfig,
),
],
);
Expand Down
5 changes: 5 additions & 0 deletions lib/src/widgets/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ChatView extends StatefulWidget {
ChatViewStateConfiguration? chatViewStateConfig,
this.featureActiveConfig = const FeatureActiveConfig(),
this.chatTextFieldTopPadding = 0,
this.emojiPickerSheetConfig,
}) : chatBackgroundConfig =
chatBackgroundConfig ?? const ChatBackgroundConfiguration(),
chatViewStateConfig =
Expand Down Expand Up @@ -141,6 +142,9 @@ class ChatView extends StatefulWidget {
/// Provides top padding of chat text field
final double chatTextFieldTopPadding;

/// Configuration for emoji picker sheet
final Config? emojiPickerSheetConfig;

@override
State<ChatView> createState() => _ChatViewState();
}
Expand Down Expand Up @@ -256,6 +260,7 @@ class _ChatViewState extends State<ChatView>
?.assignReplyMessage(message),
chatTextFieldTopPadding:
widget.chatTextFieldTopPadding,
emojiPickerSheetConfig: widget.emojiPickerSheetConfig,
);
},
),
Expand Down
59 changes: 34 additions & 25 deletions lib/src/widgets/emoji_picker_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,27 @@ import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import '../values/typedefs.dart';

class EmojiPickerWidget extends StatelessWidget {
const EmojiPickerWidget({Key? key, required this.onSelected})
: super(key: key);
const EmojiPickerWidget({
Key? key,
required this.onSelected,
this.emojiPickerSheetConfig,
}) : super(key: key);

/// Provides callback when user selects emoji.
final StringCallback onSelected;

/// Configuration for emoji picker sheet
final Config? emojiPickerSheetConfig;

@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return Container(
padding: const EdgeInsets.only(top: 10, left: 15, right: 15),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
decoration: BoxDecoration(
color: emojiPickerSheetConfig?.emojiViewConfig.backgroundColor ??
Colors.white,
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
),
height: size.height * 0.6,
width: size.width,
Expand All @@ -61,26 +68,28 @@ class EmojiPickerWidget extends StatelessWidget {
child: EmojiPicker(
onEmojiSelected: (Category? category, Emoji emoji) =>
onSelected(emoji.emoji),
config: Config(
emojiViewConfig: EmojiViewConfig(
columns: 7,
emojiSizeMax: 32 * ((!kIsWeb && Platform.isIOS) ? 1.30 : 1.0),
recentsLimit: 28,
backgroundColor: Colors.white,
),
searchViewConfig: const SearchViewConfig(
buttonIconColor: Colors.black,
),
categoryViewConfig: const CategoryViewConfig(
initCategory: Category.RECENT,
recentTabBehavior: RecentTabBehavior.NONE,
),
bottomActionBarConfig: const BottomActionBarConfig(
backgroundColor: Colors.white,
buttonIconColor: Colors.black,
buttonColor: Colors.white,
),
),
config: emojiPickerSheetConfig ??
Config(
emojiViewConfig: EmojiViewConfig(
columns: 7,
emojiSizeMax:
32 * ((!kIsWeb && Platform.isIOS) ? 1.30 : 1.0),
recentsLimit: 28,
backgroundColor: Colors.white,
),
searchViewConfig: const SearchViewConfig(
buttonIconColor: Colors.black,
),
categoryViewConfig: const CategoryViewConfig(
initCategory: Category.RECENT,
recentTabBehavior: RecentTabBehavior.NONE,
),
bottomActionBarConfig: const BottomActionBarConfig(
backgroundColor: Colors.white,
buttonIconColor: Colors.black,
buttonColor: Colors.white,
),
),
),
),
],
Expand Down
16 changes: 12 additions & 4 deletions lib/src/widgets/emoji_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:flutter/material.dart';
import 'package:chatview/src/models/reaction_popup_configuration.dart';
import 'package:chatview/src/utils/constants/constants.dart';
Expand All @@ -31,6 +32,7 @@ class EmojiRow extends StatelessWidget {
Key? key,
required this.onEmojiTap,
this.emojiConfiguration,
this.emojiPickerSheetConfig,
}) : super(key: key);

/// Provides callback when user taps on emoji in reaction pop-up.
Expand All @@ -49,6 +51,9 @@ class EmojiRow extends StatelessWidget {
thumbsUp,
];

/// Configuration for emoji picker sheet
final Config? emojiPickerSheetConfig;

@override
Widget build(BuildContext context) {
final emojiList = emojiConfiguration?.emojiList ?? _emojiUnicodes;
Expand Down Expand Up @@ -86,9 +91,12 @@ class EmojiRow extends StatelessWidget {

void _showBottomSheet(BuildContext context) => showModalBottomSheet<void>(
context: context,
builder: (context) => EmojiPickerWidget(onSelected: (emoji) {
Navigator.pop(context);
onEmojiTap(emoji);
}),
builder: (context) => EmojiPickerWidget(
emojiPickerSheetConfig: emojiPickerSheetConfig,
onSelected: (emoji) {
Navigator.pop(context);
onEmojiTap(emoji);
},
),
);
}
5 changes: 5 additions & 0 deletions lib/src/widgets/reaction_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ReactionPopup extends StatefulWidget {
this.reactionPopupConfig,
required this.onTap,
required this.showPopUp,
this.emojiPickerSheetConfig,
}) : super(key: key);

/// Provides configuration of reaction pop-up appearance.
Expand All @@ -43,6 +44,9 @@ class ReactionPopup extends StatefulWidget {
/// Represents should pop-up show or not.
final bool showPopUp;

/// Configuration for emoji picker sheet
final Config? emojiPickerSheetConfig;

@override
ReactionPopupState createState() => ReactionPopupState();
}
Expand Down Expand Up @@ -168,6 +172,7 @@ class ReactionPopupState extends State<ReactionPopup>
}
},
emojiConfiguration: reactionPopupConfig?.emojiConfig,
emojiPickerSheetConfig: widget.emojiPickerSheetConfig,
);

void refreshWidget({
Expand Down

0 comments on commit a2dee7e

Please sign in to comment.