diff --git a/example/lib/controllers/home_controller.dart b/example/lib/controllers/home_controller.dart index e3c904b8..0034516d 100644 --- a/example/lib/controllers/home_controller.dart +++ b/example/lib/controllers/home_controller.dart @@ -26,8 +26,7 @@ class HomeController { void startChat(String email) async { try { - await VChatController.instance - .createSingleChat(context: context, peerEmail: email); + await VChatController.instance.createSingleChat(context: context, peerEmail: email); } on VChatSdkException catch (err) { CustomAlert.showError(context: context, err: err.toString()); rethrow; diff --git a/example/lib/controllers/login_controller.dart b/example/lib/controllers/login_controller.dart index 336cd843..ffed0c80 100644 --- a/example/lib/controllers/login_controller.dart +++ b/example/lib/controllers/login_controller.dart @@ -21,23 +21,18 @@ class LoginController { try { ///Login on your system backend CustomAlert.customLoadingDialog(context: context); - final d = (await CustomDio().send( - reqMethod: "post", - path: "user/login", - body: {"email": email, "password": password})) - .data['data']; + final d = + (await CustomDio().send(reqMethod: "post", path: "user/login", body: {"email": email, "password": password})) + .data['data']; final u = User.fromMap(d); await GetStorage().write("myModel", u.toMap()); ///Login on v_chat_sdk system - await VChatController.instance.login( - context: context, - dto: VChatLoginDto(email: email, password: password)); + await VChatController.instance.login(context: context, dto: VChatLoginDto(email: email, password: password)); Navigator.pop(context); - Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute(builder: (context) => const Home()), - (Route route) => false); + Navigator.of(context) + .pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route route) => false); } on VChatSdkException catch (err) { Navigator.pop(context); CustomAlert.showError(context: context, err: err.toString()); diff --git a/example/lib/controllers/register_controller.dart b/example/lib/controllers/register_controller.dart index e5a28d55..eca0b2fd 100644 --- a/example/lib/controllers/register_controller.dart +++ b/example/lib/controllers/register_controller.dart @@ -33,18 +33,14 @@ class RegisterController { if (File(imagePath!).lengthSync() > 1024 * 1024 * 10) { throw "image size must be less than 10 Mb"; } - myUser = (await CustomDio().uploadFile( - apiEndPoint: "user/register", - filePath: imagePath!, - body: [ - {"email": email}, - {"password": password}, - {"name": name}, - ])) + myUser = (await CustomDio().uploadFile(apiEndPoint: "user/register", filePath: imagePath!, body: [ + {"email": email}, + {"password": password}, + {"name": name}, + ])) .data['data']; } else { - myUser = (await CustomDio() - .send(reqMethod: "post", path: "user/register", body: { + myUser = (await CustomDio().send(reqMethod: "post", path: "user/register", body: { "email": email, "password": password, "name": name, @@ -56,18 +52,16 @@ class RegisterController { ///Register on v_chat_sdk system await VChatController.instance.register( - dto: VChatRegisterDto( - name: name, - userImage: imagePath == null ? null : File(imagePath!), - email: email, - password: password, - ), - context: context - ); + dto: VChatRegisterDto( + name: name, + userImage: imagePath == null ? null : File(imagePath!), + email: email, + password: password, + ), + context: context); Navigator.pop(context); - Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute(builder: (context) => const Home()), - (Route route) => false); + Navigator.of(context) + .pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route route) => false); } on VChatSdkException catch (err) { Navigator.pop(context); CustomAlert.showError(context: context, err: err.toString()); diff --git a/example/lib/generated/intl/messages_all.dart b/example/lib/generated/intl/messages_all.dart index d5519736..f03899a1 100644 --- a/example/lib/generated/intl/messages_all.dart +++ b/example/lib/generated/intl/messages_all.dart @@ -41,9 +41,8 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) async { - var availableLocale = Intl.verifiedLocale( - localeName, (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null); + var availableLocale = + Intl.verifiedLocale(localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new Future.value(false); } @@ -63,8 +62,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = - Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/example/lib/generated/intl/messages_ar_EG.dart b/example/lib/generated/intl/messages_ar_EG.dart index f2a886b7..17170326 100644 --- a/example/lib/generated/intl/messages_ar_EG.dart +++ b/example/lib/generated/intl/messages_ar_EG.dart @@ -22,8 +22,7 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { - "allChatNotifications": - MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"), + "allChatNotifications": MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"), "ar": MessageLookupByLibrary.simpleMessage("عربي"), "changeLanguage": MessageLookupByLibrary.simpleMessage("تغيسر اللغه"), "changeTheme": MessageLookupByLibrary.simpleMessage("تغير الثيم"), @@ -48,8 +47,7 @@ class MessageLookup extends MessageLookupByLibrary { "register": MessageLookupByLibrary.simpleMessage("تسجيل حساب"), "settings": MessageLookupByLibrary.simpleMessage("الاعدادات"), "test": MessageLookupByLibrary.simpleMessage("تست"), - "thisDataFromMyServerNotVchat": - MessageLookupByLibrary.simpleMessage("هذه الداتا من سيرفر خارجي"), + "thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("هذه الداتا من سيرفر خارجي"), "update": MessageLookupByLibrary.simpleMessage("تحديث"), "updateProfile": MessageLookupByLibrary.simpleMessage("تحديث الحساب") }; diff --git a/example/lib/generated/intl/messages_en.dart b/example/lib/generated/intl/messages_en.dart index 10c1c59e..ef6b5073 100644 --- a/example/lib/generated/intl/messages_en.dart +++ b/example/lib/generated/intl/messages_en.dart @@ -22,11 +22,9 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { - "allChatNotifications": - MessageLookupByLibrary.simpleMessage("All Chat notifications"), + "allChatNotifications": MessageLookupByLibrary.simpleMessage("All Chat notifications"), "ar": MessageLookupByLibrary.simpleMessage("ar"), - "changeLanguage": - MessageLookupByLibrary.simpleMessage("Change language"), + "changeLanguage": MessageLookupByLibrary.simpleMessage("Change language"), "changeTheme": MessageLookupByLibrary.simpleMessage("Change Theme"), "chats": MessageLookupByLibrary.simpleMessage("Chats"), "chooseImage": MessageLookupByLibrary.simpleMessage("choose image"), @@ -49,8 +47,7 @@ class MessageLookup extends MessageLookupByLibrary { "register": MessageLookupByLibrary.simpleMessage("Register"), "settings": MessageLookupByLibrary.simpleMessage("Settings"), "test": MessageLookupByLibrary.simpleMessage("test"), - "thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage( - "This data from my server not vchat"), + "thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("This data from my server not vchat"), "update": MessageLookupByLibrary.simpleMessage("Update"), "updateProfile": MessageLookupByLibrary.simpleMessage("Update profile") }; diff --git a/example/lib/generated/intl/messages_fr.dart b/example/lib/generated/intl/messages_fr.dart index 448c6fc8..0bbd3388 100644 --- a/example/lib/generated/intl/messages_fr.dart +++ b/example/lib/generated/intl/messages_fr.dart @@ -22,11 +22,9 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { - "allChatNotifications": - MessageLookupByLibrary.simpleMessage("All Chat notifications"), + "allChatNotifications": MessageLookupByLibrary.simpleMessage("All Chat notifications"), "ar": MessageLookupByLibrary.simpleMessage("ar"), - "changeLanguage": - MessageLookupByLibrary.simpleMessage("Change language"), + "changeLanguage": MessageLookupByLibrary.simpleMessage("Change language"), "changeTheme": MessageLookupByLibrary.simpleMessage("Change Theme"), "chats": MessageLookupByLibrary.simpleMessage("Chats"), "chooseImage": MessageLookupByLibrary.simpleMessage("choose image"), @@ -48,8 +46,7 @@ class MessageLookup extends MessageLookupByLibrary { "password": MessageLookupByLibrary.simpleMessage("Password"), "register": MessageLookupByLibrary.simpleMessage("Register"), "settings": MessageLookupByLibrary.simpleMessage("Settings"), - "thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage( - "This data from my server not vchat"), + "thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("This data from my server not vchat"), "update": MessageLookupByLibrary.simpleMessage("Update"), "updateProfile": MessageLookupByLibrary.simpleMessage("Update profile") }; diff --git a/example/lib/generated/l10n.dart b/example/lib/generated/l10n.dart index 1a669606..9a21761e 100644 --- a/example/lib/generated/l10n.dart +++ b/example/lib/generated/l10n.dart @@ -18,17 +18,15 @@ class S { static S? _current; static S get current { - assert(_current != null, - 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + assert( + _current != null, 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); return _current!; } static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); static Future load(Locale locale) { - final name = (locale.countryCode?.isEmpty ?? false) - ? locale.languageCode - : locale.toString(); + final name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString(); final localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((_) { Intl.defaultLocale = localeName; diff --git a/example/lib/main.dart b/example/lib/main.dart index 53d9a739..1da6fda1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -8,7 +8,6 @@ import './screens/splash_screen.dart'; import 'controllers/language_controller.dart'; import 'generated/l10n.dart'; - class VChatCustomWidgets extends VChatWidgetBuilder { @override Color sendButtonColor(BuildContext context, bool isDark) { @@ -35,8 +34,7 @@ void main() async { // add support new language // v_chat will change the language one you change it - VChatController.instance.setLocaleMessages( - languageCode: "ar", countryCode: "EG", lookupMessages: ArLanguage()); + VChatController.instance.setLocaleMessages(languageCode: "ar", countryCode: "EG", lookupMessages: ArLanguage()); // VChatController.instance.forceLanguage(languageCode: "ar",countryCode:'EG'); diff --git a/example/lib/models/user.dart b/example/lib/models/user.dart index 73d9cac7..4516f9c3 100644 --- a/example/lib/models/user.dart +++ b/example/lib/models/user.dart @@ -27,12 +27,7 @@ class User { accessToken == other.accessToken); @override - int get hashCode => - id.hashCode ^ - imageThumb.hashCode ^ - email.hashCode ^ - name.hashCode ^ - accessToken.hashCode; + int get hashCode => id.hashCode ^ imageThumb.hashCode ^ email.hashCode ^ name.hashCode ^ accessToken.hashCode; @override String toString() { diff --git a/example/lib/screens/home.dart b/example/lib/screens/home.dart index 71787b39..15c86511 100644 --- a/example/lib/screens/home.dart +++ b/example/lib/screens/home.dart @@ -35,9 +35,7 @@ class _HomeState extends State { if (GetStorage().hasData("myModel")) { // this mean my user has auth so i will bind chat controller to make him online else will throw exception - VChatController.instance.bindChatControllers( - context - ); + VChatController.instance.bindChatControllers(context); } } @@ -53,7 +51,6 @@ class _HomeState extends State { actions: [ IconButton( onPressed: () async { - final users = await _controller.getUsers(); _usersList.clear(); _usersList.addAll(users); @@ -96,7 +93,6 @@ class _HomeState extends State { appBar: PreferredSize( child: _childrenAppBars[_currentIndex], preferredSize: const Size.fromHeight(kToolbarHeight), - ), body: _children[_currentIndex], // new bottomNavigationBar: BottomNavigationBar( diff --git a/example/lib/screens/login_screen.dart b/example/lib/screens/login_screen.dart index 269fa3ef..bc49bfcd 100644 --- a/example/lib/screens/login_screen.dart +++ b/example/lib/screens/login_screen.dart @@ -44,14 +44,11 @@ class _LoginScreenState extends State { const SizedBox( height: 10, ), - TextButton( - onPressed: _controller.login, child: S.of(context).login.text), + TextButton(onPressed: _controller.login, child: S.of(context).login.text), const SizedBox( height: 10, ), - TextButton( - onPressed: _controller.register, - child: S.of(context).register.text), + TextButton(onPressed: _controller.register, child: S.of(context).register.text), ], ), ), diff --git a/example/lib/screens/register_screen.dart b/example/lib/screens/register_screen.dart index 04893b9b..97e4a7c8 100644 --- a/example/lib/screens/register_screen.dart +++ b/example/lib/screens/register_screen.dart @@ -56,13 +56,10 @@ class _RegisterScreenState extends State { InkWell( onTap: () async { final picker = ImagePicker(); - final img = - await picker.pickImage(source: ImageSource.gallery); + final img = await picker.pickImage(source: ImageSource.gallery); if (img != null) { _controller.imagePath = img.path; - CustomAlert.showSuccess( - context: context, - err: "image has been set successfully"); + CustomAlert.showSuccess(context: context, err: "image has been set successfully"); } }, child: Row( @@ -78,9 +75,7 @@ class _RegisterScreenState extends State { const SizedBox( height: 10, ), - TextButton( - onPressed: _controller.register, - child: S.of(context).register.text), + TextButton(onPressed: _controller.register, child: S.of(context).register.text), ], ), ), diff --git a/example/lib/screens/setting_screen.dart b/example/lib/screens/setting_screen.dart index c6bb217d..b7cb3112 100644 --- a/example/lib/screens/setting_screen.dart +++ b/example/lib/screens/setting_screen.dart @@ -29,9 +29,8 @@ class _SettingScreenState extends State { title: S.of(context).changeLanguage, icon: Icons.language, onTap: () async { - final res = await CustomAlert.customChooseDialog( - context: context, - data: [S.of(context).ar, S.of(context).en]); + final res = + await CustomAlert.customChooseDialog(context: context, data: [S.of(context).ar, S.of(context).en]); if (res == 0) { Provider.of(context, listen: false) .setLocale(const Locale.fromSubtags(languageCode: "ar")); @@ -47,15 +46,12 @@ class _SettingScreenState extends State { icon: Icons.wb_sunny, onTap: () async { final res = await CustomAlert.customChooseDialog( - context: context, - data: [S.of(context).light, S.of(context).dark]); + context: context, data: [S.of(context).light, S.of(context).dark]); if (res == 0) { - Provider.of(context, listen: false) - .changeTheme(false); + Provider.of(context, listen: false).changeTheme(false); } if (res == 1) { - Provider.of(context, listen: false) - .changeTheme(true); + Provider.of(context, listen: false).changeTheme(true); } }, ), @@ -63,17 +59,15 @@ class _SettingScreenState extends State { title: S.of(context).updateProfile, icon: Icons.edit, onTap: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => const UpdateUserProfileScreen())); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => const UpdateUserProfileScreen())); }, ), ProfileItem( title: S.of(context).allChatNotifications, icon: Icons.notification_important, onTap: () async { - final res = await CustomAlert.customChooseDialog( - context: context, - data: [S.of(context).on, S.of(context).off]); + final res = + await CustomAlert.customChooseDialog(context: context, data: [S.of(context).on, S.of(context).off]); if (res == 0) { VChatController.instance.enableAllNotification(); } @@ -86,15 +80,12 @@ class _SettingScreenState extends State { title: S.of(context).logOut, icon: Icons.logout, onTap: () async { - await VChatController.instance.logOut(); await GetStorage().remove("myModel"); Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute( - builder: (context) => const SplashScreen()), - (Route route) => false); + MaterialPageRoute(builder: (context) => const SplashScreen()), (Route route) => false); }, ), ], diff --git a/example/lib/screens/splash_screen.dart b/example/lib/screens/splash_screen.dart index 9dbde30f..78f86b7a 100644 --- a/example/lib/screens/splash_screen.dart +++ b/example/lib/screens/splash_screen.dart @@ -1,8 +1,6 @@ import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:get_storage/get_storage.dart'; -import 'package:v_chat_sdk/v_chat_sdk.dart'; import 'home.dart'; import 'login_screen.dart'; @@ -19,7 +17,6 @@ class _SplashScreenState extends State { void initState() { super.initState(); startNavigate(); - } @override @@ -41,14 +38,12 @@ class _SplashScreenState extends State { log(myModel.toString()); if (myModel) { // there are login data saved - Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute(builder: (context) => const Home()), - (Route route) => false); + Navigator.of(context) + .pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route route) => false); } else { // its the first time to open the app Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute(builder: (context) => const LoginScreen()), - (Route route) => false); + MaterialPageRoute(builder: (context) => const LoginScreen()), (Route route) => false); } } } diff --git a/example/lib/screens/update_user_profile_screen.dart b/example/lib/screens/update_user_profile_screen.dart index 84457227..527e3c7e 100644 --- a/example/lib/screens/update_user_profile_screen.dart +++ b/example/lib/screens/update_user_profile_screen.dart @@ -13,8 +13,7 @@ class UpdateUserProfileScreen extends StatefulWidget { const UpdateUserProfileScreen({Key? key}) : super(key: key); @override - _UpdateUserProfileScreenState createState() => - _UpdateUserProfileScreenState(); + _UpdateUserProfileScreenState createState() => _UpdateUserProfileScreenState(); } class _UpdateUserProfileScreenState extends State { @@ -67,8 +66,7 @@ class _UpdateUserProfileScreenState extends State { const SizedBox( height: 10, ), - ElevatedButton( - onPressed: changePassword, child: "update password".text), + ElevatedButton(onPressed: changePassword, child: "update password".text), ], ), ), @@ -81,13 +79,10 @@ class _UpdateUserProfileScreenState extends State { if (nameC.text.isEmpty) { throw "Enter the name"; } - await CustomDio() - .send(reqMethod: "patch", path: "user", body: {"name": nameC.text}); - await VChatController.instance - .updateUserName(name: nameC.text.toString()); + await CustomDio().send(reqMethod: "patch", path: "user", body: {"name": nameC.text}); + await VChatController.instance.updateUserName(name: nameC.text.toString()); nameC.clear(); - CustomAlert.showSuccess( - context: context, err: "your name has been updated !"); + CustomAlert.showSuccess(context: context, err: "your name has been updated !"); } on VChatSdkException catch (err) { //handle Errors log(err.data.toString()); @@ -105,15 +100,11 @@ class _UpdateUserProfileScreenState extends State { if (newPassC.text.isEmpty) { throw "Enter the new password"; } - await CustomDio().send( - reqMethod: "patch", - path: "user", - body: {"oldPassword": oldPassC.text, "newPassword": newPassC.text}); + await CustomDio() + .send(reqMethod: "patch", path: "user", body: {"oldPassword": oldPassC.text, "newPassword": newPassC.text}); - await VChatController.instance.updateUserPassword( - newPassword: newPassC.text, oldPassword: oldPassC.text); - CustomAlert.showSuccess( - context: context, err: "your password has been updated !"); + await VChatController.instance.updateUserPassword(newPassword: newPassC.text, oldPassword: oldPassC.text); + CustomAlert.showSuccess(context: context, err: "your password has been updated !"); oldPassC.clear(); newPassC.clear(); } on VChatSdkException catch (err) { @@ -141,8 +132,7 @@ class _UpdateUserProfileScreenState extends State { .data['data'] .toString(); await VChatController.instance.updateUserImage(imagePath: img.path); - CustomAlert.showSuccess( - context: context, err: "your image has been updated !"); + CustomAlert.showSuccess(context: context, err: "your image has been updated !"); } } on VChatSdkException catch (err) { log(err.data.toString()); diff --git a/example/lib/screens/user_profile_screen.dart b/example/lib/screens/user_profile_screen.dart index c045445b..dca2cb17 100644 --- a/example/lib/screens/user_profile_screen.dart +++ b/example/lib/screens/user_profile_screen.dart @@ -44,8 +44,7 @@ class _UserProfileState extends State { void startChat() async { try { - await VChatController.instance - .createSingleChat(context: context, peerEmail: widget.user.email); + await VChatController.instance.createSingleChat(context: context, peerEmail: widget.user.email); } on VChatSdkException catch (err) { CustomAlert.showError(context: context, err: err.toString()); rethrow; diff --git a/example/lib/utils/custom_alert.dart b/example/lib/utils/custom_alert.dart index 48636250..a58d615c 100644 --- a/example/lib/utils/custom_alert.dart +++ b/example/lib/utils/custom_alert.dart @@ -3,8 +3,7 @@ import 'package:flutter/material.dart'; import 'package:textless/textless.dart'; class CustomAlert { - static void customLoadingDialog( - {bool dismissible = false, required BuildContext context}) { + static void customLoadingDialog({bool dismissible = false, required BuildContext context}) { showGeneralDialog( barrierColor: Colors.black.withOpacity(0.5), transitionBuilder: (context, a1, a2, widget) { @@ -19,8 +18,7 @@ class CustomAlert { child: AlertDialog( clipBehavior: Clip.antiAliasWithSaveLayer, elevation: 0, - contentPadding: const EdgeInsets.only( - top: 8, bottom: 5, left: 10, right: 10), + contentPadding: const EdgeInsets.only(top: 8, bottom: 5, left: 10, right: 10), content: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -71,8 +69,7 @@ class CustomAlert { ); } - static void showSuccess( - {required BuildContext context, required String err}) { + static void showSuccess({required BuildContext context, required String err}) { showDialog( context: context, builder: (context) { @@ -92,9 +89,7 @@ class CustomAlert { } static Future customChooseDialog( - {required BuildContext context, - String? title, - required List data}) async { + {required BuildContext context, String? title, required List data}) async { return await showDialog( context: context, builder: (context) { diff --git a/example/lib/utils/custom_dio.dart b/example/lib/utils/custom_dio.dart index 62775e6f..3b5451b3 100644 --- a/example/lib/utils/custom_dio.dart +++ b/example/lib/utils/custom_dio.dart @@ -16,9 +16,7 @@ class CustomDio { dio.options.followRedirects = false; dio.options.validateStatus = (_) => true; dio.options.headers = { - 'authorization': GetStorage().read("myModel") == null - ? "" - : GetStorage().read("myModel")['accessToken'] + 'authorization': GetStorage().read("myModel") == null ? "" : GetStorage().read("myModel")['accessToken'] }; dio.options.sendTimeout = 10000; dio.options.receiveTimeout = 10000; @@ -128,8 +126,8 @@ class CustomDio { final x = body.map((e) => MapEntry(e.keys.first, e.values.first)); formData.fields.addAll(x); } - final Response response = await dio.post(apiEndPoint, - data: formData, onSendProgress: sendProgress, cancelToken: cancelToken); + final Response response = + await dio.post(apiEndPoint, data: formData, onSendProgress: sendProgress, cancelToken: cancelToken); throwIfNoSuccess(response); return response; } @@ -155,11 +153,9 @@ class CustomDio { } late Response response; if (isPost) { - response = await dio.post(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + response = await dio.post(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); } else { - response = await dio.patch(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + response = await dio.patch(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); } throwIfNoSuccess(response); @@ -181,8 +177,8 @@ class CustomDio { final x = body.map((e) => MapEntry(e.keys.first, e.values.first)); data.fields.addAll(x); } - final Response response = await dio.post(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + final Response response = + await dio.post(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); throwIfNoSuccess(response); return response; } @@ -213,6 +209,5 @@ class DioUploadFileModel { final String filePath; final String fileFiledName; - const DioUploadFileModel( - {required this.filePath, required this.fileFiledName}); + const DioUploadFileModel({required this.filePath, required this.fileFiledName}); } diff --git a/example/pubspec.lock b/example/pubspec.lock index d13fa991..bfe82ab0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -98,7 +98,7 @@ packages: name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "0.3.1+5" + version: "0.3.2" crypto: dependency: transitive description: @@ -112,7 +112,7 @@ packages: name: csslib url: "https://pub.dartlang.org" source: hosted - version: "0.17.0" + version: "0.17.1" cupertino_icons: dependency: "direct main" description: @@ -161,7 +161,7 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "4.2.4" + version: "4.2.5" firebase_core: dependency: transitive description: @@ -229,7 +229,7 @@ packages: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.2.0" flutter_launcher_icons: dependency: "direct main" description: @@ -283,7 +283,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.5" flutter_secure_storage: dependency: transitive description: @@ -433,7 +433,7 @@ packages: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" image_picker_platform_interface: dependency: transitive description: @@ -524,7 +524,7 @@ packages: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.9" path_provider_ios: dependency: transitive description: @@ -538,14 +538,14 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" path_provider_platform_interface: dependency: transitive description: @@ -559,7 +559,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" pedantic: dependency: transitive description: @@ -587,7 +587,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" photo_view: dependency: transitive description: @@ -615,7 +615,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.4" provider: dependency: "direct main" description: @@ -650,7 +650,7 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.2" + version: "0.27.3" sky_engine: dependency: transitive description: flutter @@ -774,14 +774,14 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "3.0.5" v_chat_sdk: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.3.0" + version: "0.4.0" vector_math: dependency: transitive description: @@ -872,7 +872,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.9" + version: "2.3.1" xdg_directories: dependency: transitive description: @@ -886,7 +886,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.0" + version: "5.3.1" yaml: dependency: transitive description: diff --git a/lib/src/dto/dto.dart b/lib/src/dto/dto.dart index b9a39328..24045854 100644 --- a/lib/src/dto/dto.dart +++ b/lib/src/dto/dto.dart @@ -1,3 +1,3 @@ export 'create_single_room_dto.dart'; export 'v_chat_login_dto.dart'; -export 'v_chat_register_dto.dart'; \ No newline at end of file +export 'v_chat_register_dto.dart'; diff --git a/lib/src/enums/load_more_type.dart b/lib/src/enums/load_more_type.dart index f57e56cd..93ec50b0 100644 --- a/lib/src/enums/load_more_type.dart +++ b/lib/src/enums/load_more_type.dart @@ -5,4 +5,4 @@ enum LoadMoreStatus { loading, loaded, error, completed } // ignore: camel_case_extensions extension loadMoreStatus on LoadMoreStatus { String get inString => describeEnum(this); -} \ No newline at end of file +} diff --git a/lib/src/enums/message_type.dart b/lib/src/enums/message_type.dart index d879e213..0f3645f2 100644 --- a/lib/src/enums/message_type.dart +++ b/lib/src/enums/message_type.dart @@ -6,5 +6,5 @@ extension MessageTypeEnum on MessageType { String get inString => describeEnum(this); MessageType enumType(String type) { return MessageType.values.firstWhere((e) => e.inString == type); - } + } } diff --git a/lib/src/enums/room_typing_type.dart b/lib/src/enums/room_typing_type.dart index 3073d28b..fff2b891 100644 --- a/lib/src/enums/room_typing_type.dart +++ b/lib/src/enums/room_typing_type.dart @@ -7,5 +7,5 @@ extension RoomTypingTypeEnum on RoomTypingType { RoomTypingType enumType(String type) { return RoomTypingType.values.firstWhere((e) => e.inString == type); - } + } } diff --git a/lib/src/models/group_chat_setting.dart b/lib/src/models/group_chat_setting.dart index 4a3291f1..3d94626a 100644 --- a/lib/src/models/group_chat_setting.dart +++ b/lib/src/models/group_chat_setting.dart @@ -1,9 +1,7 @@ -import 'package:get/get.dart'; - class GroupChatSetting { - final RxString title; - final RxString image; - final RxString imageThumb; + final String title; + final String image; + final String imageThumb; // @@ -14,9 +12,9 @@ class GroupChatSetting { }); GroupChatSetting copyWith({ - RxString? title, - RxString? image, - RxString? imageThumb, + String? title, + String? image, + String? imageThumb, }) { return GroupChatSetting( title: title ?? this.title, @@ -32,9 +30,9 @@ class GroupChatSetting { factory GroupChatSetting.fromMap(Map map) { return GroupChatSetting( - title: (map['title'] as String).obs, - image: (map['image'] as String).obs, - imageThumb: (map['imageThumb'] as String).obs, + title: (map['title'] as String), + image: (map['image'] as String), + imageThumb: (map['imageThumb'] as String), ); } diff --git a/lib/src/models/v_chat_message.dart b/lib/src/models/v_chat_message.dart index cc45ba87..7bcbd196 100644 --- a/lib/src/models/v_chat_message.dart +++ b/lib/src/models/v_chat_message.dart @@ -103,9 +103,8 @@ class VChatMessage { return VChatMessage( id: map['_id'] as int, messageType: messageType.enumType(map['messageType']), - messageAttachment: map['messageAttachment'] == null - ? null - : VChatMessageAttachment.fromMap(map['messageAttachment']), + messageAttachment: + map['messageAttachment'] == null ? null : VChatMessageAttachment.fromMap(map['messageAttachment']), createdAt: createdAtLocal.millisecondsSinceEpoch, createdAtString: DateFormat.jm().format(createdAtLocal), updatedAt: updatedAtLocal.millisecondsSinceEpoch, @@ -121,8 +120,7 @@ class VChatMessage { // ignore: unnecessary_cast return { 'messageType': messageType.inString, - 'messageAttachment': - messageAttachment == null ? null : messageAttachment!.toMap(), + 'messageAttachment': messageAttachment == null ? null : messageAttachment!.toMap(), 'content': content, 'roomId': roomId, } as Map; @@ -133,8 +131,7 @@ class VChatMessage { return { '_id': id, 'messageType': messageType.inString, - 'messageAttachment': - messageAttachment == null ? null : messageAttachment!.toMap(), + 'messageAttachment': messageAttachment == null ? null : messageAttachment!.toMap(), 'createdAt': createdAt, 'updatedAt': updatedAt, 'content': content, diff --git a/lib/src/models/v_chat_message_attachment.dart b/lib/src/models/v_chat_message_attachment.dart index 1dc6f1eb..c709fd2c 100644 --- a/lib/src/models/v_chat_message_attachment.dart +++ b/lib/src/models/v_chat_message_attachment.dart @@ -1,6 +1,5 @@ import 'package:dio/dio.dart'; - class VChatMessageAttachment { CancelToken? cancelToken; @@ -16,7 +15,6 @@ class VChatMessageAttachment { final String? linkDescription; final String? linkDataUrl; - // VChatMessageAttachment({ @@ -62,7 +60,6 @@ class VChatMessageAttachment { ); } - @override String toString() { return 'VChatMessageAttachment{cancelToken: $cancelToken, imageUrl: $imageUrl, playUrl: $playUrl, fileSize: $fileSize, fileDuration: $fileDuration, width: $width, height: $height, lat: $lat, lang: $lang, linkTitle: $linkTitle, linkDescription: $linkDescription, linkDataUrl: $linkDataUrl}'; diff --git a/lib/src/models/v_chat_room.dart b/lib/src/models/v_chat_room.dart index b60584b8..874def05 100644 --- a/lib/src/models/v_chat_room.dart +++ b/lib/src/models/v_chat_room.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:get/get.dart'; import '../enums/room_type.dart'; import '../enums/room_typing_type.dart'; import 'group_chat_setting.dart'; @@ -52,21 +51,14 @@ class VChatRoom { factory VChatRoom.fromMap(dynamic map) { return VChatRoom( id: map['_id'] as int, - roomType: map['roomType'] == RoomType.single.inString - ? RoomType.single - : RoomType.groupChat, + roomType: map['roomType'] == RoomType.single.inString ? RoomType.single : RoomType.groupChat, blockerId: (map['blockerId'] as int), createdAt: map['createdAt'] as int, updatedAt: (map['updatedAt'] as int), - groupSetting: map['setting'] == null - ? null - : GroupChatSetting.fromMap(map['groupSetting']), + groupSetting: map['setting'] == null ? null : GroupChatSetting.fromMap(map['groupSetting']), creatorId: map['creatorId'] as int, isMute: (map['isMute'] as int), - lastMessageSeenBy: (map['lastMessageSeenBy'] as List) - .map((e) => e as int) - .toList() - .obs, + lastMessageSeenBy: (map['lastMessageSeenBy'] as List).map((e) => e as int).toList(), isOnline: (map['isOnline'] as int), title: map['title'] as String, thumbImage: map['thumbImage'] as String, diff --git a/lib/src/models/v_chat_room_typing.dart b/lib/src/models/v_chat_room_typing.dart index 8249ee3a..5f0432c9 100644 --- a/lib/src/models/v_chat_room_typing.dart +++ b/lib/src/models/v_chat_room_typing.dart @@ -32,16 +32,12 @@ class VChatRoomTyping { factory VChatRoomTyping.fromMap(Map map) { const t = RoomTypingType.stop; - return VChatRoomTyping( - status: t.enumType(map['status']), - name: map['name'] as String?, - roomId: map['roomId']); + return VChatRoomTyping(status: t.enumType(map['status']), name: map['name'] as String?, roomId: map['roomId']); } Map toMap() { // ignore: unnecessary_cast - return {'status': status.inString, 'name': name, 'roomId': roomId} - as Map; + return {'status': status.inString, 'name': name, 'roomId': roomId} as Map; } // diff --git a/lib/src/models/v_chat_user.dart b/lib/src/models/v_chat_user.dart index 997c32a5..a0482b59 100644 --- a/lib/src/models/v_chat_user.dart +++ b/lib/src/models/v_chat_user.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:get/get.dart'; @immutable class VChatUser { @@ -8,7 +7,7 @@ class VChatUser { final String imageThumb; final String email; final String accessToken; - final RxBool isSelected = false.obs; + final bool isSelected = false; // diff --git a/lib/src/modules/message/cubit/message_cubit.dart b/lib/src/modules/message/cubit/message_cubit.dart index f6ffefba..0eebf98e 100644 --- a/lib/src/modules/message/cubit/message_cubit.dart +++ b/lib/src/modules/message/cubit/message_cubit.dart @@ -190,8 +190,7 @@ class MessageCubit extends Cubit with WidgetsBindingObserver { final _pickedImage = File(path); final compressedFile = await FileUtils.compressImage(_pickedImage); - final properties = - await FlutterNativeImage.getImageProperties(compressedFile.path); + final properties = await FlutterNativeImage.getImageProperties(compressedFile.path); final fileSize = FileUtils.getFileSize(compressedFile); await FileUtils.uploadFile( [ @@ -266,8 +265,7 @@ class MessageCubit extends Cubit with WidgetsBindingObserver { CustomAlert.customLoadingDialog(context: context); final videoFile = File(path); final videoThumb = await FileUtils.getVideoThumb(videoFile); - final properties = - await FlutterNativeImage.getImageProperties(videoThumb.path); + final properties = await FlutterNativeImage.getImageProperties(videoThumb.path); final d = await FileUtils.getVideoDuration(videoFile.path); final fileSize = FileUtils.getFileSize(videoFile); if (!getIt.get().isConnected) { diff --git a/lib/src/modules/message/providers/message_provider.dart b/lib/src/modules/message/providers/message_provider.dart index 35e5dfe8..9ba8342d 100644 --- a/lib/src/modules/message/providers/message_provider.dart +++ b/lib/src/modules/message/providers/message_provider.dart @@ -1,18 +1,13 @@ -import 'package:get/get.dart'; - import '../../../models/v_chat_message.dart'; - import '../../../utils/api_utils/dio/custom_dio.dart'; -class MessageProvider extends DisposableInterface { +class MessageProvider { Future> loadMoreMessages( int roomId, String lastMessageId, ) async { - final messages = (await CustomDio().send( - reqMethod: "GET", - path: "message", - query: {"id": lastMessageId, "roomId": roomId.toString()})) + final messages = (await CustomDio() + .send(reqMethod: "GET", path: "message", query: {"id": lastMessageId, "roomId": roomId.toString()})) .data['data'] as List; return messages.map((e) => VChatMessage.fromMap(e)).toList(); } diff --git a/lib/src/modules/message/providers/message_socket.dart b/lib/src/modules/message/providers/message_socket.dart index 9b2a9268..5b2a97b5 100644 --- a/lib/src/modules/message/providers/message_socket.dart +++ b/lib/src/modules/message/providers/message_socket.dart @@ -32,15 +32,13 @@ class MessageSocket { _socket.on("all_messages", (data) async { final msgList = (jsonDecode(data)) as List; final x = msgList.map((e) => VChatMessage.fromMap(e)).toList(); - unawaited( - localStorageService.setRoomMessages(currentRoomId.toString(), x)); + unawaited(localStorageService.setRoomMessages(currentRoomId.toString(), x)); onAllMessages(x); }); _socket.on('new_message', (data) async { final msgMap = jsonDecode(data); final message = VChatMessage.fromMap(msgMap); - unawaited(localStorageService.insertMessage( - currentRoomId.toString(), message)); + unawaited(localStorageService.insertMessage(currentRoomId.toString(), message)); onNewMessage(message); }); _socket.onReconnecting((data) { @@ -58,9 +56,7 @@ class MessageSocket { 'pingTimeout': 5000, 'connectTimeout': 5000, 'pingInterval': 5000, - 'extraHeaders': { - 'Authorization': VChatAppService.instance.vChatUser!.accessToken - }, + 'extraHeaders': {'Authorization': VChatAppService.instance.vChatUser!.accessToken}, 'forceNew': true }); } diff --git a/lib/src/modules/message/views/list_view_widgets/message_file_view.dart b/lib/src/modules/message/views/list_view_widgets/message_file_view.dart index aa81145d..ecb7a2e3 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_file_view.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_file_view.dart @@ -8,8 +8,7 @@ class MessageFileView extends StatelessWidget { final bool isSender; final myId = VChatAppService.instance.vChatUser!.id; - MessageFileView(this._message, {Key? key, required this.isSender}) - : super(key: key); + MessageFileView(this._message, {Key? key, required this.isSender}) : super(key: key); @override Widget build(BuildContext context) { @@ -19,15 +18,17 @@ class MessageFileView extends StatelessWidget { onTap: () { FileUtils.newDownloadFile(context, att); }, - child:isSender? VChatAppService.instance.vcBuilder.senderFileMessageWidget( - context, - att.linkTitle!, - att.fileSize!, - ):VChatAppService.instance.vcBuilder.receiverFileMessageWidget( - context, - att.linkTitle!, - att.fileSize!, - ), + child: isSender + ? VChatAppService.instance.vcBuilder.senderFileMessageWidget( + context, + att.linkTitle!, + att.fileSize!, + ) + : VChatAppService.instance.vcBuilder.receiverFileMessageWidget( + context, + att.linkTitle!, + att.fileSize!, + ), ); } } diff --git a/lib/src/modules/message/views/list_view_widgets/message_image_item.dart b/lib/src/modules/message/views/list_view_widgets/message_image_item.dart index 9b0f8c1a..f5c9deaf 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_image_item.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_image_item.dart @@ -1,29 +1,25 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:get/get.dart'; import '../../../../models/v_chat_message.dart'; import '../../../../utils/api_utils/server_config.dart'; import '../../../image_viewer/views/image_viewer_view.dart'; -class MessageImageItem extends GetView { +class MessageImageItem extends StatelessWidget { final VChatMessage _message; final bool isSender; - const MessageImageItem(this._message, {Key? key, required this.isSender}) - : super(key: key); + const MessageImageItem(this._message, {Key? key, required this.isSender}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( onTap: () { - Navigator.push( context, MaterialPageRoute( - builder: (context) => ImageViewerView( - ServerConfig.messagesMediaBaseUrl + - _message.messageAttachment!.imageUrl.toString()), + builder: (context) => + ImageViewerView(ServerConfig.messagesMediaBaseUrl + _message.messageAttachment!.imageUrl.toString()), ), ); }, @@ -41,8 +37,7 @@ class MessageImageItem extends GetView { width: double.parse(_message.messageAttachment!.width!), color: Colors.grey, child: CachedNetworkImage( - imageUrl: ServerConfig.messagesMediaBaseUrl + - _message.messageAttachment!.imageUrl.toString(), + imageUrl: ServerConfig.messagesMediaBaseUrl + _message.messageAttachment!.imageUrl.toString(), fit: BoxFit.cover, ), ), diff --git a/lib/src/modules/message/views/list_view_widgets/message_item_view.dart b/lib/src/modules/message/views/list_view_widgets/message_item_view.dart index 3b0aa4a7..2c8ffb7b 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_item_view.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_item_view.dart @@ -17,12 +17,7 @@ class MessageItemView extends StatelessWidget { final int index; final int myId; - const MessageItemView( - {required this.myId, - required this.message, - required this.index, - Key? key}) - : super(key: key); + const MessageItemView({required this.myId, required this.message, required this.index, Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -47,8 +42,7 @@ class MessageItemView extends StatelessWidget { ), ConstrainedBox( constraints: BoxConstraints(maxWidth: maxPaddingWidth), - child: - getItemBody(isSender: isSender, context: context, isDark: isDark), + child: getItemBody(isSender: isSender, context: context, isDark: isDark), ), const SizedBox(height: 2), if (isSender) diff --git a/lib/src/modules/message/views/list_view_widgets/message_text_item.dart b/lib/src/modules/message/views/list_view_widgets/message_text_item.dart index c7899790..fc11a45c 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_text_item.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_text_item.dart @@ -15,12 +15,9 @@ class MessageTextItem extends StatelessWidget { @override Widget build(BuildContext context) { if (isSender) { - return VChatAppService.instance.vcBuilder - .senderTextMessageWidget(context, message.content); + return VChatAppService.instance.vcBuilder.senderTextMessageWidget(context, message.content); } else { - return VChatAppService.instance.vcBuilder - .receiverTextMessageWidget(context, message.content); + return VChatAppService.instance.vcBuilder.receiverTextMessageWidget(context, message.content); } } - } diff --git a/lib/src/modules/message/views/list_view_widgets/message_video_item.dart b/lib/src/modules/message/views/list_view_widgets/message_video_item.dart index 3a54ae39..62ae6f5f 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_video_item.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_video_item.dart @@ -10,10 +10,7 @@ class MessageVideoItem extends StatelessWidget { final VChatMessage _message; final bool isSender; - - - MessageVideoItem(this._message, {Key? key, required this.isSender}) - : super(key: key); + MessageVideoItem(this._message, {Key? key, required this.isSender}) : super(key: key); @override Widget build(BuildContext context) { @@ -24,8 +21,7 @@ class MessageVideoItem extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => VideoPlayerView( - ServerConfig.messagesMediaBaseUrl + att.playUrl.toString()), + builder: (context) => VideoPlayerView(ServerConfig.messagesMediaBaseUrl + att.playUrl.toString()), )); }, child: Container( @@ -42,8 +38,7 @@ class MessageVideoItem extends StatelessWidget { ClipRRect( borderRadius: BorderRadius.circular(15), child: CachedNetworkImage( - imageUrl: ServerConfig.messagesMediaBaseUrl + - att.imageUrl.toString(), + imageUrl: ServerConfig.messagesMediaBaseUrl + att.imageUrl.toString(), fit: BoxFit.cover, ), ), diff --git a/lib/src/modules/message/views/list_view_widgets/message_voice_view.dart b/lib/src/modules/message/views/list_view_widgets/message_voice_view.dart index 5dfa6715..462aab29 100644 --- a/lib/src/modules/message/views/list_view_widgets/message_voice_view.dart +++ b/lib/src/modules/message/views/list_view_widgets/message_voice_view.dart @@ -9,8 +9,7 @@ class MessageVoiceView extends StatelessWidget { final VChatMessage _message; final bool isSender; - const MessageVoiceView(this._message, {Key? key, required this.isSender}) - : super(key: key); + const MessageVoiceView(this._message, {Key? key, required this.isSender}) : super(key: key); @override Widget build(BuildContext context) { @@ -28,8 +27,7 @@ class MessageVoiceView extends StatelessWidget { }, ); }, - child: VChatAppService.instance.vcBuilder - .senderVoiceMessageWidget(context, att.fileDuration!), + child: VChatAppService.instance.vcBuilder.senderVoiceMessageWidget(context, att.fileDuration!), ); } else { return InkWell( @@ -43,8 +41,7 @@ class MessageVoiceView extends StatelessWidget { }, ); }, - child: VChatAppService.instance.vcBuilder - .receiverVoiceMessageWidget(context, att.fileDuration!), + child: VChatAppService.instance.vcBuilder.receiverVoiceMessageWidget(context, att.fileDuration!), ); } } diff --git a/lib/src/modules/message/views/list_view_widgets/render_message_send_at_day_item.dart b/lib/src/modules/message/views/list_view_widgets/render_message_send_at_day_item.dart index d216a1fd..7756a08e 100644 --- a/lib/src/modules/message/views/list_view_widgets/render_message_send_at_day_item.dart +++ b/lib/src/modules/message/views/list_view_widgets/render_message_send_at_day_item.dart @@ -9,40 +9,33 @@ class RenderMessageSendAtDayItem extends StatelessWidget { final VChatMessage message; final List messages; - const RenderMessageSendAtDayItem( - {Key? key, - required this.index, - required this.message, - required this.messages}) + const RenderMessageSendAtDayItem({Key? key, required this.index, required this.message, required this.messages}) : super(key: key); @override Widget build(BuildContext context) { if (index == messages.length - 1) { - return getLabelDay(context,message.createdAt); + return getLabelDay(context, message.createdAt); } - final lastMessageSendAt = - DateTime.fromMillisecondsSinceEpoch(messages[index + 1].createdAt); + final lastMessageSendAt = DateTime.fromMillisecondsSinceEpoch(messages[index + 1].createdAt); - final messageSendAt = - DateTime.fromMillisecondsSinceEpoch(message.createdAt); + final messageSendAt = DateTime.fromMillisecondsSinceEpoch(message.createdAt); final formatter = UtilDates.formatDay; - final formattedLastMessageSendAt = - formatter.format(lastMessageSendAt); + final formattedLastMessageSendAt = formatter.format(lastMessageSendAt); - final formattedMessageSendAt = formatter.format(messageSendAt); + final formattedMessageSendAt = formatter.format(messageSendAt); if (formattedLastMessageSendAt != formattedMessageSendAt) { - return getLabelDay(context,message.createdAt); + return getLabelDay(context, message.createdAt); } return const SizedBox.shrink(); } - Widget getLabelDay(BuildContext context,int milliseconds) { - final day = UtilDates.getSendAtDay(context,milliseconds); + Widget getLabelDay(BuildContext context, int milliseconds) { + final day = UtilDates.getSendAtDay(context, milliseconds); return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/src/modules/message/views/message_view.dart b/lib/src/modules/message/views/message_view.dart index 0427ad03..ccde9249 100644 --- a/lib/src/modules/message/views/message_view.dart +++ b/lib/src/modules/message/views/message_view.dart @@ -54,7 +54,6 @@ class _MessageViewScreenState extends State { Expanded( child: BlocBuilder( builder: (context, state) { - final v = VChatAppService.instance.getTrans(context); return Builder( builder: (c) { if (state is MessageLoaded) { @@ -87,8 +86,7 @@ class _MessageViewScreenState extends State { BlocBuilder( bloc: RoomCubit.instance, builder: (context, state) { - final _room = roomController.rooms.firstWhere( - (element) => element.id == messageController.roomId); + final _room = roomController.rooms.firstWhere((element) => element.id == messageController.roomId); if (state is RoomLoaded) { if (_room.roomType == RoomType.single) { @@ -103,8 +101,7 @@ class _MessageViewScreenState extends State { ), Align( alignment: Alignment.centerRight, - child: CircleImage.network( - path: _room.thumbImage, radius: 10), + child: CircleImage.network(path: _room.thumbImage, radius: 10), ), ], ); @@ -122,8 +119,7 @@ class _MessageViewScreenState extends State { child: BlocBuilder( bloc: RoomCubit.instance, builder: (context, state) { - final _room = roomController.rooms.firstWhere( - (element) => element.id == messageController.roomId); + final _room = roomController.rooms.firstWhere((element) => element.id == messageController.roomId); if (state is RoomLoaded) { final bkId = _room.blockerId; diff --git a/lib/src/modules/message/views/widgets/message_appbar_view.dart b/lib/src/modules/message/views/widgets/message_appbar_view.dart index 17d4e9f9..620c8655 100644 --- a/lib/src/modules/message/views/widgets/message_appbar_view.dart +++ b/lib/src/modules/message/views/widgets/message_appbar_view.dart @@ -9,22 +9,18 @@ import '../../../../utils/custom_widgets/circle_image.dart'; import '../../../rooms/cubit/room_cubit.dart'; class MessageAppBarView extends StatelessWidget implements PreferredSizeWidget { - - - const MessageAppBarView({Key? key}) : super(key: key); + const MessageAppBarView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final roomController = RoomCubit.instance; return AppBar( - centerTitle: true, elevation: 1, title: BlocBuilder( bloc: RoomCubit.instance, builder: (context, state) { - final _room = roomController.rooms.firstWhere( - (element) => element.id == roomController.currentRoomId!); + final _room = roomController.rooms.firstWhere((element) => element.id == roomController.currentRoomId!); if (state is RoomLoaded) { final isOnline = _room.isOnline; final typingSt = _room.typingStatus; @@ -32,7 +28,7 @@ class MessageAppBarView extends StatelessWidget implements PreferredSizeWidget { final t = VChatAppService.instance.getTrans(context); return Column( children: [ - _room.title.text , + _room.title.text, Builder( builder: (_) { if (isSingle) { @@ -52,9 +48,7 @@ class MessageAppBarView extends StatelessWidget implements PreferredSizeWidget { } } else { if (typingSt.status != RoomTypingType.stop) { - return "${typingSt.name} is ${typingSt.status.inString} ..." - .b2.color(Colors.green); - + return "${typingSt.name} is ${typingSt.status.inString} ...".b2.color(Colors.green); } else { return const SizedBox(); } @@ -72,18 +66,14 @@ class MessageAppBarView extends StatelessWidget implements PreferredSizeWidget { child: BlocBuilder( bloc: RoomCubit.instance, builder: (context, state) { - final _room = roomController.rooms.firstWhere( - (element) => element.id == roomController.currentRoomId!); + final _room = roomController.rooms.firstWhere((element) => element.id == roomController.currentRoomId!); return Padding( padding: const EdgeInsets.only(right: 5), child: InkWell( onTap: () { //todo call back when icon clicked }, - child: CircleImage.network( - path: _room.thumbImage, - radius: 25, - isOnline: _room.isOnline == 1), + child: CircleImage.network(path: _room.thumbImage, radius: 25, isOnline: _room.isOnline == 1), ), ); }, diff --git a/lib/src/modules/message/views/widgets/v_chat_message_input/attachment_picker_widget.dart b/lib/src/modules/message/views/widgets/v_chat_message_input/attachment_picker_widget.dart index 70f7e2ca..5fd9ed58 100644 --- a/lib/src/modules/message/views/widgets/v_chat_message_input/attachment_picker_widget.dart +++ b/lib/src/modules/message/views/widgets/v_chat_message_input/attachment_picker_widget.dart @@ -26,18 +26,15 @@ class AttachmentPickerWidget extends StatelessWidget { child: Text(VChatAppService.instance.getTrans(ctx).photo()), onPressed: () async { final picker = ImagePicker(); - final pickedFile = - await picker.pickImage(source: ImageSource.gallery); + final pickedFile = await picker.pickImage(source: ImageSource.gallery); if (pickedFile != null) { - if (File(pickedFile.path).lengthSync() > - ServerConfig.maxMessageFileSize) { + if (File(pickedFile.path).lengthSync() > ServerConfig.maxMessageFileSize) { File(pickedFile.path).deleteSync(); CustomAlert.error(msg: t.fileIsTooBig()); Navigator.pop(ctx); } - return Navigator.pop( - ctx, {"type": "photo", "path": pickedFile.path}); + return Navigator.pop(ctx, {"type": "photo", "path": pickedFile.path}); } Navigator.pop(ctx); }, @@ -45,17 +42,14 @@ class AttachmentPickerWidget extends StatelessWidget { CupertinoActionSheetAction( child: Text(t.file()), onPressed: () async { - final FilePickerResult? result = - await FilePicker.platform.pickFiles(); + final FilePickerResult? result = await FilePicker.platform.pickFiles(); if (result != null) { - if (File(result.files.first.path!).lengthSync() > - ServerConfig.maxMessageFileSize) { + if (File(result.files.first.path!).lengthSync() > ServerConfig.maxMessageFileSize) { File(result.files.first.path!).deleteSync(); CustomAlert.error(msg: t.fileIsTooBig()); return Navigator.pop(ctx); } - return Navigator.pop( - ctx, {"type": "file", "path": result.files.first.path}); + return Navigator.pop(ctx, {"type": "file", "path": result.files.first.path}); } return Navigator.pop(ctx); }, @@ -63,20 +57,17 @@ class AttachmentPickerWidget extends StatelessWidget { CupertinoActionSheetAction( child: Text(t.video()), onPressed: () async { - final FilePickerResult? result = - await FilePicker.platform.pickFiles( + final FilePickerResult? result = await FilePicker.platform.pickFiles( type: FileType.custom, allowedExtensions: ['mp4', 'mkv', 'avi', 'm4p', 'flv'], ); if (result != null) { - if (File(result.files.first.path!).lengthSync() > - ServerConfig.maxMessageFileSize) { + if (File(result.files.first.path!).lengthSync() > ServerConfig.maxMessageFileSize) { File(result.files.first.path!).deleteSync(); CustomAlert.error(msg: t.fileIsTooBig()); return Navigator.pop(ctx); } - return Navigator.pop( - ctx, {"type": "video", "path": result.files.first.path}); + return Navigator.pop(ctx, {"type": "video", "path": result.files.first.path}); } return Navigator.pop(ctx); }, diff --git a/lib/src/modules/message/views/widgets/v_chat_message_input/message_filed.dart b/lib/src/modules/message/views/widgets/v_chat_message_input/message_filed.dart index d5c2af6e..50b7ef56 100644 --- a/lib/src/modules/message/views/widgets/v_chat_message_input/message_filed.dart +++ b/lib/src/modules/message/views/widgets/v_chat_message_input/message_filed.dart @@ -44,7 +44,6 @@ class _MessageFiledState extends State { text: txt, child: TextField( cursorHeight: 25, - controller: widget.controller, textCapitalization: TextCapitalization.sentences, textInputAction: TextInputAction.newline, @@ -58,9 +57,7 @@ class _MessageFiledState extends State { }); }, decoration: InputDecoration( - hintText: VChatAppService.instance - .getTrans(context) - .yourMessage(), + hintText: VChatAppService.instance.getTrans(context).yourMessage(), border: InputBorder.none, ), ), @@ -68,9 +65,7 @@ class _MessageFiledState extends State { ), ), ), - InkWell( - onTap: widget.onAttachmentPressed, - child: const Icon(Icons.attach_file)), + InkWell(onTap: widget.onAttachmentPressed, child: const Icon(Icons.attach_file)), const SizedBox(width: 8) ], ); diff --git a/lib/src/modules/message/views/widgets/v_chat_message_input/message_recored_view.dart b/lib/src/modules/message/views/widgets/v_chat_message_input/message_recored_view.dart index 22417ea3..c3fedf4a 100644 --- a/lib/src/modules/message/views/widgets/v_chat_message_input/message_recored_view.dart +++ b/lib/src/modules/message/views/widgets/v_chat_message_input/message_recored_view.dart @@ -15,9 +15,7 @@ class MessageRecordView extends StatefulWidget { final Function(String path, String duration) onReceiveRecord; final Function() onCancel; - const MessageRecordView( - {Key? key, required this.onReceiveRecord, required this.onCancel}) - : super(key: key); + const MessageRecordView({Key? key, required this.onReceiveRecord, required this.onCancel}) : super(key: key); @override State createState() => _MessageRecordViewState(); @@ -76,7 +74,7 @@ class _MessageRecordViewState extends State { onTap: stopRecord, child: RoundedContainer( boxShape: BoxShape.circle, - color: VChatAppService.instance.vcBuilder.sendButtonColor(context,context.isDark), + color: VChatAppService.instance.vcBuilder.sendButtonColor(context, context.isDark), height: 50, width: 50, child: Icon( @@ -115,9 +113,7 @@ class _MessageRecordViewState extends State { } catch (err) { Helpers.vlog(err.toString()); CustomAlert.customAlertDialog( - context: context, - errorMessage: - "record not supported on emulator run on real device !"); + context: context, errorMessage: "record not supported on emulator run on real device !"); widget.onCancel(); rethrow; } diff --git a/lib/src/modules/message/views/widgets/v_chat_message_input/v_chat_message_input.dart b/lib/src/modules/message/views/widgets/v_chat_message_input/v_chat_message_input.dart index db9ec6ad..dcf7844f 100644 --- a/lib/src/modules/message/views/widgets/v_chat_message_input/v_chat_message_input.dart +++ b/lib/src/modules/message/views/widgets/v_chat_message_input/v_chat_message_input.dart @@ -81,8 +81,7 @@ class _VChatMessageInputState extends State { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(50), - color: VChatAppService.instance.vcBuilder - .messageInputBackgroundColor(context), + color: VChatAppService.instance.vcBuilder.messageInputBackgroundColor(context), ), child: MessageFiled( controller: widget.controller, @@ -103,7 +102,7 @@ class _VChatMessageInputState extends State { return const AttachmentPickerWidget(); }, ); - if(res!=null){ + if (res != null) { final type = res['type']; final path = res['path']; if (type == "photo") { @@ -114,16 +113,13 @@ class _VChatMessageInputState extends State { widget.onReceiveVideo(path); } } - }, onCameraPressed: () async { final picker = ImagePicker(); - final pickedFile = - await picker.pickImage(source: ImageSource.camera); + final pickedFile = await picker.pickImage(source: ImageSource.camera); if (pickedFile != null) { final t = VChatAppService.instance.getTrans(context); - if (File(pickedFile.path).lengthSync() > - ServerConfig.maxMessageFileSize) { + if (File(pickedFile.path).lengthSync() > ServerConfig.maxMessageFileSize) { File(pickedFile.path).deleteSync(); CustomAlert.error(msg: t.fileIsTooBig()); } @@ -147,7 +143,8 @@ class _VChatMessageInputState extends State { }, child: RoundedContainer( boxShape: BoxShape.circle, - color: VChatAppService.instance.vcBuilder.sendButtonColor(context,Theme.of(context).brightness == Brightness.dark), + color: VChatAppService.instance.vcBuilder + .sendButtonColor(context, Theme.of(context).brightness == Brightness.dark), height: 50, width: 50, child: Icon( @@ -171,7 +168,7 @@ class _VChatMessageInputState extends State { }, child: RoundedContainer( boxShape: BoxShape.circle, - color: VChatAppService.instance.vcBuilder.sendButtonColor(context,context.isDark), + color: VChatAppService.instance.vcBuilder.sendButtonColor(context, context.isDark), height: 50, width: 50, child: Icon( diff --git a/lib/src/modules/modules.dart b/lib/src/modules/modules.dart index e9db112e..d2618323 100644 --- a/lib/src/modules/modules.dart +++ b/lib/src/modules/modules.dart @@ -1 +1 @@ -export './rooms/room_page.dart'; \ No newline at end of file +export './rooms/room_page.dart'; diff --git a/lib/src/modules/rooms/cubit/room_cubit.dart b/lib/src/modules/rooms/cubit/room_cubit.dart index 99d8e0b2..03fbaf5c 100644 --- a/lib/src/modules/rooms/cubit/room_cubit.dart +++ b/lib/src/modules/rooms/cubit/room_cubit.dart @@ -13,7 +13,6 @@ import '../room_api_provider.dart'; part 'room_state.dart'; class RoomCubit extends Cubit { - RoomCubit._privateConstructor() : super(RoomInitial()); static final RoomCubit instance = RoomCubit._privateConstructor(); @@ -34,9 +33,6 @@ class RoomCubit extends Cubit { emit(RoomLoaded(this.rooms)); } - - - void setSocketRooms(List rooms) { this.rooms.clear(); this.rooms.addAll(rooms); @@ -71,7 +67,6 @@ class RoomCubit extends Cubit { } rooms.addAll(loadedRooms); emit(RoomLoaded(rooms)); - } bool isRoomOpen(int roomId) => currentRoomId == roomId; @@ -128,8 +123,7 @@ class RoomCubit extends Cubit { } void _scrollListener() async { - if (scrollController.offset >= - scrollController.position.maxScrollExtent / 2 && + if (scrollController.offset >= scrollController.position.maxScrollExtent / 2 && !scrollController.position.outOfRange && loadingStatus != LoadMoreStatus.loading && loadingStatus != LoadMoreStatus.completed) { @@ -139,7 +133,7 @@ class RoomCubit extends Cubit { } @override - Future close() async{ + Future close() async { scrollController.dispose(); super.close(); } diff --git a/lib/src/modules/rooms/cubit/room_state.dart b/lib/src/modules/rooms/cubit/room_state.dart index e762dce8..9b625fc3 100644 --- a/lib/src/modules/rooms/cubit/room_state.dart +++ b/lib/src/modules/rooms/cubit/room_state.dart @@ -1,6 +1,5 @@ part of 'room_cubit.dart'; - @immutable abstract class RoomState {} @@ -11,4 +10,5 @@ class RoomLoaded extends RoomState { RoomLoaded(this.rooms); } + class RoomEmpty extends RoomState {} diff --git a/lib/src/modules/rooms/room_api_provider.dart b/lib/src/modules/rooms/room_api_provider.dart index 6d5fefb4..68ddc45b 100644 --- a/lib/src/modules/rooms/room_api_provider.dart +++ b/lib/src/modules/rooms/room_api_provider.dart @@ -1,21 +1,15 @@ - import '../../models/v_chat_room.dart'; import '../../utils/api_utils/dio/custom_dio.dart'; - -class RoomsApiProvider { +class RoomsApiProvider { Future> loadMore(int id) async { - final roomsMaps = (await CustomDio() - .send(reqMethod: "GET", path: "room", query: {"id": id.toString()})) - .data['data'] as List; + final roomsMaps = + (await CustomDio().send(reqMethod: "GET", path: "room", query: {"id": id.toString()})).data['data'] as List; return roomsMaps.map((e) => VChatRoom.fromMap(e)).toList(); } Future blockOrUnBlock(String ifSinglePeerId) async { - await CustomDio().send( - reqMethod: "POST", - path: "room/ban-chat-user", - body: {"id": ifSinglePeerId}); + await CustomDio().send(reqMethod: "POST", path: "room/ban-chat-user", body: {"id": ifSinglePeerId}); } Future leaveGroupChat(String id) async { @@ -26,10 +20,7 @@ class RoomsApiProvider { } Future changeNotifaictions(int roomId) async { - return (await CustomDio().send( - reqMethod: "POST", - path: "room/chat-notification", - body: {"id": roomId.toString()})) + return (await CustomDio().send(reqMethod: "POST", path: "room/chat-notification", body: {"id": roomId.toString()})) .data['data']; } } diff --git a/lib/src/modules/rooms/room_page.dart b/lib/src/modules/rooms/room_page.dart index d4725c49..c05f3a5c 100644 --- a/lib/src/modules/rooms/room_page.dart +++ b/lib/src/modules/rooms/room_page.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:textless/textless.dart'; -import '../../services/v_chat_app_service.dart'; import '../../utils/custom_widgets/connection_checker.dart'; import 'cubit/room_cubit.dart'; import 'widgets/room_item.dart'; @@ -39,7 +38,6 @@ class VChatRoomsScreen extends StatelessWidget { return "No rooms yet".text; } else if (state is RoomLoaded) { final rooms = state.rooms; - final v = VChatAppService.instance.getTrans(context); return Expanded( child: Scrollbar( child: ListView.separated( diff --git a/lib/src/modules/rooms/widgets/message_with_icon.dart b/lib/src/modules/rooms/widgets/message_with_icon.dart index 8a0d5604..dded0038 100644 --- a/lib/src/modules/rooms/widgets/message_with_icon.dart +++ b/lib/src/modules/rooms/widgets/message_with_icon.dart @@ -16,12 +16,8 @@ class MessageWithIcon extends StatelessWidget { @override Widget build(BuildContext context) { - if (_room.lastMessage.messageType == MessageType.info) { - return _room.lastMessage.content.b1 - .maxLine(1) - .alignStart - .overflowEllipsis; + return _room.lastMessage.content.b1.maxLine(1).alignStart.overflowEllipsis; } return Row( @@ -46,10 +42,7 @@ class MessageWithIcon extends StatelessWidget { /// I read the message if (_isMeSeen) { - return _room.lastMessage.content.b1.color(Colors.grey) - .maxLine(1) - .alignStart - .overflowEllipsis; + return _room.lastMessage.content.b1.color(Colors.grey).maxLine(1).alignStart.overflowEllipsis; } else { /// I not read the message yet return Row( @@ -78,21 +71,14 @@ class MessageWithIcon extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( - child: _room.lastMessage.content.b1.color(Colors.grey) - .maxLine(1) - - .alignStart - .overflowEllipsis, + child: _room.lastMessage.content.b1.color(Colors.grey).maxLine(1).alignStart.overflowEllipsis, ), CircleImage.network(path: _room.thumbImage, radius: 10), ], ); } - return _room.lastMessage.content.b1.color(Colors.grey) - .maxLine(1) - .alignStart - .overflowEllipsis; + return _room.lastMessage.content.b1.color(Colors.grey).maxLine(1).alignStart.overflowEllipsis; } } } diff --git a/lib/src/modules/rooms/widgets/room_item.dart b/lib/src/modules/rooms/widgets/room_item.dart index 66f870f4..98e25abb 100644 --- a/lib/src/modules/rooms/widgets/room_item.dart +++ b/lib/src/modules/rooms/widgets/room_item.dart @@ -37,18 +37,13 @@ class RoomItem extends StatelessWidget { //Get.toNamed(Routes.MESSAGE); }, onLongPress: () async { - final isMyBlock = - _room.blockerId == VChatAppService.instance.vChatUser!.id; + final isMyBlock = _room.blockerId == VChatAppService.instance.vChatUser!.id; final res = await CustomVerticalSheetItem.normal(context, [ CustomSheetModel( value: 1, - text: _room.isMute == 1 - ? t.enableNotification() - : t.muteNotification(), - iconData: _room.isMute == 1 - ? Icons.notifications - : Icons.notifications_off, + text: _room.isMute == 1 ? t.enableNotification() : t.muteNotification(), + iconData: _room.isMute == 1 ? Icons.notifications : Icons.notifications_off, ), _room.roomType == RoomType.single ? CustomSheetModel( @@ -71,8 +66,7 @@ class RoomItem extends StatelessWidget { context.read().muteAction(context, _room); } } else if (res == 2) { - final res = await CustomAlert.customAskDialog( - title: t.areYouSure(), context: context); + final res = await CustomAlert.customAskDialog(title: t.areYouSure(), context: context); if (res == 1) { context.read().blockOrLeaveAction(context, _room); } @@ -82,9 +76,7 @@ class RoomItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ CircleImage.network( - path: _room.thumbImage, - isOnline: _room.isOnline == 1, - isGroup: _room.roomType == RoomType.groupChat), + path: _room.thumbImage, isOnline: _room.isOnline == 1, isGroup: _room.roomType == RoomType.groupChat), const SizedBox( width: 15, ), @@ -100,12 +92,7 @@ class RoomItem extends StatelessWidget { Flexible( child: AutoDirection( text: _room.title, - child: _room.title - .toString() - .h6 - .maxLine(1) - .alignStart - .overflowEllipsis, + child: _room.title.toString().h6.maxLine(1).alignStart.overflowEllipsis, ), ), _room.lastMessage.createdAtString.toString().b2 @@ -129,9 +116,7 @@ class RoomItem extends StatelessWidget { return txt.text; } else { - return "${tSt.name} is $txt" - .text - .color(Colors.green); + return "${tSt.name} is $txt".text.color(Colors.green); } } else { return Flexible( @@ -140,9 +125,7 @@ class RoomItem extends StatelessWidget { } }, ), - _room.isMute == 1 - ? const Icon(Icons.notifications_off) - : const SizedBox.shrink() + _room.isMute == 1 ? const Icon(Icons.notifications_off) : const SizedBox.shrink() ], ), ], diff --git a/lib/src/modules/voice_player/views/voice_player.dart b/lib/src/modules/voice_player/views/voice_player.dart index 00bf6059..aa9d8f30 100644 --- a/lib/src/modules/voice_player/views/voice_player.dart +++ b/lib/src/modules/voice_player/views/voice_player.dart @@ -43,15 +43,13 @@ class _VoicePlayerState extends State { mainAxisSize: MainAxisSize.min, children: [ Container( - height: 100, child: isPlaying ? InkWell( onTap: pauseVoice, child: Container( margin: const EdgeInsets.symmetric(horizontal: 10), - decoration: const BoxDecoration( - color: Colors.indigo, shape: BoxShape.circle), + decoration: const BoxDecoration(color: Colors.indigo, shape: BoxShape.circle), child: const Icon( Icons.pause, color: Colors.white, @@ -86,7 +84,7 @@ class _VoicePlayerState extends State { height: 32, animation: isPlaying, spacing: 2.5, - width: MediaQuery.of(context).size.width/2, + width: MediaQuery.of(context).size.width / 2, bars: [ AudioWaveBar(height: 10, color: Colors.lightBlueAccent), AudioWaveBar(height: 30, color: Colors.blue), @@ -108,7 +106,6 @@ class _VoicePlayerState extends State { AudioWaveBar(height: 70, color: Colors.black), AudioWaveBar(height: 40), AudioWaveBar(height: 20, color: Colors.orange), - ], ), ], @@ -131,8 +128,7 @@ class _VoicePlayerState extends State { void startPlayVoice() async { await audioPlayer.play( - ServerConfig.messagesMediaBaseUrl + - widget.message.messageAttachment!.playUrl!, + ServerConfig.messagesMediaBaseUrl + widget.message.messageAttachment!.playUrl!, stayAwake: true, ); audioPlayer.onDurationChanged.listen((event) { diff --git a/lib/src/services/auth_provider.dart b/lib/src/services/auth_provider.dart index a32e9362..dbf7604a 100644 --- a/lib/src/services/auth_provider.dart +++ b/lib/src/services/auth_provider.dart @@ -1,5 +1,3 @@ - - import '../dto/v_chat_login_dto.dart'; import '../dto/v_chat_register_dto.dart'; import '../models/v_chat_user.dart'; @@ -7,9 +5,7 @@ import '../utils/api_utils/dio/custom_dio.dart'; class AuthProvider { Future login(VChatLoginDto dto) async { - final data = (await CustomDio() - .send(reqMethod: "POST", path: "user/login", body: dto.toMap())) - .data['data']; + final data = (await CustomDio().send(reqMethod: "POST", path: "user/login", body: dto.toMap())).data['data']; return VChatUser.fromMap(data); } diff --git a/lib/src/services/local_storage_service.dart b/lib/src/services/local_storage_service.dart index 0138a031..03bc38bc 100644 --- a/lib/src/services/local_storage_service.dart +++ b/lib/src/services/local_storage_service.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'package:get/get.dart'; import 'package:sqflite/sqflite.dart'; import '../models/v_chat_message.dart'; import '../models/v_chat_room.dart'; @@ -7,11 +6,10 @@ import '../sqlite/db_provider.dart'; import '../sqlite/tables/message_table.dart'; import '../sqlite/tables/room_table.dart'; -class LocalStorageService extends GetxService { +class LocalStorageService { LocalStorageService._privateConstructor(); - static final LocalStorageService instance = - LocalStorageService._privateConstructor(); + static final LocalStorageService instance = LocalStorageService._privateConstructor(); late Database database; @@ -20,12 +18,10 @@ class LocalStorageService extends GetxService { } Future> getRooms() async { - final maps = await database.query(RoomTable.TABLE_NAME, - orderBy: "${RoomTable.COLUMN_UPDATED_AT} DESC"); + final maps = await database.query(RoomTable.TABLE_NAME, orderBy: "${RoomTable.COLUMN_UPDATED_AT} DESC"); final rooms = []; for (var map in maps) { - final r = - VChatRoom.fromMap(jsonDecode(map[RoomTable.COLUMN_DATA].toString())); + final r = VChatRoom.fromMap(jsonDecode(map[RoomTable.COLUMN_DATA].toString())); rooms.add(r); } @@ -37,7 +33,8 @@ class LocalStorageService extends GetxService { final roomsToInsert = rooms; try { final x = rooms.sublist(0, 20); - roomsToInsert.assignAll(x); + roomsToInsert.clear(); + roomsToInsert.addAll(x); } catch (err) { // } @@ -72,13 +69,13 @@ class LocalStorageService extends GetxService { final messageToInsert = messages; try { final x = messages.sublist(0, 30); - messageToInsert.assignAll(x); + messageToInsert.clear(); + messageToInsert.addAll(x); } catch (err) { // } - await database.delete(MessageTable.tableName, - where: "${MessageTable.COLUMN_ROOM_ID} =?", - whereArgs: [int.parse(roomId)]); + await database + .delete(MessageTable.tableName, where: "${MessageTable.COLUMN_ROOM_ID} =?", whereArgs: [int.parse(roomId)]); final batch = database.batch(); for (var msg in messageToInsert) { @@ -127,7 +124,6 @@ class LocalStorageService extends GetxService { } Future deleteRoom(int id) async { - await database.delete(RoomTable.TABLE_NAME, - where: "${RoomTable.COLUMN_ID}=?", whereArgs: [id]); + await database.delete(RoomTable.TABLE_NAME, where: "${RoomTable.COLUMN_ID}=?", whereArgs: [id]); } } diff --git a/lib/src/services/notification_service.dart b/lib/src/services/notification_service.dart index 2ad2799f..d489210b 100644 --- a/lib/src/services/notification_service.dart +++ b/lib/src/services/notification_service.dart @@ -13,8 +13,7 @@ import 'v_chat_app_service.dart'; class NotificationService { NotificationService._privateConstructor(); - static final NotificationService instance = - NotificationService._privateConstructor(); + static final NotificationService instance = NotificationService._privateConstructor(); late BuildContext context; final androidNotificationDetails = const AndroidNotificationDetails( "v_chat_channel", @@ -25,8 +24,7 @@ class NotificationService { playSound: true, priority: Priority.max, ); - final iosNotificationDetails = - const IOSNotificationDetails(presentBadge: true, presentSound: true); + final iosNotificationDetails = const IOSNotificationDetails(presentBadge: true, presentSound: true); void init(BuildContext context) async { this.context = context; @@ -35,8 +33,7 @@ class NotificationService { } } - static final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = - FlutterLocalNotificationsPlugin(); + static final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); void cancelAll() { flutterLocalNotificationsPlugin.cancelAll(); @@ -98,8 +95,7 @@ class NotificationService { }); await flutterLocalNotificationsPlugin - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin>() + .resolvePlatformSpecificImplementation() ?.createNotificationChannel(channel); await flutterLocalNotificationsPlugin.initialize( @@ -129,10 +125,7 @@ class NotificationService { messaging.onTokenRefresh.listen((event) async { try { - await CustomDio().send( - reqMethod: "PATCH", - path: "user", - body: {"fcmToken": event.toString()}); + await CustomDio().send(reqMethod: "PATCH", path: "user", body: {"fcmToken": event.toString()}); } catch (err) { // } @@ -140,8 +133,7 @@ class NotificationService { FirebaseMessaging.onMessage.listen((message) { if (message.notification != null) { - if (!RoomCubit.instance - .isRoomOpen(int.parse(message.data['roomId'].toString()))) { + if (!RoomCubit.instance.isRoomOpen(int.parse(message.data['roomId'].toString()))) { showNotification( title: "${message.notification!.title}", msg: message.notification!.body.toString(), @@ -173,18 +165,10 @@ class NotificationService { flutterLocalNotificationsPlugin.cancelAll(); } - void showNotification( - {required String title, - required String msg, - required int hashCode, - required String roomId}) { + void showNotification({required String title, required String msg, required int hashCode, required String roomId}) { unawaited( flutterLocalNotificationsPlugin.show( - hashCode, - title, - msg, - NotificationDetails( - android: androidNotificationDetails, iOS: iosNotificationDetails), + hashCode, title, msg, NotificationDetails(android: androidNotificationDetails, iOS: iosNotificationDetails), payload: roomId), ); diff --git a/lib/src/services/socket_service.dart b/lib/src/services/socket_service.dart index 3acf9c0d..c59157ec 100644 --- a/lib/src/services/socket_service.dart +++ b/lib/src/services/socket_service.dart @@ -14,14 +14,12 @@ import 'local_storage_service.dart'; import 'v_chat_app_service.dart'; class SocketService { - ValueNotifier socketStateValue = - ValueNotifier(SocketStateType.connecting); + ValueNotifier socketStateValue = ValueNotifier(SocketStateType.connecting); SocketService() { connectSocket(); } - Socket? _socket; bool get isConnected => _socket!.connected; @@ -32,9 +30,7 @@ class SocketService { 'pingTimeout': 5000, 'connectTimeout': 5000, 'pingInterval': 5000, - 'extraHeaders': { - 'Authorization': VChatAppService.instance.vChatUser!.accessToken - }, + 'extraHeaders': {'Authorization': VChatAppService.instance.vChatUser!.accessToken}, 'forceNew': true }); } @@ -61,8 +57,7 @@ class SocketService { }); _socket!.onError((data) { - if (data.toString() == "{message: auth must be provided ! $data}" && - !isErrorAlertShown) { + if (data.toString() == "{message: auth must be provided ! $data}" && !isErrorAlertShown) { isErrorAlertShown = true; CustomAlert.error(msg: data.toString()); } diff --git a/lib/src/services/v_chat_app_service.dart b/lib/src/services/v_chat_app_service.dart index 169b1a2b..69746c77 100644 --- a/lib/src/services/v_chat_app_service.dart +++ b/lib/src/services/v_chat_app_service.dart @@ -2,8 +2,6 @@ import 'dart:convert'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; import 'package:v_chat_sdk/src/utils/theme/v_chat_const_dark_theme.dart'; import 'package:v_chat_sdk/src/utils/theme/v_chat_const_light_theme.dart'; import '../../v_chat_sdk.dart'; @@ -67,9 +65,7 @@ class VChatAppService { } } - final Map _lookupMessagesMap = { - 'en': EnLanguage() - }; + final Map _lookupMessagesMap = {'en': EnLanguage()}; void setLocaleMessages(String locale, VChatLookupString lookupMessages) { _lookupMessagesMap[locale] = lookupMessages; @@ -82,23 +78,12 @@ class VChatAppService { if (isUseFirebase) { await Firebase.initializeApp(); } - await GetStorage.init(); - final String? userJson = - await storage.read(key: StorageKeys.KV_CHAT_MY_MODEL); + final String? userJson = await storage.read(key: StorageKeys.KV_CHAT_MY_MODEL); if (userJson != null) { vChatUser = VChatUser.fromMap(jsonDecode(userJson)); } else { - final getXData = GetStorage().read(StorageKeys.KV_CHAT_MY_MODEL); - if (getXData != null) { - vChatUser = VChatUser.fromMap(getXData); - await storage.write( - key: StorageKeys.KV_CHAT_MY_MODEL, - value: jsonEncode(getXData), - ); - } else { - vChatUser = null; - } + vChatUser = null; } return this; } diff --git a/lib/src/services/v_chat_provider.dart b/lib/src/services/v_chat_provider.dart index 53147799..cb0fe315 100644 --- a/lib/src/services/v_chat_provider.dart +++ b/lib/src/services/v_chat_provider.dart @@ -39,8 +39,7 @@ class VChatProvider { .toString(); } - Future updateUserPassword( - {required String oldPassword, required String newPassword}) async { + Future updateUserPassword({required String oldPassword, required String newPassword}) async { return (await CustomDio().send( reqMethod: "patch", path: "user", diff --git a/lib/src/utils/api_utils/dio/custom_dio.dart b/lib/src/utils/api_utils/dio/custom_dio.dart index 10a483d3..12e5135b 100644 --- a/lib/src/utils/api_utils/dio/custom_dio.dart +++ b/lib/src/utils/api_utils/dio/custom_dio.dart @@ -15,11 +15,9 @@ class CustomDio { dio.options.validateStatus = (_) => true; dio.options.followRedirects = false; dio.options.headers = { - 'authorization': vChatController.vChatUser != null - ? vChatController.vChatUser!.accessToken.toString() - : "" + 'authorization': vChatController.vChatUser != null ? vChatController.vChatUser!.accessToken.toString() : "" }; - // print(vChatController.vChatUser!.accessToken.toString()); + // print(vChatController.vChatUser!.accessToken.toString()); dio.options.sendTimeout = 10000; dio.options.receiveTimeout = 10000; @@ -47,11 +45,9 @@ class CustomDio { } late Response response; if (isPost) { - response = await dio.post(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + response = await dio.post(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); } else { - response = await dio.patch(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + response = await dio.patch(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); } throwIfNoSuccess(response); @@ -72,8 +68,8 @@ class CustomDio { if (body != null) { data.fields.addAll(body); } - final Response response = await dio.post(apiEndPoint, - data: data, onSendProgress: sendProgress, cancelToken: cancelToken); + final Response response = + await dio.post(apiEndPoint, data: data, onSendProgress: sendProgress, cancelToken: cancelToken); throwIfNoSuccess(response); return response; } catch (err) { @@ -164,8 +160,7 @@ class CustomDio { if (err.type == DioErrorType.other || err.type == DioErrorType.connectTimeout || err.type == DioErrorType.receiveTimeout) { - throw VChatSdkException( - "Check your internet connection and try again "); + throw VChatSdkException("Check your internet connection and try again "); } else { throw VChatSdkException(res.data.toString()); } diff --git a/lib/src/utils/api_utils/dio/v_chat_sdk_exception.dart b/lib/src/utils/api_utils/dio/v_chat_sdk_exception.dart index c05e5a24..407dad0c 100644 --- a/lib/src/utils/api_utils/dio/v_chat_sdk_exception.dart +++ b/lib/src/utils/api_utils/dio/v_chat_sdk_exception.dart @@ -6,6 +6,6 @@ class VChatSdkException implements Exception { @override String toString() { - return data; + return data; } } diff --git a/lib/src/utils/api_utils/server_config.dart b/lib/src/utils/api_utils/server_config.dart index 03d0aced..833f8f74 100644 --- a/lib/src/utils/api_utils/server_config.dart +++ b/lib/src/utils/api_utils/server_config.dart @@ -1,25 +1,23 @@ - class ServerConfig { ServerConfig._(); + /// if you found bug contact me whats app +0201012309598 /// note !!!!!!!!!!!!!!!!!!!! /// 10.0.2.2 only works for emulator if u run on real device you should get your ipv4 from terminal /// type ipconfig then copy it like this format 192.168.1.* //192.168.1.3 - static late String serverIp ; + static late String serverIp; static String serverBaseUrl = "$serverIp/api/v1/"; static const useOneSingle = false; //http://localhost:3000/api/v1/public/images/messages/image_picker6911144535190976387.jpg - static String messageImages = - 'http://$serverIp/api/v1/public/images/messages/'; - + static String messageImages = 'http://$serverIp/api/v1/public/images/messages/'; static String profileImageBaseUrl = "${serverBaseUrl}public/profile/"; static String messagesMediaBaseUrl = "${serverBaseUrl}public/messages/"; - static late int maxMessageFileSize ; // = 50 mb; + static late int maxMessageFileSize; // = 50 mb; } diff --git a/lib/src/utils/custom_widgets/audio_wave.dart b/lib/src/utils/custom_widgets/audio_wave.dart index c0b3d893..d691fa29 100644 --- a/lib/src/utils/custom_widgets/audio_wave.dart +++ b/lib/src/utils/custom_widgets/audio_wave.dart @@ -1,15 +1,7 @@ - - -import 'dart:async'; - import 'package:flutter/material.dart'; class AudioWaveBar { - AudioWaveBar({ - required this.height, - this.color = Colors.red, - this.radius = 50.0 - }); + AudioWaveBar({required this.height, this.color = Colors.red, this.radius = 50.0}); /// [height] is the height of the bar based. It is percentage rate of widget height. /// @@ -103,7 +95,6 @@ class _AudioWaveState extends State { // setState(() {}); // } - @override Widget build(BuildContext context) { double width = (widget.width - (widget.spacing * widget.bars.length)) / widget.bars.length; @@ -117,8 +108,8 @@ class _AudioWaveState extends State { crossAxisAlignment: widget.alignment == 'top' ? WrapCrossAlignment.start : widget.alignment == 'bottom' - ? WrapCrossAlignment.end - : WrapCrossAlignment.center, + ? WrapCrossAlignment.end + : WrapCrossAlignment.center, spacing: widget.spacing, children: [ if (bars != null) diff --git a/lib/src/utils/custom_widgets/auto_direction.dart b/lib/src/utils/custom_widgets/auto_direction.dart index b01bbd8a..a085daf6 100644 --- a/lib/src/utils/custom_widgets/auto_direction.dart +++ b/lib/src/utils/custom_widgets/auto_direction.dart @@ -6,12 +6,7 @@ class AutoDirection extends StatefulWidget { final Widget child; final void Function(bool isRTL)? onDirectionChange; - const AutoDirection( - {Key? key, - required this.text, - required this.child, - this.onDirectionChange}) - : super(key: key); + const AutoDirection({Key? key, required this.text, required this.child, this.onDirectionChange}) : super(key: key); @override _AutoDirectionState createState() => _AutoDirectionState(); @@ -25,9 +20,7 @@ class _AutoDirectionState extends State { Widget build(BuildContext context) { text = widget.text; childWidget = widget.child; - return Directionality( - textDirection: isRTL(text) ? TextDirection.rtl : TextDirection.ltr, - child: childWidget); + return Directionality(textDirection: isRTL(text) ? TextDirection.rtl : TextDirection.ltr, child: childWidget); } @override diff --git a/lib/src/utils/custom_widgets/circle_image.dart b/lib/src/utils/custom_widgets/circle_image.dart index 218f0603..1e265567 100644 --- a/lib/src/utils/custom_widgets/circle_image.dart +++ b/lib/src/utils/custom_widgets/circle_image.dart @@ -15,11 +15,7 @@ class CircleImage { } static Widget network( - {required String path, - int radius = 30, - bool isOnline = false, - bool isGroup = false, - bool isSelected = false}) { + {required String path, int radius = 30, bool isOnline = false, bool isGroup = false, bool isSelected = false}) { return Stack( children: [ Padding( @@ -50,8 +46,7 @@ class CircleImage { decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.green, - border: - Border.all(color: Colors.green, width: isGroup ? 0 : 0)), + border: Border.all(color: Colors.green, width: isGroup ? 0 : 0)), child: Icon( isGroup ? Icons.home_sharp diff --git a/lib/src/utils/custom_widgets/connection_checker.dart b/lib/src/utils/custom_widgets/connection_checker.dart index d9806bae..edcad771 100644 --- a/lib/src/utils/custom_widgets/connection_checker.dart +++ b/lib/src/utils/custom_widgets/connection_checker.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:get/get.dart'; import 'package:get_it/get_it.dart'; import 'package:textless/textless.dart'; @@ -8,8 +7,8 @@ import '../../services/socket_service.dart'; import '../../services/v_chat_app_service.dart'; import 'rounded_container.dart'; -class ConnectionChecker extends GetView { - const ConnectionChecker({Key? key}) : super(key: key); +class ConnectionChecker extends StatelessWidget { + const ConnectionChecker({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final SocketService _socket = GetIt.I.get(); @@ -17,7 +16,7 @@ class ConnectionChecker extends GetView { builder: (context, value, child) { if (value == SocketStateType.connecting) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 5 ), + padding: const EdgeInsets.symmetric(horizontal: 5), child: RoundedContainer( color: Colors.redAccent, borderRadius: BorderRadius.circular(10), diff --git a/lib/src/utils/custom_widgets/create_single_chat_dialog.dart b/lib/src/utils/custom_widgets/create_single_chat_dialog.dart index 0f192bcd..cbbbf285 100644 --- a/lib/src/utils/custom_widgets/create_single_chat_dialog.dart +++ b/lib/src/utils/custom_widgets/create_single_chat_dialog.dart @@ -10,65 +10,58 @@ class CreateSingleChatDialog extends StatelessWidget { final String? createBtnTxt; String txt = ""; - + CreateSingleChatDialog({ + this.titleTxt, + this.createBtnTxt, + }); @override Widget build(BuildContext context) { if (Platform.isIOS) { return Material( child: CupertinoAlertDialog( - title: titleTxt != null - ? titleTxt!.text - : VChatAppService.instance.getTrans(context).sayHello().text, + title: titleTxt != null ? titleTxt!.text : VChatAppService.instance.getTrans(context).sayHello().text, content: TextField( onChanged: (value) { txt = value; }, ), actions: [ - TextButton(onPressed: ()=>Navigator.pop(context), child: VChatAppService.instance.getTrans(context).cancel().text.color(Colors.red)), + TextButton( + onPressed: () => Navigator.pop(context), + child: VChatAppService.instance.getTrans(context).cancel().text.color(Colors.red)), TextButton( onPressed: () async { if (txt.isNotEmpty) { Navigator.pop(context, txt); } }, - child: createBtnTxt != null - ? createBtnTxt!.text - : VChatAppService.instance.getTrans(context).create().text, + child: + createBtnTxt != null ? createBtnTxt!.text : VChatAppService.instance.getTrans(context).create().text, ), - ], ), ); } else {} return AlertDialog( - title: titleTxt != null - ? titleTxt!.text - : VChatAppService.instance.getTrans(context).sayHello().text, + title: titleTxt != null ? titleTxt!.text : VChatAppService.instance.getTrans(context).sayHello().text, content: TextField( onChanged: (value) { txt = value; }, ), actions: [ - TextButton(onPressed: ()=>Navigator.pop(context), child: VChatAppService.instance.getTrans(context).cancel().text.color(Colors.red)), + TextButton( + onPressed: () => Navigator.pop(context), + child: VChatAppService.instance.getTrans(context).cancel().text.color(Colors.red)), TextButton( onPressed: () async { if (txt.isNotEmpty) { Navigator.pop(context, txt); } }, - child: createBtnTxt != null - ? createBtnTxt!.text - : VChatAppService.instance.getTrans(context).create().text, + child: createBtnTxt != null ? createBtnTxt!.text : VChatAppService.instance.getTrans(context).create().text, ), - ], ); } - - CreateSingleChatDialog({ - this.titleTxt, - this.createBtnTxt, - }); } diff --git a/lib/src/utils/custom_widgets/custom_alert_dialog.dart b/lib/src/utils/custom_widgets/custom_alert_dialog.dart index d70d5632..d78cbccd 100644 --- a/lib/src/utils/custom_widgets/custom_alert_dialog.dart +++ b/lib/src/utils/custom_widgets/custom_alert_dialog.dart @@ -43,11 +43,7 @@ class CustomAlert { } static void customAlertDialog( - {String? title, - Function()? onPress, - required String errorMessage, - required BuildContext context, - bool dismissible = true}) { + {Function()? onPress, required String errorMessage, required BuildContext context, bool dismissible = true}) { showGeneralDialog( barrierColor: Colors.black.withOpacity(0.5), transitionBuilder: (context, a1, a2, widget) { @@ -61,12 +57,7 @@ class CustomAlert { opacity: a1.value, child: AlertDialog( clipBehavior: Clip.antiAliasWithSaveLayer, - title: title == null ? null : title.text.alignCenter, - contentPadding: EdgeInsets.zero.copyWith( - top: title == null ? 20 : 8, - bottom: 5, - left: 10, - right: 10), + contentPadding: EdgeInsets.zero.copyWith(top: 20, bottom: 5, left: 10, right: 10), content: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -77,10 +68,7 @@ class CustomAlert { SizedBox( child: ElevatedButton( onPressed: onPress ?? () => Navigator.pop(context), - child: VChatAppService.instance - .getTrans(context) - .oK() - .text), + child: VChatAppService.instance.getTrans(context).oK().text), ) ], ), @@ -99,8 +87,7 @@ class CustomAlert { ); } - static void customLoadingDialog( - {required BuildContext context, bool dismissible = false}) { + static void customLoadingDialog({required BuildContext context, bool dismissible = false}) { showGeneralDialog( barrierColor: Colors.black.withOpacity(0.5), transitionBuilder: (context, a1, a2, widget) { @@ -114,19 +101,14 @@ class CustomAlert { opacity: a1.value, child: AlertDialog( clipBehavior: Clip.antiAliasWithSaveLayer, - contentPadding: const EdgeInsets.only( - top: 8, bottom: 5, left: 10, right: 10), + contentPadding: const EdgeInsets.only(top: 8, bottom: 5, left: 10, right: 10), content: Column( mainAxisSize: MainAxisSize.min, children: [ const SizedBox( height: 10, ), - VChatAppService.instance - .getTrans(context) - .loadingPleaseWait() - .text - .bold, + VChatAppService.instance.getTrans(context).loadingPleaseWait().text.bold, const SizedBox( height: 33, ), @@ -187,25 +169,18 @@ class CustomAlert { actions: [ TextButton( onPressed: () => Navigator.pop(context, -1), - child: VChatAppService.instance - .getTrans(context) - .cancel() - .text, + child: VChatAppService.instance.getTrans(context).cancel().text, ), TextButton( onPressed: () => Navigator.pop(context, 1), - child: VChatAppService.instance - .getTrans(context) - .oK() - .text, + child: VChatAppService.instance.getTrans(context).oK().text, ), ], ) : AlertDialog( clipBehavior: Clip.antiAliasWithSaveLayer, title: title.text, - contentPadding: EdgeInsets.zero - .copyWith(top: 8, bottom: 5, left: 10, right: 10), + contentPadding: EdgeInsets.zero.copyWith(top: 8, bottom: 5, left: 10, right: 10), content: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -217,17 +192,11 @@ class CustomAlert { actions: [ TextButton( onPressed: () => Navigator.pop(context, -1), - child: VChatAppService.instance - .getTrans(context) - .cancel() - .text, + child: VChatAppService.instance.getTrans(context).cancel().text, ), TextButton( onPressed: () => Navigator.pop(context, 1), - child: VChatAppService.instance - .getTrans(context) - .oK() - .text, + child: VChatAppService.instance.getTrans(context).oK().text, ), ], ), diff --git a/lib/src/utils/custom_widgets/read_more_text.dart b/lib/src/utils/custom_widgets/read_more_text.dart index 23c00a10..6992a2ef 100644 --- a/lib/src/utils/custom_widgets/read_more_text.dart +++ b/lib/src/utils/custom_widgets/read_more_text.dart @@ -88,20 +88,15 @@ class ReadMoreTextState extends State { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); } - final textAlign = - widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start; + final textAlign = widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start; final textDirection = widget.textDirection ?? Directionality.of(context); - final textScaleFactor = - widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context); + final textScaleFactor = widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context); final overflow = defaultTextStyle.overflow; final locale = widget.locale ?? Localizations.maybeLocaleOf(context); - final colorClickableText = - widget.colorClickableText ?? Theme.of(context).colorScheme.secondary; - final _defaultLessStyle = widget.lessStyle ?? - effectiveTextStyle?.copyWith(color: colorClickableText); - final _defaultMoreStyle = widget.moreStyle ?? - effectiveTextStyle?.copyWith(color: colorClickableText); + final colorClickableText = widget.colorClickableText ?? Theme.of(context).colorScheme.secondary; + final _defaultLessStyle = widget.lessStyle ?? effectiveTextStyle?.copyWith(color: colorClickableText); + final _defaultMoreStyle = widget.moreStyle ?? effectiveTextStyle?.copyWith(color: colorClickableText); final _defaultDelimiterStyle = widget.delimiterStyle ?? effectiveTextStyle; TextSpan link = TextSpan( @@ -161,9 +156,7 @@ class ReadMoreTextState extends State { if (linkSize.width < maxWidth) { final readMoreSize = linkSize.width + delimiterSize.width; final pos = textPainter.getPositionForOffset(Offset( - textDirection == TextDirection.rtl - ? readMoreSize - : textSize.width - readMoreSize, + textDirection == TextDirection.rtl ? readMoreSize : textSize.width - readMoreSize, textSize.height, )); endIndex = textPainter.getOffsetBefore(pos.offset) ?? 0; @@ -181,9 +174,7 @@ class ReadMoreTextState extends State { if (widget.trimLength < widget.data.length) { textSpan = TextSpan( style: effectiveTextStyle, - text: _readMore - ? widget.data.substring(0, widget.trimLength) - : widget.data, + text: _readMore ? widget.data.substring(0, widget.trimLength) : widget.data, children: [_delimiter, link], ); } else { @@ -198,8 +189,7 @@ class ReadMoreTextState extends State { textSpan = TextSpan( style: effectiveTextStyle, text: _readMore - ? widget.data.substring(0, endIndex) + - (linkLongerThanLine ? _kLineSeparator : '') + ? widget.data.substring(0, endIndex) + (linkLongerThanLine ? _kLineSeparator : '') : widget.data, children: [_delimiter, link], ); @@ -211,8 +201,7 @@ class ReadMoreTextState extends State { } break; default: - throw Exception( - 'TrimMode type: ${widget.trimMode} is not supported'); + throw Exception('TrimMode type: ${widget.trimMode} is not supported'); } return RichText( diff --git a/lib/src/utils/custom_widgets/rounded_container.dart b/lib/src/utils/custom_widgets/rounded_container.dart index 109bc8d1..85bd8eb9 100644 --- a/lib/src/utils/custom_widgets/rounded_container.dart +++ b/lib/src/utils/custom_widgets/rounded_container.dart @@ -26,8 +26,7 @@ class RoundedContainer extends StatelessWidget { Widget build(BuildContext context) { return Container( alignment: alignment, - decoration: BoxDecoration( - color: color, borderRadius: borderRadius, shape: boxShape), + decoration: BoxDecoration(color: color, borderRadius: borderRadius, shape: boxShape), height: height, width: width, padding: padding, diff --git a/lib/src/utils/custom_widgets/sheet_action/custom_vertical_sheet_item.dart b/lib/src/utils/custom_widgets/sheet_action/custom_vertical_sheet_item.dart index 83aa8a19..4ecafecd 100644 --- a/lib/src/utils/custom_widgets/sheet_action/custom_vertical_sheet_item.dart +++ b/lib/src/utils/custom_widgets/sheet_action/custom_vertical_sheet_item.dart @@ -7,8 +7,7 @@ import 'sheet_vertical_item.dart'; class CustomVerticalSheetItem { CustomVerticalSheetItem._(); - static Future normal( - BuildContext context, final List items) async { + static Future normal(BuildContext context, final List items) async { return await showCupertinoModalPopup( barrierDismissible: true, semanticsDismissible: true, @@ -26,14 +25,11 @@ class CustomVerticalSheetItem { if (!e.isHidden) { return CupertinoActionSheetAction( child: Row( - mainAxisAlignment: e.iconData != null - ? MainAxisAlignment.start - : MainAxisAlignment.center, + mainAxisAlignment: e.iconData != null ? MainAxisAlignment.start : MainAxisAlignment.center, children: [ e.iconData != null ? Padding( - padding: - const EdgeInsets.only(right: 15, left: 5), + padding: const EdgeInsets.only(right: 15, left: 5), child: Icon(e.iconData!), ) : const SizedBox.shrink(), diff --git a/lib/src/utils/custom_widgets/sheet_action/sheet_vertical_item.dart b/lib/src/utils/custom_widgets/sheet_action/sheet_vertical_item.dart index 1b5f53d5..f26afff4 100644 --- a/lib/src/utils/custom_widgets/sheet_action/sheet_vertical_item.dart +++ b/lib/src/utils/custom_widgets/sheet_action/sheet_vertical_item.dart @@ -6,9 +6,5 @@ class CustomSheetModel { IconData? iconData; bool isHidden; - CustomSheetModel( - {required this.value, - required this.text, - this.iconData, - this.isHidden = false}); + CustomSheetModel({required this.value, required this.text, this.iconData, this.isHidden = false}); } diff --git a/lib/src/utils/file_utils.dart b/lib/src/utils/file_utils.dart index 4241921a..92ce310f 100644 --- a/lib/src/utils/file_utils.dart +++ b/lib/src/utils/file_utils.dart @@ -21,8 +21,7 @@ import 'helpers/dir_helper.dart'; class FileUtils { FileUtils._(); - static Future newDownloadFile( - BuildContext context, VChatMessageAttachment attachment) async { + static Future newDownloadFile(BuildContext context, VChatMessageAttachment attachment) async { try { await _requestStoragePermission(context); final downloadFile = await DirHelper.downloadPath(); @@ -34,15 +33,11 @@ class FileUtils { final cancelToken = CancelToken(); CustomAlert.customLoadingDialog(context: context); await CustomDio().download( - path: ServerConfig.messagesMediaBaseUrl + - attachment.playUrl.toString(), + path: ServerConfig.messagesMediaBaseUrl + attachment.playUrl.toString(), cancelToken: cancelToken, filePath: file.path); Navigator.pop(context); - CustomAlert.done( - context: context, - msg: - "File saved on device /download/${VChatAppService.instance.appName}"); + CustomAlert.done(context: context, msg: "File saved on device /download/${VChatAppService.instance.appName}"); await OpenFile.open(file.path); } catch (err) { Navigator.pop(context); @@ -50,22 +45,18 @@ class FileUtils { } } } catch (err) { - CustomAlert.customAlertDialog( - errorMessage: err.toString(), context: context); + CustomAlert.customAlertDialog(errorMessage: err.toString(), context: context); rethrow; } } static Future compressImage(File file) async { - final ImageProperties properties = - await FlutterNativeImage.getImageProperties(file.path); + final ImageProperties properties = await FlutterNativeImage.getImageProperties(file.path); File compressedFile = file; if (file.lengthSync() > 150 * 1000) { // compress only images bigger than 150 kb compressedFile = await FlutterNativeImage.compressImage(file.path, - quality: 100, - targetWidth: 700, - targetHeight: (properties.height! * 700 / properties.width!).round()); + quality: 100, targetWidth: 700, targetHeight: (properties.height! * 700 / properties.width!).round()); } // final compressFile = await _copyTheCompressImage(compressedFile); @@ -98,8 +89,7 @@ class FileUtils { timeMs: 1, ); final t = (await getTemporaryDirectory()).path; - final String fileName = - "IMG_THUMB_${DateTime.now().microsecondsSinceEpoch}.png"; + final String fileName = "IMG_THUMB_${DateTime.now().microsecondsSinceEpoch}.png"; final newFile = File("$t$fileName"); return await newFile.writeAsBytes(uint8list!); } @@ -111,8 +101,7 @@ class FileUtils { return _printDuration(Duration(milliseconds: info!.duration!.round())); } - static Future uploadFile(List files, String endPoint, - {Map? body}) async { + static Future uploadFile(List files, String endPoint, {Map? body}) async { final request = http.MultipartRequest( 'POST', Uri.parse('${ServerConfig.serverBaseUrl}$endPoint'), @@ -129,10 +118,7 @@ class FileUtils { ); } - request.headers.addAll({ - "authorization": - VChatAppService.instance.vChatUser!.accessToken.toString() - }); + request.headers.addAll({"authorization": VChatAppService.instance.vChatUser!.accessToken.toString()}); if (body != null) { request.fields.addAll(body); } @@ -159,8 +145,7 @@ class FileUtils { return c.complete(); } else { Navigator.pop(context); - return c.completeError( - "storage permission must be accepted to download the file"); + return c.completeError("storage permission must be accepted to download the file"); } }); } else { diff --git a/lib/src/utils/helpers/dir_helper.dart b/lib/src/utils/helpers/dir_helper.dart index f9339334..3eb9b662 100644 --- a/lib/src/utils/helpers/dir_helper.dart +++ b/lib/src/utils/helpers/dir_helper.dart @@ -9,8 +9,7 @@ class DirHelper { DirHelper._(); static Future downloadPath() async { if (Platform.isAndroid) { - final path1 = join( - 'storage', "emulated", "0", "Documents", VChatAppService.instance.appName); + final path1 = join('storage', "emulated", "0", "Documents", VChatAppService.instance.appName); final dir = await Directory(path1).create(recursive: true); return "${dir.path}/"; } else { diff --git a/lib/src/utils/helpers/helpers.dart b/lib/src/utils/helpers/helpers.dart index 171f45b5..5e537648 100644 --- a/lib/src/utils/helpers/helpers.dart +++ b/lib/src/utils/helpers/helpers.dart @@ -36,8 +36,6 @@ class Helpers { static get getCreatedAtUtc => DateTime.now().toUtc().millisecondsSinceEpoch; static bool isMessageHasAttachment(MessageType t) { - return t != MessageType.text && - t != MessageType.info && - t != MessageType.allDeleted; + return t != MessageType.text && t != MessageType.info && t != MessageType.allDeleted; } } diff --git a/lib/src/utils/theme/v_chat_const_dark_theme.dart b/lib/src/utils/theme/v_chat_const_dark_theme.dart index eefee3c5..d8cf75dd 100644 --- a/lib/src/utils/theme/v_chat_const_dark_theme.dart +++ b/lib/src/utils/theme/v_chat_const_dark_theme.dart @@ -16,8 +16,7 @@ final appBarTheme = AppBarTheme( elevation: 1, centerTitle: true, shadowColor: Colors.white, - titleTextStyle: GoogleFonts.nunito( - color: Colors.white, fontSize: 17, fontWeight: FontWeight.w800), + titleTextStyle: GoogleFonts.nunito(color: Colors.white, fontSize: 17, fontWeight: FontWeight.w800), backgroundColor: Colors.black54, iconTheme: const IconThemeData(color: Colors.white), ); @@ -51,30 +50,18 @@ final vChatConstDarkTheme = ThemeData.dark().copyWith( modalElevation: 0), elevatedButtonTheme: elevatedButtonThemeData, textTheme: GoogleFonts.nunitoTextTheme().copyWith( - headline6: - GoogleFonts.nunito(fontWeight: FontWeight.w700, color: Colors.white), - subtitle2: GoogleFonts.nunito( - letterSpacing: .1, - color: Colors.white70, - fontSize: 15, - fontWeight: FontWeight.normal), - bodyText2: GoogleFonts.nunito( - color: Colors.white, - fontSize: 19, - fontWeight: FontWeight.normal, - letterSpacing: .15), - bodyText1: GoogleFonts.nunito( - color: Colors.white, fontSize: 19, letterSpacing: .5), - subtitle1: GoogleFonts.nunito( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.normal, - letterSpacing: .15), + headline6: GoogleFonts.nunito(fontWeight: FontWeight.w700, color: Colors.white), + subtitle2: + GoogleFonts.nunito(letterSpacing: .1, color: Colors.white70, fontSize: 15, fontWeight: FontWeight.normal), + bodyText2: + GoogleFonts.nunito(color: Colors.white, fontSize: 19, fontWeight: FontWeight.normal, letterSpacing: .15), + bodyText1: GoogleFonts.nunito(color: Colors.white, fontSize: 19, letterSpacing: .5), + subtitle1: + GoogleFonts.nunito(color: Colors.white, fontSize: 18, fontWeight: FontWeight.normal, letterSpacing: .15), caption: GoogleFonts.nunito( color: Colors.white, ), ), backgroundColor: Colors.black, appBarTheme: appBarTheme, - colorScheme: - ColorScheme.fromSwatch().copyWith(secondary: Colors.redAccent)); + colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.redAccent)); diff --git a/lib/src/utils/theme/v_chat_const_light_theme.dart b/lib/src/utils/theme/v_chat_const_light_theme.dart index 6b4e46d6..d9d8a7b4 100644 --- a/lib/src/utils/theme/v_chat_const_light_theme.dart +++ b/lib/src/utils/theme/v_chat_const_light_theme.dart @@ -16,8 +16,7 @@ final elevatedButtonThemeData = ElevatedButtonThemeData( final appBarTheme = AppBarTheme( elevation: 1, centerTitle: true, - titleTextStyle: GoogleFonts.nunito( - color: Colors.black, fontSize: 17, fontWeight: FontWeight.w800), + titleTextStyle: GoogleFonts.nunito(color: Colors.black, fontSize: 17, fontWeight: FontWeight.w800), backgroundColor: Colors.white, iconTheme: const IconThemeData(color: Colors.red), ); @@ -68,8 +67,7 @@ final vChatConstLightTheme = ThemeData( caption: GoogleFonts.nunito( color: Colors.black, ), - bodyText1: GoogleFonts.nunito( - color: Colors.black, fontSize: 19, letterSpacing: .5), + bodyText1: GoogleFonts.nunito(color: Colors.black, fontSize: 19, letterSpacing: .5), subtitle1: GoogleFonts.nunito( color: Colors.black, fontSize: 22, diff --git a/lib/src/utils/translator/ar_language.dart b/lib/src/utils/translator/ar_language.dart index a630fd4b..72f9f455 100644 --- a/lib/src/utils/translator/ar_language.dart +++ b/lib/src/utils/translator/ar_language.dart @@ -1,5 +1,3 @@ - - import 'v_chat_lookup_string.dart'; class ArLanguage implements VChatLookupString { @@ -55,8 +53,7 @@ class ArLanguage implements VChatLookupString { String muteNotification() => "ايقاف التنبيهات"; @override - String notificationsHasBeenStoppedSuccessfully() => - "تم ايثاف التنبيهات بنجاح"; + String notificationsHasBeenStoppedSuccessfully() => "تم ايثاف التنبيهات بنجاح"; @override String oK() => "تم"; @@ -125,8 +122,8 @@ class ArLanguage implements VChatLookupString { String yourMessage() => "اكتب رساله"; @override - String loadMoreFiled()=> "فشل"; + String loadMoreFiled() => "فشل"; @override - String loadingMore() =>"جاري التحميل"; + String loadingMore() => "جاري التحميل"; } diff --git a/lib/src/utils/translator/en_language.dart b/lib/src/utils/translator/en_language.dart index 19e7730c..0ef43f22 100644 --- a/lib/src/utils/translator/en_language.dart +++ b/lib/src/utils/translator/en_language.dart @@ -1,5 +1,3 @@ - - import 'v_chat_lookup_string.dart'; class EnLanguage implements VChatLookupString { @@ -76,8 +74,7 @@ class EnLanguage implements VChatLookupString { String typing() => "Typing ..."; @override - String userHasBeenBlockedSuccessfully() => - "User has been blocked successfully"; + String userHasBeenBlockedSuccessfully() => "User has been blocked successfully"; @override String video() => "Video"; @@ -110,8 +107,7 @@ class EnLanguage implements VChatLookupString { String create() => "Create"; @override - String notificationsHasBeenStoppedSuccessfully() => - "Notifications has been stopped successfully"; + String notificationsHasBeenStoppedSuccessfully() => "Notifications has been stopped successfully"; @override String sayHello() => "Say Hello !"; @@ -126,8 +122,8 @@ class EnLanguage implements VChatLookupString { String yourMessage() => "Message"; @override - String loadMoreFiled() =>"Failed"; + String loadMoreFiled() => "Failed"; @override - String loadingMore() =>"Loading"; + String loadingMore() => "Loading"; } diff --git a/lib/src/utils/translator/v_chat_lookup_string.dart b/lib/src/utils/translator/v_chat_lookup_string.dart index 8dfba081..505a7ec0 100644 --- a/lib/src/utils/translator/v_chat_lookup_string.dart +++ b/lib/src/utils/translator/v_chat_lookup_string.dart @@ -1,5 +1,3 @@ - - /// implement this class to support new languages abstract class VChatLookupString { String test(); diff --git a/lib/src/utils/utils.dart b/lib/src/utils/utils.dart index 857c297b..78699e8b 100644 --- a/lib/src/utils/utils.dart +++ b/lib/src/utils/utils.dart @@ -2,4 +2,4 @@ export './api_utils/dio/v_chat_sdk_exception.dart'; export './translator/ar_language.dart'; export './translator/en_language.dart'; export './translator/v_chat_lookup_string.dart'; -export 'v_chat_widgets_builder.dart'; \ No newline at end of file +export 'v_chat_widgets_builder.dart'; diff --git a/lib/src/utils/v_chat_extention.dart b/lib/src/utils/v_chat_extention.dart index a8cec679..09e5e925 100644 --- a/lib/src/utils/v_chat_extention.dart +++ b/lib/src/utils/v_chat_extention.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -extension VChatIsDark on BuildContext{ - bool get isDark => Theme.of(this).brightness == Brightness.dark; -} \ No newline at end of file +extension VChatIsDark on BuildContext { + bool get isDark => Theme.of(this).brightness == Brightness.dark; +} diff --git a/lib/src/utils/v_chat_widgets_builder.dart b/lib/src/utils/v_chat_widgets_builder.dart index 27de36fc..0cd2f904 100644 --- a/lib/src/utils/v_chat_widgets_builder.dart +++ b/lib/src/utils/v_chat_widgets_builder.dart @@ -40,10 +40,7 @@ class VChatWidgetBuilder { trimMode: TrimMode.line, trimCollapsedText: "show More", trimExpandedText: "show Less", - moreStyle: Theme.of(context) - .textTheme - .bodyText1! - .copyWith(fontWeight: FontWeight.bold), + moreStyle: Theme.of(context).textTheme.bodyText1!.copyWith(fontWeight: FontWeight.bold), style: Theme.of(context).textTheme.bodyText1, ), ), @@ -72,10 +69,7 @@ class VChatWidgetBuilder { trimMode: TrimMode.line, trimCollapsedText: "show More", trimExpandedText: "show Less", - moreStyle: Theme.of(context) - .textTheme - .bodyText1! - .copyWith(fontWeight: FontWeight.bold), + moreStyle: Theme.of(context).textTheme.bodyText1!.copyWith(fontWeight: FontWeight.bold), style: Theme.of(context).textTheme.bodyText1, ), ), @@ -86,8 +80,7 @@ class VChatWidgetBuilder { final isDark = Theme.of(context).brightness == Brightness.dark; return Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: isDark ? const Color(0xff876969) : Colors.tealAccent), + borderRadius: BorderRadius.circular(20), color: isDark ? const Color(0xff876969) : Colors.tealAccent), height: 40, child: Row( children: [ @@ -197,8 +190,7 @@ class VChatWidgetBuilder { ); } - Widget senderFileMessageWidget( - BuildContext context, String fileName, String fileSize) { + Widget senderFileMessageWidget(BuildContext context, String fileName, String fileSize) { final isDark = Theme.of(context).brightness == Brightness.dark; return RoundedContainer( height: 75, @@ -229,8 +221,7 @@ class VChatWidgetBuilder { ); } - Widget receiverFileMessageWidget( - BuildContext context, String fileName, String fileSize) { + Widget receiverFileMessageWidget(BuildContext context, String fileName, String fileSize) { final isDark = Theme.of(context).brightness == Brightness.dark; return RoundedContainer( height: 75, @@ -253,10 +244,7 @@ class VChatWidgetBuilder { child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, - children: [ - fileName.b2.size(13.4).maxLine(1).overflowEllipsis, - fileSize.cap - ], + children: [fileName.b2.size(13.4).maxLine(1).overflowEllipsis, fileSize.cap], ), ) ], diff --git a/lib/src/v_chat_controller.dart b/lib/src/v_chat_controller.dart index 853c83d0..ea400187 100644 --- a/lib/src/v_chat_controller.dart +++ b/lib/src/v_chat_controller.dart @@ -77,16 +77,12 @@ class VChatController { /// to add new language to v chat void setLocaleMessages( - {required String languageCode, - String? countryCode, - required VChatLookupString lookupMessages}) { + {required String languageCode, String? countryCode, required VChatLookupString lookupMessages}) { try { if (countryCode == null) { - VChatAppService.instance - .setLocaleMessages(languageCode, lookupMessages); + VChatAppService.instance.setLocaleMessages(languageCode, lookupMessages); } else { - VChatAppService.instance.setLocaleMessages( - "${languageCode}_${countryCode.toUpperCase()}", lookupMessages); + VChatAppService.instance.setLocaleMessages("${languageCode}_${countryCode.toUpperCase()}", lookupMessages); } } catch (err) { Helpers.vlog("you should call function after init v chat"); @@ -98,9 +94,7 @@ class VChatController { Future stopAllNotification(BuildContext context) async { if (VChatAppService.instance.isUseFirebase) { await FirebaseMessaging.instance.deleteToken(); - return VChatAppService.instance - .getTrans(context) - .notificationsHasBeenStoppedSuccessfully(); + return VChatAppService.instance.getTrans(context).notificationsHasBeenStoppedSuccessfully(); } else { throw "you have to enable firebase for this project first"; } @@ -128,18 +122,15 @@ class VChatController { } /// **throw** No internet connection - Future updateUserPassword( - {required String oldPassword, required String newPassword}) async { - return await _vChatUsersApi.updateUserPassword( - oldPassword: oldPassword, newPassword: newPassword); + Future updateUserPassword({required String oldPassword, required String newPassword}) async { + return await _vChatUsersApi.updateUserPassword(oldPassword: oldPassword, newPassword: newPassword); } /// when you call this function the user will be online and can receive notification /// first you have to login or register in v chat other wise will throw Exception void bindChatControllers(BuildContext context) { if (VChatAppService.instance.vChatUser == null) { - throw VChatSdkException( - "You must login or register to v chat first delete the app and login again !"); + throw VChatSdkException("You must login or register to v chat first delete the app and login again !"); } if (!getIt.isRegistered()) { @@ -152,8 +143,7 @@ class VChatController { /// **throw** User already in v chat data base /// **throw** No internet connection - Future register( - {required BuildContext context, required VChatRegisterDto dto}) async { + Future register({required BuildContext context, required VChatRegisterDto dto}) async { if (VChatAppService.instance.isUseFirebase) { dto.fcmToken = (await FirebaseMessaging.instance.getToken()).toString(); } else { @@ -209,8 +199,7 @@ class VChatController { } } - Future _navigateToRoomMessage( - dynamic data, BuildContext context) async { + Future _navigateToRoomMessage(dynamic data, BuildContext context) async { final room = VChatRoom.fromMap(data); RoomCubit.instance.currentRoomId = room.id; @@ -228,8 +217,7 @@ class VChatController { /// **throw** User not in v chat data base /// **throw** No internet connection - Future login( - {required BuildContext context, required VChatLoginDto dto}) async { + Future login({required BuildContext context, required VChatLoginDto dto}) async { if (VChatAppService.instance.isUseFirebase) { dto.fcmToken = (await FirebaseMessaging.instance.getToken()).toString(); } else { @@ -247,13 +235,12 @@ class VChatController { ///i made this api for who use getx translate projects ///you must call this api any time you open the app void forceLanguage({required String languageCode, String? countryCode}) { - return VChatAppService.instance.changeLanguage(languageCode:languageCode,countryCode: countryCode ); + return VChatAppService.instance.changeLanguage(languageCode: languageCode, countryCode: countryCode); } Future _saveUser(VChatUser user) async { const storage = FlutterSecureStorage(); - await storage.write( - key: StorageKeys.KV_CHAT_MY_MODEL, value: jsonEncode(user.toMap())); + await storage.write(key: StorageKeys.KV_CHAT_MY_MODEL, value: jsonEncode(user.toMap())); VChatAppService.instance.vChatUser = user; } diff --git a/lib/v_chat_sdk.dart b/lib/v_chat_sdk.dart index 85987540..e0485fdc 100644 --- a/lib/v_chat_sdk.dart +++ b/lib/v_chat_sdk.dart @@ -1,4 +1,5 @@ library v_chat_sdk; + export './src/dto/dto.dart'; export './src/modules/modules.dart'; export './src/utils/utils.dart'; diff --git a/pubspec.lock b/pubspec.lock index fcf523e2..ffd23043 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -91,7 +91,7 @@ packages: name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "0.3.1+5" + version: "0.3.2" crypto: dependency: transitive description: @@ -105,7 +105,7 @@ packages: name: csslib url: "https://pub.dartlang.org" source: hosted - version: "0.17.0" + version: "0.17.1" dbus: dependency: transitive description: @@ -147,7 +147,7 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "4.2.4" + version: "4.2.5" firebase_core: dependency: "direct main" description: @@ -215,7 +215,7 @@ packages: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.2.0" flutter_lints: dependency: "direct dev" description: @@ -257,7 +257,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.5" flutter_secure_storage: dependency: "direct main" description: @@ -331,13 +331,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - get: - dependency: transitive - description: - name: get - url: "https://pub.dartlang.org" - source: hosted - version: "4.3.8" get_it: dependency: "direct main" description: @@ -345,13 +338,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.2.0" - get_storage: - dependency: "direct main" - description: - name: get_storage - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.3" google_fonts: dependency: "direct main" description: @@ -400,7 +386,7 @@ packages: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" image_picker_platform_interface: dependency: transitive description: @@ -491,7 +477,7 @@ packages: name: path_provider_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.9" path_provider_ios: dependency: transitive description: @@ -505,14 +491,14 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" path_provider_platform_interface: dependency: transitive description: @@ -526,7 +512,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" pedantic: dependency: transitive description: @@ -554,7 +540,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" photo_view: dependency: "direct main" description: @@ -582,7 +568,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.4" provider: dependency: transitive description: @@ -617,7 +603,7 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.2" + version: "0.27.3" sky_engine: dependency: transitive description: flutter @@ -741,7 +727,7 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "3.0.5" vector_math: dependency: transitive description: @@ -832,7 +818,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.9" + version: "2.3.1" xdg_directories: dependency: transitive description: @@ -846,7 +832,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.0" + version: "5.3.1" sdks: dart: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index e8dbe24d..a46c07c9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: path_provider: ^2.0.7 socket_io_client: ^1.0.2 intl: ^0.17.0 - file_picker: ^4.2.4 + file_picker: ^4.2.5 flutter_native_image: ^0.0.6+1 permission_handler: ^8.3.0 flutter_video_info: ^1.2.0 @@ -39,10 +39,10 @@ dependencies: google_fonts: ^2.1.0 path: ^1.8.0 flutter_secure_storage: ^5.0.2 - get_storage: ^2.0.3 fluttertoast: ^8.0.8 get_it: ^7.2.0 + dev_dependencies: flutter_test: sdk: flutter diff --git a/test/audio_player.dart b/test/audio_player.dart index df03e133..1768e331 100644 --- a/test/audio_player.dart +++ b/test/audio_player.dart @@ -4,7 +4,7 @@ class TestAudioPlayer { void urlPlay() async { //https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_1MG.mp3 AudioPlayer audioPlayer = AudioPlayer(); - int result = await audioPlayer.play( - "http://ec2-3-142-209-237.us-east-2.compute.amazonaws.com:3000/api/v1/public/messages/1635246286427.m4a"); + int result = await audioPlayer + .play("http://ec2-3-142-209-237.us-east-2.compute.amazonaws.com:3000/api/v1/public/messages/1635246286427.m4a"); } }