Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): migrate components to material 3 and remove interception #1897

Merged
merged 2 commits into from Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
## Unreleased

- Migrate to Material 3 and remove `useMaterial3` flag interception.

## 8.0.0-beta.2

- Bump `photo_manager` dependency to `^3.0.0-dev.5`.
Expand Down
Expand Up @@ -75,6 +75,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
Expand Up @@ -7,7 +7,7 @@ import 'package:stream_chat_flutter/src/theme/themes.dart';
import 'package:stream_chat_flutter/src/utils/utils.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';

/// {@macro streamGalleryHeader}
/// {@template streamGalleryHeader}
/// Header/AppBar widget for media display screen
/// {@endtemplate}
class StreamGalleryHeader extends StatelessWidget
Expand Down Expand Up @@ -97,6 +97,8 @@ class StreamGalleryHeader extends StatelessWidget
: const SizedBox(),
backgroundColor:
backgroundColor ?? galleryHeaderThemeData.backgroundColor,
surfaceTintColor:
backgroundColor ?? galleryHeaderThemeData.backgroundColor,
actions: <Widget>[
if (!message.isEphemeral)
IconButton(
Expand Down
Expand Up @@ -263,6 +263,7 @@ class BottomRow extends StatelessWidget {
// textScaleFactor is already applied to the textSpan.
//
// issue: https://github.com/GetStream/stream-chat-flutter/issues/1250
// ignore: deprecated_member_use
data: mediaQueryData.copyWith(textScaleFactor: 1),
child: child,
),
Expand Down
Expand Up @@ -339,7 +339,7 @@ class StreamMessageWidget extends StatefulWidget {
/// with the tap action on the reactions picker.
final OnReactionsTap? onReactionsTap;

/// {@template onReactionsHover}
/// {@macro onReactionsHover}
///
/// Note: Only used in desktop devices (web and desktop).
final OnReactionsHover? onReactionsHover;
Expand Down
Expand Up @@ -234,6 +234,7 @@ class MediaThumbnailProvider extends ImageProvider<MediaThumbnailProvider> {
}

@override
//ignore: non_nullable_equals_parameter
bool operator ==(dynamic other) {
if (other is MediaThumbnailProvider) {
return media == other.media &&
Expand Down
74 changes: 32 additions & 42 deletions packages/stream_chat_flutter/lib/src/stream_chat.dart
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 Down Expand Up @@ -68,10 +67,6 @@ class StreamChat extends StatefulWidget {
@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;

@override
StreamChatState createState() => StreamChatState();

Expand Down Expand Up @@ -112,45 +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(
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
1 change: 1 addition & 0 deletions packages/stream_chat_flutter/lib/src/utils/extensions.dart
Expand Up @@ -230,6 +230,7 @@ extension InputDecorationX on InputDecoration {
extension BuildContextX on BuildContext {
// ignore: public_member_api_docs
double get textScaleFactor =>
// ignore: deprecated_member_use
MediaQuery.maybeOf(this)?.textScaleFactor ?? 1.0;

/// Retrieves current translations according to locale
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/lib/src/utils/typedefs.dart
Expand Up @@ -136,7 +136,7 @@ typedef AttachmentThumbnailBuilder = Widget Function(
Attachment,
);

/// {@macro mentionTileBuilder}
/// {@template mentionTileBuilder}
/// A widget builder for representing a custom mention tile.
/// {@endtemplate}
typedef MentionTileBuilder = Widget Function(
Expand Down
Expand Up @@ -1309,7 +1309,11 @@ void main() {
await setUpWidgetTest(tester, itemPositionsListener: itemPositionsListener);

final root = WidgetsBinding
.instance.pipelineOwner.semanticsOwner!.rootSemanticsNode!;
.instance
//ignore: deprecated_member_use
.pipelineOwner
.semanticsOwner!
.rootSemanticsNode!;

final semanticNodes = <SemanticsNode>[root];

Expand Down