2023-07-27 01:40:26 -06:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:rluv/features/account/signup.dart';
|
|
|
|
import 'package:rluv/global/styles.dart';
|
|
|
|
|
|
|
|
import '../../global/api.dart';
|
|
|
|
import '../../global/widgets/ui_button.dart';
|
|
|
|
import '../../main.dart';
|
|
|
|
import 'login.dart';
|
|
|
|
|
|
|
|
class AccountCreateScreen extends ConsumerStatefulWidget {
|
|
|
|
const AccountCreateScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
2024-09-10 15:03:32 -06:00
|
|
|
ConsumerState<AccountCreateScreen> createState() => _AccountCreateScreenState();
|
2023-07-27 01:40:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
enum _AccountScreen { options, login, signup }
|
|
|
|
|
|
|
|
class _AccountCreateScreenState extends ConsumerState<AccountCreateScreen> {
|
|
|
|
_AccountScreen currentScreen = _AccountScreen.options;
|
|
|
|
static final signupFormKey = GlobalKey<FormState>();
|
|
|
|
static final loginFormKey = GlobalKey<FormState>();
|
|
|
|
|
|
|
|
bool usingUsername = true;
|
|
|
|
bool hasFamilyCode = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (ref.watch(tokenProvider) != null) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback(
|
|
|
|
(_) {
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (ctx) => const Home()),
|
|
|
|
(r) => false,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2024-09-10 15:03:32 -06:00
|
|
|
final screen = MediaQuery.of(context).size;
|
2023-07-27 01:40:26 -06:00
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Styles.purpleNurple,
|
|
|
|
body: SafeArea(
|
|
|
|
child: AnimatedSwitcher(
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
child: currentScreen == _AccountScreen.options
|
|
|
|
? Center(
|
|
|
|
child: SizedBox(
|
|
|
|
width: screen.width * 0.5 > 400 ? 400 : screen.width * 0.5,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
const Spacer(),
|
|
|
|
const Text(
|
|
|
|
'Welcome!',
|
|
|
|
style: TextStyle(fontSize: 28),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
|
|
|
child: Image.asset("assets/app_icon.png",
|
2024-09-10 15:03:32 -06:00
|
|
|
height: screen.width > 500 ? 250 : screen.width * 0.5,
|
|
|
|
width: screen.width > 500 ? 250 : screen.width * 0.5),
|
2023-07-27 01:40:26 -06:00
|
|
|
),
|
|
|
|
UiButton(
|
|
|
|
color: Styles.sunflower,
|
|
|
|
onPressed: () {
|
|
|
|
setState(
|
|
|
|
() => currentScreen = _AccountScreen.signup,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
text: 'Signup',
|
|
|
|
),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
UiButton(
|
|
|
|
color: Styles.flounderBlue,
|
|
|
|
onPressed: () {
|
|
|
|
setState(
|
|
|
|
() => currentScreen = _AccountScreen.login,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
text: 'Login',
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: currentScreen == _AccountScreen.login
|
|
|
|
? Login(formKey: loginFormKey, exitNav: exitNav())
|
|
|
|
: Signup(
|
|
|
|
formKey: signupFormKey,
|
|
|
|
exitNav: exitNav(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget exitNav() => Align(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: IconButton(
|
|
|
|
icon: const Icon(Icons.chevron_left),
|
|
|
|
onPressed: () {
|
|
|
|
setState(
|
|
|
|
() => currentScreen = _AccountScreen.options,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|