✨ Sign up screen
This commit is contained in:
parent
cd5cfedb2f
commit
fd200105c0
@ -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",
|
||||
|
@ -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 © 版权所有",
|
||||
|
@ -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<AuthProvider>();
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user