Skip to content

Commit a0d37b3

Browse files
committed
v 0.5.0 which support backend v 1.0.1
* improve app performance * get project ready for group chat
1 parent 43fae67 commit a0d37b3

File tree

91 files changed

+1248
-587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1248
-587
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## 0.0.5
1818

19-
* format the code
19+
* format the code
2020

2121
## 0.0.6
2222

@@ -28,17 +28,24 @@
2828

2929
## 0.1.0
3030

31-
* beta release
31+
* beta release
3232

3333
## 0.2.0
3434

3535
* fix ios recording and enable notification clicks to open the chat page
3636

3737
## 0.2.1
38+
3839
* encrypt user access token
3940

4041
## 0.2.5
42+
4143
* support android 12
4244

4345
## 0.4.0
44-
*change from getx to bloc state management new design and more ...
46+
47+
* change from getx to bloc state management new design and more ...
48+
49+
## 0.5.0
50+
51+
* hug update on backend service v 1.0.1 must use with vchat v 0.5.0

example/lib/controllers/language_controller.dart renamed to example/lib/controllers/app_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'dart:ui' as ui;
33

44
import 'package:flutter/material.dart';
55

6-
class LanguageController extends ChangeNotifier {
6+
class AppController extends ChangeNotifier {
77
Locale locale = ui.window.locale;
88
ThemeData theme = ThemeData.light();
99

example/lib/controllers/home_controller.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ class HomeController {
1212

1313
Future<List<User>> getUsers() async {
1414
try {
15-
final res = (await CustomDio().send(
16-
reqMethod: "get",
17-
path: "user/all",
18-
))
15+
final res = (await CustomDio()
16+
.send(reqMethod: "get", path: "user", query: {"lastId": "first"}))
1917
.data['data'] as List;
2018
return res.map((e) => User.fromMap(e)).toList();
2119
} catch (err) {
@@ -26,7 +24,8 @@ class HomeController {
2624

2725
void startChat(String email) async {
2826
try {
29-
await VChatController.instance.createSingleChat(context: context, peerEmail: email);
27+
await VChatController.instance
28+
.createSingleChat(context: context, peerEmail: email);
3029
} on VChatSdkException catch (err) {
3130
CustomAlert.showError(context: context, err: err.toString());
3231
rethrow;

example/lib/controllers/login_controller.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:get_storage/get_storage.dart';
44
import 'package:v_chat_sdk/v_chat_sdk.dart';
5-
import '../models/user.dart';
65
import '../screens/home.dart';
76
import '../screens/register_screen.dart';
87
import '../utils/custom_alert.dart';
9-
import '../utils/custom_dio.dart';
108

119
class LoginController {
1210
BuildContext context;
@@ -17,22 +15,26 @@ class LoginController {
1715

1816
void login() async {
1917
final email = emailTxtController.text.toString();
20-
final password = passwordTxtController.text.toString();
18+
//final password = passwordTxtController.text.toString();
2119
try {
22-
///Login on your system backend
2320
CustomAlert.customLoadingDialog(context: context);
24-
final d =
25-
(await CustomDio().send(reqMethod: "post", path: "user/login", body: {"email": email, "password": password}))
26-
.data['data'];
27-
final u = User.fromMap(d);
2821

29-
await GetStorage().write("myModel", u.toMap());
22+
///Login on your system backend
23+
// final d = (await CustomDio().send(
24+
// reqMethod: "post",
25+
// path: "user/login",
26+
// body: {"email": email, "password": password}))
27+
// .data['data'];
28+
// final u = User.fromMap(d);
3029

3130
///Login on v_chat_sdk system
32-
await VChatController.instance.login(context: context, dto: VChatLoginDto(email: email, password: password));
31+
final u =
32+
await VChatController.instance.login(context: context, email: email);
33+
await GetStorage().write("myModel", u.toMap());
3334
Navigator.pop(context);
34-
Navigator.of(context)
35-
.pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route<dynamic> route) => false);
35+
Navigator.of(context).pushAndRemoveUntil(
36+
MaterialPageRoute(builder: (context) => const Home()),
37+
(Route<dynamic> route) => false);
3638
} on VChatSdkException catch (err) {
3739
Navigator.pop(context);
3840
CustomAlert.showError(context: context, err: err.toString());

example/lib/controllers/register_controller.dart

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import 'package:flutter/cupertino.dart';
33
import 'package:flutter/material.dart';
44
import 'package:get_storage/get_storage.dart';
55
import 'package:v_chat_sdk/v_chat_sdk.dart';
6-
import '../models/user.dart';
76
import '../screens/home.dart';
87
import '../utils/custom_alert.dart';
9-
import '../utils/custom_dio.dart';
108

119
class RegisterController {
1210
BuildContext context;
@@ -21,47 +19,33 @@ class RegisterController {
2119
void register() async {
2220
final email = emailTxtController.text.toString();
2321
final name = nameTxtController.text.toString();
24-
final password = passwordTxtController.text.toString();
25-
26-
dynamic myUser;
22+
//final password = passwordTxtController.text.toString();
2723

2824
try {
2925
CustomAlert.customLoadingDialog(context: context);
3026

3127
///Register on your system backend
3228
if (imagePath != null) {
33-
if (File(imagePath!).lengthSync() > 1024 * 1024 * 10) {
34-
throw "image size must be less than 10 Mb";
29+
if (File(imagePath!).lengthSync() > 1024 * 1024 * 20) {
30+
throw "image size must be less than 20 Mb";
3531
}
36-
myUser = (await CustomDio().uploadFile(apiEndPoint: "user/register", filePath: imagePath!, body: [
37-
{"email": email},
38-
{"password": password},
39-
{"name": name},
40-
]))
41-
.data['data'];
42-
} else {
43-
myUser = (await CustomDio().send(reqMethod: "post", path: "user/register", body: {
44-
"email": email,
45-
"password": password,
46-
"name": name,
47-
}))
48-
.data['data'];
4932
}
50-
final u = User.fromMap(myUser);
51-
await GetStorage().write("myModel", u.toMap());
5233

53-
///Register on v_chat_sdk system
54-
await VChatController.instance.register(
55-
dto: VChatRegisterDto(
34+
///first register on your system
35+
36+
///then Register on v_chat_sdk system
37+
final u = await VChatController.instance.register(
38+
dto: VChatRegisterDto(
5639
name: name,
5740
userImage: imagePath == null ? null : File(imagePath!),
58-
email: email,
59-
password: password,
60-
),
61-
context: context);
41+
email: email),
42+
context: context,
43+
);
44+
await GetStorage().write("myModel", u.toMap());
6245
Navigator.pop(context);
63-
Navigator.of(context)
64-
.pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route<dynamic> route) => false);
46+
Navigator.of(context).pushAndRemoveUntil(
47+
MaterialPageRoute(builder: (context) => const Home()),
48+
(Route<dynamic> route) => false);
6549
} on VChatSdkException catch (err) {
6650
Navigator.pop(context);
6751
CustomAlert.showError(context: context, err: err.toString());

example/lib/generated/intl/messages_all.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ MessageLookupByLibrary? _findExact(String localeName) {
4141

4242
/// User programs should call this before using [localeName] for messages.
4343
Future<bool> initializeMessages(String localeName) async {
44-
var availableLocale =
45-
Intl.verifiedLocale(localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null);
44+
var availableLocale = Intl.verifiedLocale(
45+
localeName, (locale) => _deferredLibraries[locale] != null,
46+
onFailure: (_) => null);
4647
if (availableLocale == null) {
4748
return new Future.value(false);
4849
}
@@ -62,7 +63,8 @@ bool _messagesExistFor(String locale) {
6263
}
6364

6465
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
65-
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
66+
var actualLocale =
67+
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
6668
if (actualLocale == null) return null;
6769
return _findExact(actualLocale);
6870
}

example/lib/generated/intl/messages_ar_EG.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class MessageLookup extends MessageLookupByLibrary {
2222

2323
final messages = _notInlinedMessages(_notInlinedMessages);
2424
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25-
"allChatNotifications": MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"),
25+
"allChatNotifications":
26+
MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"),
2627
"ar": MessageLookupByLibrary.simpleMessage("عربي"),
2728
"changeLanguage": MessageLookupByLibrary.simpleMessage("تغيسر اللغه"),
2829
"changeTheme": MessageLookupByLibrary.simpleMessage("تغير الثيم"),
@@ -47,7 +48,8 @@ class MessageLookup extends MessageLookupByLibrary {
4748
"register": MessageLookupByLibrary.simpleMessage("تسجيل حساب"),
4849
"settings": MessageLookupByLibrary.simpleMessage("الاعدادات"),
4950
"test": MessageLookupByLibrary.simpleMessage("تست"),
50-
"thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("هذه الداتا من سيرفر خارجي"),
51+
"thisDataFromMyServerNotVchat":
52+
MessageLookupByLibrary.simpleMessage("هذه الداتا من سيرفر خارجي"),
5153
"update": MessageLookupByLibrary.simpleMessage("تحديث"),
5254
"updateProfile": MessageLookupByLibrary.simpleMessage("تحديث الحساب")
5355
};

example/lib/generated/intl/messages_en.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ class MessageLookup extends MessageLookupByLibrary {
2222

2323
final messages = _notInlinedMessages(_notInlinedMessages);
2424
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25-
"allChatNotifications": MessageLookupByLibrary.simpleMessage("All Chat notifications"),
25+
"allChatNotifications":
26+
MessageLookupByLibrary.simpleMessage("All Chat notifications"),
2627
"ar": MessageLookupByLibrary.simpleMessage("ar"),
27-
"changeLanguage": MessageLookupByLibrary.simpleMessage("Change language"),
28+
"changeLanguage":
29+
MessageLookupByLibrary.simpleMessage("Change language"),
2830
"changeTheme": MessageLookupByLibrary.simpleMessage("Change Theme"),
2931
"chats": MessageLookupByLibrary.simpleMessage("Chats"),
3032
"chooseImage": MessageLookupByLibrary.simpleMessage("choose image"),
@@ -47,7 +49,8 @@ class MessageLookup extends MessageLookupByLibrary {
4749
"register": MessageLookupByLibrary.simpleMessage("Register"),
4850
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
4951
"test": MessageLookupByLibrary.simpleMessage("test"),
50-
"thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("This data from my server not vchat"),
52+
"thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage(
53+
"This data from my server not vchat"),
5154
"update": MessageLookupByLibrary.simpleMessage("Update"),
5255
"updateProfile": MessageLookupByLibrary.simpleMessage("Update profile")
5356
};

example/lib/generated/intl/messages_fr.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ class MessageLookup extends MessageLookupByLibrary {
2222

2323
final messages = _notInlinedMessages(_notInlinedMessages);
2424
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
25-
"allChatNotifications": MessageLookupByLibrary.simpleMessage("All Chat notifications"),
25+
"allChatNotifications":
26+
MessageLookupByLibrary.simpleMessage("All Chat notifications"),
2627
"ar": MessageLookupByLibrary.simpleMessage("ar"),
27-
"changeLanguage": MessageLookupByLibrary.simpleMessage("Change language"),
28+
"changeLanguage":
29+
MessageLookupByLibrary.simpleMessage("Change language"),
2830
"changeTheme": MessageLookupByLibrary.simpleMessage("Change Theme"),
2931
"chats": MessageLookupByLibrary.simpleMessage("Chats"),
3032
"chooseImage": MessageLookupByLibrary.simpleMessage("choose image"),
@@ -46,7 +48,8 @@ class MessageLookup extends MessageLookupByLibrary {
4648
"password": MessageLookupByLibrary.simpleMessage("Password"),
4749
"register": MessageLookupByLibrary.simpleMessage("Register"),
4850
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
49-
"thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage("This data from my server not vchat"),
51+
"thisDataFromMyServerNotVchat": MessageLookupByLibrary.simpleMessage(
52+
"This data from my server not vchat"),
5053
"update": MessageLookupByLibrary.simpleMessage("Update"),
5154
"updateProfile": MessageLookupByLibrary.simpleMessage("Update profile")
5255
};

example/lib/generated/l10n.dart

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/main.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:provider/provider.dart';
55
import 'package:v_chat_sdk/v_chat_sdk.dart';
66

77
import './screens/splash_screen.dart';
8-
import 'controllers/language_controller.dart';
8+
import 'controllers/app_controller.dart';
99
import 'generated/l10n.dart';
1010

1111
class VChatCustomWidgets extends VChatWidgetBuilder {
@@ -21,25 +21,27 @@ class VChatCustomWidgets extends VChatWidgetBuilder {
2121

2222
void main() async {
2323
WidgetsFlutterBinding.ensureInitialized();
24+
2425
await GetStorage.init();
2526
// http://170.178.195.150:81/
2627
await VChatController.instance.init(
27-
baseUrl: Uri.parse("http://170.178.195.150:81"),
28-
appName: "test_v_chat",
29-
isUseFirebase: true,
30-
widgetsBuilder: VChatCustomWidgets(),
31-
enableLogger: true,
32-
maxMediaUploadSize: 50 * 1000 * 1000,
33-
);
28+
baseUrl: Uri.parse("http://170.178.195.150:81"),
29+
appName: "test_v_chat",
30+
isUseFirebase: true,
31+
widgetsBuilder: VChatCustomWidgets(),
32+
enableLogger: true,
33+
maxMediaUploadSize: 50 * 1000 * 1000,
34+
passwordHashKey: "passwordHashKey");
3435

3536
// add support new language
3637
// v_chat will change the language one you change it
37-
VChatController.instance.setLocaleMessages(languageCode: "ar", countryCode: "EG", lookupMessages: ArLanguage());
38+
VChatController.instance.setLocaleMessages(
39+
languageCode: "ar", countryCode: "EG", lookupMessages: ArLanguage());
3840

3941
// VChatController.instance.forceLanguage(languageCode: "ar",countryCode:'EG');
4042

41-
runApp(ChangeNotifierProvider<LanguageController>(
42-
create: (context) => LanguageController(),
43+
runApp(ChangeNotifierProvider<AppController>(
44+
create: (context) => AppController(),
4345
child: const MyApp(),
4446
));
4547
}
@@ -54,10 +56,10 @@ class MyApp extends StatefulWidget {
5456
class _MyAppState extends State<MyApp> {
5557
@override
5658
Widget build(BuildContext context) {
57-
context.watch<LanguageController>();
59+
context.watch<AppController>();
5860
return MaterialApp(
5961
debugShowCheckedModeBanner: false,
60-
theme: ThemeData.light(),
62+
theme: context.read<AppController>().theme,
6163
darkTheme: ThemeData.dark(),
6264
localizationsDelegates: const [
6365
S.delegate,
@@ -66,7 +68,7 @@ class _MyAppState extends State<MyApp> {
6668
GlobalCupertinoLocalizations.delegate,
6769
],
6870
supportedLocales: S.delegate.supportedLocales,
69-
locale: context.read<LanguageController>().locale,
71+
locale: context.read<AppController>().locale,
7072
home: const SplashScreen(),
7173
);
7274
}

0 commit comments

Comments
 (0)