* chore: Add ImageHeaderTheme and ImageHeaderThemeData to stream_chat_theme.dart This commit adds the following classes to `stream_chat_theme.dart`: 1. `ImageHeaderTheme`, an `InheritedTheme` widget that can wrap other widgets and provide that sub-tree with an `ImageHeaderThemeData` 2. `ImageHeaderThemeData`, a class that allows for the customization of `ImageHeader` widgets * Make ImageHeaderThemeData constructor const * test: initial ImageHeaderThemeData tests Tests the copyWith, ==, and hashcode functions * test: add tests for default ImageHeaderThemeData values Tests the default values of ImageHeaderThemeData that gets built in a StreamChatThemeData against control values. * Update test name and add comments describing control * fix: use ImageHeaderTheme.of(context) instead of StreamChatTheme.of(context) This ensures that ImageHeader will always look for the closest ImageHeaderThemeData in the widget tree. * test: add dark theme default values test * run dartfmt on test file * test: lerping between ImageHeaderThemeData Added tests that lerp from one ImageHeaderThemeData to another (light to dark and dark to light) * test: merging ImageHeaderThemeData Added tests that merge light and dark ImageHeaderThemeData together (light + dark = dark, dark + light = light) * test: add a half-lerp test Added a test that lerps halway between light and dark ImageHeaderThemeData * chore: Add ImageFooterTheme and ImageFooterThemeData to stream_chat_theme.dart This commit adds the following classes to `stream_chat_theme.dart`: 1. `ImageFooterTheme`, an `InheritedTheme` widget that can wrap other widgets and provide that sub-tree with an `ImageFooterThemeData` 2. `ImageFooterThemeData`, a class that allows for the customization of `ImageFooter` widget * chore: apply ImageFooterThemeData to image_footer.dart * fix: make ImageFooterThemeData constructor const * test: add tests for ImageFooterThemeData * add a missing trailing comma * chore: rename ImageHeader & ImageFooter to GalleryHeader and GalleryFooter The respective theme classes and tests have also been renamed * Run dartfmt on test * test: fix failing tests due to renaming
53 lines
1.6 KiB
Dart
53 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mocktail/mocktail.dart';
|
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|
|
|
import 'mocks.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'it should show channel typing',
|
|
(WidgetTester tester) async {
|
|
final client = MockClient();
|
|
final clientState = MockClientState();
|
|
final channel = MockChannel();
|
|
final channelState = MockChannelState();
|
|
final lastMessageAt = DateTime.parse('2020-06-22 12:00:00');
|
|
|
|
when(() => client.state).thenReturn(clientState);
|
|
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
|
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
|
when(() => channel.state).thenReturn(channelState);
|
|
when(() => channel.client).thenReturn(client);
|
|
when(() => channel.isMuted).thenReturn(false);
|
|
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
|
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
|
'name': 'test',
|
|
}));
|
|
when(() => channel.extraData).thenReturn({
|
|
'name': 'test',
|
|
});
|
|
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: StreamChat(
|
|
client: client,
|
|
child: StreamChannel(
|
|
channel: channel,
|
|
child: WillPopScope(
|
|
onWillPop: () async => false,
|
|
child: Scaffold(
|
|
body: GalleryFooter(
|
|
message: Message(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
|
|
expect(find.byType(StreamSvgIcon), findsNWidgets(2));
|
|
},
|
|
);
|
|
}
|