diff --git a/lib/i18n/app_en.arb b/lib/i18n/app_en.arb index e567df7..e3b7f67 100644 --- a/lib/i18n/app_en.arb +++ b/lib/i18n/app_en.arb @@ -9,7 +9,9 @@ "signInRequired": "Sign in required", "signInRiskDetected": "Risk detected, click Next to open a webpage and signin through it to pass security check.", "signUp": "Sign Up", - "signUpCaption": "Create an account on Solarpass and then get the access of entire Solar Networks!", + "signUpCaption": "Create an account on Solarpass and then get the access of entire Solar Network!", + "signUpDone": "Sign Up Successfully", + "signUpDoneCaption": "Welcome to join Solar Network! Now go to sign in!", "signOut": "Sign Out", "poweredBy": "Powered by Project Hydrogen", "copyright": "Copyright © 2024 Solsynth LLC", diff --git a/lib/i18n/app_zh.arb b/lib/i18n/app_zh.arb index baa7b66..a187af6 100644 --- a/lib/i18n/app_zh.arb +++ b/lib/i18n/app_zh.arb @@ -9,7 +9,9 @@ "signInRequired": "请先登录", "signInRiskDetected": "检测到风险,点击下一步按钮来打开一个网页,并通过在其上面登录来通过安全检查。", "signUp": "注册", - "signUpCaption": "在 Solarpass 注册一个账号以获得整个 Solar Networks 的存取权!", + "signUpCaption": "在 Solarpass 注册一个账号以获得整个 Solar Network 的存取权!", + "signUpDone": "注册成功", + "signUpDoneCaption": "欢迎您加入 Solar Network!现在去登陆吧~", "signOut": "登出", "poweredBy": "由 Project Hydrogen 强力驱动", "copyright": "2024 Solsynth LLC © 版权所有", @@ -96,4 +98,4 @@ "chatMessageEditNotify": "你正在编辑信息中……", "chatMessageReplyNotify": "你正在回复消息中……", "chatMessageDeleteConfirm": "你确定要删除这条消息吗?这条消息将永远的从所有人的视图中消失,并且不会有本地消息记录保存!" -} \ No newline at end of file +} diff --git a/lib/screens/auth/signup.dart b/lib/screens/auth/signup.dart index b8197e8..cf08d4d 100644 --- a/lib/screens/auth/signup.dart +++ b/lib/screens/auth/signup.dart @@ -1,8 +1,12 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:solian/providers/auth.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:solian/router.dart'; +import 'package:solian/utils/service_url.dart'; +import 'package:solian/widgets/exts.dart'; import 'package:solian/widgets/indent_wrapper.dart'; +import 'package:http/http.dart' as http; class SignUpScreen extends StatelessWidget { final _emailController = TextEditingController(); @@ -10,11 +14,11 @@ class SignUpScreen extends StatelessWidget { final _nicknameController = TextEditingController(); final _passwordController = TextEditingController(); + final http.Client _client = http.Client(); + SignUpScreen({super.key}); - void performSignIn(BuildContext context) { - final auth = context.read(); - + void performSignIn(BuildContext context) async { final email = _emailController.value.text; final username = _usernameController.value.text; final nickname = _passwordController.value.text; @@ -23,6 +27,43 @@ class SignUpScreen extends StatelessWidget { username.isEmpty || nickname.isEmpty || password.isEmpty) return; + + final uri = getRequestUri('passport', '/api/users'); + final res = await _client.post( + uri, + headers: { + 'Content-Type': 'application/json', + }, + body: jsonEncode({ + 'name': username, + 'nick': nickname, + 'email': email, + 'password': password, + }), + ); + + if (res.statusCode == 200) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text(AppLocalizations.of(context)!.signUpDone), + content: Text(AppLocalizations.of(context)!.signUpDoneCaption), + actions: [ + TextButton( + child: Text(AppLocalizations.of(context)!.confirmOkay), + onPressed: () => Navigator.pop(context), + ), + ], + ); + }, + ).then((_) { + router.replaceNamed('auth.sign-in'); + }); + } else { + var message = utf8.decode(res.bodyBytes); + context.showErrorDialog(message); + } } @override