-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 🔨 updated config dependencies using inherited widget and re…
…move unnecessary repetitive code
- Loading branch information
1 parent
2f530e0
commit 371f8d4
Showing
10 changed files
with
309 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
lib/src/inherited_widgets/configurations_inherited_widgets.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:chatview/src/models/models.dart'; | ||
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class ConfigurationsInheritedWidget extends InheritedWidget { | ||
const ConfigurationsInheritedWidget({ | ||
Key? key, | ||
required Widget child, | ||
required this.chatBackgroundConfig, | ||
this.reactionPopupConfig, | ||
this.messageConfig, | ||
this.chatBubbleConfig, | ||
this.profileCircleConfig, | ||
this.swipeToReplyConfig, | ||
this.repliedMessageConfig, | ||
this.typeIndicatorConfig, | ||
this.replyPopupConfig, | ||
this.emojiPickerSheetConfig, | ||
}) : super(key: key, child: child); | ||
|
||
/// Provides configuration for background of chat. | ||
final ChatBackgroundConfiguration chatBackgroundConfig; | ||
|
||
/// Provides configuration for reaction pop up appearance. | ||
final ReactionPopupConfiguration? reactionPopupConfig; | ||
|
||
/// Provides configuration for customisation of different types | ||
/// messages. | ||
final MessageConfiguration? messageConfig; | ||
|
||
/// Provides configuration of chat bubble's appearance. | ||
final ChatBubbleConfiguration? chatBubbleConfig; | ||
|
||
/// Provides configuration for profile circle avatar of user. | ||
final ProfileCircleConfiguration? profileCircleConfig; | ||
|
||
/// Provides configuration for when user swipe to chat bubble. | ||
final SwipeToReplyConfiguration? swipeToReplyConfig; | ||
|
||
/// Provides configuration for replied message view which is located upon chat | ||
/// bubble. | ||
final RepliedMessageConfiguration? repliedMessageConfig; | ||
|
||
/// Provides configuration of typing indicator's appearance. | ||
final TypeIndicatorConfiguration? typeIndicatorConfig; | ||
|
||
/// Provides configuration for reply snack bar's appearance and options. | ||
final ReplyPopupConfiguration? replyPopupConfig; | ||
|
||
/// Configuration for emoji picker sheet | ||
final Config? emojiPickerSheetConfig; | ||
|
||
static ConfigurationsInheritedWidget? of(BuildContext context) => context | ||
.dependOnInheritedWidgetOfExactType<ConfigurationsInheritedWidget>(); | ||
|
||
@override | ||
bool updateShouldNotify(covariant ConfigurationsInheritedWidget oldWidget) => | ||
oldWidget != this; | ||
} |
Oops, something went wrong.