mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 02:43:50 +02:00
feat: translations
This commit is contained in:
parent
2d36d02533
commit
7b03c934cf
18 changed files with 83 additions and 76 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -32,3 +32,5 @@ migrate_working_dir/
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.packages
|
.packages
|
||||||
build/
|
build/
|
||||||
|
.flutter-plugins-dependencies
|
||||||
|
.flutter-plugins
|
|
@ -1,13 +0,0 @@
|
||||||
# This is a generated file; do not edit or check into version control.
|
|
||||||
flutter_plugin_android_lifecycle=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.7/
|
|
||||||
image_picker=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker-0.8.6/
|
|
||||||
image_picker_android=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_android-0.8.5+3/
|
|
||||||
image_picker_for_web=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_for_web-2.1.10/
|
|
||||||
image_picker_ios=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_ios-0.8.6+1/
|
|
||||||
path_provider=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/
|
|
||||||
path_provider_android=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.21/
|
|
||||||
path_provider_ios=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/
|
|
||||||
path_provider_linux=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/
|
|
||||||
path_provider_macos=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/
|
|
||||||
path_provider_windows=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/
|
|
||||||
sqflite=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/
|
|
|
@ -1 +0,0 @@
|
||||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_ios-0.8.6+1/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-2.0.7/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_android-0.8.5+3/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider_android","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.21/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[{"name":"image_picker_for_web","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/image_picker_for_web-2.1.10/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-11-07 15:48:01.951577","version":"3.3.7"}
|
|
|
@ -14,14 +14,16 @@ export 'package:flutter_community_chat_view/flutter_community_chat_view.dart';
|
||||||
class CommunityChat extends StatelessWidget {
|
class CommunityChat extends StatelessWidget {
|
||||||
const CommunityChat({
|
const CommunityChat({
|
||||||
required this.dataProvider,
|
required this.dataProvider,
|
||||||
this.chatOptions = const ChatOptions(),
|
this.options = const ChatOptions(),
|
||||||
|
this.translations = const ChatTranslations(),
|
||||||
this.imagePickerTheme = const ImagePickerTheme(),
|
this.imagePickerTheme = const ImagePickerTheme(),
|
||||||
this.imagePickerConfig = const ImagePickerConfig(),
|
this.imagePickerConfig = const ImagePickerConfig(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final CommunityChatInterface dataProvider;
|
final CommunityChatInterface dataProvider;
|
||||||
final ChatOptions chatOptions;
|
final ChatOptions options;
|
||||||
|
final ChatTranslations translations;
|
||||||
final ImagePickerTheme imagePickerTheme;
|
final ImagePickerTheme imagePickerTheme;
|
||||||
final ImagePickerConfig imagePickerConfig;
|
final ImagePickerConfig imagePickerConfig;
|
||||||
|
|
||||||
|
@ -34,7 +36,8 @@ class CommunityChat extends StatelessWidget {
|
||||||
dataProvider.getChatUsers().then((users) => _push(
|
dataProvider.getChatUsers().then((users) => _push(
|
||||||
context,
|
context,
|
||||||
NewChatScreen(
|
NewChatScreen(
|
||||||
chatOptions: chatOptions,
|
options: options,
|
||||||
|
translations: translations,
|
||||||
onPressCreateChat: (user) => dataProvider.createChat(
|
onPressCreateChat: (user) => dataProvider.createChat(
|
||||||
PersonalChatModel(user: user),
|
PersonalChatModel(user: user),
|
||||||
),
|
),
|
||||||
|
@ -45,7 +48,8 @@ class CommunityChat extends StatelessWidget {
|
||||||
Future<void> _onPressChat(BuildContext context, ChatModel chat) => _push(
|
Future<void> _onPressChat(BuildContext context, ChatModel chat) => _push(
|
||||||
context,
|
context,
|
||||||
ChatDetailScreen(
|
ChatDetailScreen(
|
||||||
chatOptions: chatOptions,
|
options: options,
|
||||||
|
translations: translations,
|
||||||
chat: chat,
|
chat: chat,
|
||||||
chatMessages: dataProvider.getMessagesStream(chat),
|
chatMessages: dataProvider.getMessagesStream(chat),
|
||||||
onPressSelectImage: (ChatModel chat) =>
|
onPressSelectImage: (ChatModel chat) =>
|
||||||
|
@ -58,12 +62,12 @@ class CommunityChat extends StatelessWidget {
|
||||||
Future<void> _onPressSelectImage(BuildContext context, ChatModel chat) =>
|
Future<void> _onPressSelectImage(BuildContext context, ChatModel chat) =>
|
||||||
showModalBottomSheet<Uint8List?>(
|
showModalBottomSheet<Uint8List?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) =>
|
builder: (BuildContext context) => options.imagePickerContainerBuilder(
|
||||||
chatOptions.imagePickerContainerBuilder(
|
|
||||||
ImagePicker(
|
ImagePicker(
|
||||||
customButton: chatOptions.closeImagePickerButtonBuilder(
|
customButton: options.closeImagePickerButtonBuilder(
|
||||||
context,
|
context,
|
||||||
() => Navigator.of(context).pop(),
|
() => Navigator.of(context).pop(),
|
||||||
|
translations,
|
||||||
),
|
),
|
||||||
imagePickerTheme: imagePickerTheme,
|
imagePickerTheme: imagePickerTheme,
|
||||||
imagePickerConfig: imagePickerConfig,
|
imagePickerConfig: imagePickerConfig,
|
||||||
|
@ -82,6 +86,7 @@ class CommunityChat extends StatelessWidget {
|
||||||
chats: dataProvider.getChatsStream(),
|
chats: dataProvider.getChatsStream(),
|
||||||
onPressStartChat: () => _onPressStartChat(context),
|
onPressStartChat: () => _onPressStartChat(context),
|
||||||
onPressChat: (chat) => _onPressChat(context, chat),
|
onPressChat: (chat) => _onPressChat(context, chat),
|
||||||
chatOptions: chatOptions,
|
options: options,
|
||||||
|
translations: translations,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ packages:
|
||||||
description:
|
description:
|
||||||
path: "packages/flutter_community_chat_view"
|
path: "packages/flutter_community_chat_view"
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: bfca7ca229a0f9e6749d079a5b447e50bef6d56f
|
resolved-ref: "4af8360850b7d8d220f3052e4be25d6eb45ef963"
|
||||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
@ -562,7 +562,7 @@ packages:
|
||||||
name: win32
|
name: win32
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.1"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# This is a generated file; do not edit or check into version control.
|
|
||||||
cloud_firestore=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.2.0/
|
|
||||||
cloud_firestore_web=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-2.8.10/
|
|
||||||
firebase_auth=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.11.2/
|
|
||||||
firebase_auth_web=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.6.1/
|
|
||||||
firebase_core=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/
|
|
||||||
firebase_core_web=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-1.7.3/
|
|
||||||
firebase_storage=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage-10.3.11/
|
|
||||||
firebase_storage_web=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage_web-3.3.9/
|
|
|
@ -1 +0,0 @@
|
||||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.2.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.11.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage-10.3.11/","native_build":true,"dependencies":["firebase_core"]}],"android":[{"name":"cloud_firestore","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.2.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.11.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage-10.3.11/","native_build":true,"dependencies":["firebase_core"]}],"macos":[{"name":"cloud_firestore","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-3.2.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.11.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage-10.3.11/","native_build":true,"dependencies":["firebase_core"]}],"linux":[],"windows":[],"web":[{"name":"cloud_firestore_web","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-2.8.10/","dependencies":["firebase_core_web"]},{"name":"firebase_auth_web","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_auth_web-4.6.1/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-1.7.3/","dependencies":[]},{"name":"firebase_storage_web","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/firebase_storage_web-3.3.9/","dependencies":["firebase_core_web"]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]}],"date_created":"2022-11-07 15:48:03.926356","version":"3.3.7"}
|
|
|
@ -1,8 +0,0 @@
|
||||||
# This is a generated file; do not edit or check into version control.
|
|
||||||
path_provider=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.11/
|
|
||||||
path_provider_android=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.21/
|
|
||||||
path_provider_ios=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/
|
|
||||||
path_provider_linux=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/
|
|
||||||
path_provider_macos=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/
|
|
||||||
path_provider_windows=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/
|
|
||||||
sqflite=/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/
|
|
|
@ -1 +0,0 @@
|
||||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_ios","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_android-2.0.21/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/sqflite-2.2.0+3/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/steinmilder/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-11-07 15:48:06.563678","version":"3.3.7"}
|
|
|
@ -6,6 +6,7 @@ library flutter_community_chat_view;
|
||||||
|
|
||||||
export 'src/components/chat_row.dart';
|
export 'src/components/chat_row.dart';
|
||||||
export 'src/config/chat_options.dart';
|
export 'src/config/chat_options.dart';
|
||||||
|
export 'src/config/chat_translations.dart';
|
||||||
export 'src/screens/chat_detail_screen.dart';
|
export 'src/screens/chat_detail_screen.dart';
|
||||||
export 'src/screens/chat_screen.dart';
|
export 'src/screens/chat_screen.dart';
|
||||||
export 'src/screens/new_chat_screen.dart';
|
export 'src/screens/new_chat_screen.dart';
|
||||||
|
|
|
@ -11,6 +11,7 @@ class ChatBottom extends StatefulWidget {
|
||||||
required this.chat,
|
required this.chat,
|
||||||
required this.onMessageSubmit,
|
required this.onMessageSubmit,
|
||||||
required this.messageInputBuilder,
|
required this.messageInputBuilder,
|
||||||
|
required this.translations,
|
||||||
this.onPressSelectImage,
|
this.onPressSelectImage,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
@ -18,8 +19,8 @@ class ChatBottom extends StatefulWidget {
|
||||||
final Future<void> Function(ChatModel chat, String text) onMessageSubmit;
|
final Future<void> Function(ChatModel chat, String text) onMessageSubmit;
|
||||||
final TextInputBuilder messageInputBuilder;
|
final TextInputBuilder messageInputBuilder;
|
||||||
final Function(ChatModel)? onPressSelectImage;
|
final Function(ChatModel)? onPressSelectImage;
|
||||||
|
|
||||||
final ChatModel chat;
|
final ChatModel chat;
|
||||||
|
final ChatTranslations translations;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ChatBottom> createState() => _ChatBottomState();
|
State<ChatBottom> createState() => _ChatBottomState();
|
||||||
|
@ -46,9 +47,7 @@ class _ChatBottomState extends State<ChatBottom> {
|
||||||
if (widget.onPressSelectImage != null)
|
if (widget.onPressSelectImage != null)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => widget.onPressSelectImage!(widget.chat),
|
onPressed: () => widget.onPressSelectImage!(widget.chat),
|
||||||
icon: const Icon(
|
icon: const Icon(Icons.image),
|
||||||
Icons.image,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -59,13 +58,12 @@ class _ChatBottomState extends State<ChatBottom> {
|
||||||
_textEditingController.clear();
|
_textEditingController.clear();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(Icons.send),
|
||||||
Icons.send,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
widget.translations,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -58,9 +58,7 @@ class _ChatDetailRowState extends State<ChatDetailRow> {
|
||||||
child: widget.message is ChatTextMessageModel
|
child: widget.message is ChatTextMessageModel
|
||||||
? Text(
|
? Text(
|
||||||
(widget.message as ChatTextMessageModel).text,
|
(widget.message as ChatTextMessageModel).text,
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 16),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 999,
|
maxLines: 999,
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,9 +24,7 @@ class ChatRow extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 10.0),
|
padding: const EdgeInsets.only(left: 10.0),
|
||||||
child: ChatImage(
|
child: ChatImage(image: image),
|
||||||
image: image,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_community_chat_view/flutter_community_chat_view.dart';
|
||||||
|
|
||||||
class ChatOptions {
|
class ChatOptions {
|
||||||
const ChatOptions({
|
const ChatOptions({
|
||||||
|
@ -25,6 +26,7 @@ class ChatOptions {
|
||||||
Widget _createNewChatButton(
|
Widget _createNewChatButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
VoidCallback onPressed,
|
VoidCallback onPressed,
|
||||||
|
ChatTranslations translations,
|
||||||
) =>
|
) =>
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
@ -33,18 +35,19 @@ Widget _createNewChatButton(
|
||||||
minimumSize: const Size.fromHeight(50),
|
minimumSize: const Size.fromHeight(50),
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: const Text('Start chat'),
|
child: Text(translations.newChatButton),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _createMessageInput(
|
Widget _createMessageInput(
|
||||||
TextEditingController textEditingController,
|
TextEditingController textEditingController,
|
||||||
Widget suffixIcon,
|
Widget suffixIcon,
|
||||||
|
ChatTranslations translations,
|
||||||
) =>
|
) =>
|
||||||
TextField(
|
TextField(
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Schrijf hier je bericht',
|
hintText: translations.messagePlaceholder,
|
||||||
suffixIcon: suffixIcon,
|
suffixIcon: suffixIcon,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -72,10 +75,13 @@ Widget _createImagePickerContainer(
|
||||||
Widget _createCloseImagePickerButton(
|
Widget _createCloseImagePickerButton(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
VoidCallback onPressed,
|
VoidCallback onPressed,
|
||||||
|
ChatTranslations translations,
|
||||||
) =>
|
) =>
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: const Text('Annuleren'),
|
child: Text(
|
||||||
|
translations.cancelImagePickerBtn,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Scaffold _createScaffold(
|
Scaffold _createScaffold(
|
||||||
|
@ -90,11 +96,13 @@ Scaffold _createScaffold(
|
||||||
typedef ButtonBuilder = Widget Function(
|
typedef ButtonBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
VoidCallback onPressed,
|
VoidCallback onPressed,
|
||||||
|
ChatTranslations translations,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef TextInputBuilder = Widget Function(
|
typedef TextInputBuilder = Widget Function(
|
||||||
TextEditingController textEditingController,
|
TextEditingController textEditingController,
|
||||||
Widget suffixIcon,
|
Widget suffixIcon,
|
||||||
|
ChatTranslations translations,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef ContainerBuilder = Widget Function(
|
typedef ContainerBuilder = Widget Function(
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
// SPDX-FileCopyrightText: 2022 Iconica
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
class ChatTranslations {
|
||||||
|
const ChatTranslations({
|
||||||
|
this.chatsTitle = 'Chats',
|
||||||
|
this.newChatButton = 'Start chat',
|
||||||
|
this.newChatTitle = 'Start chat',
|
||||||
|
this.image = 'Image',
|
||||||
|
this.searchPlaceholder = 'Search...',
|
||||||
|
this.cancelImagePickerBtn = 'Cancel',
|
||||||
|
this.messagePlaceholder = 'Write your message here...',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String chatsTitle;
|
||||||
|
final String newChatButton;
|
||||||
|
final String newChatTitle;
|
||||||
|
final String image;
|
||||||
|
final String searchPlaceholder;
|
||||||
|
final String cancelImagePickerBtn;
|
||||||
|
final String messagePlaceholder;
|
||||||
|
}
|
|
@ -11,16 +11,18 @@ import 'package:flutter_community_chat_view/src/components/chat_image.dart';
|
||||||
|
|
||||||
class ChatDetailScreen extends StatelessWidget {
|
class ChatDetailScreen extends StatelessWidget {
|
||||||
const ChatDetailScreen({
|
const ChatDetailScreen({
|
||||||
required this.chatOptions,
|
required this.options,
|
||||||
required this.chat,
|
required this.chat,
|
||||||
required this.onMessageSubmit,
|
required this.onMessageSubmit,
|
||||||
|
this.translations = const ChatTranslations(),
|
||||||
this.chatMessages,
|
this.chatMessages,
|
||||||
this.onPressSelectImage,
|
this.onPressSelectImage,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ChatModel chat;
|
final ChatModel chat;
|
||||||
final ChatOptions chatOptions;
|
final ChatOptions options;
|
||||||
|
final ChatTranslations translations;
|
||||||
final Stream<List<ChatMessageModel>>? chatMessages;
|
final Stream<List<ChatMessageModel>>? chatMessages;
|
||||||
final Function(ChatModel)? onPressSelectImage;
|
final Function(ChatModel)? onPressSelectImage;
|
||||||
final Future<void> Function(ChatModel chat, String text) onMessageSubmit;
|
final Future<void> Function(ChatModel chat, String text) onMessageSubmit;
|
||||||
|
@ -81,9 +83,10 @@ class ChatDetailScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
ChatBottom(
|
ChatBottom(
|
||||||
chat: chat,
|
chat: chat,
|
||||||
messageInputBuilder: chatOptions.messageInputBuilder,
|
messageInputBuilder: options.messageInputBuilder,
|
||||||
onPressSelectImage: onPressSelectImage,
|
onPressSelectImage: onPressSelectImage,
|
||||||
onMessageSubmit: onMessageSubmit,
|
onMessageSubmit: onMessageSubmit,
|
||||||
|
translations: translations,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -3,21 +3,22 @@
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_community_chat_interface/flutter_community_chat_interface.dart';
|
import 'package:flutter_community_chat_interface/flutter_community_chat_interface.dart';
|
||||||
import 'package:flutter_community_chat_view/flutter_community_chat_view.dart';
|
import 'package:flutter_community_chat_view/flutter_community_chat_view.dart';
|
||||||
import 'package:flutter_community_chat_view/src/services/date_formatter.dart';
|
import 'package:flutter_community_chat_view/src/services/date_formatter.dart';
|
||||||
|
|
||||||
class ChatScreen extends StatefulWidget {
|
class ChatScreen extends StatefulWidget {
|
||||||
const ChatScreen({
|
const ChatScreen({
|
||||||
required this.chatOptions,
|
required this.options,
|
||||||
required this.chats,
|
required this.chats,
|
||||||
required this.onPressStartChat,
|
required this.onPressStartChat,
|
||||||
required this.onPressChat,
|
required this.onPressChat,
|
||||||
|
this.translations = const ChatTranslations(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ChatOptions chatOptions;
|
final ChatOptions options;
|
||||||
|
final ChatTranslations translations;
|
||||||
final Stream<List<ChatModel>> chats;
|
final Stream<List<ChatModel>> chats;
|
||||||
final VoidCallback? onPressStartChat;
|
final VoidCallback? onPressStartChat;
|
||||||
final void Function(ChatModel chat) onPressChat;
|
final void Function(ChatModel chat) onPressChat;
|
||||||
|
@ -30,9 +31,9 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
final DateFormatter _dateFormatter = DateFormatter();
|
final DateFormatter _dateFormatter = DateFormatter();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => widget.chatOptions.scaffoldBuilder(
|
Widget build(BuildContext context) => widget.options.scaffoldBuilder(
|
||||||
AppBar(
|
AppBar(
|
||||||
title: const Text('Chats'),
|
title: Text(widget.translations.chatsTitle),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -49,7 +50,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
for (ChatModel chat in snapshot.data ?? [])
|
for (ChatModel chat in snapshot.data ?? [])
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => widget.onPressChat(chat),
|
onTap: () => widget.onPressChat(chat),
|
||||||
child: widget.chatOptions.chatRowContainerBuilder(
|
child: widget.options.chatRowContainerBuilder(
|
||||||
ChatRow(
|
ChatRow(
|
||||||
image: chat is PersonalChatModel
|
image: chat is PersonalChatModel
|
||||||
? chat.user.imageUrl
|
? chat.user.imageUrl
|
||||||
|
@ -62,7 +63,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
? (chat.lastMessage!
|
? (chat.lastMessage!
|
||||||
as ChatTextMessageModel)
|
as ChatTextMessageModel)
|
||||||
.text
|
.text
|
||||||
: '📷 Afbeelding'
|
: '📷 ${widget.translations.image}'
|
||||||
: null,
|
: null,
|
||||||
lastUsed: chat.lastUsed != null
|
lastUsed: chat.lastUsed != null
|
||||||
? _dateFormatter.format(
|
? _dateFormatter.format(
|
||||||
|
@ -79,9 +80,10 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.onPressStartChat != null)
|
if (widget.onPressStartChat != null)
|
||||||
widget.chatOptions.newChatButtonBuilder(
|
widget.options.newChatButtonBuilder(
|
||||||
context,
|
context,
|
||||||
widget.onPressStartChat!,
|
widget.onPressStartChat!,
|
||||||
|
widget.translations,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -8,13 +8,15 @@ import 'package:flutter_community_chat_view/flutter_community_chat_view.dart';
|
||||||
|
|
||||||
class NewChatScreen extends StatefulWidget {
|
class NewChatScreen extends StatefulWidget {
|
||||||
const NewChatScreen({
|
const NewChatScreen({
|
||||||
required this.chatOptions,
|
required this.options,
|
||||||
required this.users,
|
required this.users,
|
||||||
required this.onPressCreateChat,
|
required this.onPressCreateChat,
|
||||||
|
this.translations = const ChatTranslations(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ChatOptions chatOptions;
|
final ChatOptions options;
|
||||||
|
final ChatTranslations translations;
|
||||||
final List<ChatUserModel> users;
|
final List<ChatUserModel> users;
|
||||||
final Function(ChatUserModel) onPressCreateChat;
|
final Function(ChatUserModel) onPressCreateChat;
|
||||||
|
|
||||||
|
@ -51,12 +53,12 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
||||||
child: TextField(
|
child: TextField(
|
||||||
focusNode: _textFieldFocusNode,
|
focusNode: _textFieldFocusNode,
|
||||||
onChanged: filterUsers,
|
onChanged: filterUsers,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Zoeken...',
|
hintText: widget.translations.searchPlaceholder,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const Text('Start een chat'),
|
: Text(widget.translations.newChatButton),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
@ -78,7 +80,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
||||||
children: [
|
children: [
|
||||||
for (var user in _filteredUsers ?? widget.users)
|
for (var user in _filteredUsers ?? widget.users)
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: widget.chatOptions.chatRowContainerBuilder(
|
child: widget.options.chatRowContainerBuilder(
|
||||||
ChatRow(
|
ChatRow(
|
||||||
image: user.imageUrl,
|
image: user.imageUrl,
|
||||||
title: user.name ?? '',
|
title: user.name ?? '',
|
||||||
|
|
Loading…
Reference in a new issue