feat: add chatTitle to baseScreenBuilder

This commit is contained in:
Freek van de Ven 2025-02-13 14:25:48 +01:00 committed by FlutterJoey
parent 8604ccada7
commit 281188c2b7
8 changed files with 20 additions and 17 deletions

View file

@ -10,6 +10,7 @@
- Added flutter_hooks as a dependency for easier state management - 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 - 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 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 ## 4.0.0
- Move to the new user story architecture - Move to the new user story architecture

View file

@ -101,10 +101,12 @@ typedef TextInputBuilder = Widget Function(
); );
/// The base screen builder /// The base screen builder
/// [title] is the title of the screen and can be null while loading
typedef BaseScreenBuilder = Widget Function( typedef BaseScreenBuilder = Widget Function(
BuildContext context, BuildContext context,
ScreenType screenType, ScreenType screenType,
PreferredSizeWidget appBar, PreferredSizeWidget appBar,
String? title,
Widget body, Widget body,
); );

View file

@ -120,6 +120,7 @@ class ChatDetailScreen extends HookWidget {
context, context,
mapScreenType, mapScreenType,
appBar, appBar,
chatTitle.value,
body, body,
); );
} }

View file

@ -44,10 +44,13 @@ class ChatProfileScreen extends HookWidget {
return () => chatScope.popHandler.remove(onExit); return () => chatScope.popHandler.remove(onExit);
}); });
var appBar = _AppBar( var chatTitle = userModel != null
user: userModel, ? "${userModel!.fullname}"
chat: chatModel, : chatModel != null
); ? chatModel?.chatName ?? options.translations.groupNameEmpty
: "";
var appBar = _AppBar(title: chatTitle);
var body = _Body( var body = _Body(
user: userModel, user: userModel,
@ -67,6 +70,7 @@ class ChatProfileScreen extends HookWidget {
context, context,
mapScreenType, mapScreenType,
appBar, appBar,
chatTitle,
body, body,
); );
} }
@ -74,27 +78,17 @@ class ChatProfileScreen extends HookWidget {
class _AppBar extends StatelessWidget implements PreferredSizeWidget { class _AppBar extends StatelessWidget implements PreferredSizeWidget {
const _AppBar({ const _AppBar({
required this.user, required this.title,
required this.chat,
}); });
final UserModel? user; final String title;
final ChatModel? chat;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var chatScope = ChatScope.of(context);
var options = chatScope.options;
var theme = Theme.of(context); var theme = Theme.of(context);
return AppBar( return AppBar(
iconTheme: theme.appBarTheme.iconTheme, iconTheme: theme.appBarTheme.iconTheme,
title: Text( title: Text(title),
user != null
? "${user!.fullname}"
: chat != null
? chat?.chatName ?? options.translations.groupNameEmpty
: "",
),
); );
} }

View file

@ -35,6 +35,7 @@ class ChatScreen extends HookWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var chatScope = ChatScope.of(context); var chatScope = ChatScope.of(context);
var options = chatScope.options; var options = chatScope.options;
var translations = options.translations;
useEffect(() { useEffect(() {
if (onExit == null) return null; if (onExit == null) return null;
@ -57,6 +58,7 @@ class ChatScreen extends HookWidget {
context, context,
mapScreenType, mapScreenType,
const _AppBar(), const _AppBar(),
translations.chatsTitle,
_Body( _Body(
onPressChat: onPressChat, onPressChat: onPressChat,
onPressStartChat: onPressStartChat, onPressStartChat: onPressStartChat,

View file

@ -100,6 +100,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
}, },
focusNode: _textFieldFocusNode, focusNode: _textFieldFocusNode,
), ),
options.translations.newChatTitle,
_Body( _Body(
isSearching: _isSearching, isSearching: _isSearching,
onPressCreateGroupChat: widget.onPressCreateGroupChat, onPressCreateGroupChat: widget.onPressCreateGroupChat,

View file

@ -58,6 +58,7 @@ class NewGroupChatOverview extends HookWidget {
context, context,
mapScreenType, mapScreenType,
const _AppBar(), const _AppBar(),
options.translations.newGroupChatTitle,
_Body( _Body(
users: users, users: users,
onComplete: onComplete, onComplete: onComplete,

View file

@ -98,6 +98,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
}, },
focusNode: _textFieldFocusNode, focusNode: _textFieldFocusNode,
), ),
options.translations.newGroupChatTitle,
_Body( _Body(
onSelectedUser: handleUserTap, onSelectedUser: handleUserTap,
selectedUsers: selectedUsers, selectedUsers: selectedUsers,