Skip to content

Commit

Permalink
v 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemragab committed Nov 29, 2021
1 parent fbb6cb3 commit 43fae67
Show file tree
Hide file tree
Showing 89 changed files with 380 additions and 817 deletions.
3 changes: 1 addition & 2 deletions example/lib/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 6 additions & 11 deletions example/lib/controllers/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<dynamic> route) => false);
Navigator.of(context)
.pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route<dynamic> route) => false);
} on VChatSdkException catch (err) {
Navigator.pop(context);
CustomAlert.showError(context: context, err: err.toString());
Expand Down
36 changes: 15 additions & 21 deletions example/lib/controllers/register_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<dynamic> route) => false);
Navigator.of(context)
.pushAndRemoveUntil(MaterialPageRoute(builder: (context) => const Home()), (Route<dynamic> route) => false);
} on VChatSdkException catch (err) {
Navigator.pop(context);
CustomAlert.showError(context: context, err: err.toString());
Expand Down
8 changes: 3 additions & 5 deletions example/lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ MessageLookupByLibrary? _findExact(String localeName) {

/// User programs should call this before using [localeName] for messages.
Future<bool> 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);
}
Expand All @@ -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);
}
6 changes: 2 additions & 4 deletions example/lib/generated/intl/messages_ar_EG.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class MessageLookup extends MessageLookupByLibrary {

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"allChatNotifications":
MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"),
"allChatNotifications": MessageLookupByLibrary.simpleMessage("كل اشعارات المحادثه"),
"ar": MessageLookupByLibrary.simpleMessage("عربي"),
"changeLanguage": MessageLookupByLibrary.simpleMessage("تغيسر اللغه"),
"changeTheme": MessageLookupByLibrary.simpleMessage("تغير الثيم"),
Expand All @@ -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("تحديث الحساب")
};
Expand Down
9 changes: 3 additions & 6 deletions example/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ class MessageLookup extends MessageLookupByLibrary {

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"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"),
Expand All @@ -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")
};
Expand Down
9 changes: 3 additions & 6 deletions example/lib/generated/intl/messages_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ class MessageLookup extends MessageLookupByLibrary {

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"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"),
Expand All @@ -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")
};
Expand Down
8 changes: 3 additions & 5 deletions example/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');

Expand Down
7 changes: 1 addition & 6 deletions example/lib/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions example/lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class _HomeState extends State<Home> {

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);
}
}

Expand All @@ -53,7 +51,6 @@ class _HomeState extends State<Home> {
actions: [
IconButton(
onPressed: () async {

final users = await _controller.getUsers();
_usersList.clear();
_usersList.addAll(users);
Expand Down Expand Up @@ -96,7 +93,6 @@ class _HomeState extends State<Home> {
appBar: PreferredSize(
child: _childrenAppBars[_currentIndex],
preferredSize: const Size.fromHeight(kToolbarHeight),

),
body: _children[_currentIndex], // new
bottomNavigationBar: BottomNavigationBar(
Expand Down
7 changes: 2 additions & 5 deletions example/lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ class _LoginScreenState extends State<LoginScreen> {
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),
],
),
),
Expand Down
11 changes: 3 additions & 8 deletions example/lib/screens/register_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ class _RegisterScreenState extends State<RegisterScreen> {
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(
Expand All @@ -78,9 +75,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
const SizedBox(
height: 10,
),
TextButton(
onPressed: _controller.register,
child: S.of(context).register.text),
TextButton(onPressed: _controller.register, child: S.of(context).register.text),
],
),
),
Expand Down
27 changes: 9 additions & 18 deletions example/lib/screens/setting_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ class _SettingScreenState extends State<SettingScreen> {
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<LanguageController>(context, listen: false)
.setLocale(const Locale.fromSubtags(languageCode: "ar"));
Expand All @@ -47,33 +46,28 @@ class _SettingScreenState extends State<SettingScreen> {
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<LanguageController>(context, listen: false)
.changeTheme(false);
Provider.of<LanguageController>(context, listen: false).changeTheme(false);
}
if (res == 1) {
Provider.of<LanguageController>(context, listen: false)
.changeTheme(true);
Provider.of<LanguageController>(context, listen: false).changeTheme(true);
}
},
),
ProfileItem(
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();
}
Expand All @@ -86,15 +80,12 @@ class _SettingScreenState extends State<SettingScreen> {
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<dynamic> route) => false);
MaterialPageRoute(builder: (context) => const SplashScreen()), (Route<dynamic> route) => false);
},
),
],
Expand Down
Loading

0 comments on commit 43fae67

Please sign in to comment.