Migrate away from helpers package
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:rluv/features/account/signup.dart';
|
||||
import 'package:rluv/global/styles.dart';
|
||||
|
||||
@@ -13,8 +12,7 @@ class AccountCreateScreen extends ConsumerStatefulWidget {
|
||||
const AccountCreateScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<AccountCreateScreen> createState() =>
|
||||
_AccountCreateScreenState();
|
||||
ConsumerState<AccountCreateScreen> createState() => _AccountCreateScreenState();
|
||||
}
|
||||
|
||||
enum _AccountScreen { options, login, signup }
|
||||
@@ -40,7 +38,7 @@ class _AccountCreateScreenState extends ConsumerState<AccountCreateScreen> {
|
||||
},
|
||||
);
|
||||
}
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Scaffold(
|
||||
backgroundColor: Styles.purpleNurple,
|
||||
body: SafeArea(
|
||||
@@ -60,11 +58,8 @@ class _AccountCreateScreenState extends ConsumerState<AccountCreateScreen> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Image.asset("assets/app_icon.png",
|
||||
height:
|
||||
screen.width > 500 ? 250 : screen.width * 0.5,
|
||||
width: screen.width > 500
|
||||
? 250
|
||||
: screen.width * 0.5),
|
||||
height: screen.width > 500 ? 250 : screen.width * 0.5,
|
||||
width: screen.width > 500 ? 250 : screen.width * 0.5),
|
||||
),
|
||||
UiButton(
|
||||
color: Styles.sunflower,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
|
||||
import '../../global/api.dart';
|
||||
import '../../global/styles.dart';
|
||||
@@ -32,7 +30,7 @@ class _LoginState extends ConsumerState<Login> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Form(
|
||||
key: widget.formKey,
|
||||
child: Stack(
|
||||
@@ -205,14 +203,11 @@ class _LoginState extends ConsumerState<Login> {
|
||||
|
||||
Future login() async {
|
||||
try {
|
||||
if (widget.formKey.currentState != null &&
|
||||
!widget.formKey.currentState!.validate()) {
|
||||
if (widget.formKey.currentState != null && !widget.formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
final data =
|
||||
await ref.read(apiProvider.notifier).post(path: 'auth/login', data: {
|
||||
'username':
|
||||
usernameController.text.isEmpty ? null : usernameController.text,
|
||||
final data = await ref.read(apiProvider.notifier).post(path: 'auth/login', data: {
|
||||
'username': usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'email': emailController.text.isEmpty ? null : emailController.text,
|
||||
'password': passwordController.text,
|
||||
});
|
||||
@@ -227,13 +222,10 @@ class _LoginState extends ConsumerState<Login> {
|
||||
}
|
||||
}
|
||||
// final bool success = data?['success'] ?? false;
|
||||
printAmber(data);
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: message,
|
||||
type: !success ? SnackType.error : SnackType.success);
|
||||
print(data);
|
||||
showSnack(ref: ref, text: message, type: !success ? SnackType.error : SnackType.success);
|
||||
} catch (err, st) {
|
||||
printRed('Error in login: $err\n$st');
|
||||
print('Error in login: $err\n$st');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:helpers/helpers/misc_build/build_media.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
|
||||
import '../../global/api.dart';
|
||||
import '../../global/styles.dart';
|
||||
@@ -36,7 +34,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = BuildMedia(context).size;
|
||||
final screen = MediaQuery.of(context).size;
|
||||
return Form(
|
||||
key: widget.formKey,
|
||||
child: Stack(
|
||||
@@ -126,8 +124,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
),
|
||||
UiButton(
|
||||
width: screen.width * 0.4,
|
||||
icon: const Icon(Icons.cancel,
|
||||
color: Styles.washedStone, size: 20),
|
||||
icon: const Icon(Icons.cancel, color: Styles.washedStone, size: 20),
|
||||
onPressed: () {
|
||||
setState(
|
||||
() => hasFamilyCode = false,
|
||||
@@ -140,9 +137,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: UiButton(
|
||||
width: screen.width * 0.5 > 400
|
||||
? 400
|
||||
: screen.width * 0.5,
|
||||
width: screen.width * 0.5 > 400 ? 400 : screen.width * 0.5,
|
||||
text: 'JOIN FAMILY',
|
||||
// color: Styles.flounderBlue,
|
||||
onPressed: () {
|
||||
@@ -190,8 +185,7 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
text,
|
||||
style: TextStyle(fontSize: size.width < 350 ? 16 : 20),
|
||||
),
|
||||
if (subtext != null)
|
||||
Text(subtext, style: const TextStyle(fontSize: 12)),
|
||||
if (subtext != null) Text(subtext, style: const TextStyle(fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -223,36 +217,29 @@ class _SignupState extends ConsumerState<Signup> {
|
||||
|
||||
Future signup() async {
|
||||
try {
|
||||
if (widget.formKey.currentState != null &&
|
||||
!widget.formKey.currentState!.validate()) {
|
||||
if (widget.formKey.currentState != null && !widget.formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
final data =
|
||||
await ref.read(apiProvider.notifier).post(path: 'auth/signup', data: {
|
||||
final data = await ref.read(apiProvider.notifier).post(path: 'auth/signup', data: {
|
||||
'name': nameCotroller.text,
|
||||
'username':
|
||||
usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'username': usernameController.text.isEmpty ? null : usernameController.text,
|
||||
'email': emailController.text.isEmpty ? null : emailController.text,
|
||||
'password': passwordController.text,
|
||||
'family_code': familyCodeController.text.isEmpty
|
||||
? null
|
||||
: familyCodeController.text.toUpperCase(),
|
||||
'family_code': familyCodeController.text.isEmpty ? null : familyCodeController.text.toUpperCase(),
|
||||
'budget_name': 'Budget'
|
||||
});
|
||||
|
||||
final success = data?['success'] ?? false;
|
||||
showSnack(
|
||||
ref: ref,
|
||||
text: data?['message'] ?? success
|
||||
? 'Login successful'
|
||||
: 'Login unsuccessful',
|
||||
text: data?['message'] ?? success ? 'Login successful' : 'Login unsuccessful',
|
||||
type: !success ? SnackType.error : SnackType.success);
|
||||
|
||||
printAmber(data);
|
||||
print(data);
|
||||
// final user = User.fromJson(data?['user']);
|
||||
// ref.read(tokenProvider.notifier).state =
|
||||
} catch (err) {
|
||||
printRed(err);
|
||||
print(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user