Skip to content

Commit

Permalink
(Breaking) Change type of noRecentsText from String to Widget (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
LostInDarkMath authored Mar 16, 2022
1 parent c2e3a7a commit bb04802
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 28 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.2.0
- Breaking Change: `noRecentsText` of type `String` was changed to `noRecents` of type `Widget` and `noRecentsStyle` was removed from `Config`

## 1.1.2
- Fix a issue with macos platform 👨‍🔧
- Close Skin-Tone dialog on several other timings
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ EmojiPicker(
enableSkinTones: true,
showRecentsTab: true,
recentsLimit: 28,
noRecentsText: "No Recents",
noRecentsStyle:
const TextStyle(fontSize: 20, color: Colors.black26),
noRecents: const Text(
'No Recents',
style: TextStyle(fontSize: 20, color: Colors.black26),
textAlign: TextAlign.center,
),
tabIndicatorAnimDuration: kTabScrollDuration,
categoryIcons: const CategoryIcons(),
buttonMode: ButtonMode.MATERIAL
buttonMode: ButtonMode.MATERIAL,
),
)
```
Expand All @@ -82,8 +84,7 @@ See the [demo](https://github.com/Fintasys/emoji_picker_flutter/blob/master/exam
| 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 |
| noRecentsText | The text to be displayed if no recent emojis to display | "No Recents" |
| noRecentsStyle | The text style for [noRecentsText] | TextStyle(fontSize: 20, color: Colors.black26) |
| 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) |
| categoryIcons | Determines the icon to display for each Category. You can change icons by setting them in the constructor. | CategoryIcons() |
| buttonMode | Choose between Material and Cupertino button style | ButtonMode.MATERIAL |
Expand Down
8 changes: 5 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ class _MyAppState extends State<MyApp> {
enableSkinTones: true,
showRecentsTab: true,
recentsLimit: 28,
noRecentsText: 'No Recents',
noRecentsStyle: const TextStyle(
fontSize: 20, color: Colors.black26),
noRecents: const Text(
'No Recents',
style: TextStyle(fontSize: 20, color: Colors.black26),
textAlign: TextAlign.center,
),
tabIndicatorAnimDuration: kTabScrollDuration,
categoryIcons: const CategoryIcons(),
buttonMode: ButtonMode.MATERIAL)),
Expand Down
9 changes: 8 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.1.2"
version: "1.2.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -53,6 +53,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down
24 changes: 12 additions & 12 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import 'package:emoji_picker_flutter/src/category_icons.dart';
import 'package:emoji_picker_flutter/src/emoji_picker.dart';
import 'package:flutter/material.dart';

/// Default Widget if no recent is available
const DefaultNoRecentsWidget = Text(
'No Recents',
style: TextStyle(fontSize: 20, color: Colors.black26),
textAlign: TextAlign.center,
);

/// Config for customizations
class Config {
/// Constructor
Expand All @@ -24,9 +31,7 @@ class Config {
this.enableSkinTones = true,
this.showRecentsTab = true,
this.recentsLimit = 28,
this.noRecentsText = 'No Recents',
this.noRecentsStyle =
const TextStyle(fontSize: 20, color: Colors.black26),
this.noRecents = DefaultNoRecentsWidget,
this.tabIndicatorAnimDuration = kTabScrollDuration,
this.categoryIcons = const CategoryIcons(),
this.buttonMode = ButtonMode.MATERIAL});
Expand Down Expand Up @@ -81,11 +86,8 @@ class Config {
/// Limit of recently used emoji that will be saved
final int recentsLimit;

/// The text to be displayed if no recent emojis to display
final String noRecentsText;

/// The text style for [noRecentsText]
final TextStyle noRecentsStyle;
/// A widget (usually [Text]) to be displayed if no recent emojis to display
final Widget noRecents;

/// Duration of tab indicator to animate to next category
final Duration tabIndicatorAnimDuration;
Expand Down Expand Up @@ -147,8 +149,7 @@ class Config {
other.enableSkinTones == enableSkinTones &&
other.showRecentsTab == showRecentsTab &&
other.recentsLimit == recentsLimit &&
other.noRecentsText == noRecentsText &&
other.noRecentsStyle == noRecentsStyle &&
other.noRecents == noRecents &&
other.tabIndicatorAnimDuration == tabIndicatorAnimDuration &&
other.categoryIcons == categoryIcons &&
other.buttonMode == buttonMode;
Expand All @@ -172,8 +173,7 @@ class Config {
enableSkinTones.hashCode ^
showRecentsTab.hashCode ^
recentsLimit.hashCode ^
noRecentsText.hashCode ^
noRecentsStyle.hashCode ^
noRecents.hashCode ^
tabIndicatorAnimDuration.hashCode ^
categoryIcons.hashCode ^
buttonMode.hashCode;
Expand Down
7 changes: 2 additions & 5 deletions lib/src/default_emoji_picker_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,8 @@ class _DefaultEmojiPickerViewState extends State<DefaultEmojiPickerView>
/// Build Widget for when no recent emoji are available
Widget _buildNoRecent() {
return Center(
child: Text(
widget.config.noRecentsText,
style: widget.config.noRecentsStyle,
textAlign: TextAlign.center,
));
child: widget.config.noRecents,
);
}

/// Overlay for SkinTone
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: emoji_picker_flutter
description: A Flutter package that provides an Emoji picker widget with 1500+ emojis in 8 categories.
version: 1.1.2
version: 1.2.0
homepage: https://github.com/Fintasys/emoji_picker_flutter

environment:
Expand Down

0 comments on commit bb04802

Please sign in to comment.