diff --git a/lib/core/themes/language/lang/en_us.dart b/lib/core/themes/language/lang/en_us.dart new file mode 100644 index 000000000..a767d5d7d --- /dev/null +++ b/lib/core/themes/language/lang/en_us.dart @@ -0,0 +1,93 @@ +const Map enUS = { + "bottomNavHome": "home", + "bottomNavSleep": "sleep", + "bottomNavProfile": "profile", + "requestCancellation": "Request cancellation", + "connectionTimeout": "Connection timeout", + "requestTimeout": "Request timeout", + "responseTimeout": "Response timeout", + "unknownError": "Unknown error", + "welcomeHint": "DeepSound makes communication smoother", + "loginTitle": "Login/Register", + "contactCustomerService": "Connection", + "phoneHint": "Please enter your phone number", + "phoneError": "Wrong phone number!", + "emailHint": "Please enter email", + "emailError": "Email input error, please re-enter!", + "codeHint": "Please enter the verification code", + "codeError": "Verification code error", + "pleaseAgreeToTerms": + "Please check the box to agree to our Terms and Privacy Policy", + "getCode": "Get code", + "reacquireCode": "S Reacquire", + "bind": "Deterministic binding", + "login": "Login", + "otherLogin": "Other login methods", + "readAndAgree": "I have read and agree", + "serviceAgreement": " User Service Agreement ", + "and": "And", + "privacyAgreement": " User Privacy Agreement ", + "codeSend": "Verification code has been sent, please check email!", + "connectHeadphones": "Connect headphones", + "bindHeadphones": "Bind headphones", + "intelligentTool": "Intelligent tool", + "sessionMode": "AI conversation mode", + "translation": "Simultaneous translation", + "together": "Face-to-face translation", + "telephoneVoice": "Telephone translation", + "translationRecord": "Translation record", + "bindDevice": "Bind device", + "bound": "Bound", + "appVersion": "APP version", + "languageSetting": "Language setting", + "followingSystem": "Following system", + "userAgreement": "User agreement", + "privacyDeal": "Privacy agreement", + "chinese": "Chinese", + "english": "English", + "chineseComplex": "Chinese (Traditional)", + "japanese": "Japanese", + "korean": "Korean", + "russian": "Russian", + "french": "French", + "qrCode": "Authorization code or QR code", + "link": "Link", + "copy": "Copy", + "successfulReplication": "Successful replication", + "edit": "Edit", + "delete": "Delete", + "aiDialogue": "AI dialogue", + "initialChatMessage": + "Hi, I'm your new friend! Nice to meet you for the first time. I can answer your various questions, provide help with your work and studies, and even chat with you anytime. So, what would you like to ask?", + "defaultContent1": "Help me write a Python web scraper code", + "defaultContent2": "Help me plan a short video script", + "defaultContent3": "Help me design a mind-exercising game", + "defaultContent4": "Recommend a cost-effective phone", + "defaultContent5": "Come up with a creative name for my Honor of Kings ID", + "defaultContent6": + "Guide me on using Python to scrape real-time weather data", + "defaultContent7": "Tell me daily habits to boost kidney qi", + "defaultContent8": "Help me understand the basics of CNC programming", + "defaultContent9": "Help me find a short folk story", + "defaultContent10": "Recommend a cost-effective SUV", + "defaultContent11": "Teach me to make a small game using Python", + "defaultContent12": "Introduce some free-to-play mobile games", + "holdToSpeak": "Hold to speak", + "tapToSpeak": "Click to talk", + "hangUp": "Hang up", + "holdToStartSpeak": "Hold down and start talking", + "tapToStartSpeak": "Click to start Talking", + "sendMessage": "Ask me anything you want", + "beTalking": "Be talking ...", + "headphonesBeTalking": "Talking through headphones...", + "interlanguage": "Cannot choose the same language", + "notice": "Look out", + "connectingDevice": "Please set up the connected device first", + "bindDeviceTips": "Unbind the device first", + "cancel": "Cancel", + "confirm": "Confirm", + "goToSettings": "Go to Settings", + "goToBind": "Unbind", + "scanQrCode": "Scan the QR code", + "endRecording": "Do you want to end the recording?", +}; diff --git a/lib/core/themes/language/lang/zh_cn.dart b/lib/core/themes/language/lang/zh_cn.dart new file mode 100644 index 000000000..07806c5cb --- /dev/null +++ b/lib/core/themes/language/lang/zh_cn.dart @@ -0,0 +1,91 @@ +const Map zhCN = { + "bottomNavHome": "首页", + "bottomNavSleep": "睡眠", + "bottomNavProfile": "我的", + "requestCancellation": "请求取消", + "connectionTimeout": "连接超时", + "requestTimeout": "请求超时", + "responseTimeout": "响应超时", + "unknownError": "未知错误", + "welcomeHint": "DeepSound让沟通更顺畅", + "loginTitle": "登录/注册账号", + "contactCustomerService": "联系客服", + "phoneHint": "请输入手机号", + "phoneError": "手机号码错误!", + "emailHint": "请输入邮箱", + "emailError": "邮箱输入错误,请重新输入!", + "codeHint": "请输入验证码", + "codeError": "验证码错误", + "pleaseAgreeToTerms": "请勾选以同意用户协议和隐私政策", + "getCode": "获取验证码", + "reacquireCode": "S后重新获取", + "bind": "确定绑定", + "login": "登录", + "otherLogin": "其他登录方式", + "readAndAgree": "我已阅读并同意", + "serviceAgreement": "《用户服务协议》", + "and": "和", + "privacyAgreement": "《用户隐私协议》", + "codeSend": "验证码已发送,请到邮箱查看!", + "connectHeadphones": "请连接耳机", + "bindHeadphones": "请绑定耳机", + "intelligentTool": "智能工具", + "sessionMode": "AI对话模式", + "translation": "同声传译", + "together": "面对面翻译", + "telephoneVoice": "通话语音翻译", + "translationRecord": "翻译记录", + "bindDevice": "绑定设备", + "bound": "已绑定", + "appVersion": "APP版本", + "languageSetting": "语言设置", + "followingSystem": "跟随系统", + "userAgreement": "用户协议", + "privacyDeal": "隐私协议", + "chinese": "中文", + "english": "英语", + "chineseComplex": "中文(繁体)", + "japanese": "日语", + "korean": "韩语", + "russian": "俄语", + "french": "法语", + "qrCode": "授权码或二维码", + "link": "链接", + "copy": "复制", + "successfulReplication": "复制成功", + "edit": "编辑", + "delete": "删除", + "aiDialogue": "AI对话", + "initialChatMessage": + "嗨,我是你的新朋友!初次见面很开心。我呢,可以回答你的各种问题,给你工作学习上提供帮助,还能随时陪你聊天。嗯,你想问点什么呢?", + "defaultContent1": "请帮我写个Python爬虫代码", + "defaultContent2": "帮我策划一个短视频脚本", + "defaultContent3": "请帮我设计一个锻炼思维的小游戏", + "defaultContent4": "请推荐一部性价比高的手机", + "defaultContent5": "帮我想一个王者ID的创意名称", + "defaultContent6": "请指导我使用Python爬取实时天气数据", + "defaultContent7": "告诉我补肾气的日常习惯", + "defaultContent8": "帮我了解CNC编程的基础知识", + "defaultContent9": "帮我找一个简短的民间故事", + "defaultContent10": "给我推荐一辆性价比高的SUV", + "defaultContent11": "教我用Python制作小游戏", + "defaultContent12": "介绍一些适合零氪玩家的手游", + "holdToSpeak": "按住说话", + "tapToSpeak": "点击说话", + "hangUp": "挂断", + "holdToStartSpeak": "按住开始说话", + "tapToStartSpeak": "点击开始说话", + "sendMessage": "有什么问的尽管问我", + "beTalking": "正在说话...", + "headphonesBeTalking": "正在使用耳机说话...", + "interlanguage": "不能选择同语种", + "notice": "注意", + "connectingDevice": "请先去设置连接设备", + "bindDeviceTips": "请先去绑定设备", + "cancel": "取消", + "confirm": "确定", + "goToSettings": "去设置", + "goToBind": "去绑定", + "scanQrCode": "扫描二维码", + "endRecording": "你想结束录音吗?", +}; diff --git a/lib/core/themes/language/translation_service.dart b/lib/core/themes/language/translation_service.dart new file mode 100644 index 000000000..6ca44bda0 --- /dev/null +++ b/lib/core/themes/language/translation_service.dart @@ -0,0 +1,18 @@ +import 'dart:ui'; + +import 'package:get/get.dart'; + +import 'lang/en_us.dart'; +import 'lang/zh_cn.dart'; + +class TranslationService extends Translations { + static Locale? get locale => Get.deviceLocale; + static final fallbackLocale = Locale('zh', 'CN'); + static final supportedLocales = [ + const Locale('zh', 'CN'), + const Locale('en', 'US'), + ]; + + @override + Map> get keys => {'en_US': enUS, 'zh_CN': zhCN}; +} diff --git a/lib/modules/login/controllers/googleLogin.dart b/lib/modules/login/controllers/googleLogin.dart index 36a080cc6..196699b15 100644 --- a/lib/modules/login/controllers/googleLogin.dart +++ b/lib/modules/login/controllers/googleLogin.dart @@ -6,6 +6,7 @@ class Google { String? token = ''; String? email = ''; String? displayName = ''; + String? pictureurl = ''; String? id = ''; String? accessToken = ''; @@ -21,6 +22,8 @@ class Google { email = currentUser.email; displayName = currentUser.displayName; id = currentUser.uid; + pictureurl = currentUser.photoURL; + print('Future响应数据pictureurl: $pictureurl'); token = await currentUser.getIdToken(); print('Future响应数据tokenResult: $token'); @@ -51,6 +54,7 @@ class Google { email = googleUser?.email; id = googleUser?.id; displayName = googleUser?.displayName; + pictureurl = googleUser?.photoUrl; print('loginGoogle: $googleUser'); print("user login loginGoogle ${email}${id}${displayName}"); diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index 142c71ca7..366fe48c5 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -155,6 +155,7 @@ class LoginController extends GetxController { } else { _displayContact.value = contact; } + loginType = 0; } else if (RegExp(r'^\d+$').hasMatch(contact)) { // 手机号 if (contact.length > 7) { @@ -165,6 +166,7 @@ class LoginController extends GetxController { } else { _displayContact.value = contact; } + loginType = 1; } else { _displayContact.value = contact; } @@ -181,9 +183,18 @@ class LoginController extends GetxController { } // 发送验证码 - void _sendVerificationCode() { + Future _sendVerificationCode() async { // 这里应该是实际发送验证码的逻辑 // 为了演示,我们只是模拟发送 + var response = await Api.getCode({ + "addr": contactController.text, + "vtype": 0, + }); + if (response != null) { + print("请求后台数据验证码params=${response}"); + //短信已发送 + //EasyLoading.showInfo('codeSend'.tr); + } } // 重新发送验证码 @@ -232,7 +243,33 @@ class LoginController extends GetxController { // 模拟验证过程 await Future.delayed(const Duration(seconds: 2)); switch (loginType) { - case 1: + case 0 || 1: + { + if (!isVerificationCodeComplete()) { + Get.snackbar( + '提示', + '请输入完整的验证码', + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.red.withOpacity(0.1), + colorText: Colors.red, + ); + break; + } + requestLogin({ + "mail": verificationCodeController.text, + "phone": "", + "stype": loginType, + "vcode": contactController.text, + "ttoken": "", + "phonemodel": "", + "phonemac": "", + "name": "", + "avatar": "", + }); + break; + } + + case 4: { print("数据获取Facebook"); final facebook = Facebook(); @@ -240,6 +277,8 @@ class LoginController extends GetxController { print("数据获取Facebook().token${authResult}"); if (authResult) { print("数据获取_Facebook.token${facebook.token}"); + print("数据获取_Facebook.pictureurl${facebook.pictureurl}"); + print("数据获取_Facebook.pictureurl${facebook.email}"); // SettingsController().userName = Facebook().name; // SettingsController().avatar = Facebook().pictureurl; // SettingsController().userId = Facebook().id; @@ -247,37 +286,50 @@ class LoginController extends GetxController { // 验证成功,跳转到配对页面 requestLogin({ - "email": facebook.email, + "mail": facebook.email, + "phone": "", + "stype": loginType, + "vcode": "", + "ttoken": facebook.token, + "phonemodel": "", + "phonemac": "", "name": facebook.name, "avatar": facebook.pictureurl, - "stype": 4, - "ttoken": facebook.token, }); } break; } - case 2: + case 3: { print("数据获取_Google()"); final google = Google(); bool authResult = await google.signInWithGoogle(); print("数据获取_Google().token${authResult}"); if (authResult) { + print("数据获取_Google.token${google.token}"); + print("数据获取_Google.pictureurl${google.pictureurl}"); + print("数据获取_Google.email${google.email}"); + print("数据获取_Google.email${google.displayName}"); // 验证成功,跳转到配对页面 // SettingsController().userName = Google().displayName!; // //SettingsController().avatar = Google().email; // SettingsController().userId = Google().id!; requestLogin({ - "name": google.displayName, - "email": google.email, - "stype": 3, + "mail": google.email, + "phone": "", + "stype": loginType, + "vcode": "", "ttoken": google.token, + "phonemodel": "", + "phonemac": "", + "name": google.displayName, + "avatar": google.pictureurl, }); } break; } - case 3: + case 2: { print("数据获取_FlWX()"); @@ -297,10 +349,15 @@ class LoginController extends GetxController { // SettingsController().avatar = FlWX().headimgurl; // SettingsController().userId = FlWX().openid; requestLogin({ + "mail": "", + "phone": "", + "stype": loginType, + "vcode": "", + "ttoken": FlWX().code, + "phonemodel": "", + "phonemac": "", "name": FlWX().nickname, "avatar": FlWX().headimgurl, - "stype": 2, - "ttoken": FlWX().code, }); // 验证成功,跳转到配对页面 } @@ -333,35 +390,16 @@ class LoginController extends GetxController { // 使用登陆请求服务器 Future requestLogin(Map params) async { - // switch (loginType) { - // case 0: //邮箱 - // { - // String verificationCode = verificationCodeController.text; - // String contactControll22er = contactController.text; - // } - // case 1: //手机号 - // { - // String verificationCode = verificationCodeController.text; - // String contactContr22oller = contactController.text; - // } - // case 2: //微信 - // {} - // case 3: //谷歌 - // {} - // case 4: //facebook - // {} - // } - var response = await Api.login({ - "mail": params?["mail"].toString() ?? "", - "phone": params?["phone"].toString() ?? "", + "mail": params["mail"], + "phone": params["phone"], "stype": params["stype"], - "vcode": params?["vcode"].toString() ?? "", - "ttoken": params?["ttoken"].toString() ?? "", - "phonemodel": params?["phonemodel"].toString() ?? "", - "phonemac": params?["phonemac"].toString() ?? "", - "name": params?["name"].toString() ?? "", - "avatar": params?["avatar"].toString() ?? "", + "vcode": params["vcode"], + "ttoken": params["ttoken"], + "phonemodel": params["phonemodel"], + "phonemac": params["phonemac"], + "name": params["name"], + "avatar": params["avatar"], }); if (response != null) { print("请求后台数据login回复数据=${response}"); diff --git a/lib/modules/login/entity/api.dart b/lib/modules/login/entity/api.dart index 22c78ce9d..263db3187 100644 --- a/lib/modules/login/entity/api.dart +++ b/lib/modules/login/entity/api.dart @@ -14,6 +14,7 @@ class Api { // 获取验证码 static getCode([params]) { + print("请求后台数据params=${params}"); return DioManager().request( NWMethod.post, '/api/home/user_verification', diff --git a/lib/modules/login/views/login_view.dart b/lib/modules/login/views/login_view.dart index 85581536e..84a3aa649 100644 --- a/lib/modules/login/views/login_view.dart +++ b/lib/modules/login/views/login_view.dart @@ -3,10 +3,6 @@ import 'package:get/get.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import '../controllers/login_controller.dart'; -import '../controllers/facebookLogin.dart'; -import '../controllers/googleLogin.dart'; -import '../controllers/weixinLogin.dart'; -import '../../../core/themes/app_theme.dart'; class LoginView extends GetView { const LoginView({Key? key}) : super(key: key); @@ -397,17 +393,17 @@ class LoginView extends GetView { switch (icon) { case FontAwesomeIcons.facebook: { - controller.loginType = 1; + controller.loginType = 4; break; } case FontAwesomeIcons.google: { - controller.loginType = 2; + controller.loginType = 3; break; } case FontAwesomeIcons.weixin: { - controller.loginType = 3; + controller.loginType = 2; break; } } diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index e545a083c..773d442d3 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -17,6 +17,8 @@ class SettingsView extends GetView { String get userId => User.getuserId(); String get standing => User.getstanding(); String get avatar => User.getnavatar(); + //String get avatar => + //"https://lh3.googleusercontent.com/a/ACg8ocJw96pHqo3uceyxyrWziQr8eGS-CZZ_NhRBNC_EvmGkAyf6TQ=s96-c"; @override Widget build(BuildContext context) { // 直接使用 Theme.of(context) 获取当前主题