mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 02:43:50 +02:00
feat: add chatTitle to baseScreenBuilder
This commit is contained in:
parent
6c7887700e
commit
ab8045e6bf
8 changed files with 20 additions and 17 deletions
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ class ChatDetailScreen extends HookWidget {
|
||||||
context,
|
context,
|
||||||
mapScreenType,
|
mapScreenType,
|
||||||
appBar,
|
appBar,
|
||||||
|
chatTitle.value,
|
||||||
body,
|
body,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
: "",
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue