2023-06-21 17:44:28 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
|
|
|
import 'package:together_mobile/common/constants.dart';
|
|
|
|
import 'components/email_signin.dart';
|
|
|
|
import 'components/username_signin.dart';
|
|
|
|
|
|
|
|
class SigninScreen extends StatefulWidget {
|
|
|
|
const SigninScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<SigninScreen> createState() => _SigninScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SigninScreenState extends State<SigninScreen> {
|
|
|
|
String _method = 'username';
|
|
|
|
|
|
|
|
void chageSigninMethod() {
|
|
|
|
if (_method == 'username') {
|
|
|
|
_method = 'email';
|
|
|
|
} else {
|
|
|
|
_method = 'username';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: IconButton(
|
|
|
|
icon: const Icon(Icons.arrow_back),
|
|
|
|
onPressed: () => context.pop(),
|
|
|
|
),
|
2024-03-16 16:46:53 +08:00
|
|
|
title: _method == 'username'
|
|
|
|
? const Text(
|
|
|
|
'用户名登录',
|
|
|
|
)
|
|
|
|
: const Text('邮箱登录'),
|
2023-06-21 17:44:28 +08:00
|
|
|
centerTitle: true,
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
chageSigninMethod();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
style: TextButton.styleFrom(foregroundColor: kContentColorDark),
|
|
|
|
child: Text(
|
|
|
|
_method == 'username' ? '邮箱登录' : '用户名登录',
|
|
|
|
style: const TextStyle(color: kContentColorDark),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
body: _method == 'username'
|
|
|
|
? const UsernameSigninBody()
|
|
|
|
: const EmailSigninBody(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|