Skip to content

Commit

Permalink
Add gridPadding to make GridView padding configurable (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohom authored Jun 11, 2022
1 parent 5a51a4d commit 2db9d6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ EmojiPicker(
emojiSizeMax: 32 * (Platform.isIOS ? 1.30 : 1.0), // Issue: https://github.com/flutter/flutter/issues/28894
verticalSpacing: 0,
horizontalSpacing: 0,
gridPadding: EdgeInsets.zero,
initCategory: Category.RECENT,
bgColor: Color(0xFFF2F2F2),
indicatorColor: Colors.blue,
Expand Down Expand Up @@ -72,6 +73,7 @@ See the [demo](https://github.com/Fintasys/emoji_picker_flutter/blob/master/exam
| emojiSizeMax | Width and height the emoji will be maximal displayed |32.0 |
| verticalSpacing | Vertical spacing between emojis | 0 |
| horizontalSpacing | Horizontal spacing between emojis | 0 |
| gridPadding | The padding of GridView | EdgeInsets.zero |
| initCategory | The initial Category that will be selected |Category.RECENT |
| bgColor | The background color of the Widget |Color(0xFFF2F2F2) |
| indicatorColor | The color of the category indicator | Colors.blue |
Expand All @@ -83,7 +85,7 @@ See the [demo](https://github.com/Fintasys/emoji_picker_flutter/blob/master/exam
| skinToneIndicatorColor | Color of the small triangle next to multiple skin tone emoji | Colors.grey |
| enableSkinTones | Enable feature to select a skin tone of certain emoji's | true |
| showRecentsTab | Show extra tab with recently used emoji | true |
| recentsLimit | Limit of recently used emoji that will be saved | 28
| recentsLimit | Limit of recently used emoji that will be saved | 28 |
| replaceEmojiOnLimitExceed | Replace latest emoji on recents list on limit exceed | false
| noRecents | A widget (usually [Text]) to be displayed if no recent emojis to display | Text('No Recents', style: TextStyle(fontSize: 20, color: Colors.black26), textAlign: TextAlign.center) |
| tabIndicatorAnimDuration | Duration of tab indicator to animate to next category | Duration(milliseconds: 300) |
Expand Down
6 changes: 6 additions & 0 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Config {
this.emojiSizeMax = 32.0,
this.verticalSpacing = 0,
this.horizontalSpacing = 0,
this.gridPadding = EdgeInsets.zero,
this.initCategory = Category.RECENT,
this.bgColor = const Color(0xFFEBEFF2),
this.indicatorColor = Colors.blue,
Expand Down Expand Up @@ -99,6 +100,9 @@ class Config {
/// Change between Material and Cupertino button style
final ButtonMode buttonMode;

/// The padding of GridView, default is [EdgeInsets.zero]
final EdgeInsets gridPadding;

/// Replace latest emoji on recents list on limit exceed
final bool replaceEmojiOnLimitExceed;

Expand Down Expand Up @@ -157,6 +161,7 @@ class Config {
other.tabIndicatorAnimDuration == tabIndicatorAnimDuration &&
other.categoryIcons == categoryIcons &&
other.buttonMode == buttonMode &&
other.gridPadding == gridPadding &&
other.replaceEmojiOnLimitExceed == replaceEmojiOnLimitExceed;
}

Expand All @@ -182,5 +187,6 @@ class Config {
tabIndicatorAnimDuration.hashCode ^
categoryIcons.hashCode ^
buttonMode.hashCode ^
gridPadding.hashCode ^
replaceEmojiOnLimitExceed.hashCode;
}
2 changes: 1 addition & 1 deletion lib/src/default_emoji_picker_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
controller: _scrollController,
shrinkWrap: true,
primary: false,
padding: const EdgeInsets.all(0),
padding: widget.config.gridPadding,
crossAxisCount: widget.config.columns,
mainAxisSpacing: widget.config.verticalSpacing,
crossAxisSpacing: widget.config.horizontalSpacing,
Expand Down

0 comments on commit 2db9d6b

Please sign in to comment.