rename Client to StreamChatClient

This commit is contained in:
Salvatore Giordano
2021-02-01 15:30:46 +01:00
parent 1751cd6092
commit 23feabe85e
33 changed files with 185 additions and 176 deletions
+2 -2
View File
@@ -91,7 +91,7 @@ Out of the box, all chat widgets use their default styling, and there are two wa
1. Initialize the `StreamChatTheme` from your existing `MaterialApp` style
```dart
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -117,7 +117,7 @@ Out of the box, all chat widgets use their default styling, and there are two wa
2. Construct a custom theme and provide all the customizations needed
```dart
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -267,7 +267,7 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
),
);
final client = Client(
final client = StreamChatClient(
apiKey,
logLevel: Level.INFO,
)..chatPersistenceClient = chatPersistentClient;
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
/// or to retrieve outer scope needed such as messages from the [Channel.state].
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -29,7 +29,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// We also change the message color posted by the current user.
/// You can perform these more granular style changes using [StreamChatTheme.copyWith].
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -33,7 +33,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -20,7 +20,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// - We retrieve the count of unread messages from [Channel.state]
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -34,7 +34,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
/// or to retrieve outer scope needed such as messages from the [Channel.state].
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -29,7 +29,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -29,7 +29,7 @@ void main() async {
final apiKey = await secureStorage.read(key: kStreamApiKey);
final userId = await secureStorage.read(key: kStreamUserId);
final client = Client(
final client = StreamChatClient(
apiKey ?? kDefaultStreamApiKey,
logLevel: Level.INFO,
)..chatPersistenceClient = chatPersistentClient;
@@ -46,7 +46,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// In this case we are showing the list of channels the current user is a member and we order them based on the time they had a new message.
/// [ChannelListView] handles pagination and updates automatically out of the box when new channels are created or when a new message is added to a channel.
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -33,7 +33,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -5,8 +5,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// There are three important things to notice that are common to all Flutter application using StreamChat:
///
/// 1. The Dart API [Client] is initialized with your API Key
/// 2. The current user is set by calling [Client.setUser]
/// 1. The Dart API [StreamChatClient] is initialized with your API Key
/// 2. The current user is set by calling [StreamChatClient.setUser]
/// 3. The client is then passed to the top-level [StreamChat] widget
/// [StreamChat] is an inherited widget and must be the parent of all Chat related widgets.
///
@@ -15,9 +15,9 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// Let's have a look at what we've built:
///
/// - We set up the Chat [Client] with the API key
/// - We set up the Chat [StreamChatClient] with the API key
///
/// - We set the the current user for Chat with [Client.setUser] and a pre-generated user token
/// - We set the the current user for Chat with [StreamChatClient.setUser] and a pre-generated user token
///
/// - We make [StreamChat] the root Widget of our application
///
@@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// If you now run the simulator you will see a single channel UI.
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -44,7 +44,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
final Channel channel;
MyApp(this.client, this.channel);
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -16,7 +16,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -10,7 +10,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// Now we can open threads and create new ones as well, if you long press a message you can tap on Reply and it will open the same [ThreadPage].
void main() async {
final client = Client(
final client = StreamChatClient(
's2dxdhpxd94g',
logLevel: Level.INFO,
);
@@ -24,7 +24,7 @@ void main() async {
}
class MyApp extends StatelessWidget {
final Client client;
final StreamChatClient client;
MyApp(this.client);
@@ -1,13 +1,13 @@
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'package:stream_chat_flutter/src/back_button.dart';
import 'package:stream_chat_flutter/src/channel_info.dart';
import 'package:stream_chat_flutter/src/channel_name.dart';
import 'package:stream_chat_flutter/src/info_tile.dart';
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import '../stream_chat_flutter.dart';
import './channel_name.dart';
import '../stream_chat_flutter.dart';
import 'channel_image.dart';
import 'connection_status_builder.dart';
@@ -18,7 +18,7 @@ import 'connection_status_builder.dart';
///
/// ```dart
/// class MyApp extends StatelessWidget {
/// final Client client;
/// final StreamChatClient client;
/// final Channel channel;
///
/// MyApp(this.client, this.channel);
@@ -1,8 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'package:stream_chat_flutter/src/group_image.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_image.png)
/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_image_paint.png)
@@ -11,7 +11,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// ```dart
/// class MyApp extends StatelessWidget {
/// final Client client;
/// final StreamChatClient client;
/// final Channel channel;
///
/// MyApp(this.client, this.channel);
@@ -111,7 +111,8 @@ class ChannelInfo extends StatelessWidget {
);
}
Widget _buildDisconnectedTitleState(BuildContext context, Client client) {
Widget _buildDisconnectedTitleState(
BuildContext context, StreamChatClient client) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -2,9 +2,9 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'package:stream_chat_flutter/src/stream_neumorphic_button.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'connection_status_builder.dart';
import 'info_tile.dart';
@@ -13,15 +13,15 @@ import 'stream_chat.dart';
typedef _TitleBuilder = Widget Function(
BuildContext context,
ConnectionStatus status,
Client client,
StreamChatClient client,
);
///
/// It shows the current [Client] status.
/// It shows the current [StreamChatClient] status.
///
/// ```dart
/// class MyApp extends StatelessWidget {
/// final Client client;
/// final StreamChatClient client;
///
/// MyApp(this.client);
///
@@ -42,8 +42,8 @@ typedef _TitleBuilder = Widget Function(
/// Usually you would use this widget as an [AppBar] inside a [Scaffold].
/// However you can also use it as a normal widget.
///
/// The widget by default uses the inherited [Client] to fetch information about the status.
/// However you can also pass your own [Client] if you don't have it in the widget tree.
/// The widget by default uses the inherited [StreamChatClient] to fetch information about the status.
/// However you can also pass your own [StreamChatClient] if you don't have it in the widget tree.
///
/// The widget components render the ui based on the first ancestor of type [StreamChatTheme] and on its [ChannelTheme.channelHeaderTheme] property.
/// Modify it to change the widget appearance.
@@ -59,8 +59,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
this.preNavigationCallback,
}) : super(key: key);
/// Pass this if you don't have a [Client] in your widget tree.
final Client client;
/// Pass this if you don't have a [StreamChatClient] in your widget tree.
final StreamChatClient client;
/// Use this to build your own title as per different [ConnectionStatus]
final _TitleBuilder titleBuilder;
@@ -215,7 +215,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
);
}
Widget _buildDisconnectedTitleState(BuildContext context, Client client) {
Widget _buildDisconnectedTitleState(
BuildContext context, StreamChatClient client) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'stream_chat.dart';
/// Widget that builds itself based on the latest snapshot of interaction with
/// a [Stream] of type [ConnectionStatus].
///
/// The widget will use the closest [Client.wsConnectionStatusStream] in case no
/// The widget will use the closest [StreamChatClient.wsConnectionStatusStream] in case no
/// stream is provided.
class ConnectionStatusBuilder extends StatelessWidget {
/// Creates a new ConnectionStatusBuilder
@@ -4,14 +4,14 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
/// Widget used to provide information about the chat to the widget tree
///
/// class MyApp extends StatelessWidget {
/// final Client client;
/// final StreamChatClient client;
///
/// MyApp(this.client);
///
@@ -30,7 +30,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
///
/// Use [StreamChat.of] to get the current [StreamChatState] instance.
class StreamChat extends StatefulWidget {
final Client client;
final StreamChatClient client;
final Widget child;
final StreamChatThemeData streamChatThemeData;
@@ -73,7 +73,7 @@ class StreamChat extends StatefulWidget {
/// The current state of the StreamChat widget
class StreamChatState extends State<StreamChat> {
Client get client => widget.client;
StreamChatClient get client => widget.client;
@override
Widget build(BuildContext context) {
+1 -1
View File
@@ -1,7 +1,7 @@
import 'package:mockito/mockito.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
class MockClient extends Mock implements Client {}
class MockClient extends Mock implements StreamChatClient {}
class MockClientState extends Mock implements ClientState {}