mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-18 18:33:49 +02:00
feat: add chatTitle to baseScreenBuilder
This commit is contained in:
parent
8604ccada7
commit
281188c2b7
8 changed files with 20 additions and 17 deletions
|
@ -10,6 +10,7 @@
|
|||
- Added flutter_hooks as a dependency for easier state management
|
||||
- Added FlutterChatDetailNavigatorUserstory that can be used to start the userstory from the chat detail screen without having the chat overview screen
|
||||
- Changed the ChatDetailScreen to use the chatId instead of the ChatModel, the screen will now fetch the chat from the ChatService
|
||||
- Changed baseScreenBuilder to include a chatTitle that can be used to show provide the title logic to apps that use the baseScreenBuilder
|
||||
|
||||
## 4.0.0
|
||||
- Move to the new user story architecture
|
||||
|
|
|
@ -101,10 +101,12 @@ typedef TextInputBuilder = Widget Function(
|
|||
);
|
||||
|
||||
/// The base screen builder
|
||||
/// [title] is the title of the screen and can be null while loading
|
||||
typedef BaseScreenBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
ScreenType screenType,
|
||||
PreferredSizeWidget appBar,
|
||||
String? title,
|
||||
Widget body,
|
||||
);
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ class ChatDetailScreen extends HookWidget {
|
|||
context,
|
||||
mapScreenType,
|
||||
appBar,
|
||||
chatTitle.value,
|
||||
body,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,10 +44,13 @@ class ChatProfileScreen extends HookWidget {
|
|||
return () => chatScope.popHandler.remove(onExit);
|
||||
});
|
||||
|
||||
var appBar = _AppBar(
|
||||
user: userModel,
|
||||
chat: chatModel,
|
||||
);
|
||||
var chatTitle = userModel != null
|
||||
? "${userModel!.fullname}"
|
||||
: chatModel != null
|
||||
? chatModel?.chatName ?? options.translations.groupNameEmpty
|
||||
: "";
|
||||
|
||||
var appBar = _AppBar(title: chatTitle);
|
||||
|
||||
var body = _Body(
|
||||
user: userModel,
|
||||
|
@ -67,6 +70,7 @@ class ChatProfileScreen extends HookWidget {
|
|||
context,
|
||||
mapScreenType,
|
||||
appBar,
|
||||
chatTitle,
|
||||
body,
|
||||
);
|
||||
}
|
||||
|
@ -74,27 +78,17 @@ class ChatProfileScreen extends HookWidget {
|
|||
|
||||
class _AppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const _AppBar({
|
||||
required this.user,
|
||||
required this.chat,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final UserModel? user;
|
||||
final ChatModel? chat;
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var chatScope = ChatScope.of(context);
|
||||
var options = chatScope.options;
|
||||
var theme = Theme.of(context);
|
||||
return AppBar(
|
||||
iconTheme: theme.appBarTheme.iconTheme,
|
||||
title: Text(
|
||||
user != null
|
||||
? "${user!.fullname}"
|
||||
: chat != null
|
||||
? chat?.chatName ?? options.translations.groupNameEmpty
|
||||
: "",
|
||||
),
|
||||
title: Text(title),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class ChatScreen extends HookWidget {
|
|||
Widget build(BuildContext context) {
|
||||
var chatScope = ChatScope.of(context);
|
||||
var options = chatScope.options;
|
||||
var translations = options.translations;
|
||||
|
||||
useEffect(() {
|
||||
if (onExit == null) return null;
|
||||
|
@ -57,6 +58,7 @@ class ChatScreen extends HookWidget {
|
|||
context,
|
||||
mapScreenType,
|
||||
const _AppBar(),
|
||||
translations.chatsTitle,
|
||||
_Body(
|
||||
onPressChat: onPressChat,
|
||||
onPressStartChat: onPressStartChat,
|
||||
|
|
|
@ -100,6 +100,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||
},
|
||||
focusNode: _textFieldFocusNode,
|
||||
),
|
||||
options.translations.newChatTitle,
|
||||
_Body(
|
||||
isSearching: _isSearching,
|
||||
onPressCreateGroupChat: widget.onPressCreateGroupChat,
|
||||
|
|
|
@ -58,6 +58,7 @@ class NewGroupChatOverview extends HookWidget {
|
|||
context,
|
||||
mapScreenType,
|
||||
const _AppBar(),
|
||||
options.translations.newGroupChatTitle,
|
||||
_Body(
|
||||
users: users,
|
||||
onComplete: onComplete,
|
||||
|
|
|
@ -98,6 +98,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||
},
|
||||
focusNode: _textFieldFocusNode,
|
||||
),
|
||||
options.translations.newGroupChatTitle,
|
||||
_Body(
|
||||
onSelectedUser: handleUserTap,
|
||||
selectedUsers: selectedUsers,
|
||||
|
|
Loading…
Reference in a new issue