diff --git a/stream_chat_v1/android/app/src/main/res/drawable/launch_background.xml b/stream_chat_v1/android/app/src/main/res/drawable/launch_background.xml
index 304732f..3618fa7 100644
--- a/stream_chat_v1/android/app/src/main/res/drawable/launch_background.xml
+++ b/stream_chat_v1/android/app/src/main/res/drawable/launch_background.xml
@@ -1,12 +1,5 @@
-
-
-
-
+
diff --git a/stream_chat_v1/android/app/src/main/res/values/colors.xml b/stream_chat_v1/android/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..e0b6c6f
--- /dev/null
+++ b/stream_chat_v1/android/app/src/main/res/values/colors.xml
@@ -0,0 +1,4 @@
+
+
+ #005fff
+
\ No newline at end of file
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json
new file mode 100644
index 0000000..9f447e1
--- /dev/null
+++ b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json
@@ -0,0 +1,21 @@
+{
+ "images" : [
+ {
+ "filename" : "background.png",
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png
new file mode 100644
index 0000000..3617880
Binary files /dev/null and b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png differ
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
index 0bedcf2..00cabce 100644
--- a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
+++ b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
@@ -1,23 +1,23 @@
{
"images" : [
{
- "idiom" : "universal",
"filename" : "LaunchImage.png",
+ "idiom" : "universal",
"scale" : "1x"
},
{
- "idiom" : "universal",
"filename" : "LaunchImage@2x.png",
+ "idiom" : "universal",
"scale" : "2x"
},
{
- "idiom" : "universal",
"filename" : "LaunchImage@3x.png",
+ "idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
- "version" : 1,
- "author" : "xcode"
+ "author" : "xcode",
+ "version" : 1
}
}
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
index 9da19ea..67774cf 100644
Binary files a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png and b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
index 9da19ea..67774cf 100644
Binary files a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png and b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ
diff --git a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
index 9da19ea..67774cf 100644
Binary files a/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png and b/stream_chat_v1/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ
diff --git a/stream_chat_v1/ios/Runner/Base.lproj/LaunchScreen.storyboard b/stream_chat_v1/ios/Runner/Base.lproj/LaunchScreen.storyboard
index f2e259c..c9811f0 100644
--- a/stream_chat_v1/ios/Runner/Base.lproj/LaunchScreen.storyboard
+++ b/stream_chat_v1/ios/Runner/Base.lproj/LaunchScreen.storyboard
@@ -16,13 +16,19 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
@@ -33,5 +39,6 @@
+
-
+
\ No newline at end of file
diff --git a/stream_chat_v1/ios/Runner/Info.plist b/stream_chat_v1/ios/Runner/Info.plist
index 7e63f46..d9f250b 100644
--- a/stream_chat_v1/ios/Runner/Info.plist
+++ b/stream_chat_v1/ios/Runner/Info.plist
@@ -1,64 +1,66 @@
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- ChatSample
- CFBundlePackageType
- APPL
- CFBundleShortVersionString
- $(FLUTTER_BUILD_NAME)
- CFBundleSignature
- ????
- CFBundleVersion
- $(FLUTTER_BUILD_NUMBER)
- LSRequiresIPhoneOS
-
- NSAppleMusicUsageDescription
- Used to send message attachments
- NSCameraUsageDescription
- Used to send message attachments
- NSMicrophoneUsageDescription
- Used to send message attachments
- NSPhotoLibraryUsageDescription
- Used to send message attachments
- UIBackgroundModes
-
- fetch
- remote-notification
-
- UILaunchStoryboardName
- LaunchScreen
- UIMainStoryboardFile
- Main
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UIViewControllerBasedStatusBarAppearance
-
- UIBackgroundModes
-
- remote-notification
-
- UIViewControllerBasedStatusBarAppearance
-
-
-
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ ChatSample
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ $(FLUTTER_BUILD_NAME)
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ $(FLUTTER_BUILD_NUMBER)
+ LSRequiresIPhoneOS
+
+ NSAppleMusicUsageDescription
+ Used to send message attachments
+ NSCameraUsageDescription
+ Used to send message attachments
+ NSMicrophoneUsageDescription
+ Used to send message attachments
+ NSPhotoLibraryUsageDescription
+ Used to send message attachments
+ UIBackgroundModes
+
+ fetch
+ remote-notification
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIMainStoryboardFile
+ Main
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UIViewControllerBasedStatusBarAppearance
+
+ UIBackgroundModes
+
+ remote-notification
+
+ UIViewControllerBasedStatusBarAppearance
+
+ UIStatusBarHidden
+
+
+
\ No newline at end of file
diff --git a/stream_chat_v1/lib/main.dart b/stream_chat_v1/lib/main.dart
index 3278426..12ec3ac 100644
--- a/stream_chat_v1/lib/main.dart
+++ b/stream_chat_v1/lib/main.dart
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
+import 'package:flutter_svg/flutter_svg.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';
@@ -24,61 +25,75 @@ final chatPersistentClient = StreamChatPersistenceClient(
void main() async {
WidgetsFlutterBinding.ensureInitialized();
- final secureStorage = FlutterSecureStorage();
- final apiKey = await secureStorage.read(key: kStreamApiKey);
- final userId = await secureStorage.read(key: kStreamUserId);
-
- final client = StreamChatClient(
- apiKey ?? kDefaultStreamApiKey,
- logLevel: Level.INFO,
- )..chatPersistenceClient = chatPersistentClient;
-
- if (userId != null) {
- final token = await secureStorage.read(key: kStreamToken);
- await client.connectUser(
- User(id: userId),
- token,
- );
- }
-
- runApp(MyApp(client));
+ runApp(MyApp());
}
class MyApp extends StatelessWidget {
- final StreamChatClient client;
+ Future _initConnection() async {
+ final secureStorage = FlutterSecureStorage();
- MyApp(this.client);
+ final apiKey = await secureStorage.read(key: kStreamApiKey);
+ final userId = await secureStorage.read(key: kStreamUserId);
+
+ final client = StreamChatClient(
+ apiKey ?? kDefaultStreamApiKey,
+ logLevel: Level.INFO,
+ )..chatPersistenceClient = chatPersistentClient;
+
+ if (userId != null) {
+ final token = await secureStorage.read(key: kStreamToken);
+ await client.connectUser(
+ User(id: userId),
+ token,
+ );
+ }
+
+ var prefs = await StreamingSharedPreferences.instance;
+
+ return InitData(client, prefs);
+ }
@override
Widget build(BuildContext context) {
- return FutureBuilder(
- future: StreamingSharedPreferences.instance,
- builder: (context, snapshot) {
- if (!snapshot.hasData) {
- return SizedBox();
+ return FutureBuilder(
+ future: _initConnection(),
+ builder: (context, initData) {
+ if (!initData.hasData) {
+ return MaterialApp(
+ home: Container(
+ alignment: Alignment.center,
+ color: Colors.white,
+ child: Container(
+ height: 80.0,
+ width: 80.0,
+ child: SvgPicture.asset('assets/logo.svg'),
+ ),
+ ),
+ );
}
+
return PreferenceBuilder(
- preference: snapshot.data.getInt(
+ preference: initData.data.preferences.getInt(
'theme',
defaultValue: 0,
),
builder: (context, snapshot) => MaterialApp(
builder: (context, child) {
return StreamChat(
- client: client,
+ client: initData.data.client,
onBackgroundEventReceived: (e) =>
- showLocalNotification(e, client.state.user.id),
+ showLocalNotification(e, initData.data.client.state.user.id),
child: Builder(
builder: (context) => AnnotatedRegion(
child: child,
value: SystemUiOverlayStyle(
systemNavigationBarColor:
- StreamChatTheme.of(context).colorTheme.white,
+ StreamChatTheme.of(context).colorTheme.white,
systemNavigationBarIconBrightness:
- Theme.of(context).brightness == Brightness.dark
- ? Brightness.light
- : Brightness.dark,
+ Theme.of(context).brightness == Brightness.dark
+ ? Brightness.light
+ : Brightness.dark,
),
),
),
@@ -94,7 +109,7 @@ class MyApp extends StatelessWidget {
}[snapshot],
onGenerateRoute: AppRoutes.generateRoute,
initialRoute:
- client.state.user == null ? Routes.CHOOSE_USER : Routes.HOME,
+ initData.data.client.state.user == null ? Routes.CHOOSE_USER : Routes.HOME,
),
);
},
@@ -833,3 +848,10 @@ class _ThreadPageState extends State {
);
}
}
+
+class InitData {
+ final StreamChatClient client;
+ final StreamingSharedPreferences preferences;
+
+ InitData(this.client, this.preferences);
+}
diff --git a/stream_chat_v1/lib/routes/app_routes.dart b/stream_chat_v1/lib/routes/app_routes.dart
index e7c7e31..c641b04 100644
--- a/stream_chat_v1/lib/routes/app_routes.dart
+++ b/stream_chat_v1/lib/routes/app_routes.dart
@@ -19,7 +19,7 @@ class AppRoutes {
return MaterialPageRoute(
settings: const RouteSettings(name: Routes.APP),
builder: (_) {
- return MyApp(args);
+ return MyApp();
});
case Routes.HOME:
return MaterialPageRoute(