align app with main repo
This commit is contained in:
@@ -1,17 +1,12 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:example/routes/app_routes.dart';
|
|
||||||
import 'package:example/routes/routes.dart';
|
import 'package:example/routes/routes.dart';
|
||||||
import 'package:example/stream_version.dart';
|
import 'package:example/stream_version.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';
|
|
||||||
|
|
||||||
import 'choose_user_page.dart';
|
import 'choose_user_page.dart';
|
||||||
import 'notifications_service.dart';
|
import 'main.dart';
|
||||||
|
|
||||||
class AdvancedOptionsPage extends StatefulWidget {
|
class AdvancedOptionsPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@@ -272,14 +267,10 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
apiKey,
|
apiKey,
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
showLocalNotification: (!kIsWeb && Platform.isAndroid)
|
)..chatPersistenceClient = chatPersistentClient;
|
||||||
? showLocalNotification
|
|
||||||
: null,
|
|
||||||
persistenceEnabled: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.setUser(
|
await client.setUser(
|
||||||
@@ -289,10 +280,6 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
|||||||
userToken,
|
userToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!kIsWeb) {
|
|
||||||
initNotifications(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
final secureStorage = FlutterSecureStorage();
|
final secureStorage = FlutterSecureStorage();
|
||||||
secureStorage.write(
|
secureStorage.write(
|
||||||
key: kStreamApiKey,
|
key: kStreamApiKey,
|
||||||
@@ -319,73 +306,13 @@ class _AdvancedOptionsPageState extends State<AdvancedOptionsPage> {
|
|||||||
await client.disconnect();
|
await client.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kIsWeb) {
|
|
||||||
initNotifications(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
Navigator.pop(context);
|
|
||||||
Navigator.pop(context);
|
|
||||||
await Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) {
|
|
||||||
return FutureBuilder<StreamingSharedPreferences>(
|
|
||||||
future: StreamingSharedPreferences.instance,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (!snapshot.hasData) {
|
|
||||||
return SizedBox();
|
|
||||||
}
|
|
||||||
return PreferenceBuilder<int>(
|
|
||||||
preference: snapshot.data.getInt(
|
|
||||||
'theme',
|
|
||||||
defaultValue: 0,
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) => MaterialApp(
|
|
||||||
builder: (context, child) {
|
|
||||||
return StreamChat(
|
|
||||||
client: client,
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) =>
|
|
||||||
AnnotatedRegion<
|
|
||||||
SystemUiOverlayStyle>(
|
|
||||||
child: child,
|
|
||||||
value: SystemUiOverlayStyle(
|
|
||||||
systemNavigationBarColor:
|
|
||||||
StreamChatTheme.of(context)
|
|
||||||
.colorTheme
|
|
||||||
.white,
|
|
||||||
systemNavigationBarIconBrightness:
|
|
||||||
Theme.of(context)
|
|
||||||
.brightness ==
|
|
||||||
Brightness.dark
|
|
||||||
? Brightness.light
|
|
||||||
: Brightness.dark,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
theme: ThemeData.light(),
|
|
||||||
darkTheme: ThemeData.dark(),
|
|
||||||
themeMode: {
|
|
||||||
-1: ThemeMode.dark,
|
|
||||||
0: ThemeMode.system,
|
|
||||||
1: ThemeMode.light,
|
|
||||||
}[snapshot],
|
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
|
||||||
initialRoute: client.state.user == null
|
|
||||||
? Routes.CHOOSE_USER
|
|
||||||
: Routes.HOME,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
loading = false;
|
loading = false;
|
||||||
|
await Navigator.pushNamedAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
Routes.APP,
|
||||||
|
ModalRoute.withName(Routes.APP),
|
||||||
|
arguments: client,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:jiffy/jiffy.dart';
|
import 'package:jiffy/jiffy.dart';
|
||||||
|
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
import 'main.dart';
|
import 'main.dart';
|
||||||
@@ -285,7 +284,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
|||||||
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
|
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
|
||||||
leading: Padding(
|
leading: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 22.0),
|
padding: const EdgeInsets.symmetric(horizontal: 22.0),
|
||||||
child: StreamSvgIcon.Icon_group(
|
child: StreamSvgIcon.iconGroup(
|
||||||
size: 24.0,
|
size: 24.0,
|
||||||
color:
|
color:
|
||||||
StreamChatTheme.of(context).colorTheme.black.withOpacity(0.5),
|
StreamChatTheme.of(context).colorTheme.black.withOpacity(0.5),
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import 'package:example/stream_version.dart';
|
import 'package:example/stream_version.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
import 'notifications_service.dart';
|
|
||||||
import 'routes/routes.dart';
|
import 'routes/routes.dart';
|
||||||
|
|
||||||
const kStreamApiKey = 'STREAM_API_KEY';
|
const kStreamApiKey = 'STREAM_API_KEY';
|
||||||
@@ -187,10 +185,6 @@ class ChooseUserPage extends StatelessWidget {
|
|||||||
key: kStreamToken,
|
key: kStreamToken,
|
||||||
value: token,
|
value: token,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!kIsWeb) {
|
|
||||||
initNotifications(client);
|
|
||||||
}
|
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
Routes.HOME,
|
Routes.HOME,
|
||||||
@@ -219,7 +213,7 @@ class ChooseUserPage extends StatelessWidget {
|
|||||||
.grey,
|
.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: StreamSvgIcon.arrow_right(
|
trailing: StreamSvgIcon.arrowRight(
|
||||||
color: StreamChatTheme.of(context)
|
color: StreamChatTheme.of(context)
|
||||||
.colorTheme
|
.colorTheme
|
||||||
.accentBlue,
|
.accentBlue,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
||||||
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -29,7 +29,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
/// We also change the message color posted by the current user.
|
/// We also change the message color posted by the current user.
|
||||||
/// You can perform these more granular style changes using [StreamChatTheme.copyWith].
|
/// You can perform these more granular style changes using [StreamChatTheme.copyWith].
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -33,7 +33,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// - We retrieve the count of unread messages from [Channel.state]
|
/// - We retrieve the count of unread messages from [Channel.state]
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -34,7 +34,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
/// you can use [StreamChat.of], [StreamChannel.of] and [StreamChatTheme.of] to use the API client directly
|
||||||
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
/// or to retrieve outer scope needed such as messages from the [Channel.state].
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -29,7 +29,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -150,9 +150,8 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: ValueListenableBuilder<ConnectionStatus>(
|
body: ConnectionStatusBuilder(
|
||||||
valueListenable: StreamChat.of(context).client.wsConnectionStatus,
|
statusBuilder: (context, status) {
|
||||||
builder: (context, status, _) {
|
|
||||||
String statusString = '';
|
String statusString = '';
|
||||||
bool showStatus = true;
|
bool showStatus = true;
|
||||||
|
|
||||||
@@ -259,7 +258,8 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
child: StreamSvgIcon.close_small(),
|
child: StreamSvgIcon.closeSmall(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_nameController.text =
|
_nameController.text =
|
||||||
@@ -739,7 +739,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 16.0),
|
SizedBox(width: 16.0),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: StreamSvgIcon.close_small(
|
icon: StreamSvgIcon.closeSmall(
|
||||||
color: theme.colorTheme.grey,
|
color: theme.colorTheme.grey,
|
||||||
),
|
),
|
||||||
constraints: BoxConstraints.tightFor(
|
constraints: BoxConstraints.tightFor(
|
||||||
@@ -869,7 +869,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
isUserAdmin)
|
isUserAdmin)
|
||||||
_buildModalListTile(
|
_buildModalListTile(
|
||||||
context,
|
context,
|
||||||
StreamSvgIcon.Icon_user_settings(
|
StreamSvgIcon.iconUserSettings(
|
||||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||||
size: 24.0,
|
size: 24.0,
|
||||||
),
|
),
|
||||||
@@ -891,7 +891,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
|||||||
}, color: StreamChatTheme.of(context).colorTheme.accentRed),
|
}, color: StreamChatTheme.of(context).colorTheme.accentRed),
|
||||||
_buildModalListTile(
|
_buildModalListTile(
|
||||||
context,
|
context,
|
||||||
StreamSvgIcon.close_small(
|
StreamSvgIcon.closeSmall(
|
||||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||||
size: 24.0,
|
size: 24.0,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:example/chat_info_screen.dart';
|
import 'package:example/chat_info_screen.dart';
|
||||||
import 'package:example/choose_user_page.dart';
|
import 'package:example/choose_user_page.dart';
|
||||||
@@ -10,6 +9,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
|
||||||
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';
|
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';
|
||||||
|
|
||||||
import 'notifications_service.dart';
|
import 'notifications_service.dart';
|
||||||
@@ -17,6 +17,11 @@ import 'routes/app_routes.dart';
|
|||||||
import 'routes/routes.dart';
|
import 'routes/routes.dart';
|
||||||
import 'search_text_field.dart';
|
import 'search_text_field.dart';
|
||||||
|
|
||||||
|
final chatPersistentClient = StreamChatPersistenceClient(
|
||||||
|
logLevel: Level.INFO,
|
||||||
|
connectionMode: ConnectionMode.background,
|
||||||
|
);
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
final secureStorage = FlutterSecureStorage();
|
final secureStorage = FlutterSecureStorage();
|
||||||
@@ -24,13 +29,10 @@ void main() async {
|
|||||||
final apiKey = await secureStorage.read(key: kStreamApiKey);
|
final apiKey = await secureStorage.read(key: kStreamApiKey);
|
||||||
final userId = await secureStorage.read(key: kStreamUserId);
|
final userId = await secureStorage.read(key: kStreamUserId);
|
||||||
|
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
apiKey ?? kDefaultStreamApiKey,
|
apiKey ?? kDefaultStreamApiKey,
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
showLocalNotification:
|
)..chatPersistenceClient = chatPersistentClient;
|
||||||
(!kIsWeb && Platform.isAndroid) ? showLocalNotification : null,
|
|
||||||
persistenceEnabled: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
final token = await secureStorage.read(key: kStreamToken);
|
final token = await secureStorage.read(key: kStreamToken);
|
||||||
@@ -38,16 +40,13 @@ void main() async {
|
|||||||
User(id: userId),
|
User(id: userId),
|
||||||
token,
|
token,
|
||||||
);
|
);
|
||||||
if (!kIsWeb) {
|
|
||||||
initNotifications(client);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp(MyApp(client));
|
runApp(MyApp(client));
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
@@ -68,6 +67,7 @@ class MyApp extends StatelessWidget {
|
|||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
return StreamChat(
|
return StreamChat(
|
||||||
client: client,
|
client: client,
|
||||||
|
onBackgroundEventReceived: showLocalNotification,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>(
|
builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
child: child,
|
child: child,
|
||||||
@@ -294,7 +294,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: StreamSvgIcon.Icon_moon(
|
icon: StreamSvgIcon.iconMoon(
|
||||||
size: 24,
|
size: 24,
|
||||||
),
|
),
|
||||||
color: StreamChatTheme.of(context).colorTheme.grey,
|
color: StreamChatTheme.of(context).colorTheme.grey,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
/// In this case we are showing the list of channels the current user is a member and we order them based on the time they had a new message.
|
/// In this case we are showing the list of channels the current user is a member and we order them based on the time they had a new message.
|
||||||
/// [ChannelListView] handles pagination and updates automatically out of the box when new channels are created or when a new message is added to a channel.
|
/// [ChannelListView] handles pagination and updates automatically out of the box when new channels are created or when a new message is added to a channel.
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -33,7 +33,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -134,9 +134,8 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
body: ValueListenableBuilder<ConnectionStatus>(
|
body: ConnectionStatusBuilder(
|
||||||
valueListenable: StreamChat.of(context).client.wsConnectionStatus,
|
statusBuilder: (context, status) {
|
||||||
builder: (context, status, _) {
|
|
||||||
String statusString = '';
|
String statusString = '';
|
||||||
bool showStatus = true;
|
bool showStatus = true;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
actions: [
|
actions: [
|
||||||
if (_selectedUsers.isNotEmpty)
|
if (_selectedUsers.isNotEmpty)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: StreamSvgIcon.arrow_right(
|
icon: StreamSvgIcon.arrowRight(
|
||||||
color: StreamChatTheme.of(context).colorTheme.accentBlue,
|
color: StreamChatTheme.of(context).colorTheme.accentBlue,
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -87,9 +87,8 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: ValueListenableBuilder<ConnectionStatus>(
|
body: ConnectionStatusBuilder(
|
||||||
valueListenable: StreamChat.of(context).client.wsConnectionStatus,
|
statusBuilder: (context, status) {
|
||||||
builder: (context, status, _) {
|
|
||||||
String statusString = '';
|
String statusString = '';
|
||||||
bool showStatus = true;
|
bool showStatus = true;
|
||||||
|
|
||||||
@@ -163,8 +162,7 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
.white,
|
.white,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color:
|
color: StreamChatTheme.of(context)
|
||||||
StreamChatTheme.of(context)
|
|
||||||
.colorTheme
|
.colorTheme
|
||||||
.whiteSnow,
|
.whiteSnow,
|
||||||
),
|
),
|
||||||
@@ -201,9 +199,8 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: StreamChatTheme.of(context)
|
gradient:
|
||||||
.colorTheme
|
StreamChatTheme.of(context).colorTheme.bgGradient,
|
||||||
.bgGradient,
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -307,7 +304,8 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter_apns/flutter_apns.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart'
|
||||||
hide Message;
|
hide Message;
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
void showLocalNotification(Message message, ChannelModel channel) async {
|
void showLocalNotification(Event event) async {
|
||||||
|
if (event.message == null) return;
|
||||||
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
final initializationSettingsAndroid =
|
final initializationSettingsAndroid =
|
||||||
AndroidInitializationSettings('launch_background');
|
AndroidInitializationSettings('launch_background');
|
||||||
@@ -16,9 +14,9 @@ void showLocalNotification(Message message, ChannelModel channel) async {
|
|||||||
);
|
);
|
||||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||||
await flutterLocalNotificationsPlugin.show(
|
await flutterLocalNotificationsPlugin.show(
|
||||||
message.id.hashCode,
|
event.message.id.hashCode,
|
||||||
'${message.user.name} @ ${channel.name}',
|
event.message.user.name,
|
||||||
message.text,
|
event.message.text,
|
||||||
NotificationDetails(
|
NotificationDetails(
|
||||||
android: AndroidNotificationDetails(
|
android: AndroidNotificationDetails(
|
||||||
'message channel',
|
'message channel',
|
||||||
@@ -31,33 +29,3 @@ void showLocalNotification(Message message, ChannelModel channel) async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future backgroundHandler(Map<String, dynamic> notification) async {
|
|
||||||
print('new notification ${notification}');
|
|
||||||
final messageId = notification['data']['id'];
|
|
||||||
|
|
||||||
final notificationData =
|
|
||||||
await NotificationService.getAndStoreMessage(messageId);
|
|
||||||
|
|
||||||
showLocalNotification(
|
|
||||||
notificationData.message,
|
|
||||||
notificationData.channel,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initNotifications(Client client) {
|
|
||||||
final connector = createPushConnector();
|
|
||||||
connector.configure(
|
|
||||||
onBackgroundMessage: backgroundHandler,
|
|
||||||
);
|
|
||||||
|
|
||||||
connector.requestNotificationPermissions();
|
|
||||||
connector.token.addListener(() {
|
|
||||||
if (connector.token.value != null) {
|
|
||||||
client.addDevice(
|
|
||||||
connector.token.value,
|
|
||||||
Platform.isAndroid ? PushProvider.firebase : PushProvider.apn,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ class AppRoutes {
|
|||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
final args = settings.arguments;
|
final args = settings.arguments;
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
|
case Routes.APP:
|
||||||
|
return MaterialPageRoute(
|
||||||
|
settings: const RouteSettings(name: Routes.APP),
|
||||||
|
builder: (_) {
|
||||||
|
return MyApp(args);
|
||||||
|
});
|
||||||
case Routes.HOME:
|
case Routes.HOME:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
settings: const RouteSettings(name: Routes.HOME),
|
settings: const RouteSettings(name: Routes.HOME),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/// Define all the route names here
|
/// Define all the route names here
|
||||||
class Routes {
|
class Routes {
|
||||||
|
static const String APP = '/app';
|
||||||
static const String HOME = '/home';
|
static const String HOME = '/home';
|
||||||
static const String CHOOSE_USER = '/choose_user';
|
static const String CHOOSE_USER = '/choose_user';
|
||||||
static const String ADVANCED_OPTIONS = '/advance_options';
|
static const String ADVANCED_OPTIONS = '/advance_options';
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class SearchTextField extends StatelessWidget {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
icon: StreamSvgIcon.close_small(
|
icon: StreamSvgIcon.closeSmall(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
splashRadius: 24,
|
splashRadius: 24,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// There are three important things to notice that are common to all Flutter application using StreamChat:
|
/// There are three important things to notice that are common to all Flutter application using StreamChat:
|
||||||
///
|
///
|
||||||
/// 1. The Dart API [Client] is initialized with your API Key
|
/// 1. The Dart API [StreamChatClient] is initialized with your API Key
|
||||||
/// 2. The current user is set by calling [Client.setUser]
|
/// 2. The current user is set by calling [StreamChatClient.setUser]
|
||||||
/// 3. The client is then passed to the top-level [StreamChat] widget
|
/// 3. The client is then passed to the top-level [StreamChat] widget
|
||||||
/// [StreamChat] is an inherited widget and must be the parent of all Chat related widgets.
|
/// [StreamChat] is an inherited widget and must be the parent of all Chat related widgets.
|
||||||
///
|
///
|
||||||
@@ -15,9 +15,9 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// Let's have a look at what we've built:
|
/// Let's have a look at what we've built:
|
||||||
///
|
///
|
||||||
/// - We set up the Chat [Client] with the API key
|
/// - We set up the Chat [StreamChatClient] with the API key
|
||||||
///
|
///
|
||||||
/// - We set the the current user for Chat with [Client.setUser] and a pre-generated user token
|
/// - We set the the current user for Chat with [StreamChatClient.setUser] and a pre-generated user token
|
||||||
///
|
///
|
||||||
/// - We make [StreamChat] the root Widget of our application
|
/// - We make [StreamChat] the root Widget of our application
|
||||||
///
|
///
|
||||||
@@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// If you now run the simulator you will see a single channel UI.
|
/// If you now run the simulator you will see a single channel UI.
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -44,7 +44,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
final Channel channel;
|
final Channel channel;
|
||||||
|
|
||||||
MyApp(this.client, this.channel);
|
MyApp(this.client, this.channel);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -16,7 +16,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
///
|
///
|
||||||
/// Now we can open threads and create new ones as well, if you long press a message you can tap on Reply and it will open the same [ThreadPage].
|
/// Now we can open threads and create new ones as well, if you long press a message you can tap on Reply and it will open the same [ThreadPage].
|
||||||
void main() async {
|
void main() async {
|
||||||
final client = Client(
|
final client = StreamChatClient(
|
||||||
's2dxdhpxd94g',
|
's2dxdhpxd94g',
|
||||||
logLevel: Level.INFO,
|
logLevel: Level.INFO,
|
||||||
);
|
);
|
||||||
@@ -24,7 +24,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
final Client client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
MyApp(this.client);
|
MyApp(this.client);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
stream_chat_flutter:
|
stream_chat_flutter:
|
||||||
path: ../
|
path: ../
|
||||||
|
stream_chat_persistence:
|
||||||
|
path: ../../stream_chat_persistence
|
||||||
flutter_apns: ^1.4.1
|
flutter_apns: ^1.4.1
|
||||||
flutter_local_notifications: ^2.0.2
|
flutter_local_notifications: ^2.0.2
|
||||||
flutter_svg: ^0.19.1
|
flutter_svg: ^0.19.1
|
||||||
|
|||||||
Reference in New Issue
Block a user