Skip to content

Commit 9cc2378

Browse files
authored
Merge pull request GetStream#53 from GetStream/chore/update-samples
chore: update dependencies and readme
2 parents 31e5a98 + ca35156 commit 9cc2378

33 files changed

+194
-145
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ With Stream's chat components, developers quickly add chat to their app for a va
2525
## Repo Overview 😎
2626

2727
This repo contains projects and samples developed by the team and Stream community. Projects are broke up into directories under the `packages` folder.
28-
Each project contains a README with build and execution instructions.
2928

30-
## **Projects 🚀**
29+
Each project contains a README with build and execution instructions.
3130

31+
## **Maintained Projects 🚀**
3232
- [Stream Chat v1](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1): a sample app implemented using Stream Chat and Flutter. It is a fully fledged messaging app built using a combination of our pre-made widgets and custom Flutter widgets.
33+
- [Chatter YouTube Series](https://github.com/HayesGordon/chatter): an ongoing, beginner friendly, YouTube video series showing how to use Stream's Flutter packages.
34+
- [iMessage clone](https://github.com/GetStream/flutter-samples/tree/main/packages/imessage): an iMessage clone implemented using Flutter and the `stream_chat_flutter_core` package.
3335

36+
## **Historic Projects 📕**
37+
*These projects are not actively maintained. They were developed using older versions of our packages and Flutter.*
3438
- [Stream Chatty](https://github.com/GetStream/flutter-samples/tree/main/packages/chatty) Stream Chatty is a sample chat app made in Flutter using Stream Chat, Firebase, and flutter_bloc. It has full light and dark mode support, real-time chat, and full authentication using Firebase auth.
3539

36-
- [iMessage clone](https://github.com/GetStream/flutter-samples/tree/main/packages/imessage): an iMessage clone implemented using Flutter and the `stream_chat_flutter_core` package.
37-
3840
## Requirements 🛠
3941

4042
Before running this project please ensure Flutter is installed and configured on your machine. If you're new to Flutter, please checkout the [official guide](https://flutter.dev/docs/get-started/install) with installation instructions for your OS.

packages/chatty/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Stream Chatty
22

3+
⚠️ **Attention**: This example is no longer maintained. It uses older versions of our packages and was tested on an older version of Flutter.
4+
5+
---
6+
37
Stream Chatty is a sample chat app made in Flutter using [Stream Chat](https://getstream.io/chat/sdk/flutter/), [Firebase](https://firebase.google.com/), and [flutter_bloc](https://bloclibrary.dev/#/). It has full light and dark mode support, real-time chat, and full authentication using Firebase auth.
48

59
Stream Chatty was created by [Diego Velasquez](http://www.twitter.com/diegoveloper) as part of a Youtube series. A step by step guide to building Stream Chatty from scratch can be found here:

packages/chatty/lib/data/local/image_picker_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ImagePickerImpl extends ImagePickerRepository {
66
@override
77
Future<File?> pickImage() async {
88
final picker = ImagePicker();
9-
final pickedFile = await picker.getImage(
9+
final pickedFile = await picker.pickImage(
1010
source: ImageSource.gallery,
1111
maxWidth: 400,
1212
);

packages/chatty/lib/data/local/stream_api_local_impl.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class StreamApiLocalImpl extends StreamApiRepository {
88
final StreamChatClient _client;
99

1010
@override
11-
Future<ChatUser> connectUser(ChatUser user, String? token) async {
11+
Future<ChatUser> connectUser(ChatUser user, String token) async {
1212
Map<String, dynamic> extraData = {};
1313
if (user.image != null) {
1414
extraData['image'] = user.image;
1515
}
1616
if (user.name != null) {
1717
extraData['name'] = user.name;
1818
}
19-
await _client.disconnect();
19+
await _client.disconnectUser();
2020
await _client.connectUser(
2121
User(id: user.id!, extraData: extraData as Map<String, Object>),
2222
token,
@@ -28,7 +28,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
2828
Future<List<ChatUser>> getChatUsers() async {
2929
final result = await _client.queryUsers();
3030
final chatUsers = result.users
31-
.where((element) => element.id != _client.state.user!.id)
31+
.where((element) => element.id != _client.state.currentUser!.id)
3232
.map(
3333
(e) => ChatUser(
3434
id: e.id,
@@ -42,7 +42,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
4242

4343
@override
4444
Future<String> getToken(String userId) async {
45-
return _client.devToken(userId);
45+
return _client.devToken(userId).rawValue;
4646
}
4747

4848
@override
@@ -52,7 +52,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
5252
final channel = _client.channel('messaging', id: channelId, extraData: {
5353
'name': name!,
5454
'image': image!,
55-
'members': [_client.state.user!.id, ...members!],
55+
'members': [_client.state.currentUser!.id, ...members!],
5656
});
5757
await channel.watch();
5858
return channel;
@@ -61,11 +61,11 @@ class StreamApiLocalImpl extends StreamApiRepository {
6161
@override
6262
Future<Channel> createSimpleChat(String? friendId) async {
6363
final channel = _client.channel('messaging',
64-
id: '${_client.state.user!.id.hashCode}${friendId.hashCode}',
64+
id: '${_client.state.currentUser!.id.hashCode}${friendId.hashCode}',
6565
extraData: {
6666
'members': [
6767
friendId,
68-
_client.state.user!.id,
68+
_client.state.currentUser!.id,
6969
],
7070
});
7171
await channel.watch();
@@ -74,7 +74,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
7474

7575
@override
7676
Future<void> logout() {
77-
return _client.disconnect();
77+
return _client.disconnectUser();
7878
}
7979

8080
@override
@@ -84,6 +84,6 @@ class StreamApiLocalImpl extends StreamApiRepository {
8484
User(id: userId),
8585
token,
8686
);
87-
return _client.state.user!.name != userId;
87+
return _client.state.currentUser!.name != userId;
8888
}
8989
}

packages/chatty/lib/data/prod/stream_api_impl.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class StreamApiImpl extends StreamApiRepository {
1111
final StreamChatClient _client;
1212

1313
@override
14-
Future<ChatUser> connectUser(ChatUser user, String? token) async {
14+
Future<ChatUser> connectUser(ChatUser user, String token) async {
1515
Map<String, dynamic> extraData = {};
1616
if (user.image != null) {
1717
extraData['image'] = user.image;
1818
}
1919
if (user.name != null) {
2020
extraData['name'] = user.name;
2121
}
22-
await _client.disconnect();
22+
await _client.disconnectUser();
2323
await _client.connectUser(
2424
User(id: user.id!, extraData: extraData as Map<String, Object>),
2525
token,
@@ -31,7 +31,7 @@ class StreamApiImpl extends StreamApiRepository {
3131
Future<List<ChatUser>> getChatUsers() async {
3232
final result = await _client.queryUsers();
3333
final chatUsers = result.users
34-
.where((element) => element.id != _client.state.user!.id)
34+
.where((element) => element.id != _client.state.currentUser!.id)
3535
.map(
3636
(e) => ChatUser(
3737
id: e.id,
@@ -44,7 +44,7 @@ class StreamApiImpl extends StreamApiRepository {
4444
}
4545

4646
@override
47-
Future<String?> getToken(String userId) async {
47+
Future<String> getToken(String userId) async {
4848
//TODO: use your own implementation in Production
4949
final response = await http.post(
5050
Uri.parse('your_backend_url'),
@@ -62,12 +62,13 @@ class StreamApiImpl extends StreamApiRepository {
6262
}
6363

6464
@override
65-
Future<Channel> createGroupChat(String id, String? name, List<String?>? members,
65+
Future<Channel> createGroupChat(
66+
String id, String? name, List<String?>? members,
6667
{String? image}) async {
6768
final channel = _client.channel('messaging', id: id, extraData: {
6869
'name': name!,
6970
'image': image!,
70-
'members': [_client.state.user!.id, ...members!],
71+
'members': [_client.state.currentUser!.id, ...members!],
7172
});
7273
await channel.watch();
7374
return channel;
@@ -76,11 +77,11 @@ class StreamApiImpl extends StreamApiRepository {
7677
@override
7778
Future<Channel> createSimpleChat(String? friendId) async {
7879
final channel = _client.channel('messaging',
79-
id: '${_client.state.user!.id.hashCode}${friendId.hashCode}',
80+
id: '${_client.state.currentUser!.id.hashCode}${friendId.hashCode}',
8081
extraData: {
8182
'members': [
8283
friendId,
83-
_client.state.user!.id,
84+
_client.state.currentUser!.id,
8485
],
8586
});
8687
await channel.watch();
@@ -89,7 +90,7 @@ class StreamApiImpl extends StreamApiRepository {
8990

9091
@override
9192
Future<void> logout() async {
92-
return _client.disconnect();
93+
return _client.disconnectUser();
9394
}
9495

9596
@override
@@ -99,6 +100,6 @@ class StreamApiImpl extends StreamApiRepository {
99100
User(id: userId),
100101
token,
101102
);
102-
return _client.state.user!.name != userId;
103+
return _client.state.currentUser!.name != userId;
103104
}
104105
}

packages/chatty/lib/data/stream_api_repository.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
33

44
abstract class StreamApiRepository {
55
Future<List<ChatUser>> getChatUsers();
6-
Future<String?> getToken(String userId);
6+
7+
Future<String> getToken(String userId);
8+
79
Future<bool> connectIfExist(String userId);
8-
Future<ChatUser> connectUser(ChatUser user, String? token);
10+
11+
Future<ChatUser> connectUser(ChatUser user, String token);
12+
913
Future<Channel> createGroupChat(
10-
String channelId, String? name, List<String?>? members,
11-
{String? image});
14+
String channelId,
15+
String? name,
16+
List<String?>? members, {
17+
String? image,
18+
});
19+
1220
Future<Channel> createSimpleChat(String? friendId);
21+
1322
Future<void> logout();
1423
}

packages/chatty/lib/domain/usecases/profile_sign_in_usecase.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '../exceptions/auth_exception.dart';
99

1010
class ProfileInput {
1111
ProfileInput({this.imageFile, this.name});
12+
1213
final File? imageFile;
1314
final String? name;
1415
}
@@ -36,11 +37,12 @@ class ProfileSignInUseCase {
3637
input.imageFile, 'users/${auth.id}');
3738
}
3839
await _streamApiRepository.connectUser(
39-
ChatUser(
40-
name: input.name,
41-
id: auth.id,
42-
image: image,
43-
),
44-
token);
40+
ChatUser(
41+
name: input.name,
42+
id: auth.id,
43+
image: image,
44+
),
45+
token,
46+
);
4547
}
4648
}

packages/chatty/lib/main.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class MyApp extends StatelessWidget {
1919

2020
@override
2121
Widget build(BuildContext context) {
22-
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
22+
SystemChrome.setEnabledSystemUIMode(
23+
SystemUiMode.manual,
24+
overlays: [SystemUiOverlay.bottom],
25+
);
2326

2427
return MultiRepositoryProvider(
2528
providers: buildRepositories(_streamChatClient),
@@ -36,9 +39,10 @@ class MyApp extends StatelessWidget {
3639
client: _streamChatClient,
3740
streamChatThemeData:
3841
StreamChatThemeData.fromTheme(Theme.of(context)).copyWith(
39-
ownMessageTheme: MessageTheme(
40-
messageBackgroundColor: Theme.of(context).accentColor,
41-
messageText: TextStyle(color: Colors.white),
42+
ownMessageTheme: MessageThemeData(
43+
messageBackgroundColor:
44+
Theme.of(context).colorScheme.secondary,
45+
messageTextStyle: TextStyle(color: Colors.white),
4246
),
4347
),
4448
);

0 commit comments

Comments
 (0)