Skip to content

Commit

Permalink
release: changes for 8.0 release (#1984)
Browse files Browse the repository at this point in the history
* changes for 8.0 release

* added guide for migration to v8

* correct link for v8 migration guide

* check correctly for no connectivity

* fix tests accounting for connectivity plus
  • Loading branch information
deven98 authored Jul 22, 2024
1 parent a621277 commit 80870a8
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 106 deletions.
25 changes: 3 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,9 @@ This repository contains code for our [Dart](https://dart.dev/) and [Flutter](ht

Stream allows developers to rapidly deploy scalable feeds and chat messaging with an industry leading 99.999% uptime SLA guarantee.

**V4 Migration Guide**

> [!WARNING]
> Flutter `> = v3.16.x` uses material 3 by default which breaks the UI of some of the components.
> If you want to use these versions, you need to set the `useMaterial3` parameter to `false`
> in the `ThemeData`.
>
> eg.
>
> ```dart
> MaterialApp(
> theme: ThemeData(
> useMaterial3: false,
> ),
> ...
> );
> ```
>
> `StreamChat` widget overrides the `useMaterial3` parameter to `false` by default
> so if you are using `StreamChat` widget, you **don't** need to set it manually.
For upgrading from V6 to V7, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_7_0/)
**V8 Migration Guide**

For upgrading from V7 to V8, please refer to the [V8 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_8_0/)

## Sample apps and demos
Our team maintains a dedicated repository for full fledged sample applications and demos. Consider checking out [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples) to learn more or get started by looking at our latest [Stream Chat demo](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
id: migration_guide_8_0
title: v8.0
slug: /guides/migration_guide_8_0/
---

This guide enumerates and better explains the SDK changes introduced in v8.

If you find any bugs or have any questions, please file an [issue on our GitHub repository](https://github.com/GetStream/stream-chat-flutter/issues). We want to support you as much as we can with this migration.

Code examples:

- See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version.
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).

Our documentation has also been updated to support v8, so all guides and examples will have updated code.

### Dependencies

To migrate to v8.0.0, update your `pubspec.yaml` with the correct Stream chat package you're using:

```yaml
dependencies:
stream_chat_flutter: ^8.0.0 # full UI, core and client packages
stream_chat: ^8.0.0 # client package
```

---

## Important notes

- The package from recent versions has been restricted to Flutter 3.19+ as we generally aim to support
the latest and the previous version of Flutter when possible.

- The `attachmentBuilders` parameter in the `StreamMessageListView` now only expect custom attachments
and does not need the default attachment builders. You can also use `StreamAttachmentWidgetBuilder.defaultBuilders`
to add the default builders if necessary.

## Breaking changes

Version 8.0 has two main breaking changes.

### Removal of the `useMaterial3` flag

In v7, we introduced a temporary `useMaterial3` flag that allows users to optionally use Material3 styling in Stream components.
This was necessary at the time for various reasons.

However, this flag is now removed and Material3 will be the default styling for all components.

### Connectivity stream changes

While this is a not directly a user-facing change, it is added here for completeness of the list.

The `StreamChat` widget has a `connectivityStream` parameter to allow testing of various scenarios.
Due to changes in the relevant package, it was necessary to change the type of the stream from
`Stream<ConnectivityResult>?` to `Stream<List<ConnectivityResult>>?`.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -428,7 +428,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -477,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class _StreamGalleryFooterState extends State<StreamGalleryFooter> {
context: context,
removeTop: true,
child: BottomAppBar(
surfaceTintColor:
widget.backgroundColor ?? galleryFooterThemeData.backgroundColor,
color:
widget.backgroundColor ?? galleryFooterThemeData.backgroundColor,
child: Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class StreamGalleryHeader extends StatelessWidget
onPressed: onBackPressed,
)
: const SizedBox(),
surfaceTintColor:
backgroundColor ?? galleryHeaderThemeData.backgroundColor,
backgroundColor:
backgroundColor ?? galleryHeaderThemeData.backgroundColor,
actions: <Widget>[
Expand Down
77 changes: 33 additions & 44 deletions packages/stream_chat_flutter/lib/src/stream_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class StreamChat extends StatefulWidget {
this.onBackgroundEventReceived,
this.backgroundKeepAlive = const Duration(minutes: 1),
this.connectivityStream,
this.useMaterial3 = false,
});

/// Client to do chat operations with
Expand All @@ -66,11 +65,7 @@ class StreamChat extends StatefulWidget {
/// Stream of connectivity result
/// Visible for testing
@visibleForTesting
final Stream<ConnectivityResult>? connectivityStream;

/// Whether to use material 3 or not (default is false)
/// See our [docs](https://getstream.io/chat/docs/sdk/flutter/stream_chat_flutter/stream_chat_and_theming)
final bool useMaterial3;
final Stream<List<ConnectivityResult>>? connectivityStream;

@override
StreamChatState createState() => StreamChatState();
Expand Down Expand Up @@ -112,46 +107,40 @@ class StreamChatState extends State<StreamChat> {
@override
Widget build(BuildContext context) {
final theme = _getTheme(context, widget.streamChatThemeData);
return Theme(
data: Theme.of(context).copyWith(
// ignore: deprecated_member_use
useMaterial3: widget.useMaterial3,
),
child: Portal(
child: StreamChatConfiguration(
data: streamChatConfigData,
child: StreamChatTheme(
data: theme,
child: Builder(
builder: (context) {
final materialTheme = Theme.of(context);
final streamTheme = StreamChatTheme.of(context);
return Theme(
data: materialTheme.copyWith(
primaryIconTheme: streamTheme.primaryIconTheme,
colorScheme: materialTheme.colorScheme.copyWith(
secondary: streamTheme.colorTheme.accentPrimary,
),
return Portal(
child: StreamChatConfiguration(
data: streamChatConfigData,
child: StreamChatTheme(
data: theme,
child: Builder(
builder: (context) {
final materialTheme = Theme.of(context);
final streamTheme = StreamChatTheme.of(context);
return Theme(
data: materialTheme.copyWith(
primaryIconTheme: streamTheme.primaryIconTheme,
colorScheme: materialTheme.colorScheme.copyWith(
secondary: streamTheme.colorTheme.accentPrimary,
),
child: StreamChatCore(
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
connectivityStream: widget.connectivityStream,
child: Builder(
builder: (context) {
StreamChatClient.additionalHeaders = {
'X-Stream-Client':
'${StreamChatClient.defaultUserAgent}-'
'ui-${StreamChatClient.packageVersion}',
};
return widget.child ?? const Offstage();
},
),
),
child: StreamChatCore(
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
connectivityStream: widget.connectivityStream,
child: Builder(
builder: (context) {
StreamChatClient.additionalHeaders = {
'X-Stream-Client':
'${StreamChatClient.defaultUserAgent}-'
'ui-${StreamChatClient.packageVersion}',
};
return widget.child ?? const Offstage();
},
),
);
},
),
),
);
},
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions packages/stream_chat_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ dependencies:
image_size_getter: ^2.1.3
jiffy: ^6.2.1
just_audio: ^0.9.38
lottie: ">=2.6.0 <4.0.0"
lottie: ^3.1.2
media_kit: ^1.1.10+1
media_kit_video: ^1.2.4
meta: ^1.9.1
path_provider: ^2.1.3
photo_manager: ^3.2.0
photo_view: ^0.15.0
rxdart: ^0.27.7
share_plus: ">=8.0.2 <10.0.0"
share_plus: ^8.0.3
shimmer: ^3.0.0
stream_chat_flutter_core: ^7.3.0
synchronized: ^3.1.0+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannel.name,
methodChannel.codec.encodeSuccessEnvelope('wifi'),
methodChannel.codec.encodeSuccessEnvelope(['wifi']),
(_) {},
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannel.name,
methodChannel.codec.encodeSuccessEnvelope('wifi'),
methodChannel.codec.encodeSuccessEnvelope(['wifi']),
(_) {},
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannel.name,
methodChannel.codec.encodeSuccessEnvelope('wifi'),
methodChannel.codec.encodeSuccessEnvelope(['wifi']),
(_) {},
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannel.name,
methodChannel.codec.encodeSuccessEnvelope('wifi'),
methodChannel.codec.encodeSuccessEnvelope(['wifi']),
(_) {},
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
.instance.defaultBinaryMessenger
.handlePlatformMessage(
methodChannel.name,
methodChannel.codec.encodeSuccessEnvelope('wifi'),
methodChannel.codec.encodeSuccessEnvelope(['wifi']),
(_) {},
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void main() {
StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down Expand Up @@ -136,7 +136,7 @@ void main() {
home: StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down Expand Up @@ -194,7 +194,7 @@ void main() {
home: StreamChat(
streamChatThemeData: theme,
client: client,
connectivityStream: Stream.value(ConnectivityResult.mobile),
connectivityStream: Stream.value([ConnectivityResult.mobile]),
child: StreamChannel(
showLoading: false,
channel: channel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ cool.''';
home: SimpleFrame(
child: StreamChat(
client: client,
connectivityStream: Stream.value(ConnectivityResult.wifi),
connectivityStream: Stream.value([ConnectivityResult.wifi]),
child: StreamChannel(
channel: channel,
child: Scaffold(
Expand Down
Loading

0 comments on commit 80870a8

Please sign in to comment.