Migrated most of the code from deprecated widgets to v4 widgets, and changed data being supplied for full screen implementation

This commit is contained in:
Ayush Shekhar
2022-04-13 18:46:39 +05:30
parent 931506c002
commit 56b8f89479
21 changed files with 68 additions and 73 deletions
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
compileSdkVersion 31
ndkVersion '21.4.7075529'
sourceSets {
@@ -264,8 +264,7 @@
"${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework",
"${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
"${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework",
"${BUILT_PRODUCTS_DIR}/video_player/video_player.framework",
"${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework",
"${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework",
"${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework",
);
@@ -293,8 +292,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework",
);
@@ -3,7 +3,6 @@ import 'package:example/localizations.dart';
import 'package:example/routes/routes.dart';
import 'package:example/stream_version.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
@@ -160,7 +160,7 @@ class _ChannelFileDisplayScreenState extends State<ChannelFileDisplayScreen> {
padding: const EdgeInsets.all(1.0),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: FileAttachment(
child: StreamFileAttachment(
message: media.values.toList()[position],
attachment: media.keys.toList()[position],
),
@@ -86,7 +86,7 @@ class _ChannelList extends State<ChannelList> {
),
],
body: _isSearchActive
? MessageSearchListView(
? StreamMessageSearchListView(
showErrorTile: true,
messageQuery: _channelQuery,
filters: Filter.in_('members', [user!.id]),
@@ -40,7 +40,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
Positioned(
top: -3,
right: -16,
child: UnreadIndicator(),
child: StreamUnreadIndicator(),
),
],
),
@@ -70,7 +70,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
}
return Scaffold(
backgroundColor: StreamChatTheme.of(context).colorTheme.appBg,
appBar: ChannelListHeader(
appBar: StreamChannelListHeader(
onNewChatButtonTap: () {
Navigator.pushNamed(context, Routes.NEW_CHAT);
},
@@ -165,7 +165,7 @@ class LeftDrawer extends StatelessWidget {
),
child: Row(
children: [
UserAvatar(
StreamUserAvatar(
user: user,
showOnlineStatus: false,
constraints: BoxConstraints.tight(Size.fromRadius(20)),
@@ -21,7 +21,7 @@ class ChannelMediaDisplayScreen extends StatefulWidget {
final ShowMessageCallback? onShowMessage;
final MessageThemeData messageTheme;
final StreamMessageThemeData messageTheme;
const ChannelMediaDisplayScreen({
required this.messageTheme,
@@ -180,11 +180,16 @@ class _ChannelMediaDisplayScreenState extends State<ChannelMediaDisplayScreen> {
MaterialPageRoute(
builder: (context) => StreamChannel(
channel: channel,
child: FullScreenMedia(
mediaAttachments:
media.map((e) => e.attachment).toList(),
child: StreamFullScreenMedia(
mediaAttachmentPackages: media
.map(
(e) => StreamAttachmentPackage(
attachment: e.attachment,
message: e.message,
),
)
.toList(),
startIndex: position,
message: media[position].message,
userName: media[position].message.user!.name,
onShowMessage: widget.onShowMessage,
),
@@ -194,7 +199,7 @@ class _ChannelMediaDisplayScreenState extends State<ChannelMediaDisplayScreen> {
},
child: media[position].attachment.type == 'image'
? IgnorePointer(
child: ImageAttachment(
child: StreamImageAttachment(
attachment: media[position].attachment,
message: media[position].message,
showTitle: false,
@@ -60,7 +60,7 @@ class _ChannelPageState extends State<ChannelPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: StreamChatTheme.of(context).colorTheme.appBg,
appBar: ChannelHeader(
appBar: StreamChannelHeader(
showTypingIndicator: false,
onImageTap: () async {
var channel = StreamChannel.of(context).channel;
@@ -108,7 +108,7 @@ class _ChannelPageState extends State<ChannelPage> {
Expanded(
child: Stack(
children: <Widget>[
MessageListView(
StreamMessageListView(
initialScrollIndex: widget.initialScrollIndex,
initialAlignment: widget.initialAlignment,
highlightInitialMessage: widget.highlightInitialMessage,
@@ -137,7 +137,7 @@ class _ChannelPageState extends State<ChannelPage> {
);
},
deletedBottomRowBuilder: (context, message) {
return const VisibleFootnote();
return const StreamVisibleFootnote();
},
);
},
@@ -155,8 +155,7 @@ class _ChannelPageState extends State<ChannelPage> {
.colorTheme
.appBg
.withOpacity(.9),
child: TypingIndicator(
alignment: Alignment.centerLeft,
child: StreamTypingIndicator(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
@@ -174,7 +173,7 @@ class _ChannelPageState extends State<ChannelPage> {
],
),
),
MessageInput(
StreamMessageInput(
focusNode: _focusNode,
messageInputController: _messageInputController,
),
@@ -2,7 +2,6 @@ import 'package:collection/collection.dart' show IterableExtension;
import 'package:example/localizations.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'channel_file_display_screen.dart';
@@ -16,7 +15,7 @@ class ChatInfoScreen extends StatefulWidget {
/// User in consideration
final User? user;
final MessageThemeData messageTheme;
final StreamMessageThemeData messageTheme;
const ChatInfoScreen({
Key? key,
@@ -78,7 +77,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: UserAvatar(
child: StreamUserAvatar(
user: widget.user!,
constraints: BoxConstraints.tightFor(
width: 72.0,
@@ -95,7 +94,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
SizedBox(height: 7.0),
_buildConnectedTitleState(),
SizedBox(height: 15.0),
OptionListTile(
StreamOptionListTile(
title: '@${widget.user!.id}',
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
trailing: Padding(
@@ -148,7 +147,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
builder: (context, snapshot) {
mutedBool.value = snapshot.data;
return OptionListTile(
return StreamOptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
title: AppLocalizations.of(context).muteUser,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -201,7 +200,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
// ),
// onTap: () {},
// ),
OptionListTile(
StreamOptionListTile(
title: AppLocalizations.of(context).pinnedMessages,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -261,7 +260,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
);
},
),
OptionListTile(
StreamOptionListTile(
title: AppLocalizations.of(context).photosAndVideos,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -321,7 +320,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
);
},
),
OptionListTile(
StreamOptionListTile(
title: AppLocalizations.of(context).files,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -361,7 +360,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
);
},
),
OptionListTile(
StreamOptionListTile(
title: AppLocalizations.of(context).sharedGroups,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -391,7 +390,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
}
Widget _buildDeleteListTile() {
return OptionListTile(
return StreamOptionListTile(
title: 'Delete Conversation',
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body.copyWith(
@@ -632,7 +631,7 @@ class __SharedGroupsScreenState extends State<_SharedGroupsScreen> {
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: ChannelAvatar(
child: StreamChannelAvatar(
channel: channel,
constraints:
BoxConstraints(maxWidth: 40.0, maxHeight: 40.0),
@@ -124,7 +124,7 @@ class ChooseUserPage extends StatelessWidget {
arguments: HomePageArgs(client),
);
},
leading: UserAvatar(
leading: StreamUserAvatar(
user: user,
constraints: BoxConstraints.tight(
Size.fromRadius(20),
@@ -1,7 +1,6 @@
import 'package:example/localizations.dart';
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:uuid/uuid.dart';
import 'channel_page.dart';
import 'routes/routes.dart';
@@ -155,7 +154,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
),
],
),
body: ConnectionStatusBuilder(
body: StreamConnectionStatusBuilder(
statusBuilder: (context, status) {
String statusString = '';
bool showStatus = true;
@@ -172,7 +171,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
statusString = AppLocalizations.of(context).disconnected;
break;
}
return InfoTile(
return StreamInfoTile(
showMessage: showStatus,
tileAnchor: Alignment.topCenter,
childAnchor: Alignment.topCenter,
@@ -222,7 +221,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
final user = _selectedUsers[index];
return ListTile(
key: ObjectKey(user),
leading: UserAvatar(
leading: StreamUserAvatar(
user: user,
constraints: BoxConstraints.tightFor(
width: 40,
@@ -4,7 +4,6 @@ import 'package:collection/collection.dart' show IterableExtension;
import 'package:example/localizations.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'channel_file_display_screen.dart';
@@ -15,7 +14,7 @@ import 'pinned_messages_screen.dart';
import 'routes/routes.dart';
class GroupInfoScreen extends StatefulWidget {
final MessageThemeData messageTheme;
final StreamMessageThemeData messageTheme;
const GroupInfoScreen({
Key? key,
@@ -222,7 +221,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
horizontal: 8.0,
vertical: 12.0,
),
child: UserAvatar(
child: StreamUserAvatar(
user: member.user!,
constraints: BoxConstraints.tightFor(
height: 40.0,
@@ -456,7 +455,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
builder: (context, snapshot) {
mutedBool.value = snapshot.data;
return OptionListTile(
return StreamOptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor:
StreamChatTheme.of(context).colorTheme.disabled,
@@ -493,7 +492,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
onTap: () {},
);
}),
OptionListTile(
StreamOptionListTile(
title: AppLocalizations.of(context).pinnedMessages,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
@@ -553,7 +552,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
);
},
),
OptionListTile(
StreamOptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: AppLocalizations.of(context).photosAndVideos,
@@ -615,7 +614,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
);
},
),
OptionListTile(
StreamOptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: AppLocalizations.of(context).files,
@@ -660,7 +659,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
if (!channel.channel.isDistinct &&
channel.channel.ownCapabilities
.contains(PermissionType.leaveChannel))
OptionListTile(
StreamOptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: AppLocalizations.of(context).leaveGroup,
@@ -730,7 +729,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
child: _buildTextInputSection(modalSetState),
),
Expanded(
child: UserListView(
child: StreamUserListView(
selectedUsers: {},
onUserTap: (user, _) async {
_searchController!.clear();
@@ -900,7 +899,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: UserAvatar(
child: StreamUserAvatar(
user: user,
constraints: BoxConstraints.tightFor(
height: 64.0,
@@ -4,7 +4,6 @@ import 'package:example/channel_page.dart';
import 'package:example/notifications_service.dart';
import 'package:example/routes/app_routes.dart';
import 'package:example/routes/routes.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
-1
View File
@@ -4,7 +4,6 @@ import 'package:example/choose_user_page.dart';
import 'package:example/home_page.dart';
import 'package:example/localizations.dart';
import 'package:example/splash_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
@@ -130,7 +130,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
),
centerTitle: true,
),
body: ConnectionStatusBuilder(
body: StreamConnectionStatusBuilder(
statusBuilder: (context, status) {
String statusString = '';
bool showStatus = true;
@@ -147,7 +147,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
statusString = AppLocalizations.of(context).disconnected;
break;
}
return InfoTile(
return StreamInfoTile(
showMessage: showStatus,
tileAnchor: Alignment.topCenter,
childAnchor: Alignment.topCenter,
@@ -200,7 +200,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
.overlay,
shape: BoxShape.circle,
),
child: UserAvatar(
child: StreamUserAvatar(
showOnlineStatus: false,
user: user,
constraints: BoxConstraints.tightFor(
@@ -288,7 +288,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
behavior: HitTestBehavior.opaque,
onPanDown: (_) => FocusScope.of(context).unfocus(),
child: UsersBloc(
child: UserListView(
child: StreamUserListView(
selectedUsers: _selectedUsers,
groupAlphabetically:
_isSearchActive ? false : true,
@@ -366,7 +366,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
future: channel!.initialized,
builder: (context, snapshot) {
if (snapshot.data == true) {
return MessageListView();
return StreamMessageListView();
}
return Center(
@@ -384,7 +384,7 @@ class _NewChatScreenState extends State<NewChatScreen> {
},
),
),
MessageInput(
StreamMessageInput(
focusNode: _messageInputFocusNode,
preMessageSending: (message) async {
await channel!.watch();
@@ -88,7 +88,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
)
],
),
body: ConnectionStatusBuilder(
body: StreamConnectionStatusBuilder(
statusBuilder: (context, status) {
String statusString = '';
bool showStatus = true;
@@ -105,7 +105,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
statusString = AppLocalizations.of(context).disconnected;
break;
}
return InfoTile(
return StreamInfoTile(
showMessage: showStatus,
tileAnchor: Alignment.topCenter,
childAnchor: Alignment.topCenter,
@@ -136,7 +136,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
children: [
Stack(
children: [
UserAvatar(
StreamUserAvatar(
onlineIndicatorAlignment:
Alignment(0.9, 0.9),
user: user,
@@ -229,7 +229,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
behavior: HitTestBehavior.opaque,
onPanDown: (_) => FocusScope.of(context).unfocus(),
child: UsersBloc(
child: UserListView(
child: StreamUserListView(
selectedUsers: _selectedUsers,
pullToRefresh: false,
groupAlphabetically: _isSearchActive ? false : true,
@@ -21,7 +21,7 @@ class PinnedMessagesScreen extends StatefulWidget {
final ShowMessageCallback? onShowMessage;
final MessageThemeData messageTheme;
final StreamMessageThemeData messageTheme;
const PinnedMessagesScreen({
required this.messageTheme,
@@ -166,7 +166,7 @@ class _PinnedMessagesScreenState extends State<PinnedMessagesScreen> {
var text = data[position].message.text ?? '';
return ListTile(
leading: UserAvatar(
leading: StreamUserAvatar(
user: user,
constraints: BoxConstraints.tightFor(
width: 40.0,
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:lottie/lottie.dart';
mixin SplashScreenStateMixin<T extends StatefulWidget> on State<T>
+4 -4
View File
@@ -44,13 +44,13 @@ class _ThreadPageState extends State<ThreadPage> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: StreamChatTheme.of(context).colorTheme.appBg,
appBar: ThreadHeader(
appBar: StreamThreadHeader(
parent: widget.parent,
),
body: Column(
children: <Widget>[
Expanded(
child: MessageListView(
child: StreamMessageListView(
parentMessage: widget.parent,
initialScrollIndex: widget.initialScrollIndex,
initialAlignment: widget.initialAlignment,
@@ -62,14 +62,14 @@ class _ThreadPageState extends State<ThreadPage> {
return defaultMessage.copyWith(
onReplyTap: _reply,
deletedBottomRowBuilder: (context, message) {
return const VisibleFootnote();
return const StreamVisibleFootnote();
},
);
},
),
),
if (widget.parent.type != 'deleted')
MessageInput(
StreamMessageInput(
focusNode: _focusNode,
messageInputController: _messageInputController,
),
@@ -10,7 +10,7 @@ class UserMentionsPage extends StatelessWidget {
Widget build(BuildContext context) {
final user = StreamChat.of(context).currentUser!;
return MessageSearchBloc(
child: MessageSearchListView(
child: StreamMessageSearchListView(
filters: Filter.in_('members', [user.id]),
messageFilters: Filter.custom(
operator: r'$contains',
+4 -4
View File
@@ -26,7 +26,7 @@ dependencies:
ref: feat/capabilities
path: packages/stream_chat_localizations
flutter_local_notifications: ^9.0.0
flutter_svg: ^0.23.0
flutter_svg:
flutter_secure_storage: ^4.2.1
yaml: ^3.1.0
uuid: ^3.0.5
@@ -42,17 +42,17 @@ dependency_overrides:
stream_chat:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: feat/capabilities
ref: 5587622587e1fb31e1935d4209189db0434ef09b
path: packages/stream_chat
stream_chat_flutter_core:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: feat/capabilities
ref: 5587622587e1fb31e1935d4209189db0434ef09b
path: packages/stream_chat_flutter_core
stream_chat_flutter:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: feat/capabilities
ref: 5587622587e1fb31e1935d4209189db0434ef09b
path: packages/stream_chat_flutter
flutter: