From 9b01585faddd676d2ccf0e3370234ec530160c61 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 28 Jul 2020 15:25:10 +0200 Subject: [PATCH] update github username --- example/ios/fastlane/MatchFile | 2 +- example/lib/split_view.dart | 132 +++++++++++++++++++++++++++++++++ example/pubspec.yaml | 2 +- 3 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 example/lib/split_view.dart diff --git a/example/ios/fastlane/MatchFile b/example/ios/fastlane/MatchFile index 21b0863c..3d0ce2c0 100644 --- a/example/ios/fastlane/MatchFile +++ b/example/ios/fastlane/MatchFile @@ -2,7 +2,7 @@ git_url("https://github.com/GetStream/ios-certificates") storage_mode("git") -username("salvatore@getstream.io") +username("imtoori") team_id("EHV7XZLAHA") diff --git a/example/lib/split_view.dart b/example/lib/split_view.dart new file mode 100644 index 00000000..cbfd8798 --- /dev/null +++ b/example/lib/split_view.dart @@ -0,0 +1,132 @@ +import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +void main() async { + final client = Client( + 's2dxdhpxd94g', + logLevel: Level.INFO, + ); + + await client.setUser( + User(id: 'super-band-9'), + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A', + ); + + runApp(MyApp(client)); +} + +class MyApp extends StatelessWidget { + final Client client; + + MyApp(this.client); + + @override + Widget build(BuildContext context) { + return MaterialApp( + builder: (context, child) => StreamChat( + child: child, + client: client, + ), + home: SplitView(), + ); + } +} + +class SplitView extends StatefulWidget { + @override + _SplitViewState createState() => _SplitViewState(); +} + +class _SplitViewState extends State { + Channel selectedChannel; + + @override + Widget build(BuildContext context) { + return Flex( + direction: Axis.horizontal, + children: [ + Flexible( + child: ChannelListPage( + onTap: (channel) { + setState(() { + selectedChannel = channel; + }); + }, + ), + flex: 1, + ), + Flexible( + child: selectedChannel != null + ? StreamChannel( + key: ValueKey(selectedChannel.cid), + child: ChannelPage(), + channel: selectedChannel, + ) + : Scaffold( + body: Center( + child: Text( + 'Pick a channel to show the messages 💬', + style: Theme.of(context).textTheme.headline, + ), + ), + ), + flex: 2, + ), + ], + ); + } +} + +class ChannelListPage extends StatelessWidget { + final void Function(Channel) onTap; + + ChannelListPage({this.onTap}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ChannelsBloc( + child: ChannelListView( + onChannelTap: onTap != null + ? (channel, _) { + onTap(channel); + } + : null, + filter: { + 'members': { + '\$in': [StreamChat.of(context).user.id], + } + }, + sort: [SortOption('last_message_at')], + pagination: PaginationParams( + limit: 20, + ), + channelWidget: ChannelPage(), + ), + ), + ); + } +} + +class ChannelPage extends StatelessWidget { + const ChannelPage({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: ChannelHeader( + showBackButton: false, + ), + body: Column( + children: [ + Expanded( + child: MessageListView(), + ), + MessageInput(), + ], + ), + ); + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 86ab5a62..607913b7 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,7 +1,7 @@ name: example description: A new Flutter project. -version: 1.0.3+5 +version: 1.0.4+6 environment: sdk: ">=2.2.2 <3.0.0"